Skip to content

Commit

Permalink
feat(agent): add agent contract (#523)
Browse files Browse the repository at this point in the history
Because

we are going to remove the app-related api

This commit

adds api for agent

---------

Co-authored-by: droplet-bot <[email protected]>
  • Loading branch information
Yougigun and droplet-bot authored Nov 27, 2024
1 parent 03e0861 commit 7b8b548
Show file tree
Hide file tree
Showing 4 changed files with 472 additions and 36 deletions.
109 changes: 104 additions & 5 deletions app/app/v1alpha/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@ package app.app.v1alpha;

// Google API
import "google/api/field_behavior.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

// Agent represents a agent.
message Agent {
// agent uid
string agent_uid = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
// The agent display name.
string display_name = 2 [(google.api.field_behavior) = REQUIRED];
// The agent description.
string description = 3 [(google.api.field_behavior) = OPTIONAL];
// The namespace of the agent.
string namespace_uid = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// The agent tags.
repeated string tags = 5 [(google.api.field_behavior) = OPTIONAL];
// The agent metadata.
AIAgentAppMetadata ai_agent_metadata = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
// creator uid
string creator_uid = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// The creation time of the agent.
google.protobuf.Timestamp create_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
// The last update time of the agent.
google.protobuf.Timestamp update_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// AIAgentAppMetadata represents the metadata for the AI agent app.
message AIAgentAppMetadata {
Expand All @@ -22,8 +44,85 @@ message AIAgentAppMetadata {

// tool definitions
message Tool {
// The tool name. e.g. ["preset/[email protected]", "preset/[email protected]"].
string name = 1 [(google.api.field_behavior) = REQUIRED];
// The tool config
google.protobuf.Struct config = 3 [(google.api.field_behavior) = OPTIONAL];
// The pipeline id of the tool. e.g. "preset/xxx-search"
string pipeline_id = 1 [(google.api.field_behavior) = OPTIONAL];
// The tool name.
optional string name = 2 [(google.api.field_behavior) = OPTIONAL];
// The tool connection key(variable) and value(id).
map<string, string> config = 3 [(google.api.field_behavior) = OPTIONAL];
}

// CreateAgentRequest represents a request to create a agent.
message CreateAgentRequest {
// The app's owner(namespaces).
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// The agent display name.
string display_name = 2 [(google.api.field_behavior) = OPTIONAL];
// The agent description.
string description = 3 [(google.api.field_behavior) = OPTIONAL];
// The agent tags.
repeated string tags = 4 [(google.api.field_behavior) = OPTIONAL];
// The agent metadata.
AIAgentAppMetadata ai_agent_app = 5 [(google.api.field_behavior) = OPTIONAL];
}

// CreateAgentResponse represents a response for creating a agent.
message CreateAgentResponse {
// The created agent.
Agent agent = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// ListAgentsRequest represents a request to list agents.
message ListAgentsRequest {
// The app's owner(namespaces).
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
}

// ListAgentsResponse represents a response for listing agents.
message ListAgentsResponse {
// The agents.
repeated Agent agents = 1;
}

// UpdateAgentRequest represents a request to update a agent.
message UpdateAgentRequest {
// The app's owner(namespaces).
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// The agent uid.
string agent_uid = 2 [(google.api.field_behavior) = REQUIRED];
// The agent description.
string description = 3 [(google.api.field_behavior) = OPTIONAL];
// The agent tags.
repeated string tags = 4 [(google.api.field_behavior) = OPTIONAL];
// The agent metadata.
AIAgentAppMetadata ai_agent_app = 5 [(google.api.field_behavior) = OPTIONAL];
}

// UpdateAgentResponse represents a response for updating a agent.
message UpdateAgentResponse {
// The updated agent.
Agent agent = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// DeleteAgentRequest represents a request to delete a agent.
message DeleteAgentRequest {
// The app's owner(namespaces).
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// The agent uid.
string agent_uid = 2 [(google.api.field_behavior) = REQUIRED];
}

// DeleteAgentResponse represents a response for deleting a agent.
message DeleteAgentResponse {}

// ListToolsRequest represents a request to list tools.
message ListToolsRequest {
// The app's owner(namespaces).
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
}

// ListToolsResponse represents a response for listing tools.
message ListToolsResponse {
// The tools.
repeated Tool tools = 1;
}
89 changes: 83 additions & 6 deletions app/app/v1alpha/app_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";

package app.app.v1alpha;

import "app/app/v1alpha/agent.proto";
// App definitions
import "app/app/v1alpha/app.proto";
import "app/app/v1alpha/conversation.proto";
Expand Down Expand Up @@ -71,7 +72,7 @@ service AppPublicService {
};
}

// Update a app info
// Update an app's information
//
// Updates the information of an app.
rpc UpdateApp(UpdateAppRequest) returns (UpdateAppResponse) {
Expand All @@ -88,7 +89,7 @@ service AppPublicService {
};
}

// Delete a app
// Delete an app
//
// Deletes an app.
rpc DeleteApp(DeleteAppRequest) returns (DeleteAppResponse) {
Expand Down Expand Up @@ -164,6 +165,68 @@ service AppPublicService {
};
}

// Create an agent
//
// Creates an agent.
rpc CreateAgent(CreateAgentRequest) returns (CreateAgentResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/agents"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "🍎 App"
extensions: {
key: "x-stage"
value: {string_value: "alpha"}
}
};
}

// List all agents info
//
// Returns a paginated list of agents.
rpc ListAgents(ListAgentsRequest) returns (ListAgentsResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/agents"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "🍎 App"
extensions: {
key: "x-stage"
value: {string_value: "alpha"}
}
};
}

// Update an agent
//
// Updates the information of an agent.
rpc UpdateAgent(UpdateAgentRequest) returns (UpdateAgentResponse) {
option (google.api.http) = {
put: "/v1alpha/namespaces/{namespace_id}/agents/{agent_uid}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "🍎 App"
extensions: {
key: "x-stage"
value: {string_value: "alpha"}
}
};
}

// Delete an agent
//
// Deletes an agent.
rpc DeleteAgent(DeleteAgentRequest) returns (DeleteAgentResponse) {
option (google.api.http) = {delete: "/v1alpha/namespaces/{namespace_id}/agents/{agent_uid}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "🍎 App"
extensions: {
key: "x-stage"
value: {string_value: "alpha"}
}
};
}

// Create a chat
//
// Creates a chat.
Expand All @@ -183,7 +246,7 @@ service AppPublicService {

// List chats
//
// Returns a paginated list of conversations.
// Returns a list of chats.
rpc ListChats(ListChatsRequest) returns (ListChatsResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/chats"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
Expand Down Expand Up @@ -290,7 +353,7 @@ service AppPublicService {

// Get Playground Conversation
//
// Returns the latest conversation of auth user(e.g. login user and api key user).
// Returns the latest conversation for the authenticated user (e.g., logged-in user or API key user).
rpc GetPlaygroundConversation(GetPlaygroundConversationRequest) returns (GetPlaygroundConversationResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/ai_assistant_playground/conversation"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
Expand All @@ -302,6 +365,20 @@ service AppPublicService {
};
}

// List all tools
//
// Returns a list of tools.
rpc ListTools(ListToolsRequest) returns (ListToolsResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/tools"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "🍎 App"
extensions: {
key: "x-stage"
value: {string_value: "alpha"}
}
};
}

// List chat messages
//
// Returns a paginated list of messages.
Expand All @@ -318,8 +395,8 @@ service AppPublicService {

// Restart Playground Conversation
//
// Creates a new conversation and uses the auth user UID as creator UID and
// auto-generates a new conversation ID on the behalf of auth user.
// Creates a new conversation using the authenticated user's UID as creator and
// auto-generates a new conversation ID on behalf of the authenticated user.
rpc RestartPlaygroundConversation(RestartPlaygroundConversationRequest) returns (RestartPlaygroundConversationResponse) {
option (google.api.http) = {post: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/ai_assistant_playground/restart"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
Expand Down
8 changes: 2 additions & 6 deletions app/app/v1alpha/conversation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message Chat {
// update time of the chat
google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// agent metadata
AIAgentAppMetadata ai_agent_app = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
AIAgentAppMetadata ai_agent_metadata = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
// temp catalog id automatically created for ai agent app
optional string temp_catalog_id = 9 [(google.api.field_behavior) = OPTIONAL];
// conversation display name
Expand Down Expand Up @@ -197,10 +197,6 @@ message UpdateConversationRequest {
optional string last_used_catalog_uid = 5 [(google.api.field_behavior) = OPTIONAL];
// last used top k(only for ai assistant app)
optional uint32 last_used_top_k = 6 [(google.api.field_behavior) = OPTIONAL];
// ai agent app metadata
AIAgentAppMetadata ai_agent_app = 7 [(google.api.field_behavior) = OPTIONAL];
// conversation display name
string conversation_display_name = 8 [(google.api.field_behavior) = OPTIONAL];
}

// UpdateConversationResponse returns the updated conversation
Expand All @@ -218,7 +214,7 @@ message UpdateChatRequest {
// chat display name
string chat_display_name = 3 [(google.api.field_behavior) = OPTIONAL];
// ai agent app metadata
AIAgentAppMetadata ai_agent_app = 4 [(google.api.field_behavior) = OPTIONAL];
AIAgentAppMetadata ai_agent_metadata = 4 [(google.api.field_behavior) = OPTIONAL];
}

// UpdateChatResponse returns the updated chat
Expand Down
Loading

0 comments on commit 7b8b548

Please sign in to comment.