Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import openai
|
|
| 3 |
import os
|
| 4 |
from github import Github
|
| 5 |
import uuid
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Create UI using gradio
|
| 8 |
with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}") as chatblock:
|
|
@@ -13,14 +15,22 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
|
|
| 13 |
new_id = str(uuid.uuid4())
|
| 14 |
return gr.Markdown(f"<h1><center> Session Id: {new_id} </center></h1>",visible=True)
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
initial_message = "Please write your prompt here and press 'enter'"
|
|
|
|
| 17 |
Chatbot = gr.Chatbot(label="Anonymous User")
|
| 18 |
|
| 19 |
with gr.Row():
|
| 20 |
txt = gr.Textbox(
|
| 21 |
show_label=False,
|
| 22 |
placeholder = initial_message)
|
| 23 |
-
|
| 24 |
txt.submit(None, None, txt, js="() => {''}")
|
| 25 |
|
| 26 |
chatblock.launch()
|
|
|
|
| 3 |
import os
|
| 4 |
from github import Github
|
| 5 |
import uuid
|
| 6 |
+
|
| 7 |
+
openai.api_key = os.getenv('OPENAI_KEY')
|
| 8 |
|
| 9 |
# Create UI using gradio
|
| 10 |
with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}") as chatblock:
|
|
|
|
| 15 |
new_id = str(uuid.uuid4())
|
| 16 |
return gr.Markdown(f"<h1><center> Session Id: {new_id} </center></h1>",visible=True)
|
| 17 |
|
| 18 |
+
message_history = []
|
| 19 |
+
|
| 20 |
+
# Adding the instructions to the message history in the content dictionary for the ChatBot to understand.
|
| 21 |
+
instructions = "Choose either to be accommodative or unaccommodative to the user. Please state whether you are going to be to be accommodative or unaccommodative in your first response"
|
| 22 |
+
message_history.append({"role": "user", "content": instructions})
|
| 23 |
+
|
| 24 |
+
# Message for User Interface
|
| 25 |
initial_message = "Please write your prompt here and press 'enter'"
|
| 26 |
+
|
| 27 |
Chatbot = gr.Chatbot(label="Anonymous User")
|
| 28 |
|
| 29 |
with gr.Row():
|
| 30 |
txt = gr.Textbox(
|
| 31 |
show_label=False,
|
| 32 |
placeholder = initial_message)
|
| 33 |
+
txt.submit(None, txt, Chatbot)
|
| 34 |
txt.submit(None, None, txt, js="() => {''}")
|
| 35 |
|
| 36 |
chatblock.launch()
|