Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
elif "Star" in model:
|
9 |
-
return InferenceClient("HuggingFaceH4/starchat2-15b-v0.1")
|
10 |
-
elif "Mistral" in model:
|
11 |
-
return InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
12 |
-
elif "Phi" in model:
|
13 |
-
return InferenceClient("microsoft/Phi-3-mini-4k-instruct")
|
14 |
-
else:
|
15 |
-
return InferenceClient("google/gemma-1.1-2b-it")
|
16 |
-
|
17 |
-
system_instructions1 = "[SYSTEM] Your task is to Answer the question. Keep conversation very short, clear and concise. The expectation is that you will avoid introductions and start answering the query directly, Only answer the question asked by user, Do not say unnecessary things.[QUESTION]"
|
18 |
-
|
19 |
-
def models(text, model="Mixtral 8x7B"):
|
20 |
-
|
21 |
-
client = client_fn(model)
|
22 |
-
|
23 |
-
generate_kwargs = dict(
|
24 |
-
max_new_tokens=100,
|
25 |
-
do_sample=True,
|
26 |
-
)
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
|
39 |
description="# Chat GO"
|
40 |
|
41 |
-
demo = gr.Interface(description=description,fn=models, inputs=["text"
|
42 |
demo.queue(max_size=300000)
|
43 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
client = InferenceClient("google/gemma-1.1-2b-it")
|
5 |
|
6 |
+
system_instructions = "[SYSTEM] Your task is to Answer the question. Keep conversation very short, clear and concise. The expectation is that you will avoid introductions and start answering the query directly, Only answer the question asked by user, Do not say unnecessary things.[QUESTION]"
|
7 |
+
|
8 |
+
def models(message):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
messages.append({"role": "user", "content": f"[SYSTEM] You are REAL TIME QnA AI who answer question asked by uer in short and concise [USER] {message}"})
|
11 |
+
|
12 |
+
response = ""
|
13 |
+
|
14 |
+
for message in client.chat_completion(
|
15 |
+
messages,
|
16 |
+
max_tokens=200,
|
17 |
+
stream=True
|
18 |
+
):
|
19 |
+
token = message.choices[0].delta.content
|
20 |
+
|
21 |
+
response += token
|
22 |
+
yield response
|
23 |
|
24 |
description="# Chat GO"
|
25 |
|
26 |
+
demo = gr.Interface(description=description,fn=models, inputs=["text"], outputs="text", live=True, batch=True, max_batch_size=10000)
|
27 |
demo.queue(max_size=300000)
|
28 |
demo.launch()
|