|
4 | 4 | author_url: https://github.com/owndev/ |
5 | 5 | project_url: https://github.com/owndev/Open-WebUI-Functions |
6 | 6 | funding_url: https://github.com/sponsors/owndev |
7 | | -version: 1.6.6 |
| 7 | +version: 1.6.7 |
| 8 | +required_open_webui_version: 0.6.26 |
8 | 9 | license: Apache License 2.0 |
9 | 10 | description: Highly optimized Google Gemini pipeline with advanced image generation capabilities, intelligent compression, and streamlined processing workflows. |
10 | 11 | features: |
|
33 | 34 | """ |
34 | 35 |
|
35 | 36 | import os |
36 | | -import inspect |
37 | | -from functools import update_wrapper |
38 | 37 | import re |
39 | 38 | import time |
40 | 39 | import asyncio |
@@ -1340,53 +1339,6 @@ def _upload_image( |
1340 | 1339 | # Fallback to data URL if upload fails |
1341 | 1340 | return f"data:{mime_type};base64,{image_data}" |
1342 | 1341 |
|
1343 | | - @staticmethod |
1344 | | - def _create_tool(tool_def): |
1345 | | - """OpenwebUI tool is a functools.partial coroutine, which genai does not support directly. |
1346 | | - See https://github.com/googleapis/python-genai/issues/907 |
1347 | | -
|
1348 | | - This function wraps the tool into a callable that can be used with genai. |
1349 | | - In particular, it sets the signature of the function properly, |
1350 | | - removing any frozen keyword arguments (extra_params). |
1351 | | - """ |
1352 | | - bound_callable = tool_def["callable"] |
1353 | | - |
1354 | | - # Create a wrapper for bound_callable, which is always async |
1355 | | - async def wrapper(*args, **kwargs): |
1356 | | - return await bound_callable(*args, **kwargs) |
1357 | | - |
1358 | | - # Remove 'frozen' keyword arguments (extra_params) from the signature |
1359 | | - original_sig = inspect.signature(bound_callable) |
1360 | | - frozen_kwargs = { |
1361 | | - "__event_emitter__", |
1362 | | - "__event_call__", |
1363 | | - "__user__", |
1364 | | - "__metadata__", |
1365 | | - "__request__", |
1366 | | - "__model__", |
1367 | | - } |
1368 | | - new_parameters = [] |
1369 | | - |
1370 | | - for name, parameter in original_sig.parameters.items(): |
1371 | | - # Exclude keyword arguments that are frozen |
1372 | | - if name in frozen_kwargs and parameter.kind in ( |
1373 | | - inspect.Parameter.POSITIONAL_OR_KEYWORD, |
1374 | | - inspect.Parameter.KEYWORD_ONLY, |
1375 | | - ): |
1376 | | - continue |
1377 | | - # Keep remaining parameters |
1378 | | - new_parameters.append(parameter) |
1379 | | - |
1380 | | - new_sig = inspect.Signature( |
1381 | | - parameters=new_parameters, return_annotation=original_sig.return_annotation |
1382 | | - ) |
1383 | | - |
1384 | | - # Ensure name, docstring and signature are properly set |
1385 | | - update_wrapper(wrapper, bound_callable) |
1386 | | - wrapper.__signature__ = new_sig |
1387 | | - |
1388 | | - return wrapper |
1389 | | - |
1390 | 1342 | def _configure_generation( |
1391 | 1343 | self, |
1392 | 1344 | body: Dict[str, Any], |
@@ -1462,8 +1414,7 @@ def _configure_generation( |
1462 | 1414 | ) |
1463 | 1415 |
|
1464 | 1416 | if __tools__ is not None and __metadata__.get("function_calling") == "native": |
1465 | | - for name, tool_def in __tools__.items(): |
1466 | | - tool = self._create_tool(tool_def) |
| 1417 | + for name, tool in __tools__.items(): |
1467 | 1418 | self.log.debug( |
1468 | 1419 | f"Adding tool '{name}' with signature {tool.__signature__}" |
1469 | 1420 | ) |
@@ -1923,10 +1874,11 @@ async def pipe( |
1923 | 1874 | # For image generation models, gather ALL images from the last user turn |
1924 | 1875 | if supports_image_generation: |
1925 | 1876 | try: |
1926 | | - contents, system_instruction = ( |
1927 | | - await self._build_image_generation_contents( |
1928 | | - messages, __event_emitter__ |
1929 | | - ) |
| 1877 | + ( |
| 1878 | + contents, |
| 1879 | + system_instruction, |
| 1880 | + ) = await self._build_image_generation_contents( |
| 1881 | + messages, __event_emitter__ |
1930 | 1882 | ) |
1931 | 1883 | # For image generation, system_instruction is integrated into the prompt |
1932 | 1884 | # so it will be None here (this is expected and correct) |
|
0 commit comments