forked from freddykhant/flex-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (31 loc) 路 1.23 KB
/
Copy pathapp.py
File metadata and controls
39 lines (31 loc) 路 1.23 KB
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 json
from graph import graph, ChatState
# streamlit page config
st.set_page_config(page_title="Flex AI", page_icon="馃挭")
# title and intro
st.title("馃挭Flex AI: Your AI Personal Trainer")
st.write("Ask me anything about hypertophy, resistance training, nutrition, and muscle growth!")
# user input
user_question = st.text_input("Enter your question:")
# process user input and get response
if st.button("Get Answer"):
if user_question:
# run the RAG pipeline
input_state = ChatState(question=user_question)
response = graph.invoke(input_state)
# extract response
answer = response.get("generation", "no response generated.")
st.subheader("馃Flex's Answer:")
st.write(answer)
# show retrieved documents
documents = response.get("documents", [])
if documents:
with st.expander("馃摎 Relevant Research Documents (click to expand)"):
for i, doc in enumerate(documents):
st.write(f"**Document {i+1}:** {doc.page_content[:500]}...") # Show snippet
else:
st.warning("鈿狅笍Please enter a question before submitting.")
# footer
st.markdown("---")
st.caption("Built with Streamlit, LangChain, LangGraph, Ollama - Developed by Freddy Khant 馃殌")