Spaces:
Sleeping
Sleeping
import gradio as gr | |
json_code = "```json\n{\n \"classes\": [\n \"http://data.europa.eu/949/ContactLineSystem\"\n ],\n \"properties\": [\n \"http://data.europa.eu/949/contactLineSystemType\",\n \"http://data.europa.eu/949/energySupplySystemTSICompliant\",\n \"http://data.europa.eu/949/conditionsAppliedRegenerativeBraking\",\n \"http://data.europa.eu/949/conditionalRegenerativeBrake\"\n ]\n}\n```" | |
def chat(message, history): | |
if "test" in message.lower(): | |
return "Type Python or JavaScript to see the code.", gr.Code(language="json", value=json_code) | |
else: | |
return "Please ask about Python or JavaScript.", None | |
with gr.Blocks() as demo: | |
code = gr.Code(render=False) | |
with gr.Row(): | |
gr.Markdown("<center><h1>Write Python or JavaScript</h1></center>") | |
gr.ChatInterface( | |
chat, | |
examples=["Test"], | |
additional_outputs=[code], | |
type="messages" | |
) | |
with gr.Row(): | |
code.render() | |
demo.launch(share=True) |