Spaces:
Running
Running
Update app.py
Browse files
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=
|
22 |
-
|
|
|
|
|
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
|