anzorq commited on
Commit
955744f
1 Parent(s): 47a2cbe
Files changed (1) hide show
  1. app.py +1 -4
app.py CHANGED
@@ -37,9 +37,6 @@ def on_prompt_template_change(prompt_template):
37
 
38
  def submit_message(user_token, prompt, prompt_template, temperature, max_tokens, state):
39
 
40
- if not prompt:
41
- return gr.update(value=''), None, "", state
42
-
43
  history = state['messages']
44
 
45
  if not prompt:
@@ -62,7 +59,7 @@ def submit_message(user_token, prompt, prompt_template, temperature, max_tokens,
62
  return '', [(history[i]['content'], history[i+1]['content']) for i in range(0, len(history)-1, 2)], f"Total tokens used: 0", state
63
 
64
  try:
65
- completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=system_prompt + history + [prompt_msg], temperature=temperature, max_tokens=max_tokens)
66
 
67
  history.append(prompt_msg)
68
  history.append(completion.choices[0].message.to_dict())
 
37
 
38
  def submit_message(user_token, prompt, prompt_template, temperature, max_tokens, state):
39
 
 
 
 
40
  history = state['messages']
41
 
42
  if not prompt:
 
59
  return '', [(history[i]['content'], history[i+1]['content']) for i in range(0, len(history)-1, 2)], f"Total tokens used: 0", state
60
 
61
  try:
62
+ completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=system_prompt + history[-4:] + [prompt_msg], temperature=temperature, max_tokens=max_tokens)
63
 
64
  history.append(prompt_msg)
65
  history.append(completion.choices[0].message.to_dict())