mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-14 01:41:25 -06:00
fix eval in api server and cli for below issue:
https://github.com/google/adk-python/issues/651 PiperOrigin-RevId: 756906937
This commit is contained in:
parent
c4ecef54bc
commit
166df01236
@ -18,6 +18,8 @@ from datetime import datetime
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
from typing import AsyncGenerator
|
||||
from typing import Coroutine
|
||||
from typing import Optional
|
||||
|
||||
import click
|
||||
@ -267,9 +269,16 @@ def cli_eval(
|
||||
|
||||
eval_set_to_evals = parse_and_get_evals_to_run(eval_set_file_path)
|
||||
|
||||
async def _collect_async_gen(
|
||||
async_gen_coroutine: Coroutine[
|
||||
AsyncGenerator[EvalResult, None], None, None
|
||||
],
|
||||
) -> list[EvalResult]:
|
||||
return [result async for result in async_gen_coroutine]
|
||||
|
||||
try:
|
||||
eval_results = list(
|
||||
asyncio.run(
|
||||
eval_results = asyncio.run(
|
||||
_collect_async_gen(
|
||||
run_evals(
|
||||
eval_set_to_evals,
|
||||
root_agent,
|
||||
|
@ -24,7 +24,11 @@ import re
|
||||
import sys
|
||||
import traceback
|
||||
import typing
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing import Any
|
||||
from typing import List
|
||||
from typing import Literal
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
import click
|
||||
from fastapi import FastAPI
|
||||
@ -52,7 +56,8 @@ from ..agents import RunConfig
|
||||
from ..agents.base_agent import BaseAgent
|
||||
from ..agents.live_request_queue import LiveRequest
|
||||
from ..agents.live_request_queue import LiveRequestQueue
|
||||
from ..agents.llm_agent import Agent, LlmAgent
|
||||
from ..agents.llm_agent import Agent
|
||||
from ..agents.llm_agent import LlmAgent
|
||||
from ..agents.run_config import StreamingMode
|
||||
from ..artifacts import InMemoryArtifactService
|
||||
from ..events.event import Event
|
||||
@ -467,20 +472,7 @@ def get_fast_api_app(
|
||||
"Eval ids to run list is empty. We will all evals in the eval set."
|
||||
)
|
||||
root_agent = await _get_root_agent_async(app_name)
|
||||
eval_results = list(
|
||||
await run_evals(
|
||||
eval_set_to_evals,
|
||||
root_agent,
|
||||
getattr(root_agent, "reset_data", None),
|
||||
req.eval_metrics,
|
||||
session_service=session_service,
|
||||
artifact_service=artifact_service,
|
||||
)
|
||||
)
|
||||
|
||||
run_eval_results = []
|
||||
for eval_result in eval_results:
|
||||
run_eval_results.append(
|
||||
return [
|
||||
RunEvalResult(
|
||||
app_name=app_name,
|
||||
eval_set_id=eval_set_id,
|
||||
@ -489,8 +481,15 @@ def get_fast_api_app(
|
||||
eval_metric_results=eval_result.eval_metric_results,
|
||||
session_id=eval_result.session_id,
|
||||
)
|
||||
async for eval_result in run_evals(
|
||||
eval_set_to_evals,
|
||||
root_agent,
|
||||
getattr(root_agent, "reset_data", None),
|
||||
req.eval_metrics,
|
||||
session_service=session_service,
|
||||
artifact_service=artifact_service,
|
||||
)
|
||||
return run_eval_results
|
||||
]
|
||||
|
||||
@app.delete("/apps/{app_name}/users/{user_id}/sessions/{session_id}")
|
||||
def delete_session(app_name: str, user_id: str, session_id: str):
|
||||
|
Loading…
Reference in New Issue
Block a user