Spaces:
Sleeping
Sleeping
configure reading variable via huggingface settings
Browse files- Agents/agent.py +14 -11
- app.py +3 -3
Agents/agent.py
CHANGED
|
@@ -104,22 +104,25 @@ def build_graph(provider: str="groq"):
|
|
| 104 |
'''
|
| 105 |
builder = StateGraph(MessagesState)
|
| 106 |
print(f"running builder ")
|
|
|
|
| 107 |
#builder.add_node("retriever",retriever)
|
| 108 |
builder.add_node("assistant",assistant)
|
| 109 |
builder.add_node("tools", ToolNode(tools))
|
| 110 |
builder.add_edge(START,"assistant")
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
#builder.add_edge("retriever","assistant")
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
|
| 124 |
return builder.compile()
|
| 125 |
|
|
|
|
| 104 |
'''
|
| 105 |
builder = StateGraph(MessagesState)
|
| 106 |
print(f"running builder ")
|
| 107 |
+
directPath = bool(os.getenv("DirectPath"))
|
| 108 |
#builder.add_node("retriever",retriever)
|
| 109 |
builder.add_node("assistant",assistant)
|
| 110 |
builder.add_node("tools", ToolNode(tools))
|
| 111 |
builder.add_edge(START,"assistant")
|
| 112 |
+
if(directPath):
|
| 113 |
+
builder.add_edge("assistant","tools")
|
| 114 |
+
builder.add_edge("tools",END)
|
| 115 |
+
else:
|
| 116 |
#builder.add_edge("retriever","assistant")
|
| 117 |
+
builder.add_conditional_edges(
|
| 118 |
+
"assistant",
|
| 119 |
+
tools_condition,
|
| 120 |
+
path_map={
|
| 121 |
+
True: "tools",
|
| 122 |
+
False: END
|
| 123 |
+
}
|
| 124 |
+
)
|
| 125 |
+
builder.add_edge("tools","assistant")
|
| 126 |
|
| 127 |
return builder.compile()
|
| 128 |
|
app.py
CHANGED
|
@@ -11,8 +11,8 @@ from langfuse.langchain import CallbackHandler
|
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
langfuse_handler = CallbackHandler()
|
| 14 |
-
|
| 15 |
-
langFuseOn =
|
| 16 |
|
| 17 |
# --- Basic Agent Definition ---
|
| 18 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
@@ -71,7 +71,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 71 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 72 |
print(agent_code)
|
| 73 |
|
| 74 |
-
if(
|
| 75 |
# 5a test
|
| 76 |
question = "When was a picture of St. Thomas Aquinas first added to the wikipedia page on the principle of double effect?"
|
| 77 |
#graph = build_graph(provider="groq")
|
|
|
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
langfuse_handler = CallbackHandler()
|
| 14 |
+
testMode = bool(os.getenv("TestMode"))
|
| 15 |
+
langFuseOn = bool(os.getenv("LangFuseOn"))
|
| 16 |
|
| 17 |
# --- Basic Agent Definition ---
|
| 18 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
| 71 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 72 |
print(agent_code)
|
| 73 |
|
| 74 |
+
if(testMode):
|
| 75 |
# 5a test
|
| 76 |
question = "When was a picture of St. Thomas Aquinas first added to the wikipedia page on the principle of double effect?"
|
| 77 |
#graph = build_graph(provider="groq")
|