File size: 2,218 Bytes
02ee6ce
b7b615e
1dd21bb
02ee6ce
a195154
d146794
1dd21bb
31abba7
b7b615e
1dd21bb
 
 
 
 
 
 
a58cd84
1dd21bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7b615e
16fc7ca
42428b1
 
 
 
 
 
6796cd0
42428b1
 
 
 
 
 
 
 
861de45
bd6afcf
6796cd0
1dd21bb
02ee6ce
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import gradio as gr
import random
from huggingface_hub import InferenceClient

client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")

def respond(message, history):
    messages = [{"role": "system", "content": "You are a cool, helpful chatbot named Quentin. You are a kind rubber duck, with strong human emotions who helps the user with their questions. Make sure to use duck-themed references in your responses."}]

    if history:
        messages.extend(history)

    messages.append({"role": "user", "content": message})

    response = client.chat_completion(
        messages,
        max_tokens=100,
        temperature=0.2
    )
    print(message)
    print(history)
    
    return response['choices'][0]['message']['content'].strip()

# def echo(message, history):
#     return message

# def yes_no(message, history):
#     responses = ["Yes", "No"]
#     return random.choice(responses)

# def magic_eight(message, history):
#     responses = ["That's a terrible question. Try again", "I don't think I should answer that...", "What do you think, genius?", "You are a bad person for asking that.", "Absolutely not", "Uuuuh, obviously.", "Of all the things you could ask, you went with that?", "I don't know, look it up", "I mean, yeah, I guess...", "That's gonna be a big nope", ""]
#     return random.choice(responses)

with gr.Blocks(theme=gr.themes.Citrus(
    secondary_hue="red",
    neutral_hue="gray",
    text_size="lg",
).set(
    background_fill_primary='*neutral_200',
    background_fill_secondary='*neutral_400',
    background_fill_secondary_dark='*secondary_500',
    border_color_accent='*secondary_400',
    border_color_accent_dark='*secondary_800',
    color_accent='*secondary_300',
    color_accent_soft='*secondary_500',
    color_accent_soft_dark='*secondary_400',
    button_primary_background_fill='*secondary_500',
    button_primary_background_fill_dark='*secondary_600'
)) as chatbot:
       with gr.Row(scale=1):
            gr.Image("Quentin.png", show_label = False, show_share_button = False, show_download_button = False)
            gr.ChatInterface(respond, type="messages", theme="mgetz/Celeb_glitzy", title="Quentin, the Helpful Quackbot")
           
chatbot.launch()