Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
thread = 0
|
| 5 |
+
|
| 6 |
+
def chat_history(message,history):
|
| 7 |
+
|
| 8 |
+
global thread
|
| 9 |
+
|
| 10 |
+
response = requests.post("https://chat-csv-assistant.azurewebsites.net/api/func_generate", json={
|
| 11 |
+
"query":message,
|
| 12 |
+
"thread": thread,
|
| 13 |
+
}).json()
|
| 14 |
+
|
| 15 |
+
thread = response['thread']
|
| 16 |
+
|
| 17 |
+
return response['result']
|
| 18 |
+
|
| 19 |
+
gr.ChatInterface(
|
| 20 |
+
chat_history,
|
| 21 |
+
chatbot=gr.Chatbot(),
|
| 22 |
+
title="Grade Analyst",
|
| 23 |
+
description="Ask this bot any question about the csv",
|
| 24 |
+
theme="soft",
|
| 25 |
+
examples=["How many students are there?", "What's the average score for course total?","What are the steps you took to get this result?"],
|
| 26 |
+
retry_btn=None,
|
| 27 |
+
undo_btn=None,
|
| 28 |
+
clear_btn="Clear",
|
| 29 |
+
).launch()
|