mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix code samples in AGENTS.md files that fail pre-commit checks (#3779)
* Fix code samples in AGENTS.md files that fail pre-commit checks * Fixes
This commit is contained in:
committed by
GitHub
Unverified
parent
9f14a0f33f
commit
56603ab472
@@ -20,8 +20,13 @@ YAML/JSON-based declarative agent and workflow definitions.
|
||||
```python
|
||||
from agent_framework.declarative import AgentFactory, WorkflowFactory
|
||||
|
||||
agent = AgentFactory.create_from_file("agent.yaml")
|
||||
workflow = WorkflowFactory.create_from_file("workflow.yaml")
|
||||
# Create agent from YAML file
|
||||
agent_factory = AgentFactory()
|
||||
agent = agent_factory.create_agent_from_yaml_path("agent.yaml")
|
||||
|
||||
# Create workflow from YAML file
|
||||
workflow_factory = WorkflowFactory()
|
||||
workflow = workflow_factory.create_workflow_from_yaml_path("workflow.yaml")
|
||||
```
|
||||
|
||||
## Import Path
|
||||
|
||||
@@ -29,14 +29,29 @@ Durable execution support for long-running agent workflows using Azure Durable F
|
||||
## Usage
|
||||
|
||||
```python
|
||||
from durabletask.client import TaskHubGrpcClient
|
||||
from durabletask.worker import TaskHubGrpcWorker
|
||||
from agent_framework import ChatAgent
|
||||
from agent_framework.azure import AzureOpenAIChatClient
|
||||
from agent_framework_durabletask import DurableAIAgentClient, DurableAIAgentWorker
|
||||
|
||||
# Client side
|
||||
client = DurableAIAgentClient(endpoint="https://your-functions.azurewebsites.net")
|
||||
response = await client.run("Hello")
|
||||
dt_client = TaskHubGrpcClient(host_address="localhost:4001")
|
||||
agent_client = DurableAIAgentClient(dt_client)
|
||||
agent = agent_client.get_agent("assistant")
|
||||
response = agent.run("Hello, how are you?")
|
||||
print(response.text)
|
||||
|
||||
# Worker side
|
||||
worker = DurableAIAgentWorker(agent=my_agent)
|
||||
dt_worker = TaskHubGrpcWorker(host_address="localhost:4001")
|
||||
agent_worker = DurableAIAgentWorker(dt_worker)
|
||||
|
||||
# Create a chat client for the agent
|
||||
chat_client = AzureOpenAIChatClient()
|
||||
my_agent = ChatAgent(chat_client=chat_client, name="assistant")
|
||||
agent_worker.add_agent(my_agent)
|
||||
|
||||
dt_worker.start()
|
||||
```
|
||||
|
||||
## Import Path
|
||||
|
||||
Reference in New Issue
Block a user