mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
renamed all (#3207)
This commit is contained in:
committed by
GitHub
Unverified
parent
1ae0b09e42
commit
d8cf8361bd
+7
-10
@@ -19,9 +19,9 @@ import logging
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
import redis.asyncio as aioredis
|
||||
from agent_framework import AgentRunResponseUpdate
|
||||
import azure.functions as func
|
||||
import redis.asyncio as aioredis
|
||||
from agent_framework import AgentResponseUpdate
|
||||
from agent_framework.azure import (
|
||||
AgentCallbackContext,
|
||||
AgentFunctionApp,
|
||||
@@ -29,7 +29,6 @@ from agent_framework.azure import (
|
||||
AzureOpenAIChatClient,
|
||||
)
|
||||
from azure.identity import AzureCliCredential
|
||||
|
||||
from redis_stream_response_handler import RedisStreamResponseHandler, StreamChunk
|
||||
from tools import get_local_events, get_weather_forecast
|
||||
|
||||
@@ -39,6 +38,7 @@ logger = logging.getLogger(__name__)
|
||||
REDIS_CONNECTION_STRING = os.environ.get("REDIS_CONNECTION_STRING", "redis://localhost:6379")
|
||||
REDIS_STREAM_TTL_MINUTES = int(os.environ.get("REDIS_STREAM_TTL_MINUTES", "10"))
|
||||
|
||||
|
||||
async def get_stream_handler() -> RedisStreamResponseHandler:
|
||||
"""Create a new Redis stream handler for each request.
|
||||
|
||||
@@ -70,7 +70,7 @@ class RedisStreamCallback(AgentResponseCallbackProtocol):
|
||||
|
||||
async def on_streaming_response_update(
|
||||
self,
|
||||
update: AgentRunResponseUpdate,
|
||||
update: AgentResponseUpdate,
|
||||
context: AgentCallbackContext,
|
||||
) -> None:
|
||||
"""Write streaming update to Redis Stream.
|
||||
@@ -291,24 +291,21 @@ def _format_chunk(chunk: StreamChunk, use_sse_format: bool) -> str:
|
||||
"""Format a text chunk."""
|
||||
if use_sse_format:
|
||||
return _format_sse_event("message", chunk.text, chunk.entry_id)
|
||||
else:
|
||||
return chunk.text
|
||||
return chunk.text
|
||||
|
||||
|
||||
def _format_end_of_stream(entry_id: str, use_sse_format: bool) -> str:
|
||||
"""Format end-of-stream marker."""
|
||||
if use_sse_format:
|
||||
return _format_sse_event("done", "[DONE]", entry_id)
|
||||
else:
|
||||
return "\n"
|
||||
return "\n"
|
||||
|
||||
|
||||
def _format_error(error: str, use_sse_format: bool) -> str:
|
||||
"""Format error message."""
|
||||
if use_sse_format:
|
||||
return _format_sse_event("error", error, None)
|
||||
else:
|
||||
return f"\n[Error: {error}]\n"
|
||||
return f"\n[Error: {error}]\n"
|
||||
|
||||
|
||||
def _format_sse_event(event_type: str, data: str, event_id: str | None = None) -> str:
|
||||
|
||||
+3
-3
@@ -12,8 +12,8 @@ import json
|
||||
import logging
|
||||
from typing import Any, cast
|
||||
|
||||
from agent_framework import AgentRunResponse
|
||||
import azure.functions as func
|
||||
from agent_framework import AgentResponse
|
||||
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
|
||||
from azure.durable_functions import DurableOrchestrationClient, DurableOrchestrationContext
|
||||
from azure.identity import AzureCliCredential
|
||||
@@ -71,8 +71,8 @@ def multi_agent_concurrent_orchestration(context: DurableOrchestrationContext):
|
||||
# Execute both tasks concurrently using task_all
|
||||
task_results = yield context.task_all([physicist_task, chemist_task])
|
||||
|
||||
physicist_result = cast(AgentRunResponse, task_results[0])
|
||||
chemist_result = cast(AgentRunResponse, task_results[1])
|
||||
physicist_result = cast(AgentResponse, task_results[0])
|
||||
chemist_result = cast(AgentResponse, task_results[1])
|
||||
|
||||
return {
|
||||
"physicist": physicist_result.text,
|
||||
|
||||
Reference in New Issue
Block a user