Spaces:
Runtime error
Runtime error
sent testing
Browse files- app.py +7 -63
- app_old.py +66 -0
app.py
CHANGED
@@ -1,66 +1,10 @@
|
|
1 |
-
import
|
2 |
-
from
|
3 |
|
4 |
-
""
|
5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
-
"""
|
7 |
-
# client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
-
client = InferenceClient("TheBloke/Mistral-7B-Instruct-v0.2-GPTQ")
|
9 |
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
message,
|
15 |
-
history: list[tuple[str, str]],
|
16 |
-
system_message,
|
17 |
-
max_tokens,
|
18 |
-
temperature,
|
19 |
-
top_p,
|
20 |
-
):
|
21 |
-
messages = [{"role": "system", "content": system_message}]
|
22 |
-
|
23 |
-
for val in history:
|
24 |
-
if val[0]:
|
25 |
-
messages.append({"role": "user", "content": val[0]})
|
26 |
-
if val[1]:
|
27 |
-
messages.append({"role": "assistant", "content": val[1]})
|
28 |
-
|
29 |
-
messages.append({"role": "user", "content": message})
|
30 |
-
|
31 |
-
response = ""
|
32 |
-
|
33 |
-
for message in client.chat_completion(
|
34 |
-
messages,
|
35 |
-
max_tokens=max_tokens,
|
36 |
-
stream=True,
|
37 |
-
temperature=temperature,
|
38 |
-
top_p=top_p,
|
39 |
-
):
|
40 |
-
token = message.choices[0].delta.content
|
41 |
-
|
42 |
-
response += token
|
43 |
-
yield response
|
44 |
-
|
45 |
-
"""
|
46 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
47 |
-
"""
|
48 |
-
demo = gr.ChatInterface(
|
49 |
-
respond,
|
50 |
-
additional_inputs=[
|
51 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
52 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
53 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
54 |
-
gr.Slider(
|
55 |
-
minimum=0.1,
|
56 |
-
maximum=1.0,
|
57 |
-
value=0.95,
|
58 |
-
step=0.05,
|
59 |
-
label="Top-p (nucleus sampling)",
|
60 |
-
),
|
61 |
-
],
|
62 |
-
)
|
63 |
-
|
64 |
-
|
65 |
-
if __name__ == "__main__":
|
66 |
-
demo.launch()
|
|
|
1 |
+
import steamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
pipe = pipeline("sentiment-analysis")
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
text = st.text_area("enter some text")
|
7 |
|
8 |
+
if text:
|
9 |
+
out = pipe(text)
|
10 |
+
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app_old.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import InferenceClient
|
3 |
+
|
4 |
+
"""
|
5 |
+
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
+
"""
|
7 |
+
# client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
+
client = InferenceClient("TheBloke/Mistral-7B-Instruct-v0.2-GPTQ")
|
9 |
+
|
10 |
+
|
11 |
+
print("test")
|
12 |
+
|
13 |
+
def respond(
|
14 |
+
message,
|
15 |
+
history: list[tuple[str, str]],
|
16 |
+
system_message,
|
17 |
+
max_tokens,
|
18 |
+
temperature,
|
19 |
+
top_p,
|
20 |
+
):
|
21 |
+
messages = [{"role": "system", "content": system_message}]
|
22 |
+
|
23 |
+
for val in history:
|
24 |
+
if val[0]:
|
25 |
+
messages.append({"role": "user", "content": val[0]})
|
26 |
+
if val[1]:
|
27 |
+
messages.append({"role": "assistant", "content": val[1]})
|
28 |
+
|
29 |
+
messages.append({"role": "user", "content": message})
|
30 |
+
|
31 |
+
response = ""
|
32 |
+
|
33 |
+
for message in client.chat_completion(
|
34 |
+
messages,
|
35 |
+
max_tokens=max_tokens,
|
36 |
+
stream=True,
|
37 |
+
temperature=temperature,
|
38 |
+
top_p=top_p,
|
39 |
+
):
|
40 |
+
token = message.choices[0].delta.content
|
41 |
+
|
42 |
+
response += token
|
43 |
+
yield response
|
44 |
+
|
45 |
+
"""
|
46 |
+
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
47 |
+
"""
|
48 |
+
demo = gr.ChatInterface(
|
49 |
+
respond,
|
50 |
+
additional_inputs=[
|
51 |
+
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
52 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
53 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
54 |
+
gr.Slider(
|
55 |
+
minimum=0.1,
|
56 |
+
maximum=1.0,
|
57 |
+
value=0.95,
|
58 |
+
step=0.05,
|
59 |
+
label="Top-p (nucleus sampling)",
|
60 |
+
),
|
61 |
+
],
|
62 |
+
)
|
63 |
+
|
64 |
+
|
65 |
+
if __name__ == "__main__":
|
66 |
+
demo.launch()
|