gerasdf commited on
Commit
3886ef2
·
verified ·
1 Parent(s): 0da928c

filtering out files from hisitory

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -10,14 +10,15 @@ api_key = os.getenv("OPENAI_APIKEY")
10
  def chat(message, history):
11
  history_openai_format = []
12
  for human, assistant in history:
13
- history_openai_format.append({"role": "user", "content": human })
14
- history_openai_format.append({"role": "assistant", "content":assistant})
 
15
 
16
  history_openai_format.append({"role": "user", "content": message['text']})
17
 
18
- return f"{history}\n----\n{message}\n----\n{history_openai_format}"
19
 
20
- def comment():
21
  response = client.chat.completions.create(
22
  model='gpt-3.5-turbo',
23
  messages= history_openai_format,
 
10
  def chat(message, history):
11
  history_openai_format = []
12
  for human, assistant in history:
13
+ if (assistant is not None) and (type(human) is str):
14
+ history_openai_format.append({"role": "user", "content": human })
15
+ history_openai_format.append({"role": "assistant", "content":assistant})
16
 
17
  history_openai_format.append({"role": "user", "content": message['text']})
18
 
19
+ # return f"{history}\n----\n{message}\n----\n{history_openai_format}"
20
 
21
+ # def comment():
22
  response = client.chat.completions.create(
23
  model='gpt-3.5-turbo',
24
  messages= history_openai_format,