Skip to content

Commit

Permalink
Improve format checking
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Sep 2, 2024
1 parent b148042 commit 678fa40
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libs/core/kiln_ai/adapters/prompt_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ async def run(self, input: str) -> str:
prompt += f"\n\n{input}"
response = self.model.invoke(prompt)
if self.__is_structured:
if not isinstance(response, dict) or "parsed" not in response:
if (
not isinstance(response, dict)
or "parsed" not in response
or not isinstance(response["parsed"], dict)
):
raise RuntimeError(f"structured response not returned: {response}")
structured_response = response["parsed"]
# TODO: not JSON, use a dict here
Expand Down

0 comments on commit 678fa40

Please sign in to comment.