deploy
This commit is contained in:
28
agent.py
28
agent.py
@@ -12,6 +12,7 @@ from langchain_core.messages import BaseMessage
|
|||||||
from langchain_core.tools import StructuredTool
|
from langchain_core.tools import StructuredTool
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
import a2a_pack as a2a
|
||||||
from a2a_pack import (
|
from a2a_pack import (
|
||||||
A2AAgent,
|
A2AAgent,
|
||||||
ConsumerSetup,
|
ConsumerSetup,
|
||||||
@@ -22,7 +23,6 @@ from a2a_pack import (
|
|||||||
Pricing,
|
Pricing,
|
||||||
Resources,
|
Resources,
|
||||||
RunContext,
|
RunContext,
|
||||||
skill,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
consumer_setup = ConsumerSetup.from_fields(
|
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.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("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.", required=True),
|
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
|
llm_provisioning = LLMProvisioning.PLATFORM
|
||||||
pricing = Pricing(
|
pricing = Pricing(
|
||||||
@@ -79,7 +79,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="auto",
|
name="auto",
|
||||||
description="Use the OpenAPI service to complete a natural-language goal.",
|
description="Use the OpenAPI service to complete a natural-language goal.",
|
||||||
tags=("openapi", "auto"),
|
tags=("openapi", "auto"),
|
||||||
@@ -113,7 +113,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
"messages": [_message_to_dict(message) for message in messages[-8:]],
|
"messages": [_message_to_dict(message) for message in messages[-8:]],
|
||||||
}
|
}
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="get_blog_health",
|
name="get_blog_health",
|
||||||
description="GET /api/healthz - Check blog service health",
|
description="GET /api/healthz - Check blog service health",
|
||||||
tags=('Health',),
|
tags=('Health',),
|
||||||
@@ -133,7 +133,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="list_blog_posts",
|
name="list_blog_posts",
|
||||||
description="GET /api/posts - List posts",
|
description="GET /api/posts - List posts",
|
||||||
tags=('Posts',),
|
tags=('Posts',),
|
||||||
@@ -153,7 +153,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="create_blog_post",
|
name="create_blog_post",
|
||||||
description="POST /api/posts - Create a blog post",
|
description="POST /api/posts - Create a blog post",
|
||||||
tags=('Posts',),
|
tags=('Posts',),
|
||||||
@@ -173,7 +173,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="get_blog_post",
|
name="get_blog_post",
|
||||||
description="GET /api/posts/{slug} - Get a post by slug",
|
description="GET /api/posts/{slug} - Get a post by slug",
|
||||||
tags=('Posts',),
|
tags=('Posts',),
|
||||||
@@ -193,7 +193,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="upsert_blog_post",
|
name="upsert_blog_post",
|
||||||
description="PUT /api/posts/{slug} - Upsert a post by slug",
|
description="PUT /api/posts/{slug} - Upsert a post by slug",
|
||||||
tags=('Posts',),
|
tags=('Posts',),
|
||||||
@@ -213,7 +213,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="delete_blog_post",
|
name="delete_blog_post",
|
||||||
description="DELETE /api/posts/{slug} - Delete a post by slug",
|
description="DELETE /api/posts/{slug} - Delete a post by slug",
|
||||||
tags=('Posts',),
|
tags=('Posts',),
|
||||||
@@ -233,7 +233,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="list_blog_post_comments",
|
name="list_blog_post_comments",
|
||||||
description="GET /api/posts/{slug}/comments - List comments for a post",
|
description="GET /api/posts/{slug}/comments - List comments for a post",
|
||||||
tags=('Comments',),
|
tags=('Comments',),
|
||||||
@@ -253,7 +253,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="create_blog_post_comment",
|
name="create_blog_post_comment",
|
||||||
description="POST /api/posts/{slug}/comments - Create a comment",
|
description="POST /api/posts/{slug}/comments - Create a comment",
|
||||||
tags=('Comments',),
|
tags=('Comments',),
|
||||||
@@ -273,7 +273,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="get_blog_post_reactions",
|
name="get_blog_post_reactions",
|
||||||
description="GET /api/posts/{slug}/reaction - Get post reaction counts",
|
description="GET /api/posts/{slug}/reaction - Get post reaction counts",
|
||||||
tags=('Reactions',),
|
tags=('Reactions',),
|
||||||
@@ -293,7 +293,7 @@ class BlogOpenapiAgent(A2AAgent):
|
|||||||
body=body,
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@skill(
|
@a2a.tool(
|
||||||
name="set_blog_post_reaction",
|
name="set_blog_post_reaction",
|
||||||
description="PUT /api/posts/{slug}/reaction - Set the viewer reaction",
|
description="PUT /api/posts/{slug}/reaction - Set the viewer reaction",
|
||||||
tags=('Reactions',),
|
tags=('Reactions',),
|
||||||
|
|||||||
Reference in New Issue
Block a user