mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fix: gemini model use some tools raise error (#9993)
This commit is contained in:
parent
c8ef9223e5
commit
12adcf8925
|
@ -116,26 +116,33 @@ class GoogleLargeLanguageModel(LargeLanguageModel):
|
||||||
:param tools: tool messages
|
:param tools: tool messages
|
||||||
:return: glm tools
|
:return: glm tools
|
||||||
"""
|
"""
|
||||||
return glm.Tool(
|
function_declarations = []
|
||||||
function_declarations=[
|
for tool in tools:
|
||||||
glm.FunctionDeclaration(
|
properties = {}
|
||||||
name=tool.name,
|
for key, value in tool.parameters.get("properties", {}).items():
|
||||||
parameters=glm.Schema(
|
properties[key] = {
|
||||||
type=glm.Type.OBJECT,
|
"type_": glm.Type.STRING,
|
||||||
properties={
|
"description": value.get("description", ""),
|
||||||
key: {
|
"enum": value.get("enum", []),
|
||||||
"type_": value.get("type", "string").upper(),
|
}
|
||||||
"description": value.get("description", ""),
|
|
||||||
"enum": value.get("enum", []),
|
if properties:
|
||||||
}
|
parameters = glm.Schema(
|
||||||
for key, value in tool.parameters.get("properties", {}).items()
|
type=glm.Type.OBJECT,
|
||||||
},
|
properties=properties,
|
||||||
required=tool.parameters.get("required", []),
|
required=tool.parameters.get("required", []),
|
||||||
),
|
|
||||||
)
|
)
|
||||||
for tool in tools
|
else:
|
||||||
]
|
parameters = None
|
||||||
)
|
|
||||||
|
function_declaration = glm.FunctionDeclaration(
|
||||||
|
name=tool.name,
|
||||||
|
parameters=parameters,
|
||||||
|
description=tool.description,
|
||||||
|
)
|
||||||
|
function_declarations.append(function_declaration)
|
||||||
|
|
||||||
|
return glm.Tool(function_declarations=function_declarations)
|
||||||
|
|
||||||
def validate_credentials(self, model: str, credentials: dict) -> None:
|
def validate_credentials(self, model: str, credentials: dict) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user