-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_reduce.py
More file actions
41 lines (32 loc) · 1023 Bytes
/
Copy pathmap_reduce.py
File metadata and controls
41 lines (32 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations
from typing_extensions import TypedDict
from langgraph.types import Send
from agent.graph_state import SceneSpec, ShotPlan, State, TopicBrief
from rag.retriever import retrieve_shot_evidence
class ShotRetrievalState(TypedDict):
shot: ShotPlan
scene_spec: SceneSpec
topic_brief: TopicBrief
prompt: str
def continue_shots(state: State) -> list[Send]:
return [
Send(
"get_chunks",
{
"shot": shot,
"scene_spec": state["scene_spec"],
"topic_brief": state["topic_brief"],
"prompt": state["prompt"],
},
)
for shot in state["shot_plan"]
]
def get_chunks(state: ShotRetrievalState) -> dict:
shot = state["shot"]
evidence = retrieve_shot_evidence(
shot=shot,
scene_spec=state["scene_spec"],
topic_brief=state["topic_brief"],
prompt=state["prompt"],
)
return {"retrieval_evidence": [evidence]}