mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-16 06:28:08 +01:00
initial progress
This commit is contained in:
@@ -2,19 +2,63 @@ import asyncio
|
||||
import sys
|
||||
|
||||
from temporalio.client import Client
|
||||
from workflows import OllamaParams, EntityOllamaWorkflow
|
||||
|
||||
# Import your dataclasses/types
|
||||
from workflows import (
|
||||
OllamaParams,
|
||||
EntityOllamaWorkflow,
|
||||
ToolsData,
|
||||
ToolDefinition,
|
||||
ToolArgument,
|
||||
CombinedInput,
|
||||
)
|
||||
|
||||
|
||||
async def main(prompt):
|
||||
# Create client connected to server at the given address
|
||||
# Construct your tool definitions in code
|
||||
search_flights_tool = ToolDefinition(
|
||||
name="SearchFlights",
|
||||
description="Search for flights from an origin to a destination within a date range",
|
||||
arguments=[
|
||||
ToolArgument(
|
||||
name="origin",
|
||||
type="string",
|
||||
description="Airport or city (infer airport code from city)",
|
||||
),
|
||||
ToolArgument(
|
||||
name="destination",
|
||||
type="string",
|
||||
description="Airport or city code for arrival (infer airport code from city)",
|
||||
),
|
||||
ToolArgument(
|
||||
name="dateFrom",
|
||||
type="ISO8601",
|
||||
description="Start of date range in human readable format",
|
||||
),
|
||||
ToolArgument(
|
||||
name="dateTo",
|
||||
type="ISO8601",
|
||||
description="End of date range in human readable format",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# Wrap it in ToolsData
|
||||
tools_data = ToolsData(tools=[search_flights_tool])
|
||||
|
||||
combined_input = CombinedInput(
|
||||
ollama_params=OllamaParams(None, None), tools_data=tools_data
|
||||
)
|
||||
|
||||
# Create client connected to Temporal server
|
||||
client = await Client.connect("localhost:7233")
|
||||
|
||||
workflow_id = "ollama-agent"
|
||||
|
||||
# Sends a signal to the workflow (and starts it if needed)
|
||||
# Start or signal the workflow, passing OllamaParams and tools_data
|
||||
await client.start_workflow(
|
||||
EntityOllamaWorkflow.run,
|
||||
OllamaParams(None, None), # or pass in custom summary/prompt_queue if desired
|
||||
combined_input, # or pass custom summary/prompt_queue
|
||||
id=workflow_id,
|
||||
task_queue="ollama-task-queue",
|
||||
start_signal="user_prompt",
|
||||
|
||||
Reference in New Issue
Block a user