Skip to content

Commit

Permalink
feat(app): add chat endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
heiruwu committed Sep 26, 2024
1 parent 7765049 commit bf548b2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/app/v1alpha/app_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
}
}
27 changes: 27 additions & 0 deletions app/app/v1alpha/conversation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}

0 comments on commit bf548b2

Please sign in to comment.