Spaces:
Sleeping
Sleeping
import gradio as gr | |
from gradio import ChatMessage | |
from typing import Iterator | |
import google.generativeai as genai | |
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."] | |
) | |
demo.launch() |