File size: 1,214 Bytes
8ac4f9b
500f0ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98a925b
42dfa59
 
 
 
 
 
 
 
 
98a925b
500f0ef
 
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
35
36
37
38
39
import streamlit as st
import gradio as gr

def chat_with_model(input_text):
    # Call the chat model and return the response
    response = chat_model.predict(input_text)
    return response

# Load the chat model using Gradio
chat_model = gr.Interface.load("models/CogwiseAI/CogwiseAI-chatwithMS")

# Create a Streamlit app
def main():
    st.title("Cogwise Intelligent Assistant")
    st.markdown("---")
    
    # Create a text input for user interaction
    input_text = st.text_input("You are talking to an AI, ask any question.")
    
    # Process user input and display the response
    if st.button("Ask"):
        with st.spinner("Thinking..."):
            response = chat_with_model(input_text)
        st.markdown("---")
        st.write(response)

    # Render the Gradio interface using Streamlit's st.form and st.button
    with st.form(key="my_form"):
        text_input = st.text_input("Enter your question")
        submit_button = st.form_submit_button(label="Ask")
        if submit_button:
            with st.spinner("Thinking..."):
                response = chat_with_model(text_input)
            st.markdown("---")
            st.write(response)

if __name__ == "__main__":
    main()