Spaces:
Runtime error
Runtime error
File size: 707 Bytes
573f259 a60dec0 573f259 a60dec0 573f259 a60dec0 573f259 a60dec0 573f259 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
import requests
FASTAPI_URL = "http://localhost:7860/ask_ollama/"
def ask_ollama(question):
response = requests.get(f"{FASTAPI_URL}?question={question}")
if response.status_code == 200:
return response.json().get("response", "No response from Ollama.")
return "Error: Could not connect to API."
# Create Gradio interface
iface = gr.Interface(
fn=ask_ollama,
inputs=gr.Textbox(placeholder="Ask a question..."),
outputs="text",
title="Ollama Chat",
description="Ask anything and get responses from the Ollama model."
)
# Run on port 7861 (so FastAPI and Gradio can run together)
iface.launch(server_name="0.0.0.0", server_port=7861, share=True)
|