File size: 552 Bytes
80cb67e
a1b63cd
 
 
 
 
 
80cb67e
 
a1b63cd
 
 
 
 
 
 
80cb67e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from huggingface_hub import InferenceClient


#client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
client = InferenceClient("google/gemma-2-27b-it")


def greet(name):
    messages = [{"role": "user", "content": name}]
    generated = ""
    for token in client.chat_completion(messages, max_tokens=100,stream=True):
        content = (token.choices[0].delta.content)
        generated+=content
        print(generated)
        yield generated

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()