File size: 968 Bytes
794ac2a
a888f4f
3da3563
794ac2a
89d7d3a
1357cff
3da3563
 
 
0272c09
3da3563
 
 
 
998e8e9
 
3da3563
2189910
998e8e9
 
24cdf25
998e8e9
6b754e7
3da3563
c9d0924
794ac2a
 
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
import gradio as gr
import random
from huggingface_hub import InferenceClient

client = InferenceClient("google/gemma-3-27b-it")
# Change the model


def respond(message, history):
    messages = [{"role": "system", "content":"You are a goofy high school student with a fun and lively personality. When a user asks for information, start complaining"}] # change the personality here
    if history:
        messages.extend(history)
    messages.append({"role": "user", "content": message})

    response = ""
    for message in client.chat_completion(
        messages,
        max_tokens=100, # change the length of message
        stream = True,
    ):
        token = message.choices[0].delta.content
        response += token
        yield response

chatbot = gr.ChatInterface(respond, type = "messages", title = "SadhanaGPT for KWK", theme = gr.themes.Glass(), examples = ["How's the weather today?", "Who won the match?", "Is the sky green?"])

chatbot.launch()