From 9c4e32006352e6a96c04fc7a3fe4feaa4460b9e0 Mon Sep 17 00:00:00 2001 From: Gal Date: Mon, 10 Feb 2025 21:27:13 +0100 Subject: [PATCH] fix: Fix prompt --- anki_generator/clients/llm.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/anki_generator/clients/llm.py b/anki_generator/clients/llm.py index f0c2a60..9a690af 100644 --- a/anki_generator/clients/llm.py +++ b/anki_generator/clients/llm.py @@ -16,7 +16,8 @@ class AnthropicClient: """Get card information from Anthropic API""" prompt = f""" Create an Anki card for the German word "{word}" (source: {source}). - Return the response in the following JSON format: + IMPORTANT: Respond with ONLY the JSON object, no other text. + Format: {{ "german_word": "", "part_of_speech": "", @@ -36,7 +37,7 @@ class AnthropicClient: model=self.model, max_tokens=self.max_tokens, temperature=self.temperature, - system="You are a helpful German language teaching assistant. Always respond with valid JSON.", + system="You are a helpful German language teaching assistant. Return ONLY valid JSON without any additional text or explanations.", messages=[ { "role": "user", @@ -49,4 +50,4 @@ class AnthropicClient: return json.loads(message.content[0].text) except (json.JSONDecodeError, IndexError) as e: print(message) - raise ValueError(f"Failed to parse API response as JSON: {e}") \ No newline at end of file + raise ValueError(f"Failed to parse API response as JSON: {e}")