Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model): update chat_history schema to align with OpenAI message field #246

Merged
merged 6 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion core/mgmt/v1beta/mgmt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ message GetOrganizationSubscriptionRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {child_type: "api.instill.tech/Organization"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization.name"}
field_configuration: {path_param_name: "organization.name"}
}
];
}
Expand All @@ -914,6 +914,7 @@ message GetOrganizationSubscriptionResponse {
// The subscription resource.
Subscription subscription = 1;
}

// GetUserSubscriptionAdminRequest
message GetUserSubscriptionAdminRequest {
// parent
Expand Down
5 changes: 2 additions & 3 deletions core/mgmt/v1beta/mgmt_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "core/mgmt/v1beta/mgmt.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/visibility.proto";

// OpenAPI definition
import "protoc-gen-openapiv2/options/annotations.proto";

Expand All @@ -23,8 +22,8 @@ service MgmtPublicService {
description: "🔮 Core endpoints to manage user resources. The **base path** for this server is `core/` (e.g. `GET {protocol}://{host}/core/v1beta/users`)";
external_docs: {
description: "More about Core";
url:"https://github.com/instill-ai/core";
};
url: "https://github.com/instill-ai/core";
};
};

// Check if the MGMT server is alive
Expand Down
29 changes: 24 additions & 5 deletions model/model/v1alpha/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,31 @@ message PromptImage {
}
}

// Content used for chat history in text generation model
message Content {
// Image content for Message Content
message ImageContent {
// Image url or base64 code of Message Content
PromptImage image_url = 1;
// Additinoal information for Image Content
optional string detail = 2;
}

// Content used for chat history message in text generation model
message MessageContent {
// Type of Content
string type = 1;
// Content of Text Message
string content = 2;
// Content of Image
PromptImage prompt_image = 3;
oneof content {
// Image Url is the naming convention by openAi but not necessarily a url
ImageContent image_url = 2;
// Field for text
string text = 3;
}
}

// Message used for chat history in text generation model
message Message {
// The Role of a message
string role = 1;
// The context of the message
repeated MessageContent content = 2;
}
2 changes: 1 addition & 1 deletion model/model/v1alpha/task_text_generation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message TextGenerationInput {
// The prompt images
repeated PromptImage prompt_images = 2 [(google.api.field_behavior) = OPTIONAL];
// The chat history
repeated Content chat_history = 3 [(google.api.field_behavior) = OPTIONAL];
repeated Message chat_history = 3 [(google.api.field_behavior) = OPTIONAL];
// The system message
optional string system_message = 4 [(google.api.field_behavior) = OPTIONAL];
// The maximum number of tokens for model to generate
Expand Down
2 changes: 1 addition & 1 deletion model/model/v1alpha/task_text_generation_chat.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message TextGenerationChatInput {
// The prompt images
repeated PromptImage prompt_images = 2 [(google.api.field_behavior) = OPTIONAL];
// The chat history
repeated Content chat_history = 3 [(google.api.field_behavior) = OPTIONAL];
repeated Message chat_history = 3 [(google.api.field_behavior) = OPTIONAL];
// The system message
optional string system_message = 4 [(google.api.field_behavior) = OPTIONAL];
// The maximum number of tokens for model to generate
Expand Down
2 changes: 1 addition & 1 deletion model/model/v1alpha/task_visual_question_answering.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message VisualQuestionAnsweringInput {
// The prompt images
repeated PromptImage prompt_images = 2 [(google.api.field_behavior) = OPTIONAL];
// The chat history
repeated Content chat_history = 3 [(google.api.field_behavior) = OPTIONAL];
repeated Message chat_history = 3 [(google.api.field_behavior) = OPTIONAL];
// The system message
optional string system_message = 4 [(google.api.field_behavior) = OPTIONAL];
// The maximum number of tokens for model to generate
Expand Down
55 changes: 39 additions & 16 deletions openapiv2/openapiv2.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5502,19 +5502,6 @@ definitions:
title: Classification score
readOnly: true
title: ClassificationOutput represents the output of classification task
v1alphaContent:
type: object
properties:
type:
type: string
title: Type of Content
content:
type: string
title: Content of Text Message
prompt_image:
$ref: '#/definitions/v1alphaPromptImage'
title: Content of Image
title: Content used for chat history in text generation model
v1alphaCreateUserModelBinaryFileUploadResponse:
type: object
properties:
Expand Down Expand Up @@ -5635,6 +5622,16 @@ definitions:
$ref: '#/definitions/v1alphaModel'
title: The retrieved model
title: GetUserModelResponse represents a response for a model
v1alphaImageContent:
type: object
properties:
image_url:
$ref: '#/definitions/v1alphaPromptImage'
title: Image url or base64 code of Message Content
detail:
type: string
title: Additinoal information for Image Content
title: Image content for Message Content
v1alphaImageToImageInput:
type: object
properties:
Expand Down Expand Up @@ -5905,6 +5902,32 @@ definitions:
$ref: '#/definitions/v1alphaModel'
title: A model resource
title: LookUpModelResponse represents a response for a model
v1alphaMessage:
type: object
properties:
role:
type: string
title: The Role of a message
content:
type: array
items:
type: object
$ref: '#/definitions/v1alphaMessageContent'
title: The context of the message
title: Message used for chat history in text generation model
v1alphaMessageContent:
type: object
properties:
type:
type: string
title: Type of Content
image_url:
$ref: '#/definitions/v1alphaImageContent'
title: Image Url is the naming convention by openAi but not necessarily a url
text:
type: string
title: Field for text
title: Content used for chat history message in text generation model
v1alphaModel:
type: object
properties:
Expand Down Expand Up @@ -6443,7 +6466,7 @@ definitions:
type: array
items:
type: object
$ref: '#/definitions/v1alphaContent'
$ref: '#/definitions/v1alphaMessage'
title: The chat history
system_message:
type: string
Expand Down Expand Up @@ -6494,7 +6517,7 @@ definitions:
type: array
items:
type: object
$ref: '#/definitions/v1alphaContent'
$ref: '#/definitions/v1alphaMessage'
title: The chat history
system_message:
type: string
Expand Down Expand Up @@ -6671,7 +6694,7 @@ definitions:
type: array
items:
type: object
$ref: '#/definitions/v1alphaContent'
$ref: '#/definitions/v1alphaMessage'
title: The chat history
system_message:
type: string
Expand Down
21 changes: 10 additions & 11 deletions vdp/pipeline/v1beta/connector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ message CreateOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {child_type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization.name"}
field_configuration: {path_param_name: "organization.name"}
}
];
}
Expand Down Expand Up @@ -450,7 +450,7 @@ message ListOrganizationConnectorsRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {child_type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization.name"}
field_configuration: {path_param_name: "organization.name"}
}
];
// Include soft-deleted connectors in the result.
Expand All @@ -477,7 +477,7 @@ message GetOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
// View allows clients to specify the desired resource view in the response.
Expand Down Expand Up @@ -518,7 +518,7 @@ message DeleteOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
}
Expand All @@ -536,7 +536,7 @@ message ConnectOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
}
Expand All @@ -557,7 +557,7 @@ message DisconnectOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
}
Expand All @@ -578,7 +578,7 @@ message RenameOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
// The new resource ID. This will transform the resource name into
Expand All @@ -602,7 +602,7 @@ message ExecuteOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
// Connector input parameters.
Expand All @@ -627,7 +627,7 @@ message TestOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
}
Expand All @@ -648,7 +648,7 @@ message WatchOrganizationConnectorRequest {
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "api.instill.tech/Connector"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration: {path_param_name: "organization_connector.name"}
field_configuration: {path_param_name: "organization_connector.name"}
}
];
}
Expand All @@ -659,7 +659,6 @@ message WatchOrganizationConnectorResponse {
Connector.State state = 1;
}


