ranranrunforit commited on
Commit
0f3fe6e
·
verified ·
1 Parent(s): 7ca89a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -76,7 +76,7 @@ tools = [{"type": "function", "function": record_user_details_json},
76
  class Me:
77
 
78
  def __init__(self):
79
- open_router_api_key = os.environ.get('OPEN_ROUTER_API_KEY')
80
  if open_router_api_key:
81
  print(f"Open router API Key exists and begins {open_router_api_key[:8]}")
82
  else:
@@ -124,7 +124,16 @@ If the user is engaging in discussion, try to steer them towards getting in touc
124
  messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
125
  done = False
126
  while not done:
127
- response = self.client.chat.completions.create(model="meta-llama/llama-3.3-8b-instruct:free", messages=messages, tools=tools)
 
 
 
 
 
 
 
 
 
128
  if response.choices[0].finish_reason=="tool_calls":
129
  message = response.choices[0].message
130
  tool_calls = message.tool_calls
 
76
  class Me:
77
 
78
  def __init__(self):
79
+ open_router_api_key = os.getenv('OPEN_ROUTER_API_KEY')
80
  if open_router_api_key:
81
  print(f"Open router API Key exists and begins {open_router_api_key[:8]}")
82
  else:
 
124
  messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
125
  done = False
126
  while not done:
127
+ #response = self.client.chat.completions.create(model="meta-llama/llama-3.3-8b-instruct:free", messages=messages, tools=tools)
128
+ try:
129
+ response = self.openai.chat.completions.create(
130
+ model="meta-llama/llama-3.3-8b-instruct:free",
131
+ messages=messages,
132
+ tools=tools
133
+ )
134
+ except Exception as e:
135
+ print(f"Error during OpenAI API call: {e}")
136
+
137
  if response.choices[0].finish_reason=="tool_calls":
138
  message = response.choices[0].message
139
  tool_calls = message.tool_calls