refractoring codebase
Browse files- app.py +10 -0
- src/langgraph/UI/streamlit/loadui.py +11 -3
- src/langgraph/__init__.py +0 -0
- src/langgraph/graph/graph_builder.py +2 -2
- src/langgraph/main.py +7 -7
app.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
# Add the project root directory to Python's module search path
|
| 5 |
+
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
| 6 |
+
|
| 7 |
+
from src.langgraph.main import load_app
|
| 8 |
+
|
| 9 |
+
if __name__=="__main__":
|
| 10 |
+
load_app()
|
src/langgraph/UI/streamlit/loadui.py
CHANGED
|
@@ -3,8 +3,8 @@ import os
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
from datetime import date
|
| 5 |
|
| 6 |
-
from langchain_core import AIMessage, HumanMessage, SystemMessage
|
| 7 |
-
from
|
| 8 |
|
| 9 |
class LoadStreamlitUI:
|
| 10 |
def __init__(self):
|
|
@@ -50,22 +50,30 @@ class LoadStreamlitUI:
|
|
| 50 |
#Creating a dropdown for the LLM options
|
| 51 |
st.session_state.selected_llm = st.selectbox("Select LLM", LLM_OPTIONS)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
if st.session_state.selected_llm == "Groq":
|
| 54 |
model = self.config.get_groq_model()
|
| 55 |
st.session_state.selected_model = st.selectbox("Select Model", model)
|
| 56 |
st.session_state.selected_model_api_key = st.text_input("Enter API Key", type="password")
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
#validating the API key
|
| 59 |
if not st.session_state.selected_model_api_key:
|
| 60 |
st.error("Please enter the correct API key. refer : https://console.groq.com/keys")
|
| 61 |
|
| 62 |
#Creating a dropdown for the use case options
|
| 63 |
st.session_state.selected_usecase = st.selectbox("Select Use Case", USE_CASE_OPTIONS)
|
|
|
|
| 64 |
|
| 65 |
if "state" not in st.session_state:
|
| 66 |
st.session_state.state = self.initialize_state()
|
| 67 |
#self.render_requirements()
|
| 68 |
|
| 69 |
-
return
|
| 70 |
|
| 71 |
|
|
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
from datetime import date
|
| 5 |
|
| 6 |
+
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
| 7 |
+
from ...UI.uiconfigfile import Config
|
| 8 |
|
| 9 |
class LoadStreamlitUI:
|
| 10 |
def __init__(self):
|
|
|
|
| 50 |
#Creating a dropdown for the LLM options
|
| 51 |
st.session_state.selected_llm = st.selectbox("Select LLM", LLM_OPTIONS)
|
| 52 |
|
| 53 |
+
# Initialize the user_controls dictionary to store user selections
|
| 54 |
+
user_controls = {}
|
| 55 |
+
|
| 56 |
if st.session_state.selected_llm == "Groq":
|
| 57 |
model = self.config.get_groq_model()
|
| 58 |
st.session_state.selected_model = st.selectbox("Select Model", model)
|
| 59 |
st.session_state.selected_model_api_key = st.text_input("Enter API Key", type="password")
|
| 60 |
|
| 61 |
+
# Store the Groq-specific values in user_controls
|
| 62 |
+
user_controls["groq_api_key"] = st.session_state.selected_model_api_key
|
| 63 |
+
user_controls["selected_groq_models"] = st.session_state.selected_model
|
| 64 |
+
|
| 65 |
#validating the API key
|
| 66 |
if not st.session_state.selected_model_api_key:
|
| 67 |
st.error("Please enter the correct API key. refer : https://console.groq.com/keys")
|
| 68 |
|
| 69 |
#Creating a dropdown for the use case options
|
| 70 |
st.session_state.selected_usecase = st.selectbox("Select Use Case", USE_CASE_OPTIONS)
|
| 71 |
+
user_controls["selected_use_case"] = st.session_state.selected_usecase
|
| 72 |
|
| 73 |
if "state" not in st.session_state:
|
| 74 |
st.session_state.state = self.initialize_state()
|
| 75 |
#self.render_requirements()
|
| 76 |
|
| 77 |
+
return user_controls
|
| 78 |
|
| 79 |
|
src/langgraph/__init__.py
ADDED
|
File without changes
|
src/langgraph/graph/graph_builder.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
from langgraph.graph import StateGraph, START,END, MessagesState
|
| 2 |
from langgraph.prebuilt import tools_condition,ToolNode
|
| 3 |
from langchain_core.prompts import ChatPromptTemplate
|
| 4 |
-
from src.
|
| 5 |
-
from src.
|
| 6 |
|
| 7 |
|
| 8 |
|
|
|
|
| 1 |
from langgraph.graph import StateGraph, START,END, MessagesState
|
| 2 |
from langgraph.prebuilt import tools_condition,ToolNode
|
| 3 |
from langchain_core.prompts import ChatPromptTemplate
|
| 4 |
+
from src.langgraph.state.state import State
|
| 5 |
+
from src.langgraph.node.basic_chatbot import BasicChatbotNode
|
| 6 |
|
| 7 |
|
| 8 |
|
src/langgraph/main.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
-
from
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
from
|
| 7 |
|
| 8 |
|
| 9 |
-
def
|
| 10 |
"""
|
| 11 |
|
| 12 |
Loads and runs the LangGranph Agentic AI POC application.
|
|
@@ -46,8 +46,8 @@ def __main__():
|
|
| 46 |
#Graph Builder
|
| 47 |
graph_builder = GraphBuilder(llm=model, use_case=use_case)
|
| 48 |
try:
|
| 49 |
-
graph = graph_builder.setup_graph(
|
| 50 |
-
DisplayResultStreamlit(
|
| 51 |
except Exception as e:
|
| 52 |
st.error(f"Error: Graph setup failed - {e}")
|
| 53 |
return
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
+
from .UI.streamlit.loadui import LoadStreamlitUI
|
| 4 |
+
from .llm.groqllm import GroqLLM
|
| 5 |
+
from .graph.graph_builder import GraphBuilder
|
| 6 |
+
from .UI.streamlit.displayresult import DisplayResultStreamlit
|
| 7 |
|
| 8 |
|
| 9 |
+
def load_app():
|
| 10 |
"""
|
| 11 |
|
| 12 |
Loads and runs the LangGranph Agentic AI POC application.
|
|
|
|
| 46 |
#Graph Builder
|
| 47 |
graph_builder = GraphBuilder(llm=model, use_case=use_case)
|
| 48 |
try:
|
| 49 |
+
graph = graph_builder.setup_graph(use_case)
|
| 50 |
+
DisplayResultStreamlit(use_case, graph, user_message).display_result_on_ui()
|
| 51 |
except Exception as e:
|
| 52 |
st.error(f"Error: Graph setup failed - {e}")
|
| 53 |
return
|