Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import json
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
["assistant", response]
|
| 13 |
-
]
|
| 14 |
-
|
| 15 |
-
return chatbot_messages, json.dumps({
|
| 16 |
-
"status": "success",
|
| 17 |
-
"prompt": prompt,
|
| 18 |
-
"response": response,
|
| 19 |
-
"model": "open-r1/OlympicCoder-7B"
|
| 20 |
-
})
|
| 21 |
-
|
| 22 |
-
# Create the Gradio interface
|
| 23 |
-
with gr.Blocks() as demo:
|
| 24 |
-
with gr.Row():
|
| 25 |
-
with gr.Column(scale=3):
|
| 26 |
-
chatbot = gr.Chatbot(height=500)
|
| 27 |
-
with gr.Row():
|
| 28 |
-
with gr.Column(scale=8):
|
| 29 |
-
msg = gr.Textbox(label="Message", placeholder="Type your message here", container=False)
|
| 30 |
-
with gr.Column(scale=1, min_width=50):
|
| 31 |
-
submit = gr.Button("Send")
|
| 32 |
-
clear = gr.Button("Clear")
|
| 33 |
-
|
| 34 |
-
with gr.Column(scale=1, visible=False) as api_column:
|
| 35 |
-
# Hidden API interface
|
| 36 |
-
api_input = gr.Textbox(label="API Input")
|
| 37 |
-
api_output = gr.Textbox(label="API Output")
|
| 38 |
-
api_button = gr.Button("API Call")
|
| 39 |
-
|
| 40 |
-
# Set up event handlers
|
| 41 |
-
submit.click(fn=query_model, inputs=[msg], outputs=[chatbot], queue=True)
|
| 42 |
-
msg.submit(fn=query_model, inputs=[msg], outputs=[chatbot], queue=True)
|
| 43 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
| 44 |
-
|
| 45 |
-
# API endpoint
|
| 46 |
-
api_button.click(fn=lambda x: query_model(x)[1], inputs=[api_input], outputs=[api_output])
|
| 47 |
-
|
| 48 |
-
# Launch with debug info
|
| 49 |
-
demo.launch(
|
| 50 |
-
debug=True,
|
| 51 |
-
show_api=True # This exposes the API docs
|
| 52 |
-
)
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
with gr.Blocks(fill_height=True) as demo:
|
| 4 |
+
with gr.Sidebar():
|
| 5 |
+
gr.Markdown("# Inference Provider")
|
| 6 |
+
gr.Markdown("This Space showcases the open-r1/OlympicCoder-7B model, served by the featherless-ai API. Sign in with your Hugging Face account to use this API.")
|
| 7 |
+
button = gr.LoginButton("Sign in")
|
| 8 |
+
gr.load("models/open-r1/OlympicCoder-7B", accept_token=button, provider="featherless-ai")
|
| 9 |
+
|
| 10 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|