// ========== Private endpoints

// ListConnectorsAdminRequest represents a request by an admin to list all
Expand Down
10 changes: 4 additions & 6 deletions vdp/pipeline/v1beta/pipeline_private_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ syntax = "proto3";

package vdp.pipeline.v1beta;

import "vdp/pipeline/v1beta/connector.proto";
import "vdp/pipeline/v1beta/connector_definition.proto";
import "vdp/pipeline/v1beta/operator_definition.proto";
import "vdp/pipeline/v1beta/pipeline.proto";

// Google API
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/visibility.proto";

// OpenAPI definition
import "protoc-gen-openapiv2/options/annotations.proto";
import "vdp/pipeline/v1beta/connector.proto";
import "vdp/pipeline/v1beta/connector_definition.proto";
import "vdp/pipeline/v1beta/operator_definition.proto";
import "vdp/pipeline/v1beta/pipeline.proto";

// PipelinePrivateService defines private methods to interact with Pipeline
// resources.
Expand Down
11 changes: 5 additions & 6 deletions vdp/pipeline/v1beta/pipeline_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ package vdp.pipeline.v1beta;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/visibility.proto";
// OpenAPI definition
import "protoc-gen-openapiv2/options/annotations.proto";
import "vdp/pipeline/v1beta/connector.proto";
import "vdp/pipeline/v1beta/connector_definition.proto";
import "vdp/pipeline/v1beta/operator_definition.proto";
import "vdp/pipeline/v1beta/pipeline.proto";

// OpenAPI definition
import "protoc-gen-openapiv2/options/annotations.proto";

// VDP
//
// PipelinePublicService exposes the public VDP endpoints that allow clients to
Expand All @@ -25,7 +24,7 @@ service PipelinePublicService {
description: "💧 VDP endpoints to manage pipeline resources. The **base path** for this server is `vdp/` (e.g. `GET {protocol}://{host}/vdp/v1beta/pipelines`)";
external_docs: {
description: "More about VDP";
url:"https://github.com/instill-ai/vdp";
url: "https://github.com/instill-ai/vdp";
};
};

Expand Down Expand Up @@ -674,7 +673,7 @@ service PipelinePublicService {
rpc UpdateUserConnector(UpdateUserConnectorRequest) returns (UpdateUserConnectorResponse) {
option (google.api.http) = {
patch: "/v1beta/{connector.name=users/*/connectors/*}"
body: "connector"
body: "connector"
};
option (google.api.method_signature) = "connector,update_mask";
}
Expand Down Expand Up @@ -797,7 +796,7 @@ service PipelinePublicService {
rpc UpdateOrganizationConnector(UpdateOrganizationConnectorRequest) returns (UpdateOrganizationConnectorResponse) {
option (google.api.http) = {
patch: "/v1beta/{connector.name=organizations/*/connectors/*}"
body: "connector"
body: "connector"
};
option (google.api.method_signature) = "connector,update_mask";
}
Expand Down