Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
-
os.environ['OPENAI_API_KEY'] = "
|
| 4 |
import openai
|
| 5 |
import json
|
| 6 |
|
|
@@ -13,7 +13,7 @@ from langchain import OpenAI
|
|
| 13 |
# handling data on space
|
| 14 |
|
| 15 |
from huggingface_hub import HfFileSystem
|
| 16 |
-
fs = HfFileSystem(token=
|
| 17 |
|
| 18 |
text_list = fs.ls("datasets/GoChat/Gochat247_Data/Data", detail=False)
|
| 19 |
|
|
@@ -45,9 +45,9 @@ index = GPTSimpleVectorIndex.from_documents(docs)
|
|
| 45 |
## Define Chat BOT Class to generate Response , handle chat history,
|
| 46 |
class Chatbot:
|
| 47 |
|
| 48 |
-
def __init__(self,
|
| 49 |
self.index = index
|
| 50 |
-
openai.api_key =
|
| 51 |
self.chat_history = []
|
| 52 |
|
| 53 |
QA_PROMPT_TMPL = (
|
|
@@ -94,8 +94,9 @@ class Chatbot:
|
|
| 94 |
|
| 95 |
## Define Chat BOT Class to generate Response , handle chat history,
|
| 96 |
|
| 97 |
-
bot = Chatbot(
|
| 98 |
|
|
|
|
| 99 |
|
| 100 |
import gradio as gr
|
| 101 |
import time
|
|
@@ -120,10 +121,11 @@ with gr.Blocks(theme='SebastianBravo/simci_css') as demo:
|
|
| 120 |
|
| 121 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(agent, chatbot, chatbot)
|
| 122 |
clear.click(lambda: None, None, chatbot, queue=False)
|
|
|
|
| 123 |
|
| 124 |
# handling dark_theme
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
# def apply_dark_theme(url):
|
| 129 |
# if not url.endswith('?__theme=dark'):
|
|
@@ -133,5 +135,4 @@ import webbrowser
|
|
| 133 |
# apply_dark_theme(gradioURL)
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
| 136 |
-
demo.launch()
|
| 137 |
-
print(webbrowser.get())
|
|
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
+
os.environ['OPENAI_API_KEY'] = "Open_AI_Key"
|
| 4 |
import openai
|
| 5 |
import json
|
| 6 |
|
|
|
|
| 13 |
# handling data on space
|
| 14 |
|
| 15 |
from huggingface_hub import HfFileSystem
|
| 16 |
+
fs = HfFileSystem(token="HF_Key")
|
| 17 |
|
| 18 |
text_list = fs.ls("datasets/GoChat/Gochat247_Data/Data", detail=False)
|
| 19 |
|
|
|
|
| 45 |
## Define Chat BOT Class to generate Response , handle chat history,
|
| 46 |
class Chatbot:
|
| 47 |
|
| 48 |
+
def __init__(self, index):
|
| 49 |
self.index = index
|
| 50 |
+
openai.api_key = Open_AI_Key
|
| 51 |
self.chat_history = []
|
| 52 |
|
| 53 |
QA_PROMPT_TMPL = (
|
|
|
|
| 94 |
|
| 95 |
## Define Chat BOT Class to generate Response , handle chat history,
|
| 96 |
|
| 97 |
+
bot = Chatbot(index=index)
|
| 98 |
|
| 99 |
+
import webbrowser
|
| 100 |
|
| 101 |
import gradio as gr
|
| 102 |
import time
|
|
|
|
| 121 |
|
| 122 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(agent, chatbot, chatbot)
|
| 123 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 124 |
+
print(webbrowser.get())
|
| 125 |
|
| 126 |
# handling dark_theme
|
| 127 |
|
| 128 |
+
|
| 129 |
|
| 130 |
# def apply_dark_theme(url):
|
| 131 |
# if not url.endswith('?__theme=dark'):
|
|
|
|
| 135 |
# apply_dark_theme(gradioURL)
|
| 136 |
|
| 137 |
if __name__ == "__main__":
|
| 138 |
+
demo.launch()
|
|
|