🐛 Bug: Fix the bug when the date plugin does not require parameters.
Browse files- models.py +2 -2
- request.py +5 -4
models.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from pydantic import BaseModel
|
2 |
from typing import List, Dict, Optional, Union
|
3 |
|
4 |
class FunctionParameter(BaseModel):
|
@@ -10,7 +10,7 @@ class FunctionParameter(BaseModel):
|
|
10 |
class Function(BaseModel):
|
11 |
name: str
|
12 |
description: str
|
13 |
-
parameters: FunctionParameter
|
14 |
|
15 |
# 定义 Tool 模型
|
16 |
class Tool(BaseModel):
|
|
|
1 |
+
from pydantic import BaseModel, Field
|
2 |
from typing import List, Dict, Optional, Union
|
3 |
|
4 |
class FunctionParameter(BaseModel):
|
|
|
10 |
class Function(BaseModel):
|
11 |
name: str
|
12 |
description: str
|
13 |
+
parameters: Optional[FunctionParameter] = Field(default=None, exclude=None)
|
14 |
|
15 |
# 定义 Tool 模型
|
16 |
class Tool(BaseModel):
|
request.py
CHANGED
@@ -255,13 +255,14 @@ async def gpt2claude_tools_json(json_dict):
|
|
255 |
for old_key, new_key in keys_to_change.items():
|
256 |
if old_key in json_dict:
|
257 |
if new_key:
|
|
|
|
|
|
|
|
|
|
|
258 |
json_dict[new_key] = json_dict.pop(old_key)
|
259 |
else:
|
260 |
json_dict.pop(old_key)
|
261 |
-
# if "tools" in json_dict.keys():
|
262 |
-
# json_dict["tool_choice"] = {
|
263 |
-
# "type": "auto"
|
264 |
-
# }
|
265 |
return json_dict
|
266 |
|
267 |
async def get_claude_payload(request, engine, provider):
|
|
|
255 |
for old_key, new_key in keys_to_change.items():
|
256 |
if old_key in json_dict:
|
257 |
if new_key:
|
258 |
+
if json_dict[old_key] == None:
|
259 |
+
json_dict[old_key] = {
|
260 |
+
"type": "object",
|
261 |
+
"properties": {}
|
262 |
+
}
|
263 |
json_dict[new_key] = json_dict.pop(old_key)
|
264 |
else:
|
265 |
json_dict.pop(old_key)
|
|
|
|
|
|
|
|
|
266 |
return json_dict
|
267 |
|
268 |
async def get_claude_payload(request, engine, provider):
|