diff --git a/app/app/v1alpha/app_public_service.proto b/app/app/v1alpha/app_public_service.proto index 94513c24..bbc6b7e1 100644 --- a/app/app/v1alpha/app_public_service.proto +++ b/app/app/v1alpha/app_public_service.proto @@ -146,4 +146,16 @@ service AppPublicService { 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) = {tags: "Playground"}; } + // Chat + // + // Chat sends a message asynchronously and streams back the response. + // This method is intended for real-time conversation with a chatbot + // and the response needs to be processed incrementally. + rpc Chat(ChatRequest) returns (stream ChatResponse) { + option (google.api.http) = { + post: "/v1alpha/namespaces/{namespace_id}/apps/{app_id}/chat-stream" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "App"}; + } } diff --git a/app/app/v1alpha/conversation.proto b/app/app/v1alpha/conversation.proto index 4bf890ca..80086c56 100644 --- a/app/app/v1alpha/conversation.proto +++ b/app/app/v1alpha/conversation.proto @@ -2,8 +2,12 @@ syntax = "proto3"; package app.app.v1alpha; +// Artifact definitions +import "artifact/artifact/v1alpha/chunk.proto"; +// Google API import "google/api/field_behavior.proto"; // Protocol Buffers Well-Known Types +import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; // Conversation represents a chat conversation @@ -230,3 +234,26 @@ message DeleteMessageRequest { // DeleteMessageResponse is empty as no content needs to be returned message DeleteMessageResponse {} + +// ChatRequest represents a request to send a message +// to a chatbot synchronously and streams back the results. +message ChatRequest { + // Namespace ID + string namespace_id = 1 [(google.api.field_behavior) = REQUIRED]; + // App ID + string app_id = 2 [(google.api.field_behavior) = REQUIRED]; + // Catalog ID + string catalog_id = 3 [(google.api.field_behavior) = REQUIRED]; + // Conversation UID + string conversation_uid = 4 [(google.api.field_behavior) = REQUIRED]; + // User message + string message = 5 [(google.api.field_behavior) = REQUIRED]; +} + +// ChatResponse contains the chatbot response. +message ChatResponse { + // Conversation responses. + repeated google.protobuf.Struct outputs = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Reference chunks + repeated artifact.artifact.v1alpha.SimilarityChunk chunks = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +}