File size: 1,242 Bytes
f33e2be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()