Spaces:
Sleeping
Sleeping
initial commit
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from chatbot_simulator import ChatbotSimulation
|
3 |
from task_specific_data_population import DataPopulation
|
4 |
import os
|
5 |
-
openai_api_key = os.getenv("OPENAI_API_KEY")
|
6 |
|
7 |
|
8 |
simulation = None
|
@@ -36,8 +36,11 @@ def initialize_simulator(task, app_name, sitemap):
|
|
36 |
global conversation
|
37 |
conversation.append({"role": "assistant", "content": text})
|
38 |
log_conversation(simulation.log_location)
|
|
|
|
|
39 |
display_conversation.append(('Start Simulator', text))
|
40 |
-
display_conversation
|
|
|
41 |
return display_conversation
|
42 |
except Exception as e:
|
43 |
# Handle the exception and increment retry count
|
@@ -70,7 +73,6 @@ def chatbot_interaction(user_input):
|
|
70 |
conversation.append({"role": "assistant", "content": response})
|
71 |
log_conversation(simulation.log_location)
|
72 |
display_conversation.append((user_input, response))
|
73 |
-
display_conversation.pop(0)
|
74 |
return display_conversation
|
75 |
except Exception as e:
|
76 |
return f"An error occurred: {e}"
|
|
|
2 |
from chatbot_simulator import ChatbotSimulation
|
3 |
from task_specific_data_population import DataPopulation
|
4 |
import os
|
5 |
+
openai_api_key = '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'#os.getenv("OPENAI_API_KEY")
|
6 |
|
7 |
|
8 |
simulation = None
|
|
|
36 |
global conversation
|
37 |
conversation.append({"role": "assistant", "content": text})
|
38 |
log_conversation(simulation.log_location)
|
39 |
+
|
40 |
+
global display_conversation
|
41 |
display_conversation.append(('Start Simulator', text))
|
42 |
+
if len(display_conversation) > 2:
|
43 |
+
display_conversation.pop(0)
|
44 |
return display_conversation
|
45 |
except Exception as e:
|
46 |
# Handle the exception and increment retry count
|
|
|
73 |
conversation.append({"role": "assistant", "content": response})
|
74 |
log_conversation(simulation.log_location)
|
75 |
display_conversation.append((user_input, response))
|
|
|
76 |
return display_conversation
|
77 |
except Exception as e:
|
78 |
return f"An error occurred: {e}"
|