Skip to content

Commit

Permalink
feat(artifact&app): design agent related api (#520)
Browse files Browse the repository at this point in the history
Because

agent will use a lot of artifact and app funciton.

This commit

try to reuse the old catalog api and ai assistant api.

---------

Co-authored-by: droplet-bot <[email protected]>
  • Loading branch information
Yougigun and droplet-bot authored Nov 22, 2024
1 parent 240c559 commit b85ba0e
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 11 deletions.
29 changes: 29 additions & 0 deletions app/app/v1alpha/agent.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";

package app.app.v1alpha;

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

// AIAgentAppMetadata represents the metadata for the AI agent app.
message AIAgentAppMetadata {
// The instructions for the AI agent app.
string instructions = 1 [(google.api.field_behavior) = OPTIONAL];
// The tools(pipelines) that the AI agent app can use.
repeated Tool tools = 2 [(google.api.field_behavior) = OPTIONAL];
// The catalog uids that the AI agent app can use.
repeated string catalog_uids = 3 [(google.api.field_behavior) = OPTIONAL];
// The AI agent app top k.
int32 chunk_top_k = 4 [(google.api.field_behavior) = OPTIONAL];
// The AI agent chunk weight.
float chunk_weight = 5 [(google.api.field_behavior) = OPTIONAL];
}

// 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];
}
29 changes: 26 additions & 3 deletions app/app/v1alpha/app.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";
import "app/app/v1alpha/conversation.proto";
import "common/healthcheck/v1beta/healthcheck.proto";
// Google API
Expand Down Expand Up @@ -61,13 +62,15 @@ message App {
oneof metadata {
// The AI assistant app metadata.
AIAssistantAppMetadata ai_assistant_app = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// The AI agent app metadata.
AIAgentAppMetadata ai_agent_app = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
}
// The app type.
AppType app_type = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
AppType app_type = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
// app uid
string app_uid = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
string app_uid = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
// creator uid
string creator_uid = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
string creator_uid = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// AIAssistantAppMetadata represents the metadata for the AI assistant app.
Expand All @@ -84,6 +87,8 @@ enum AppType {
APP_TYPE_UNSPECIFIED = 0;
// AppType is a AI assistant app.
APP_TYPE_AI_ASSISTANT = 1;
// AppType is a AI agent app.
APP_TYPE_AI_AGENT = 2;
}

// CreateAppRequest represents a request to create a app.
Expand All @@ -98,6 +103,15 @@ message CreateAppRequest {
string description = 3 [(google.api.field_behavior) = OPTIONAL];
// The app tags.
repeated string tags = 4 [(google.api.field_behavior) = OPTIONAL];
// app type(default is APP_TYPE_AI_ASSISTANT)
AppType app_type = 5 [(google.api.field_behavior) = REQUIRED];
// app metadata
oneof metadata {
// ai assistant app metadata
AIAssistantAppMetadata ai_assistant_app = 6 [(google.api.field_behavior) = OPTIONAL];
// ai agent app metadata
AIAgentAppMetadata ai_agent_app = 7 [(google.api.field_behavior) = OPTIONAL];
}
}

// CreateAppResponse represents a response for creating a app.
Expand All @@ -110,6 +124,8 @@ message CreateAppResponse {
message ListAppsRequest {
// User ID for which to list the apps
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// app type(default is APP_TYPE_AI_ASSISTANT)
AppType app_type = 2 [(google.api.field_behavior) = OPTIONAL];
}

// GetAppsResponse represents a response for getting all apps from users.
Expand Down Expand Up @@ -139,6 +155,13 @@ message UpdateAppRequest {
// last AI assistant app top k
// If the last AI assistant app top k is empty, the last AI assistant app top k will be set to empty.
int32 last_ai_assistant_app_top_k = 7 [(google.api.field_behavior) = OPTIONAL];
// update app metadata
oneof metadata {
// ai assistant app metadata
AIAssistantAppMetadata ai_assistant_app = 8 [(google.api.field_behavior) = OPTIONAL];
// ai agent app metadata
AIAgentAppMetadata ai_agent_app = 9 [(google.api.field_behavior) = OPTIONAL];
}
}

// UpdateAppResponse represents a response for updating a app.
Expand Down
42 changes: 39 additions & 3 deletions app/app/v1alpha/conversation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package app.app.v1alpha;

// agent definitions
import "app/app/v1alpha/agent.proto";
// Artifact definitions
import "artifact/artifact/v1alpha/chunk.proto";
// Google API
Expand All @@ -28,6 +30,14 @@ message Conversation {
google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// update time of the conversation
google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
// agent metadata
AIAgentAppMetadata ai_agent_app = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
// temp catalog id automatically created for ai agent app
optional string temp_catalog_id = 10 [(google.api.field_behavior) = OPTIONAL];
// chat with
ChatWith chat_with = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
// conversation display name
string conversation_display_name = 12 [(google.api.field_behavior) = OPTIONAL];
}

// Message represents a single message in a conversation
Expand All @@ -47,7 +57,7 @@ message Message {
string conversation_uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// message content
string content = 4 [(google.api.field_behavior) = REQUIRED];
// message role e.g., "user" or "assistant"
// message role e.g., "user" or "assistant" or "agent"
string role = 5 [(google.api.field_behavior) = REQUIRED];
// message type
MessageType type = 6 [(google.api.field_behavior) = REQUIRED];
Expand All @@ -57,6 +67,10 @@ message Message {
google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
// message sender uid
string msg_sender_uid = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
// the chunks attached to the message
repeated artifact.artifact.v1alpha.Chunk chunks = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
// standalone question
string standalone_question = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// CreateConversationRequest is used to create a new conversation
Expand All @@ -67,6 +81,12 @@ message CreateConversationRequest {
string app_id = 2 [(google.api.field_behavior) = REQUIRED];
// conversation id. only allow kebab case
string conversation_id = 3 [(google.api.field_behavior) = REQUIRED];
// chat with(optional) default is CHAT_WITH_AI_ASSISTANT
ChatWith chat_with = 4 [(google.api.field_behavior) = OPTIONAL];
// conversation display name
string conversation_display_name = 5 [(google.api.field_behavior) = OPTIONAL];
// agent metadata
AIAgentAppMetadata ai_agent_app = 6 [(google.api.field_behavior) = OPTIONAL];
}

// CreateConversationResponse returns the created conversation
Expand All @@ -92,6 +112,18 @@ message ListConversationsRequest {
string conversation_id = 6 [(google.api.field_behavior) = OPTIONAL];
// If true, all conversations will be returned. This has higher priority over conversation_id, page_size, and page_token.
bool if_all = 7 [(google.api.field_behavior) = OPTIONAL];
// chat with
ChatWith chat_with = 8 [(google.api.field_behavior) = OPTIONAL];
}

// ChatWith enum
enum ChatWith {
// unspecified
CHAT_WITH_UNSPECIFIED = 0;
// chat with ai assistant(default)
CHAT_WITH_AI_ASSISTANT = 1;
// chat with ai agent
CHAT_WITH_AI_AGENT = 2;
}

// ListConversationsResponse returns a list of conversations
Expand All @@ -114,10 +146,14 @@ message UpdateConversationRequest {
string conversation_id = 3 [(google.api.field_behavior) = REQUIRED];
// new conversation id
optional string new_conversation_id = 4 [(google.api.field_behavior) = OPTIONAL];
// last used catalog uid
// last used catalog uid(only for ai assistant app)
optional string last_used_catalog_uid = 5 [(google.api.field_behavior) = OPTIONAL];
// last used top k
// 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 Down
17 changes: 16 additions & 1 deletion artifact/artifact/v1alpha/artifact.proto
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ message Catalog {
uint64 used_storage = 15;
}

// Catalog Type. e.g. "persistent" or "ephemeral"
enum CatalogType {
// UNSPECIFIED
CATALOG_TYPE_UNSPECIFIED = 0;
// PERSISTENT
CATALOG_TYPE_PERSISTENT = 1;
// EPHEMERAL
CATALOG_TYPE_EPHEMERAL = 2;
}

// CreateCatalogRequest represents a request to create a catalog.
message CreateCatalogRequest {
// The catalog's owner(namespaces).
Expand All @@ -279,6 +289,8 @@ message CreateCatalogRequest {
string description = 3;
// The catalog tags.
repeated string tags = 4;
// The catalog type. default is PERSISTENT
CatalogType type = 5;
}

// CreateCatalogResponse represents a response for creating a catalog.
Expand All @@ -287,7 +299,7 @@ message CreateCatalogResponse {
Catalog catalog = 1;
}

// Request message for ListCatalogs
// Request message for ListCatalogs(not include the ephemeral catalogs)
message ListCatalogsRequest {
// User ID for which to list the catalogs
string namespace_id = 1;
Expand Down Expand Up @@ -422,6 +434,9 @@ message File {

// Custom metadata provided by the user during file upload
optional google.protobuf.Struct external_metadata = 17 [(google.api.field_behavior) = OPTIONAL];
// objectUid in blob storage. user can upload to blob storage directly, then put objectUid here.
// then no need the base64 encoding for the file content.
string object_uid = 18 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// upload file request
Expand Down
1 change: 0 additions & 1 deletion core/mgmt/v1beta/mgmt_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ service MgmtPublicService {
option (google.api.method_visibility).restriction = "INTERNAL";
}


// List pipeline trigger metrics
//
// Returns a paginated list of pipeline executions aggregated by pipeline ID.
Expand Down
Loading

0 comments on commit b85ba0e

Please sign in to comment.