Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions durable-exec/deep_research_dbos.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,21 @@ async def deep_research_durable(query: str):
'name': 'deep_research_durable',
'enable_otlp': True,
'conductor_key': os.environ.get('DBOS_CONDUCTOR_KEY', None),
'application_version': '0.1.0',
}
DBOS(config=config)
DBOS.launch()
resume_id = sys.argv[1] if len(sys.argv) > 1 else None
wf_id = f'deep-research-{uuid.uuid4()}'
if resume_id is not None:
print('resuming existing workflow', resume_id)
wf_id = resume_id
# Get the workflow handle and wait for the result
wf_handle: WorkflowHandleAsync[str] = await DBOS.retrieve_workflow_async(resume_id)
summary = await wf_handle.get_result()
else:
print('starting new workflow', wf_id)

with SetWorkflowID(wf_id):
summary = await deep_research(query)
with SetWorkflowID(wf_id):
summary = await deep_research(query)

print(summary)

Expand Down
14 changes: 8 additions & 6 deletions durable-exec/twenty_questions_dbos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import StrEnum

import logfire
from dbos import DBOS, DBOSConfig, SetWorkflowID
from dbos import DBOS, DBOSConfig, SetWorkflowID, WorkflowHandleAsync
from pydantic_ai import Agent, AgentRunResult, RunContext, UsageLimits
from pydantic_ai.durable_exec.dbos import DBOSAgent

Expand Down Expand Up @@ -80,19 +80,21 @@ async def play(resume_id: str | None, answer: str) -> AgentRunResult[str]:
# run the server with
# docker run -e POSTGRES_HOST_AUTH_METHOD=trust --rm -it --name pg -p 5432:5432 -d postgres
'system_database_url': 'postgresql://postgres@localhost:5432/dbos',
'application_version': '0.1.0',
}
DBOS(config=config)
DBOS.launch()
if resume_id is not None:
print('resuming existing workflow', resume_id)
wf_id = resume_id
# Get the workflow handle and wait for the result
wf_handle: WorkflowHandleAsync[AgentRunResult] = await DBOS.retrieve_workflow_async(resume_id)
result = await wf_handle.get_result()
else:
wf_id = f'twenty-questions-{uuid.uuid4()}'
print('starting new workflow', wf_id)

state = GameState(answer=answer)
with SetWorkflowID(wf_id):
result = await dbos_questioner_agent.run('start', deps=state, usage_limits=UsageLimits(request_limit=25))
state = GameState(answer=answer)
with SetWorkflowID(wf_id):
result = await dbos_questioner_agent.run('start', deps=state, usage_limits=UsageLimits(request_limit=25))

print(f'After {len(result.all_messages()) / 2}, the answer is: {result.output}')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [
"mcp>=1.15.0",
"pydantic-ai>=1",
"tavily-python>=0.7.12",
"dbos>=2",
"dbos>=2.4.0",
]

[dependency-groups]
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.