Spaces:
Build error
Build error
Gorantla Krishna
commited on
Commit
·
e151f47
1
Parent(s):
42b1b7d
update
Browse files
src/langgraphagenticai/graph/graph_builder.py
CHANGED
|
@@ -3,6 +3,7 @@ from langgraph.prebuilt import tools_condition,ToolNode
|
|
| 3 |
from langchain_core.prompts import ChatPromptTemplate
|
| 4 |
import datetime
|
| 5 |
from src.langgraphagenticai.state.state import State
|
|
|
|
| 6 |
|
| 7 |
class GraphBuilder:
|
| 8 |
|
|
@@ -11,5 +12,25 @@ class GraphBuilder:
|
|
| 11 |
self.graph_builder = StateGraph(State)
|
| 12 |
|
| 13 |
def basic_chatbot_build_graph(self):
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
|
|
|
| 3 |
from langchain_core.prompts import ChatPromptTemplate
|
| 4 |
import datetime
|
| 5 |
from src.langgraphagenticai.state.state import State
|
| 6 |
+
from src.langgraphagenticai.nodes.basic_chatbot_node import BasicChatbotNode
|
| 7 |
|
| 8 |
class GraphBuilder:
|
| 9 |
|
|
|
|
| 12 |
self.graph_builder = StateGraph(State)
|
| 13 |
|
| 14 |
def basic_chatbot_build_graph(self):
|
| 15 |
+
"""
|
| 16 |
+
Builds a basic chatbot Graph using LangGraph.
|
| 17 |
+
This method initializes a chatbot node using the 'BasicChatbotNode' class
|
| 18 |
+
and integrates into the graph.The chatbot node is set as both the entry
|
| 19 |
+
entry and exit point of graph
|
| 20 |
+
|
| 21 |
+
"""
|
| 22 |
+
self.basic_chatbot_node = BasicChatbotNode(self.llm)
|
| 23 |
+
self.graph_builder.add_node("chatbot",self.basic_chatbot_node.process)
|
| 24 |
+
self.graph_builder.add_edge(START,"chatbot")
|
| 25 |
+
self.graph_builder.add_edge("chatbot",END)
|
| 26 |
+
|
| 27 |
+
def setup_graph(self,usecase:str):
|
| 28 |
+
"""
|
| 29 |
+
Sets up the graph for the selected use cases
|
| 30 |
+
"""
|
| 31 |
+
if usecase == "Basic Chatbot":
|
| 32 |
+
self.basic_chatbot_build_graph()
|
| 33 |
+
|
| 34 |
+
return self.graph_builder.compile()
|
| 35 |
+
|
| 36 |
|
src/langgraphagenticai/main.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import json
|
| 3 |
from src.langgraphagenticai.ui.streamlitui.loadui import LoadStreamlitUI
|
| 4 |
from src.langgraphagenticai.LLMS.groqllm import GroqLLM
|
|
|
|
| 5 |
|
| 6 |
def load_langgraph_agenticai_app():
|
| 7 |
"""
|
|
@@ -38,9 +39,19 @@ def load_langgraph_agenticai_app():
|
|
| 38 |
st.error("Error: Usecase not selected.")
|
| 39 |
return
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
except Exception as e:
|
| 42 |
raise ValueError(f"Error occured with exception : {e}")
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
|
|
|
| 46 |
|
|
|
|
| 2 |
import json
|
| 3 |
from src.langgraphagenticai.ui.streamlitui.loadui import LoadStreamlitUI
|
| 4 |
from src.langgraphagenticai.LLMS.groqllm import GroqLLM
|
| 5 |
+
from src.langgraphagenticai.graph.graph_builder import GraphBuilder
|
| 6 |
|
| 7 |
def load_langgraph_agenticai_app():
|
| 8 |
"""
|
|
|
|
| 39 |
st.error("Error: Usecase not selected.")
|
| 40 |
return
|
| 41 |
|
| 42 |
+
|
| 43 |
+
# Graph Builder
|
| 44 |
+
graph_builder = GraphBuilder(model)
|
| 45 |
+
try:
|
| 46 |
+
graph = graph_builder.setup_graph(usecase=usecase)
|
| 47 |
+
except Exception as e:
|
| 48 |
+
raise ValueError(f"Error: Graph set up Failed - {e}")
|
| 49 |
+
return
|
| 50 |
+
|
| 51 |
except Exception as e:
|
| 52 |
raise ValueError(f"Error occured with exception : {e}")
|
| 53 |
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
|