File size: 1,849 Bytes
bf135e2
 
 
 
 
a16c781
 
4ec256b
 
 
 
 
 
 
 
 
 
 
 
 
 
e70db35
 
 
 
 
 
 
 
 
 
0af3a4b
d517313
e70db35
02b8c5d
 
 
 
 
 
d517313
0af3a4b
d517313
02b8c5d
ffcf7eb
b20637f
 
 
 
 
 
02b8c5d
 
 
 
 
20e00b4
173fe06
 
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
from huggingface_hub import InferenceClient

import gradio as gr
import random

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

def respond(message, history):
    messages = [{"role":"system", "content":"You are a friendly chatbot! :)"}]
    
    if history: 
        messages.extend(history)

    messages.append({"role":"user", "content":message})
        
    response = client.chat_completion(messages, max_tokens = 100, temperature = 1.3, top_p = 0.3) #temp & top_p control random

    print(response)

    return response["choices"][0]["message"]["content"].strip()

chat_theme = gr.themes.Monochrome(
    primary_hue = "rose",
    secondary_hue = "rose",
    neutral_hue = "rose").set(
    background_fill_primary = "*primary_50",
    input_background_fill = "*neutral_100",
    input_border_color_focus = "*primary_200",
    button_secondary_background_fill = "*secondary_50",
    button_secondary_background_fill_hover = "*secondary_100")

title = """# 🐑 NutriAssist 🌱"""

with gr.Blocks(theme = chat_theme) as chatbot:
    with gr.Row(scale=1):
        gr.Image(
            value="NutriAssistBanner.png", 
            show_label=False, 
            show_share_button = False, 
            show_download_button = False)
    with gr.Row(scale=2):
        with gr.Column(scale=1):
            gr.Markdown(title)
            gr.Image(
                "NutriAssistInstructions.png", 
                show_label = False, 
                show_share_button = False, 
                show_download_button = False)
            gr.Image(
                "NutriAssistTeam.png",
                show_label = False, 
                show_share_button = False, 
                show_download_button = False)
            
        with gr.Column(scale=2):
            gr.ChatInterface(respond, type="messages")
            

chatbot.launch()