Spaces:
Runtime error
Runtime error
Can Günen commited on
Commit ·
839d8bc
1
Parent(s): fa728c7
no token needed
Browse files- app.py +1 -2
- document_chatbot.py +5 -12
app.py
CHANGED
|
@@ -13,10 +13,9 @@ with gr.Blocks() as demo:
|
|
| 13 |
text_input = gr.Textbox(label="Enter text or URL to text file")
|
| 14 |
with gr.Column():
|
| 15 |
with gr.Row():
|
| 16 |
-
api_key_input = gr.Textbox(label="Enter HF Token")
|
| 17 |
picked_model = gr.Dropdown(["google/flan-t5-large", "google/flan-t5-base","google/flan-t5-small"], label="Models", interactive=True)
|
| 18 |
load_configs = gr.Button("Load configs")
|
| 19 |
-
load_configs.click(document_chatbot.load_token_and_model, inputs=
|
| 20 |
|
| 21 |
chatbot = gr.Chatbot()
|
| 22 |
|
|
|
|
| 13 |
text_input = gr.Textbox(label="Enter text or URL to text file")
|
| 14 |
with gr.Column():
|
| 15 |
with gr.Row():
|
|
|
|
| 16 |
picked_model = gr.Dropdown(["google/flan-t5-large", "google/flan-t5-base","google/flan-t5-small"], label="Models", interactive=True)
|
| 17 |
load_configs = gr.Button("Load configs")
|
| 18 |
+
load_configs.click(document_chatbot.load_token_and_model, inputs=picked_model)
|
| 19 |
|
| 20 |
chatbot = gr.Chatbot()
|
| 21 |
|
document_chatbot.py
CHANGED
|
@@ -25,18 +25,11 @@ class DocumentChatbot:
|
|
| 25 |
self.init_mes = ["According to the document, ", "Based on the text, ", "I think, ", "According to the text, ", "Based on the document you provided, "]
|
| 26 |
|
| 27 |
|
| 28 |
-
def load_token_and_model(self,
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
if result == '{"error":"Invalid username or password."}':
|
| 34 |
-
return "Invalid API token"
|
| 35 |
-
else:
|
| 36 |
-
self.llm = HuggingFaceHub(repo_id=model_name, model_kwargs={"temperature":0, "max_length":512})
|
| 37 |
-
self.chain = load_qa_chain(self.llm, chain_type="stuff")
|
| 38 |
-
self.embeddings = HuggingFaceEmbeddings()
|
| 39 |
-
return "Model and Token successfully loaded"
|
| 40 |
|
| 41 |
|
| 42 |
def respond(self, text_input, question, chat_history):
|
|
|
|
| 25 |
self.init_mes = ["According to the document, ", "Based on the text, ", "I think, ", "According to the text, ", "Based on the document you provided, "]
|
| 26 |
|
| 27 |
|
| 28 |
+
def load_token_and_model(self, model_name):
|
| 29 |
+
self.llm = HuggingFaceHub(repo_id=model_name, model_kwargs={"temperature":0, "max_length":512})
|
| 30 |
+
self.chain = load_qa_chain(self.llm, chain_type="stuff")
|
| 31 |
+
self.embeddings = HuggingFaceEmbeddings()
|
| 32 |
+
return "Model and Token successfully loaded"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def respond(self, text_input, question, chat_history):
|