Spaces:
Runtime error
Runtime error
File size: 567 Bytes
c1cb739 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
def greet(name):
return "Hello " + name + "!!"
from huggingface_hub import InferenceClient
client = InferenceClient(api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
messages = [
{
"role": "user",
"content": "What is the capital of France?"
}
]
stream = client.chat.completions.create(
model="Qwen/Qwen2.5-Math-7B-Instruct",
messages=messages,
max_tokens=500,
stream=True
)
for chunk in stream:
print(chunk.choices[0].delta.content, end="")
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()
|