-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from wri/reactivate-tms-output
Reactivate tms output using viz parameters
- Loading branch information
Showing
9 changed files
with
55 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
from zeno.tools.contextlayer.context_layer_retriever_tool import context_layer_tool | ||
from zeno.agents.distalert.tool_context_layer import context_layer_tool | ||
|
||
|
||
def test_context_layer_tool_cereal(): | ||
msg = context_layer_tool.invoke( | ||
{ | ||
"name": "context-layer-tool", | ||
"args": {"question": "Summarize disturbance alerts by type of cereal"}, | ||
"args": {"question": "Summarize disturbance alerts by natural lands"}, | ||
"id": "42", | ||
"type": "tool_call", | ||
} | ||
) | ||
assert msg.content == "ESA/WorldCereal/2021/MODELS/v100" | ||
assert msg.content == "WRI/SBTN/naturalLands/v1/2020" | ||
assert "{z}/{x}/{y}" in msg.artifact["tms_url"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,39 @@ | ||
import datetime | ||
import uuid | ||
|
||
from zeno.agents.distalert.agent import graph | ||
from zeno.agents.maingraph.utils.state import GraphState | ||
from langgraph.types import Command | ||
|
||
from zeno.agents.distalert.graph import graph as dist_alert | ||
|
||
def test_distalert_agent_level_2(): | ||
|
||
def test_distalert_agent(): | ||
""" | ||
This test just runs the agent without checking any output, it is intended | ||
to be used for debugging | ||
""" | ||
config = { | ||
"configurable": {"thread_id": uuid.uuid4()}, | ||
} | ||
initial_state = GraphState( | ||
question="Provide data about disturbance alerts in Aveiro in 2023 summarized by natural lands" | ||
) | ||
for _, chunk in graph.stream( | ||
initial_state, | ||
query = "Provide data about disturbance alerts in Aveiro summarized by natural lands in 2023" | ||
stream = dist_alert.stream( | ||
{"messages": [query]}, | ||
stream_mode="updates", | ||
subgraphs=True, | ||
subgraphs=False, | ||
config=config, | ||
): | ||
if "assistant" in chunk: | ||
for msg in chunk["assistant"]["messages"]: | ||
for call in msg.tool_calls: | ||
print(call["name"]) | ||
if call["name"] == "location-tool": | ||
assert call["args"]["gadm_level"] == 2 | ||
assert call["args"]["query"] == "Aveiro" | ||
if call["name"] == "dist-alerts-tool": | ||
assert call["args"]["min_date"] == "2023-01-01" | ||
assert call["args"]["max_date"] == "2023-12-31" | ||
|
||
if "tools" in chunk: | ||
for msg in chunk["tools"]["messages"]: | ||
if msg.name == "context-layer-tool": | ||
assert "WRI/SBTN/naturalLands/v1" in msg.content | ||
|
||
|
||
def test_distalert_agent_level_1(): | ||
config = { | ||
"configurable": {"thread_id": uuid.uuid4()}, | ||
} | ||
initial_state = GraphState( | ||
question="Provide data about disturbance alerts in Florida summarized by natural lands in 2023" | ||
) | ||
for _, chunk in graph.stream( | ||
initial_state, | ||
for chunk in stream: | ||
print(str(chunk)[:300], "\n") | ||
|
||
query = "Averio" | ||
stream = dist_alert.stream( | ||
Command( | ||
goto="dist_alert", | ||
update={ | ||
"messages": [query], | ||
}, | ||
), | ||
stream_mode="updates", | ||
subgraphs=True, | ||
subgraphs=False, | ||
config=config, | ||
): | ||
if "assistant" in chunk: | ||
if chunk["assistant"]["messages"][0].tool_calls: | ||
call = chunk["assistant"]["messages"][0].tool_calls[0] | ||
if call["name"] == "location-tool": | ||
assert call["args"]["gadm_level"] == 1 | ||
assert call["args"]["query"] == "Florida" | ||
) | ||
for chunk in stream: | ||
print(str(chunk)[:300], "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters