Skip to content

Commit

Permalink
Fix bugs in the single returns
Browse files Browse the repository at this point in the history
  • Loading branch information
luyaxi committed Aug 23, 2024
1 parent be024c8 commit ecdeda9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions codelinker/request/objGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ async def _chatcompletion_with_tool_call(
"parameters": schemas.parameters
}
}]
kwargs["tool_choice"] = [{
kwargs["tool_choice"] = {
"type": "function",
"function": {"name": schemas.name}
}]
}

constructed_schema = {
"name": schemas.name,
Expand Down Expand Up @@ -139,7 +139,7 @@ async def _chatcompletion_with_tool_call(
req_template["required"].append(combine_name)

constructed_schema = {
"name": "structuredRet",
"name": "structuredRets",
"description": "Follow the schema",
"parameters": req_template
}
Expand All @@ -151,7 +151,7 @@ async def _chatcompletion_with_tool_call(
kwargs["tool_choice"] = {
"type": "function",
"function": {
"name": "structuredRet"
"name": "structuredRets"
}
}

Expand Down Expand Up @@ -190,18 +190,17 @@ async def _chatcompletion_with_tool_call(
else:
d = json.loads(
tool_call["function"]["arguments"])

for k, v in d.items():
if constructed_schema["name"] == "structuredRets":
for k, v in d.items():
structuredRets.append(StructuredRet(
name=k,
content=v
))
else:
structuredRets.append(StructuredRet(
name=k,
content=v
name=constructed_schema["name"],
content=d
))
# TODO: Find a better way to insert content
# if len(choice["message"]["content"].strip()) > 0:
# structuredRets.append(StructuredRet(
# name="content",
# content=choice["message"]["content"]
# ))
if len(structuredRets) == 1:
rets.append(structuredRets[0])
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "codelinker"
version = "0.2.9"
version = "0.2.10"
description = ""
authors = ["luyaxi <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit ecdeda9

Please sign in to comment.