Skip to content

Commit

Permalink
feat(catalog): add conversation and message api (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yougigun authored and heiruwu committed Aug 20, 2024
1 parent 8c41544 commit f907fc3
Show file tree
Hide file tree
Showing 3 changed files with 746 additions and 4 deletions.
60 changes: 58 additions & 2 deletions artifact/artifact/v1alpha/artifact_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import "artifact/artifact/v1alpha/artifact.proto";
import "artifact/artifact/v1alpha/chunk.proto";
import "artifact/artifact/v1alpha/file_catalog.proto";
import "artifact/artifact/v1alpha/qa.proto";
import "artifact/artifact/v1alpha/conversation.proto";

// Google API
import "google/api/annotations.proto";
import "google/api/visibility.proto";
Expand Down Expand Up @@ -125,7 +127,7 @@ service ArtifactPublicService {
// Similarity chunks search
rpc SimilarityChunksSearch(SimilarityChunksSearchRequest) returns (SimilarityChunksSearchResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/chunks/similarity"
post: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/chunks/retreive"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
Expand All @@ -134,7 +136,7 @@ service ArtifactPublicService {
// Question Answering
rpc QuestionAnswering(QuestionAnsweringRequest) returns (QuestionAnsweringResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/qa"
post: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/ask"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
Expand All @@ -145,4 +147,58 @@ service ArtifactPublicService {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/file-catalog"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}

// CreateConversaion
rpc CreateConversation(CreateConversationRequest) returns (CreateConversationResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// ListConversations
rpc ListConversations(ListConversationsRequest) returns (ListConversationsResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// UpdateConversation
rpc UpdateConversation(UpdateConversationRequest) returns (UpdateConversationResponse) {
option (google.api.http) = {
put: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations/{conversation_id}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// DeleteConversation
rpc DeleteConversation(DeleteConversationRequest) returns (DeleteConversationResponse) {
option (google.api.http) = {delete: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations/{conversation_id}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// CreateMessage
rpc CreateMessage(CreateMessageRequest) returns (CreateMessageResponse) {
option (google.api.http) = {
post: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations/{conversation_id}/messages"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// ListMessages
rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {
option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations/{conversation_id}/messages"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// UpdateMessage
rpc UpdateMessage(UpdateMessageRequest) returns (UpdateMessageResponse) {
option (google.api.http) = {
put: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations/{conversation_id}/messages/{message_uid}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}
// DeleteMessage
rpc DeleteMessage(DeleteMessageRequest) returns (DeleteMessageResponse) {
option (google.api.http) = {delete: "/v1alpha/namespaces/{namespace_id}/catalogs/{catalog_id}/conversations/{conversation_id}/messages/{message_uid}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Catalog"};
}

}
203 changes: 203 additions & 0 deletions artifact/artifact/v1alpha/conversation.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
syntax = "proto3";

package artifact.artifact.v1alpha;

// Protocol Buffers Well-Known Types
import "google/protobuf/timestamp.proto";
import "google/api/field_behavior.proto";



// Conversation represents a chat conversation
message Conversation {
// conversation id/name
string uid = 1;
// namespace id
string namespace_id = 2;
// catalog id
string catalog_id = 3;
// unique identifier of the conversation created by the system
string id = 4;
// creation time of the conversation
google.protobuf.Timestamp create_time = 5;
// update time of the conversation
google.protobuf.Timestamp update_time = 6;
}

// Message represents a single message in a conversation
message Message {
// message type
enum MessageType {
// unspecified
MESSAGE_TYPE_UNSPECIFIED = 0;
// text
MESSAGE_TYPE_TEXT = 1;
}
// message uid
string uid = 1;
// catalog uid
string catalog_uid = 2;
// conversation uid
string conversation_uid = 3;
// message content
string content = 4;
// message role e.g., "user" or "assistant"
string role = 5;
// message type
MessageType type = 6;
// creation time of the message
google.protobuf.Timestamp create_time = 7;
// update time of the message
google.protobuf.Timestamp update_time = 8;
}

// CreateConversationRequest is used to create a new conversation
message CreateConversationRequest {
// namespace id
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
// catalog id
string catalog_id = 2;
// conversation id. only allow kabab case
string conversation_id = 3 [(google.api.field_behavior) = REQUIRED];
}

// CreateConversationResponse returns the created conversation
message CreateConversationResponse {
// conversation
Conversation conversation = 1;
}

// ListConversationsRequest is used to list conversations
message ListConversationsRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// page size
int32 page_size = 3;
// page token
string page_token = 4;
}

// ListConversationsResponse returns a list of conversations
message ListConversationsResponse {
// conversations
repeated Conversation conversations = 1;
// next page token
string next_page_token = 2;
}

// UpdateConversationRequest is used to update a conversation
message UpdateConversationRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// conversation id
string conversation_id = 3;
// new conversation id
string new_conversaion_id = 4;
}

// UpdateConversationResponse returns the updated conversation
message UpdateConversationResponse {
// conversation
Conversation conversation = 1;
}

// DeleteConversationRequest is used to delete a conversation
message DeleteConversationRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// conversation id
string conversation_id = 3;
}

// DeleteConversationResponse is empty as no content needs to be returned
message DeleteConversationResponse {
}

// CreateMessageRequest is used to create a new message
message CreateMessageRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// conversation id
string conversation_id = 3;
// message content
string content = 4;
// message role
string role = 5;
// message type
Message.MessageType type = 6;
}

// CreateMessageResponse returns the created message
message CreateMessageResponse {
// message
Message message = 1;
}

// ListMessagesRequest is used to list messages in a conversation
message ListMessagesRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// conversation id
string conversation_id = 3;
// latest k messages
int32 latest_k = 4;
// page size
int32 page_size = 5;
// page token
string page_token = 6;
// include system messages
bool include_system_messages = 7;
}

// ListMessagesResponse returns a list of messages
message ListMessagesResponse {
// messages
repeated Message messages = 1;
// next page token
string next_page_token = 2;
}

// UpdateMessageRequest is used to update a message
message UpdateMessageRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// conversation id
string conversation_id = 3;
// message uid
string message_uid = 4;
// new message content
string content = 5;
}

// UpdateMessageResponse returns the updated message
message UpdateMessageResponse {
// message
Message message = 1;
}

// DeleteMessageRequest is used to delete a message
message DeleteMessageRequest {
// namespace id
string namespace_id = 1;
// catalog id
string catalog_id = 2;
// conversation id
string conversation_id = 3;
// message uid
string message_uid = 4;
}

// DeleteMessageResponse is empty as no content needs to be returned
message DeleteMessageResponse {}
Loading

0 comments on commit f907fc3

Please sign in to comment.