bstraehle commited on
Commit
a6aeefa
1 Parent(s): 4117a83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -17,7 +17,7 @@ def init_assistant():
17
  _assistant = _client.beta.assistants.create(
18
  name="Math Tutor",
19
  instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
20
- model="gpt-4o",
21
  )
22
 
23
  _thread = _client.beta.threads.create()
@@ -47,13 +47,13 @@ def extract_content_values(data):
47
  def chat(message, history):
48
  global _client, _assistant, _thread
49
 
50
- history_openai_format = []
51
 
52
- for human, assistant in history:
53
- history_openai_format.append({"role": "user", "content": human})
54
- history_openai_format.append({"role": "assistant", "content":assistant})
55
 
56
- history_openai_format.append({"role": "user", "content": message})
57
 
58
  if len(history_openai_format) == 1:
59
  init_assistant()
@@ -61,9 +61,9 @@ def chat(message, history):
61
  #show_json("assistant", _assistant)
62
  #show_json("thread", _thread)
63
 
64
- print("### history")
65
- print(len(history_openai_format))
66
- print(history_openai_format)
67
 
68
  message = _client.beta.threads.messages.create(
69
  role="user",
@@ -71,7 +71,7 @@ def chat(message, history):
71
  content=message,
72
  )
73
 
74
- #show_json("message", message)
75
 
76
  run = _client.beta.threads.runs.create(
77
  assistant_id=_assistant.id,
 
17
  _assistant = _client.beta.assistants.create(
18
  name="Math Tutor",
19
  instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
20
+ model="gpt-4o-mini",
21
  )
22
 
23
  _thread = _client.beta.threads.create()
 
47
  def chat(message, history):
48
  global _client, _assistant, _thread
49
 
50
+ #history_openai_format = []
51
 
52
+ #for human, assistant in history:
53
+ # history_openai_format.append({"role": "user", "content": human})
54
+ # history_openai_format.append({"role": "assistant", "content":assistant})
55
 
56
+ #history_openai_format.append({"role": "user", "content": message})
57
 
58
  if len(history_openai_format) == 1:
59
  init_assistant()
 
61
  #show_json("assistant", _assistant)
62
  #show_json("thread", _thread)
63
 
64
+ #print("### history")
65
+ #print(len(history_openai_format))
66
+ #print(history_openai_format)
67
 
68
  message = _client.beta.threads.messages.create(
69
  role="user",
 
71
  content=message,
72
  )
73
 
74
+ show_json("message", message)
75
 
76
  run = _client.beta.threads.runs.create(
77
  assistant_id=_assistant.id,