Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
# Initialize InferenceClient with the token
|
| 9 |
-
client = InferenceClient(
|
| 10 |
-
model="abhillubillu/ai_gameapp",
|
| 11 |
-
token=hf_token # Use your token stored in HF_TOKEN_NEW
|
| 12 |
-
)
|
| 13 |
|
| 14 |
def respond(
|
| 15 |
message,
|
|
@@ -31,19 +27,21 @@ def respond(
|
|
| 31 |
|
| 32 |
response = ""
|
| 33 |
|
| 34 |
-
# Stream the response from the model
|
| 35 |
for message in client.chat_completion(
|
| 36 |
messages,
|
| 37 |
max_tokens=max_tokens,
|
| 38 |
-
stream=True,
|
| 39 |
temperature=temperature,
|
| 40 |
top_p=top_p,
|
| 41 |
):
|
| 42 |
token = message.choices[0].delta.content
|
|
|
|
| 43 |
response += token
|
| 44 |
yield response
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
demo = gr.ChatInterface(
|
| 48 |
respond,
|
| 49 |
additional_inputs=[
|
|
@@ -60,5 +58,6 @@ demo = gr.ChatInterface(
|
|
| 60 |
],
|
| 61 |
)
|
| 62 |
|
|
|
|
| 63 |
if __name__ == "__main__":
|
| 64 |
-
demo.launch(
|
|
|
|
| 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def respond(
|
| 11 |
message,
|
|
|
|
| 27 |
|
| 28 |
response = ""
|
| 29 |
|
|
|
|
| 30 |
for message in client.chat_completion(
|
| 31 |
messages,
|
| 32 |
max_tokens=max_tokens,
|
| 33 |
+
stream=True,
|
| 34 |
temperature=temperature,
|
| 35 |
top_p=top_p,
|
| 36 |
):
|
| 37 |
token = message.choices[0].delta.content
|
| 38 |
+
|
| 39 |
response += token
|
| 40 |
yield response
|
| 41 |
|
| 42 |
+
"""
|
| 43 |
+
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 44 |
+
"""
|
| 45 |
demo = gr.ChatInterface(
|
| 46 |
respond,
|
| 47 |
additional_inputs=[
|
|
|
|
| 58 |
],
|
| 59 |
)
|
| 60 |
|
| 61 |
+
|
| 62 |
if __name__ == "__main__":
|
| 63 |
+
demo.launch()
|