22 lines
No EOL
700 B
Python
22 lines
No EOL
700 B
Python
import requests
|
|
import gradio as gr
|
|
|
|
def ask(text):
|
|
url = "http://localhost:7869/ "
|
|
payload = {"text": text}
|
|
response = requests.post(url, json=payload)
|
|
|
|
if response.status_code == 200:
|
|
return response.json().get("response", "No response from API")
|
|
else:
|
|
return f"Error: {response.status_code}"
|
|
|
|
with gr.Blocks() as server:
|
|
with gr.Tab("LLM Inferencing"):
|
|
input_text = gr.Textbox(label="Input Text", placeholder="Enter your text here...")
|
|
output_text = gr.Textbox(label="Output Text")
|
|
submit_button = gr.Button("Submit")
|
|
|
|
submit_button.click(fn=ask, inputs=input_text, outputs=output_text)
|
|
|
|
server.launch() |