File size: 4,422 Bytes
c764afa
bfe9663
 
b663990
bfe9663
c764afa
 
 
 
 
 
9243fd8
34e04e2
18a7206
c764afa
 
b9dc825
9828ab2
7cc073a
 
 
 
83f518b
7cc073a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83f518b
 
 
377e425
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from huggingface_hub import InferenceClient
import gradio as gr
import random
client=InferenceClient("Qwen/Qwen2.5-72B-Instruct")
def respond(message, history):
    #responses = ["Yes", "No"]
    #return random.choice(responses)

    if history:
        messages.extend(history)

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

    response = client.chat_completion(messages, max_tokens=100,temperature=1.3,top_p=.2)

    return response['choices'][0]['message']['content'].strip()
messages = [{"role":"system","content":"you are a friendly chatbot"}]

gr.themes.builder()
custom_theme = gr.themes.Citrus(
    primary_hue=gr.themes.Color(c100="#fff4c6", c200="#f89e19", c300="#fcd34d", c400="#fbbf24", c50="rgba(0, 0, 0, 1)", c500="#f59e0b", c600="#d97706", c700="#b45309", c800="#92400e", c900="#78350f", c950="#6c370f"),
    neutral_hue=gr.themes.Color(c100="#f89e19", c200="#f89e19", c300="#782dba", c400="rgba(255, 219.05424040450472, 76.05263157894738, 1)", c50="#fefce8", c500="rgba(255, 222.06596413600374, 119.67105263157895, 1)", c600="rgba(255, 195.35087719298247, 70.46052631578947, 1)", c700="rgba(255, 186.82715311004787, 88.35526315789473, 1)", c800="rgba(255, 185.52631578947367, 107.36842105263158, 1)", c900="rgba(255, 167.29224376731304, 88.35526315789473, 1)", c950="rgba(255, 195.00951173113506, 136.44736842105263, 1)"),
).set(
    background_fill_primary='*primary_100',
    background_fill_primary_dark='*neutral_300',
    background_fill_secondary='*primary_100',
    background_fill_secondary_dark='*primary_100',
    border_color_accent='*primary_100',
    border_color_accent_dark='*primary_100',
    border_color_accent_subdued='*primary_100',
    border_color_accent_subdued_dark='*primary_100',
    border_color_primary='*primary_100',
    border_color_primary_dark='*primary_100',
    color_accent='*primary_100',
    color_accent_soft='*primary_100',
    color_accent_soft_dark='*primary_100',
    link_text_color='*primary_50',
    link_text_color_dark='*primary_50',
    link_text_color_active='*primary_50',
    link_text_color_active_dark='*primary_50',
    link_text_color_hover='*primary_50',
    link_text_color_hover_dark='*primary_50',
    link_text_color_visited='*primary_50',
    link_text_color_visited_dark='*primary_50',
    code_background_fill='*primary_50',
    code_background_fill_dark='*primary_100',
    block_background_fill_dark='*primary_100',
    block_border_color='*primary_100',
    block_border_color_dark='*primary_100',
    block_info_text_color='*primary_50',
    block_info_text_color_dark='*primary_100',
    block_label_background_fill='*primary_100',
    block_label_background_fill_dark='*primary_100',
    block_label_border_color='*primary_100',
    block_label_border_color_dark='*primary_100',
    block_label_text_color='*primary_50',
    block_label_text_color_dark='*primary_50',
    block_title_border_color_dark='*primary_50',
    accordion_text_color='*primary_100',
    accordion_text_color_dark='*primary_100',
    checkbox_background_color_dark='*primary_100',
    input_background_fill_dark='*primary_100',
    input_background_fill_focus='*primary_100',
    input_background_fill_focus_dark='*primary_100',
    input_background_fill_hover='*primary_100',
    input_background_fill_hover_dark='*primary_100',
    table_odd_background_fill_dark='*primary_100',
    button_primary_background_fill='*primary_50',
    button_primary_background_fill_dark='*primary_100',
    button_primary_background_fill_hover='*primary_200',
    button_primary_border_color='*primary_100',
    button_primary_border_color_dark='*primary_100',
    button_primary_border_color_hover='*primary_100',
    button_primary_border_color_hover_dark='*primary_100',
    button_primary_text_color='*primary_50',
    button_primary_text_color_dark='*primary_50',
    button_primary_text_color_hover='*primary_50',
    button_primary_text_color_hover_dark='*primary_50',
    button_secondary_background_fill='*primary_200',
    button_secondary_background_fill_dark='*primary_100',
    button_secondary_border_color='*primary_100',
    button_secondary_border_color_dark='*primary_100',
    button_secondary_border_color_hover='*primary_100',
    button_secondary_border_color_hover_dark='*primary_100',
    button_secondary_text_color_dark='*primary_50'
)

chatbot = gr.ChatInterface(respond, type="messages",theme=custom_theme)
chatbot.launch(ssr_mode=False)