File size: 750 Bytes
0a042d8
 
cdfe192
703a8b7
0a042d8
cdfe192
091c93f
cdfe192
 
 
 
 
 
 
 
 
091c93f
703a8b7
db0e2dc
cdfe192
 
db0e2dc
 
cdfe192
 
db0e2dc
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
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
import gradio as gr


def chat(message, history):
    history = history or [('hi', 'hello'), ('what ya doing', 'nothing')]
    if message.startswith("How many"):
        response = random.randint(1, 10)
    elif message.startswith("How"):
        response = random.choice(["Great", "Good", "Okay", "Bad"])
    elif message.startswith("Where"):
        response = random.choice(["Here", "There", "Somewhere"])
    else:
        response = "I don't know"
    history.append((message, response))
    return history, history

iface = gr.Interface(
    chat,
    ["text", "state"],
    ["chatbot", "state"],
    allow_screenshot=False,
    allow_flagging="never",
)
iface.launch()