MCPcopy Index your code
hub / github.com/google/adk-python / save_artifact

Method save_artifact

src/google/adk/cli/api_server.py:1277–1318  ·  view source on GitHub ↗

Request payload for saving a new artifact.

(
        app_name: str,
        user_id: str,
        session_id: str,
        req: SaveArtifactRequest,
    )

Source from the content-addressed store, hash-verified

1275 response_model_exclude_none=True,
1276 )
1277 async def save_artifact(
1278 app_name: str,
1279 user_id: str,
1280 session_id: str,
1281 req: SaveArtifactRequest,
1282 ) -> ArtifactVersion:
1283 """Request payload for saving a new artifact."""
1284 try:
1285 version = await self.artifact_service.save_artifact(
1286 app_name=app_name,
1287 user_id=user_id,
1288 session_id=session_id,
1289 filename=req.filename,
1290 artifact=req.artifact,
1291 custom_metadata=req.custom_metadata,
1292 )
1293 except InputValidationError as ive:
1294 raise HTTPException(status_code=400, detail=str(ive)) from ive
1295 except Exception as exc: # pylint: disable=broad-exception-caught
1296 logger.error(
1297 "Internal error while saving artifact %s for app=%s user=%s"
1298 " session=%s: %s",
1299 req.filename,
1300 app_name,
1301 user_id,
1302 session_id,
1303 exc,
1304 exc_info=True,
1305 )
1306 raise HTTPException(status_code=500, detail=str(exc)) from exc
1307 artifact_version = await self.artifact_service.get_artifact_version(
1308 app_name=app_name,
1309 user_id=user_id,
1310 session_id=session_id,
1311 filename=req.filename,
1312 version=version,
1313 )
1314 if artifact_version is None:
1315 raise HTTPException(
1316 status_code=500, detail="Artifact metadata unavailable"
1317 )
1318 return artifact_version
1319
1320 @app.get(
1321 "/apps/{app_name}/users/{user_id}/sessions/{session_id}/artifacts/{artifact_name:path}/versions/{version_id}",

Callers

nothing calls this directly

Calls 2

errorMethod · 0.45
get_artifact_versionMethod · 0.45

Tested by

no test coverage detected