dlflannery commited on
Commit
d67b0e3
·
verified ·
1 Parent(s): 93675e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -10,16 +10,26 @@ uname = os.getenv('LOGNAME')
10
  pwd = os.getenv('PASSWORD')
11
 
12
  client = OpenAI(api_key = key)
 
 
13
 
14
  def clear():
 
 
 
 
15
  return [None, None]
16
 
17
-
18
  def chat(prompt, user_window, pwd_window):
 
 
19
  if user_window==uname and pwd_window==pwd:
 
20
  completion = client.chat.completions.create(model="gpt-4o-mini",
21
- messages=[{"role":"user", "content":prompt}])
22
- result = completion.choices[0].message.content
 
 
23
  else:
24
  result = "User name and/or password are incorrect"
25
  return result
 
10
  pwd = os.getenv('PASSWORD')
11
 
12
  client = OpenAI(api_key = key)
13
+ history = []
14
+ dialog = "Transcript:"
15
 
16
  def clear():
17
+ global history
18
+ global dialog
19
+ history=[]
20
+ dialog = "Transcript:"
21
  return [None, None]
22
 
 
23
  def chat(prompt, user_window, pwd_window):
24
+ global history
25
+ global dialog
26
  if user_window==uname and pwd_window==pwd:
27
+ history.append({"role":"user", "content":prompt})
28
  completion = client.chat.completions.create(model="gpt-4o-mini",
29
+ messages=history)
30
+ dialog += "\n\nYOU: " + prompt + "\nGPT: " + completion.choices[0].message.content
31
+ result = dialog
32
+ history.append(({"role":"assistant", "content":result}))
33
  else:
34
  result = "User name and/or password are incorrect"
35
  return result