Spaces:
Sleeping
Sleeping
updated app
Browse files
app.py
CHANGED
|
@@ -36,7 +36,6 @@ def get_llm_browser():
|
|
| 36 |
openai_api_key=os.getenv("OPENAI_API_KEY")
|
| 37 |
)
|
| 38 |
|
| 39 |
-
|
| 40 |
# -------------------------------------------------------
|
| 41 |
# TypedDict for State
|
| 42 |
# -------------------------------------------------------
|
|
@@ -46,7 +45,6 @@ class State(TypedDict):
|
|
| 46 |
sentiment: str
|
| 47 |
response: str
|
| 48 |
|
| 49 |
-
|
| 50 |
# -------------------------------------------------------
|
| 51 |
# Node functions for our workflow
|
| 52 |
# (using get_llm() or get_llm_browser() on-demand)
|
|
@@ -142,7 +140,6 @@ def route_query(state: State) -> str:
|
|
| 142 |
else:
|
| 143 |
return "handle_general"
|
| 144 |
|
| 145 |
-
|
| 146 |
# -------------------------------------------------------
|
| 147 |
# Create the workflow graph
|
| 148 |
# -------------------------------------------------------
|
|
@@ -171,7 +168,7 @@ workflow.add_edge("handle_general", END)
|
|
| 171 |
workflow.add_edge("escalate", END)
|
| 172 |
workflow.set_entry_point("categorize")
|
| 173 |
|
| 174 |
-
# Compile the workflow into a
|
| 175 |
app = workflow.compile()
|
| 176 |
|
| 177 |
|
|
@@ -199,8 +196,8 @@ async def run_customer_support(query: str, api_key: str = "") -> str:
|
|
| 199 |
"sentiment": "",
|
| 200 |
"response": ""
|
| 201 |
}
|
| 202 |
-
#
|
| 203 |
-
final_state = app.
|
| 204 |
return final_state["response"]
|
| 205 |
except Exception as e:
|
| 206 |
return f"Error: {str(e)}"
|
|
|
|
| 36 |
openai_api_key=os.getenv("OPENAI_API_KEY")
|
| 37 |
)
|
| 38 |
|
|
|
|
| 39 |
# -------------------------------------------------------
|
| 40 |
# TypedDict for State
|
| 41 |
# -------------------------------------------------------
|
|
|
|
| 45 |
sentiment: str
|
| 46 |
response: str
|
| 47 |
|
|
|
|
| 48 |
# -------------------------------------------------------
|
| 49 |
# Node functions for our workflow
|
| 50 |
# (using get_llm() or get_llm_browser() on-demand)
|
|
|
|
| 140 |
else:
|
| 141 |
return "handle_general"
|
| 142 |
|
|
|
|
| 143 |
# -------------------------------------------------------
|
| 144 |
# Create the workflow graph
|
| 145 |
# -------------------------------------------------------
|
|
|
|
| 168 |
workflow.add_edge("escalate", END)
|
| 169 |
workflow.set_entry_point("categorize")
|
| 170 |
|
| 171 |
+
# Compile the workflow into a "CompiledStateGraph" object.
|
| 172 |
app = workflow.compile()
|
| 173 |
|
| 174 |
|
|
|
|
| 196 |
"sentiment": "",
|
| 197 |
"response": ""
|
| 198 |
}
|
| 199 |
+
# Instead of app(state) or app.run(state), call .execute(...)
|
| 200 |
+
final_state = app.execute(state)
|
| 201 |
return final_state["response"]
|
| 202 |
except Exception as e:
|
| 203 |
return f"Error: {str(e)}"
|