Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
from github import Github
|
| 5 |
-
import
|
| 6 |
|
| 7 |
# Load openai key
|
| 8 |
openai.api_key = os.getenv('OPENAI_KEY')
|
|
@@ -17,8 +17,12 @@ message_history.append({"role": "user", "content": instructions})
|
|
| 17 |
# Message for User Interface
|
| 18 |
initial_message = "Please write your prompt here and press 'enter'"
|
| 19 |
|
| 20 |
-
# Creating a
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Add token and connect to repository
|
| 24 |
token = "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"
|
|
@@ -26,7 +30,7 @@ g = Github(token)
|
|
| 26 |
|
| 27 |
# Creating a new file with the user id to save the user responses and chat bot responses to the repository
|
| 28 |
repo = g.get_user().get_repo("CATData")
|
| 29 |
-
filename = 'User:' + str(
|
| 30 |
repo.create_file(filename, "Saving" + filename, "")
|
| 31 |
|
| 32 |
# Create function to process prompt and append previous prompts as "context"
|
|
@@ -71,7 +75,7 @@ def predict_prompt(input):
|
|
| 71 |
# Create UI using gradio
|
| 72 |
with gr.Blocks(theme=gr.themes.Monochrome()) as chatblock:
|
| 73 |
|
| 74 |
-
gr.Markdown("<h1><center>" + "Please type the id: " + str(
|
| 75 |
|
| 76 |
Chatbot = gr.Chatbot()
|
| 77 |
with gr.Row():
|
|
|
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
from github import Github
|
| 5 |
+
import uuid
|
| 6 |
|
| 7 |
# Load openai key
|
| 8 |
openai.api_key = os.getenv('OPENAI_KEY')
|
|
|
|
| 17 |
# Message for User Interface
|
| 18 |
initial_message = "Please write your prompt here and press 'enter'"
|
| 19 |
|
| 20 |
+
# Creating a unique id for the user
|
| 21 |
+
def generate_unique_id():
|
| 22 |
+
return str(uuid.uuid4())
|
| 23 |
+
|
| 24 |
+
# Example usage
|
| 25 |
+
unique_id = generate_unique_id()
|
| 26 |
|
| 27 |
# Add token and connect to repository
|
| 28 |
token = "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"
|
|
|
|
| 30 |
|
| 31 |
# Creating a new file with the user id to save the user responses and chat bot responses to the repository
|
| 32 |
repo = g.get_user().get_repo("CATData")
|
| 33 |
+
filename = 'User:' + str(unique_id) + '_Data.txt'
|
| 34 |
repo.create_file(filename, "Saving" + filename, "")
|
| 35 |
|
| 36 |
# Create function to process prompt and append previous prompts as "context"
|
|
|
|
| 75 |
# Create UI using gradio
|
| 76 |
with gr.Blocks(theme=gr.themes.Monochrome()) as chatblock:
|
| 77 |
|
| 78 |
+
gr.Markdown("<h1><center>" + "Please type the id: " + str(unique_id) + " in the user id question underneath the Chat Bot" + "</center></h1>")
|
| 79 |
|
| 80 |
Chatbot = gr.Chatbot()
|
| 81 |
with gr.Row():
|