Skip to content

Commit

Permalink
remove notebook, modify prepare output method
Browse files Browse the repository at this point in the history
  • Loading branch information
bfdykstra committed Jan 6, 2025
1 parent 3ebc021 commit a016a28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 166 deletions.
8 changes: 2 additions & 6 deletions libs/kotaemon/kotaemon/llms/chats/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ def prepare_output(self, resp: dict) -> StructuredOutputLLMInterface:
"""Convert the OpenAI response into StructuredOutputLLMInterface"""
additional_kwargs = {}

if 'parsed' in resp['choices'][0]['message']:
additional_kwargs['parsed'] = resp["choices"][0]["message"][
"parsed"
]

if "tool_calls" in resp["choices"][0]["message"]:
additional_kwargs["tool_calls"] = resp["choices"][0]["message"][
"tool_calls"
Expand All @@ -359,7 +354,7 @@ def prepare_output(self, resp: dict) -> StructuredOutputLLMInterface:
)

output = StructuredOutputLLMInterface(
**additional_kwargs, # TODO: clarify how additional_kwargs is used - diff bw BaseChatOpenAI usage and here
parsed = resp["choices"][0]["message"]["parsed"],
candidates=[(_["message"]["content"] or "") for _ in resp["choices"]],
content=resp["choices"][0]["message"]["content"] or "",
total_tokens=resp["usage"]["total_tokens"],
Expand All @@ -369,6 +364,7 @@ def prepare_output(self, resp: dict) -> StructuredOutputLLMInterface:
AIMessage(content=(_["message"]["content"]) or "")
for _ in resp["choices"]
],
additional_kwargs=additional_kwargs,
logprobs=logprobs,

)
Expand Down
160 changes: 0 additions & 160 deletions libs/kotaemon/test_structured_output.ipynb

This file was deleted.

0 comments on commit a016a28

Please sign in to comment.