Spaces:
Running
Running
Kalyanbrata Maity
commited on
Commit
·
203b254
1
Parent(s):
c5475da
added streamlit ui & llm model
Browse files- .idea/.gitignore +3 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/langgraph-agentic-e2e.iml +15 -0
- .idea/misc.xml +7 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- app.py +5 -0
- src/__pycache__/__init__.cpython-312.pyc +0 -0
- src/langgraphagenticai/__pycache__/__init__.cpython-312.pyc +0 -0
- src/langgraphagenticai/__pycache__/main.cpython-312.pyc +0 -0
- src/langgraphagenticai/graph/graph_builder.py +0 -0
- src/langgraphagenticai/llms/groq_llm.py +23 -0
- src/langgraphagenticai/main.py +52 -0
- src/langgraphagenticai/nodes/__init__.py +0 -0
- src/langgraphagenticai/state/__init__.py +0 -0
- src/langgraphagenticai/tools/__init__.py +0 -0
- src/langgraphagenticai/ui/__pycache__/__init__.cpython-312.pyc +0 -0
- src/langgraphagenticai/ui/__pycache__/uiconfigfile.cpython-312.pyc +0 -0
- src/langgraphagenticai/ui/streamlit/__pycache__/load_ui.cpython-312.pyc +0 -0
- src/langgraphagenticai/ui/streamlit/load_ui.py +57 -1
- src/langgraphagenticai/ui/uiconfigfile.ini +2 -2
- src/langgraphagenticai/ui/uiconfigfile.py +1 -1
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/langgraph-agentic-e2e.iml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="jdk" jdkName="$MODULE_DIR$/.venv" jdkType="Python SDK" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
<component name="PyDocumentationSettings">
|
9 |
+
<option name="format" value="NUMPY" />
|
10 |
+
<option name="myDocStringFormat" value="NumPy" />
|
11 |
+
</component>
|
12 |
+
<component name="TestRunnerService">
|
13 |
+
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
14 |
+
</component>
|
15 |
+
</module>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="Black">
|
4 |
+
<option name="sdkName" value="$PROJECT_DIR$/.venv" />
|
5 |
+
</component>
|
6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="$PROJECT_DIR$/.venv" project-jdk-type="Python SDK" />
|
7 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/langgraph-agentic-e2e.iml" filepath="$PROJECT_DIR$/.idea/langgraph-agentic-e2e.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
CHANGED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from src.langgraphagenticai.main import load_langgraph_agenticai_app
|
2 |
+
|
3 |
+
|
4 |
+
if __name__ == "__main__":
|
5 |
+
load_langgraph_agenticai_app()
|
src/__pycache__/__init__.cpython-312.pyc
ADDED
Binary file (163 Bytes). View file
|
|
src/langgraphagenticai/__pycache__/__init__.cpython-312.pyc
ADDED
Binary file (182 Bytes). View file
|
|
src/langgraphagenticai/__pycache__/main.cpython-312.pyc
ADDED
Binary file (1.48 kB). View file
|
|
src/langgraphagenticai/graph/graph_builder.py
ADDED
File without changes
|
src/langgraphagenticai/llms/groq_llm.py
CHANGED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from langchain_groq import ChatGroq
|
4 |
+
|
5 |
+
|
6 |
+
class GroqChatLLM:
|
7 |
+
def __init__(self, user_controls_input):
|
8 |
+
self.user_controls_input = user_controls_input
|
9 |
+
|
10 |
+
def get_llm_model(self):
|
11 |
+
try:
|
12 |
+
groq_api_key = self.user_controls_input['GROQ_API_KEY']
|
13 |
+
selected_groq_model = self.user_controls_input['selected_groq_model']
|
14 |
+
if groq_api_key == '' and os.environ["GROQ_API_KEY"]:
|
15 |
+
st.error("Please Enter the Groq API KEY")
|
16 |
+
|
17 |
+
llm = ChatGroq(api_key=groq_api_key, model=selected_groq_model)
|
18 |
+
|
19 |
+
except Exception as e:
|
20 |
+
raise ValueError(f"Error occurred with exception: {e}")
|
21 |
+
|
22 |
+
return llm
|
23 |
+
|
src/langgraphagenticai/main.py
CHANGED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import json
|
3 |
+
|
4 |
+
from src.langgraphagenticai.ui.streamlit.load_ui import LoadStreamlitUI
|
5 |
+
from src.langgraphagenticai.llms.groq_llm import GroqChatLLM
|
6 |
+
|
7 |
+
# MAIN function start
|
8 |
+
def load_langgraph_agenticai_app():
|
9 |
+
"""
|
10 |
+
Loads and runs the LangGraph AgenticAI application with Streamlit UI.
|
11 |
+
This function initializes the UI, handles user input, configures the
|
12 |
+
LLM model, sets up the graph based on the selected use case, and displays
|
13 |
+
the output while implementing exception handling for robustness.
|
14 |
+
"""
|
15 |
+
|
16 |
+
# Load UI
|
17 |
+
ui = LoadStreamlitUI()
|
18 |
+
user_input = ui.load_streamlit_ui()
|
19 |
+
|
20 |
+
if not user_input:
|
21 |
+
st.error("Error: Failed to load user input from the UI")
|
22 |
+
return
|
23 |
+
|
24 |
+
# Text input for user message
|
25 |
+
if st.session_state.IsFetchButtonClick:
|
26 |
+
user_message = st.session_state.timeframe
|
27 |
+
else:
|
28 |
+
user_message = st.chat_input("Enter your message")
|
29 |
+
|
30 |
+
if user_message:
|
31 |
+
try:
|
32 |
+
# Configure LLM
|
33 |
+
obj_llm_config = GroqChatLLM(user_controls_input=user_input)
|
34 |
+
model = obj_llm_config.get_llm_model()
|
35 |
+
|
36 |
+
if not model:
|
37 |
+
st.error("Error: LLM model could not be initialized")
|
38 |
+
return
|
39 |
+
|
40 |
+
# Initialize and set up the graph based on use case
|
41 |
+
usecase = user_input.get('selected_usecase')
|
42 |
+
if not usecase:
|
43 |
+
st.error("Error: No use case selected.")
|
44 |
+
return
|
45 |
+
|
46 |
+
## Graph builder
|
47 |
+
graph_builder = GraphBuilder(model)
|
48 |
+
|
49 |
+
except Exception as e:
|
50 |
+
raise ValueError(f"Error Occurred with Exception: {e}")
|
51 |
+
|
52 |
+
print(user_input)
|
src/langgraphagenticai/nodes/__init__.py
ADDED
File without changes
|
src/langgraphagenticai/state/__init__.py
ADDED
File without changes
|
src/langgraphagenticai/tools/__init__.py
ADDED
File without changes
|
src/langgraphagenticai/ui/__pycache__/__init__.cpython-312.pyc
ADDED
Binary file (185 Bytes). View file
|
|
src/langgraphagenticai/ui/__pycache__/uiconfigfile.cpython-312.pyc
ADDED
Binary file (1.84 kB). View file
|
|
src/langgraphagenticai/ui/streamlit/__pycache__/load_ui.cpython-312.pyc
ADDED
Binary file (3.48 kB). View file
|
|
src/langgraphagenticai/ui/streamlit/load_ui.py
CHANGED
@@ -9,4 +9,60 @@ from src.langgraphagenticai.ui.uiconfigfile import Config
|
|
9 |
class LoadStreamlitUI:
|
10 |
def __init__(self):
|
11 |
self.config = Config() # config
|
12 |
-
self.user_controls = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
class LoadStreamlitUI:
|
10 |
def __init__(self):
|
11 |
self.config = Config() # config
|
12 |
+
self.user_controls = {}
|
13 |
+
|
14 |
+
def initialize_session(self):
|
15 |
+
return {
|
16 |
+
"current_step": "requirements",
|
17 |
+
"requirements": "",
|
18 |
+
"user_stories": "",
|
19 |
+
"po_feedback": "",
|
20 |
+
"generated_code": "",
|
21 |
+
"review_feedback": "",
|
22 |
+
"decision": None
|
23 |
+
}
|
24 |
+
|
25 |
+
def load_streamlit_ui(self):
|
26 |
+
|
27 |
+
# set page config
|
28 |
+
st.set_page_config(page_title=self.config.get_page_title(), layout="wide")
|
29 |
+
st.header(self.config.get_page_title())
|
30 |
+
st.session_state.timeframe = ''
|
31 |
+
st.session_state.IsFetchButtonClick = False
|
32 |
+
st.session_state.IsSDLC = False
|
33 |
+
|
34 |
+
|
35 |
+
# Sidebar content
|
36 |
+
with st.sidebar:
|
37 |
+
st.header("Configuration")
|
38 |
+
|
39 |
+
# LLM selection
|
40 |
+
llm_options = self.config.get_llm_options()
|
41 |
+
selected_llm = st.selectbox("Select LLM", llm_options)
|
42 |
+
self.user_controls["selected_llm"] = selected_llm
|
43 |
+
|
44 |
+
if self.user_controls["selected_llm"] == 'Groq':
|
45 |
+
|
46 |
+
# Model selection
|
47 |
+
groq_model_options = self.config.get_groq_model_options()
|
48 |
+
self.user_controls["selected_groq_model"] = st.selectbox("Select Model", groq_model_options)
|
49 |
+
|
50 |
+
# API key input
|
51 |
+
self.user_controls["GROQ_API_KEY"] = st.session_state["GROQ_API_KEY"] = st.text_input("API Key", type="password")
|
52 |
+
|
53 |
+
# Validate API key
|
54 |
+
if not self.user_controls["GROQ_API_KEY"]:
|
55 |
+
st.warning("Please enter your GROQ API key to proceed. Don't have? refer: https://console.groq.com/keys")
|
56 |
+
|
57 |
+
# Use case selection
|
58 |
+
usecase_options = self.config.get_usecase_options()
|
59 |
+
selected_usecase = st.selectbox("Select Use Case", usecase_options)
|
60 |
+
self.user_controls["selected_usecase"] = selected_usecase
|
61 |
+
|
62 |
+
if "state" not in st.session_state:
|
63 |
+
st.session_state.state = self.initialize_session()
|
64 |
+
|
65 |
+
|
66 |
+
return self.user_controls
|
67 |
+
|
68 |
+
|
src/langgraphagenticai/ui/uiconfigfile.ini
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
[DEFAULT]
|
2 |
PAGE_TITLE = LangGraph: Build Stateful Agentic AI graph
|
3 |
-
LLM_OPTIONS = Groq
|
4 |
-
USECASE_OPTIONS = Basic Chatbot
|
5 |
GROQ_MODEL_OPTIONS = mixtral-8x7b-32768, llama3-8b-8192, gemma-7b-i
|
|
|
1 |
[DEFAULT]
|
2 |
PAGE_TITLE = LangGraph: Build Stateful Agentic AI graph
|
3 |
+
LLM_OPTIONS = Groq, OPENAI
|
4 |
+
USECASE_OPTIONS = Basic Chatbot, Voice Analyzer
|
5 |
GROQ_MODEL_OPTIONS = mixtral-8x7b-32768, llama3-8b-8192, gemma-7b-i
|
src/langgraphagenticai/ui/uiconfigfile.py
CHANGED
@@ -17,4 +17,4 @@ class Config:
|
|
17 |
return self.config["DEFAULT"].get("GROQ_MODEL_OPTIONS").split(",")
|
18 |
|
19 |
def get_page_title(self):
|
20 |
-
return self.config["DEFAULT"].get("PAGE_TITLE")
|
|
|
17 |
return self.config["DEFAULT"].get("GROQ_MODEL_OPTIONS").split(",")
|
18 |
|
19 |
def get_page_title(self):
|
20 |
+
return self.config["DEFAULT"].get("PAGE_TITLE")
|