Quantum-API / app /app.py
subatomicERROR's picture
Initial commit: Quantum-API with FastAPI and Streamlit integration
f33e2be
raw
history blame
1.24 kB
import streamlit as st
import requests
# URL of the FastAPI backend endpoint
API_URL_OLAMA = "http://localhost:7860/ollama-response"
API_URL_CODELAMA = "http://localhost:7860/run-codelama"
def main():
st.title("Quantum-API Chat Interface with Olama and CodeLlama")
user_input = st.text_input("Ask a question:")
if user_input:
if st.button("Chat with Olama"):
# Make a POST request to the FastAPI server for Olama
response = requests.post(API_URL_OLAMA, json={"question": user_input})
if response.status_code == 200:
# Display the response from Olama
st.write(f"Olama says: {response.json()['response']}")
else:
st.error("Error contacting Olama API.")
if st.button("Run Code with CodeLlama"):
# Make a GET request to the FastAPI server for CodeLlama
response = requests.get(API_URL_CODELAMA)
if response.status_code == 200:
# Display the response from CodeLlama
st.write(f"CodeLlama result: {response.json()['result']}")
else:
st.error("Error contacting CodeLlama API.")
if __name__ == "__main__":
main()