From 2e316548e7aaaef4c00f87b07e494fb71d44f852 Mon Sep 17 00:00:00 2001 From: KoalaTrapLord <265133236+KoalaTrapLord@users.noreply.github.com> Date: Thu, 26 Mar 2026 13:11:55 -0400 Subject: [PATCH] fix: repair resp= assignment and _re.sub typo in coach_service.py (#105) --- coach/coach_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coach/coach_service.py b/coach/coach_service.py index 9cb8048..a7b6768 100644 --- a/coach/coach_service.py +++ b/coach/coach_service.py @@ -281,7 +281,7 @@ class CoachService: if not anthropic_key: raise ConnectionError("Anthropic API key not configured. Set ANTHROPIC_API_KEY env var.") aclient = anthropic.AsyncAnthropic(api_key=anthropic_key) - = await aclient.messages.create( + resp = await aclient.messages.create( model=ANTHROPIC_MODEL, system=system_prompt, messages=[{"role": "user", "content": user_prompt}], @@ -300,7 +300,7 @@ class CoachService: completion_tokens=usage.output_tokens if usage else 0, parsed_json=None, ) - cleaned = _re.sub(r'\s*```$', '', cleaned.strip()) + try: cleaned = re.sub(r'^```(?:json)?\s*', '', content.strip()) cleaned = re.sub(r'\s*```$', '', cleaned.strip()) llm_response.parsed_json = json.loads(cleaned) except (json.JSONDecodeError, ValueError): # Try to find JSON object in the text