baconnier commited on
Commit
98f92f8
·
verified ·
1 Parent(s): 8b9d1e9

Update art_explorer.py

Browse files
Files changed (1) hide show
  1. art_explorer.py +11 -3
art_explorer.py CHANGED
@@ -1,7 +1,7 @@
1
  from typing import Optional, List, Dict
2
  import json
3
  from openai import OpenAI
4
- from prompts import SYSTEM_PROMPT, format_exploration_prompt, DEFAULT_RESPONSE
5
 
6
  class ExplorationPathGenerator:
7
  def __init__(self, api_key: str):
@@ -49,7 +49,15 @@ class ExplorationPathGenerator:
49
  )
50
 
51
  result = response.choices[0].message.content
52
- return json.loads(result)
 
 
 
 
 
 
 
 
53
  except Exception as e:
54
- print(f"Error generating exploration path: {e}")
55
  return DEFAULT_RESPONSE
 
1
  from typing import Optional, List, Dict
2
  import json
3
  from openai import OpenAI
4
+ from .prompts import SYSTEM_PROMPT, format_exploration_prompt, DEFAULT_RESPONSE
5
 
6
  class ExplorationPathGenerator:
7
  def __init__(self, api_key: str):
 
49
  )
50
 
51
  result = response.choices[0].message.content
52
+ try:
53
+ parsed_result = json.loads(result)
54
+ print("Generated response:", json.dumps(parsed_result, indent=2)) # Debug print
55
+ return parsed_result
56
+ except json.JSONDecodeError as e:
57
+ print(f"Error parsing JSON response: {e}")
58
+ print("Raw response:", result) # Debug print
59
+ return DEFAULT_RESPONSE
60
+
61
  except Exception as e:
62
+ print(f"Error in API call: {e}") # Debug print
63
  return DEFAULT_RESPONSE