a2a-source-edit: write agent.py
This commit is contained in:
11
agent.py
11
agent.py
@@ -5,6 +5,7 @@ bounded browser base64 bridge, managed Postgres persistence, and receipt rows.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import csv
|
||||
import hashlib
|
||||
@@ -94,7 +95,7 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]):
|
||||
"highest numeric value, persist the grounded answer in user-scoped "
|
||||
"managed Postgres, and reopen it from a polished one-page app."
|
||||
)
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
|
||||
config_model = CsvAnswersStudioV1Config
|
||||
auth_model = PlatformUserAuth
|
||||
@@ -136,7 +137,8 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]):
|
||||
if not result.ok:
|
||||
return result
|
||||
try:
|
||||
saved, receipt_id = _persist_analysis_and_receipt(
|
||||
saved, receipt_id = await asyncio.to_thread(
|
||||
_persist_analysis_and_receipt,
|
||||
tenant_key=tenant,
|
||||
analysis_id=analysis_id,
|
||||
question=question,
|
||||
@@ -220,7 +222,7 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]):
|
||||
) -> CsvAnalysisResult:
|
||||
tenant = _tenant_key(ctx)
|
||||
try:
|
||||
record = _load_analysis(tenant, analysis_id)
|
||||
record = await asyncio.to_thread(_load_analysis, tenant, analysis_id)
|
||||
except Exception: # noqa: BLE001
|
||||
return _error(
|
||||
analysis_id,
|
||||
@@ -245,7 +247,8 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]):
|
||||
tenant = _tenant_key(ctx)
|
||||
safe_limit = min(max(int(limit), 1), 50)
|
||||
try:
|
||||
return CsvAnalysisListResult(ok=True, analyses=_list_analyses(tenant, safe_limit))
|
||||
analyses = await asyncio.to_thread(_list_analyses, tenant, safe_limit)
|
||||
return CsvAnalysisListResult(ok=True, analyses=analyses)
|
||||
except Exception: # noqa: BLE001
|
||||
return CsvAnalysisListResult(
|
||||
ok=False,
|
||||
|
||||
Reference in New Issue
Block a user