Spaces:
Build error
Build error
featured model
Browse files
app.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
| 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 |
-
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
system_instruction = """
|
|
@@ -58,17 +63,15 @@ def respond(
|
|
| 58 |
|
| 59 |
response = ""
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
top_p=top_p,
|
| 67 |
-
):
|
| 68 |
-
token = message.choices[0].delta.content
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
"""
|
|
@@ -77,7 +80,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 77 |
demo = gr.ChatInterface(
|
| 78 |
respond,
|
| 79 |
additional_inputs=[
|
| 80 |
-
gr.Textbox(value="You are a
|
| 81 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 82 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 83 |
gr.Slider(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
+
from mistralai import Mistral
|
| 4 |
+
import os
|
| 5 |
+
# Use the existing model and API key from the environment
|
| 6 |
+
|
| 7 |
|
| 8 |
"""
|
| 9 |
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
|
| 10 |
"""
|
| 11 |
+
os.environ["MISTRAL_API_KEY"] = "jhqYghj36E07hZ0Uj6oREXUSQbGdzSn2"
|
| 12 |
+
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
|
| 13 |
|
| 14 |
|
| 15 |
system_instruction = """
|
|
|
|
| 63 |
|
| 64 |
response = ""
|
| 65 |
|
| 66 |
+
chat_response = client.chat.complete(
|
| 67 |
+
model = "mistral-large-latest",
|
| 68 |
+
messages=messages,
|
| 69 |
+
)
|
| 70 |
+
token = chat_response.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
response += token
|
| 73 |
+
print(message)
|
| 74 |
+
yield response
|
| 75 |
|
| 76 |
|
| 77 |
"""
|
|
|
|
| 80 |
demo = gr.ChatInterface(
|
| 81 |
respond,
|
| 82 |
additional_inputs=[
|
| 83 |
+
gr.Textbox(value="You are a HR FAQ assistant ", label="System message"),
|
| 84 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 85 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 86 |
gr.Slider(
|