krishanusinha20 commited on
Commit
92289e1
·
verified ·
1 Parent(s): cd844b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -8
app.py CHANGED
@@ -1,11 +1,11 @@
 
1
  import sqlite3
2
  import json
3
  import openai
4
- from langgraph.graph import StateGraph, START, END
5
  from typing import TypedDict, Optional
6
 
7
  # Set your OpenAI API key from environment variable
8
- import os
9
  openai.api_key = os.getenv("OPENAI_API_KEY")
10
 
11
  # Define the state for SQL Execution Workflow
@@ -19,10 +19,6 @@ class SQLExecutionState(TypedDict):
19
  # Initialize the LangGraph Workflow
20
  graph = StateGraph(state_schema=SQLExecutionState)
21
 
22
- # Add dummy nodes for START and END
23
- graph.add_node(START, lambda state: state)
24
- graph.add_node(END, lambda state: state)
25
-
26
  # ------------------ 1. Query Understanding Agent ------------------
27
  def query_understanding_agent(state: SQLExecutionState) -> SQLExecutionState:
28
  natural_language_query = state["sql_query"]
@@ -129,11 +125,9 @@ def execution_agent(state: SQLExecutionState) -> SQLExecutionState:
129
  graph.add_node("SQL Execution", execution_agent)
130
 
131
  # ------------------ Define Execution Flow ------------------
132
- graph.add_edge(START, "Query Understanding")
133
  graph.add_edge("Query Understanding", "Query Validation")
134
  graph.add_edge("Query Validation", "Query Optimization")
135
  graph.add_edge("Query Optimization", "SQL Execution")
136
- graph.add_edge("SQL Execution", END)
137
 
138
  compiled_pipeline = graph.compile()
139
 
 
1
+ import os
2
  import sqlite3
3
  import json
4
  import openai
5
+ from langgraph.graph import StateGraph
6
  from typing import TypedDict, Optional
7
 
8
  # Set your OpenAI API key from environment variable
 
9
  openai.api_key = os.getenv("OPENAI_API_KEY")
10
 
11
  # Define the state for SQL Execution Workflow
 
19
  # Initialize the LangGraph Workflow
20
  graph = StateGraph(state_schema=SQLExecutionState)
21
 
 
 
 
 
22
  # ------------------ 1. Query Understanding Agent ------------------
23
  def query_understanding_agent(state: SQLExecutionState) -> SQLExecutionState:
24
  natural_language_query = state["sql_query"]
 
125
  graph.add_node("SQL Execution", execution_agent)
126
 
127
  # ------------------ Define Execution Flow ------------------
 
128
  graph.add_edge("Query Understanding", "Query Validation")
129
  graph.add_edge("Query Validation", "Query Optimization")
130
  graph.add_edge("Query Optimization", "SQL Execution")
 
131
 
132
  compiled_pipeline = graph.compile()
133