This commit is contained in:
a2a-platform
2026-07-09 14:14:52 +00:00
parent 492a0544b8
commit 05f703a047

View File

@@ -12,6 +12,7 @@ from langchain_core.messages import BaseMessage
from langchain_core.tools import StructuredTool
from pydantic import BaseModel, Field
import a2a_pack as a2a
from a2a_pack import (
A2AAgent,
ConsumerSetup,
@@ -22,7 +23,6 @@ from a2a_pack import (
Pricing,
Resources,
RunContext,
skill,
)
@@ -52,8 +52,8 @@ class BlogOpenapiAgent(A2AAgent):
version = "0.1.0"
consumer_setup = ConsumerSetup.from_fields(
ConsumerSetupField.config("OPENAPI_BASE_URL", label="API base URL", description="Override the default API server (https://blog.a2acloud.io).", required=False, input_type="url"),
ConsumerSetupField.secret("BLOG_API_KEY", label="bearerAuth bearer credential", description="Use `Authorization: Bearer $BLOG_API_KEY`. Use the configured `BLOG_API_KEY` value.", required=True),
ConsumerSetupField.secret("A2A_SESSION", label="a2aSession API key", description="Shared a2a Cloud browser session cookie.", required=True),
ConsumerSetupField.secret("BLOG_API_KEY", label="bearerAuth bearer credential", description="Use `Authorization: Bearer $BLOG_API_KEY`. Use the configured `BLOG_API_KEY` value. Used by: create_blog_post, delete_blog_post, get_blog_post (+2 more).", required=False),
ConsumerSetupField.secret("A2A_SESSION", label="a2aSession API key", description="Shared a2a Cloud browser session cookie. Used by: create_blog_post_comment, get_blog_post_reactions, set_blog_post_reaction.", required=False),
)
llm_provisioning = LLMProvisioning.PLATFORM
pricing = Pricing(
@@ -79,7 +79,7 @@ class BlogOpenapiAgent(A2AAgent):
}
}
@skill(
@a2a.tool(
name="auto",
description="Use the OpenAPI service to complete a natural-language goal.",
tags=("openapi", "auto"),
@@ -113,7 +113,7 @@ class BlogOpenapiAgent(A2AAgent):
"messages": [_message_to_dict(message) for message in messages[-8:]],
}
@skill(
@a2a.tool(
name="get_blog_health",
description="GET /api/healthz - Check blog service health",
tags=('Health',),
@@ -133,7 +133,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="list_blog_posts",
description="GET /api/posts - List posts",
tags=('Posts',),
@@ -153,7 +153,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="create_blog_post",
description="POST /api/posts - Create a blog post",
tags=('Posts',),
@@ -173,7 +173,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="get_blog_post",
description="GET /api/posts/{slug} - Get a post by slug",
tags=('Posts',),
@@ -193,7 +193,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="upsert_blog_post",
description="PUT /api/posts/{slug} - Upsert a post by slug",
tags=('Posts',),
@@ -213,7 +213,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="delete_blog_post",
description="DELETE /api/posts/{slug} - Delete a post by slug",
tags=('Posts',),
@@ -233,7 +233,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="list_blog_post_comments",
description="GET /api/posts/{slug}/comments - List comments for a post",
tags=('Comments',),
@@ -253,7 +253,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="create_blog_post_comment",
description="POST /api/posts/{slug}/comments - Create a comment",
tags=('Comments',),
@@ -273,7 +273,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="get_blog_post_reactions",
description="GET /api/posts/{slug}/reaction - Get post reaction counts",
tags=('Reactions',),
@@ -293,7 +293,7 @@ class BlogOpenapiAgent(A2AAgent):
body=body,
)
@skill(
@a2a.tool(
name="set_blog_post_reaction",
description="PUT /api/posts/{slug}/reaction - Set the viewer reaction",
tags=('Reactions',),