Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,30 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
import json
|
4 |
-
import time
|
5 |
|
6 |
# Load data.json
|
7 |
with open('data.json') as f:
|
8 |
data = json.load(f)
|
9 |
|
10 |
-
client_endpoint = "https://olivier-truong-mistral-super-fast.hf.space/
|
11 |
|
12 |
def ask_question(question):
|
13 |
if question in data:
|
14 |
return data[question]
|
15 |
else:
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def typewriter(text: str, speed: int):
|
27 |
tokens = text.split()
|
|
|
1 |
import streamlit as st
|
2 |
+
from gradio_client import Client
|
|
|
|
|
3 |
|
4 |
# Load data.json
|
5 |
with open('data.json') as f:
|
6 |
data = json.load(f)
|
7 |
|
8 |
+
client_endpoint = "https://olivier-truong-mistral-super-fast.hf.space/"
|
9 |
|
10 |
def ask_question(question):
|
11 |
if question in data:
|
12 |
return data[question]
|
13 |
else:
|
14 |
+
client = Client(client_endpoint)
|
15 |
+
result = client.predict(
|
16 |
+
question,
|
17 |
+
0.9, # Temperature
|
18 |
+
2000, # Max new tokens
|
19 |
+
0.9, # Top-p (nucleus sampling)
|
20 |
+
1.2, # Repetition penalty
|
21 |
+
api_name="/chat"
|
22 |
+
)
|
23 |
+
answer = result["data"]
|
24 |
+
data[question] = answer
|
25 |
+
with open('data.json', 'w') as f:
|
26 |
+
json.dump(data, f)
|
27 |
+
return answer
|
28 |
|
29 |
def typewriter(text: str, speed: int):
|
30 |
tokens = text.split()
|