Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
import openai
|
| 8 |
import json
|
| 9 |
|
|
@@ -16,7 +15,7 @@ from langchain import OpenAI
|
|
| 16 |
# handling data on space
|
| 17 |
|
| 18 |
from huggingface_hub import HfFileSystem
|
| 19 |
-
fs = HfFileSystem(token=
|
| 20 |
|
| 21 |
text_list = fs.ls("datasets/GoChat/Gochat247_Data/Data", detail=False)
|
| 22 |
|
|
@@ -50,7 +49,7 @@ class Chatbot:
|
|
| 50 |
|
| 51 |
def __init__(self, index):
|
| 52 |
self.index = index
|
| 53 |
-
openai.api_key =
|
| 54 |
self.chat_history = []
|
| 55 |
|
| 56 |
QA_PROMPT_TMPL = (
|
|
@@ -99,19 +98,18 @@ class Chatbot:
|
|
| 99 |
|
| 100 |
bot = Chatbot(index=index)
|
| 101 |
|
| 102 |
-
import webbrowser
|
| 103 |
|
| 104 |
import gradio as gr
|
| 105 |
import time
|
| 106 |
|
| 107 |
with gr.Blocks(theme='SebastianBravo/simci_css') as demo:
|
| 108 |
-
|
|
|
|
| 109 |
title = 'GoChat247 AI BOT'
|
| 110 |
chatbot = gr.Chatbot(label='GoChat247 AI BOT')
|
| 111 |
msg = gr.Textbox()
|
| 112 |
clear = gr.Button("Clear")
|
| 113 |
|
| 114 |
-
|
| 115 |
def user(user_message, history):
|
| 116 |
return "", history + [[user_message, None]]
|
| 117 |
|
|
@@ -125,16 +123,5 @@ with gr.Blocks(theme='SebastianBravo/simci_css') as demo:
|
|
| 125 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(agent, chatbot, chatbot)
|
| 126 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 127 |
|
| 128 |
-
|
| 129 |
if __name__ == "__main__":
|
| 130 |
-
demo.launch()
|
| 131 |
-
|
| 132 |
-
# handling dark_theme
|
| 133 |
-
|
| 134 |
-
def apply_dark_theme(url):
|
| 135 |
-
if not url.endswith('?__theme=dark'):
|
| 136 |
-
webbrowser.open(url + '?__theme=dark', new=0, autoraise=True)
|
| 137 |
-
|
| 138 |
-
gradioURL = 'http://localhost:7860/'
|
| 139 |
-
apply_dark_theme(gradioURL)
|
| 140 |
-
|
|
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
+
Open_AI_Key = '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'
|
| 4 |
+
HF_Key = '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'
|
| 5 |
+
os.environ['OPENAI_API_KEY'] = Open_AI_Key
|
|
|
|
| 6 |
import openai
|
| 7 |
import json
|
| 8 |
|
|
|
|
| 15 |
# handling data on space
|
| 16 |
|
| 17 |
from huggingface_hub import HfFileSystem
|
| 18 |
+
fs = HfFileSystem(token=HF_Key)
|
| 19 |
|
| 20 |
text_list = fs.ls("datasets/GoChat/Gochat247_Data/Data", detail=False)
|
| 21 |
|
|
|
|
| 49 |
|
| 50 |
def __init__(self, index):
|
| 51 |
self.index = index
|
| 52 |
+
openai.api_key = Open_AI_Key
|
| 53 |
self.chat_history = []
|
| 54 |
|
| 55 |
QA_PROMPT_TMPL = (
|
|
|
|
| 98 |
|
| 99 |
bot = Chatbot(index=index)
|
| 100 |
|
|
|
|
| 101 |
|
| 102 |
import gradio as gr
|
| 103 |
import time
|
| 104 |
|
| 105 |
with gr.Blocks(theme='SebastianBravo/simci_css') as demo:
|
| 106 |
+
|
| 107 |
+
with gr.Column(variant='panel'):
|
| 108 |
title = 'GoChat247 AI BOT'
|
| 109 |
chatbot = gr.Chatbot(label='GoChat247 AI BOT')
|
| 110 |
msg = gr.Textbox()
|
| 111 |
clear = gr.Button("Clear")
|
| 112 |
|
|
|
|
| 113 |
def user(user_message, history):
|
| 114 |
return "", history + [[user_message, None]]
|
| 115 |
|
|
|
|
| 123 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(agent, chatbot, chatbot)
|
| 124 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 125 |
|
|
|
|
| 126 |
if __name__ == "__main__":
|
| 127 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|