|
import streamlit as st |
|
import requests |
|
|
|
st.set_page_config(page_title="AI Chat Client", layout="wide") |
|
st.title("AI Chat Client") |
|
|
|
|
|
fastapi_server_url = "http://127.0.0.1:8000/get_ai_response/" |
|
|
|
|
|
url = st.text_input("Enter the URL to chat with:") |
|
question = st.text_input("Enter your question:") |
|
|
|
|
|
if st.button('Get AI Response'): |
|
if url and question: |
|
with st.spinner('Fetching AI response...'): |
|
|
|
data = {"url": url, "question": question} |
|
|
|
response = requests.post(fastapi_server_url, json=data) |
|
|
|
if response.status_code == 200: |
|
|
|
ai_response = response.json().get("AI Response", "No response received.") |
|
st.write("AI Response:", ai_response) |
|
else: |
|
|
|
st.error("Error in fetching response from AI server.") |
|
else: |
|
st.warning("Please enter both URL and a question.") |
|
|