File size: 645 Bytes
d8eb084
9170802
d8eb084
 
9170802
d8eb084
9170802
d8eb084
 
 
 
 
 
 
 
80284f7
 
 
d8eb084
 
80284f7
 
d8eb084
 
 
 
9170802
d8eb084
 
 
 
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
import gradio as gr
import random

example_code = """
Here's an example Python lambda function:

lambda x: x + {}

Is this correct?
"""

def chat(message, history):
    if message == "Yes, that's correct.":
        return "Great!"
    else:
        return gr.ChatMessage(
            content=example_code.format(random.randint(1, 100)),
            options=[
                {"value": "Yes, that's correct.", "label": "Yes"},
                {"value": "No"}
            ]
        )

demo = gr.ChatInterface(
    chat,
    type="messages",
    examples=["Write an example Python lambda function."]
)

if __name__ == "__main__":
    demo.launch()