Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: ai completion api (#15619)

Danny Xu861d34119460
diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.ts
index 049f7780b2..5dc3803d20 100644
--- a/frontend/src/types/proto/v1/sql_service.ts
+++ b/frontend/src/types/proto/v1/sql_service.ts
@@ -633,6 +633,33 @@ export function queryHistory_TypeToNumber(object: QueryHistory_Type): number {
}
}
+export interface AICompletionRequest {
+ messages: AICompletionRequest_Message[];
+}
+
+export interface AICompletionRequest_Message {
+ role: string;
+ content: string;
+}
+
+export interface AICompletionResponse {
+ /** candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini. */
+ candidates: AICompletionResponse_Candidate[];
+}
+
+export interface AICompletionResponse_Candidate {
+ content: AICompletionResponse_Candidate_Content | undefined;
+}
+
+export interface AICompletionResponse_Candidate_Content {
+ /** parts is used for a result content with multiple parts. */
+ parts: AICompletionResponse_Candidate_Content_Part[];
+}
+
+export interface AICompletionResponse_Candidate_Content_Part {
+ text: string;
+}
+
function createBaseAdminExecuteRequest(): AdminExecuteRequest {
return { name: "", statement: "", limit: 0, schema: undefined, container: undefined };
}
@@ -3683,6 +3710,393 @@ export const QueryHistory: MessageFns<QueryHistory> = {
},
};
+function createBaseAICompletionRequest(): AICompletionRequest {
+ return { messages: [] };
+}
+
+export const AICompletionRequest: MessageFns<AICompletionRequest> = {
+ encode(message: AICompletionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ for (const v of message.messages) {
+ AICompletionRequest_Message.encode(v!, writer.uint32(10).fork()).join();
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): AICompletionRequest {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAICompletionRequest();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.messages.push(AICompletionRequest_Message.decode(reader, reader.uint32()));
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AICompletionRequest {
+ return {
+ messages: globalThis.Array.isArray(object?.messages)
+ ? object.messages.map((e: any) => AICompletionRequest_Message.fromJSON(e))
+ : [],
+ };
+ },
+
+ toJSON(message: AICompletionRequest): unknown {
+ const obj: any = {};
+ if (message.messages?.length) {
+ obj.messages = message.messages.map((e) => AICompletionRequest_Message.toJSON(e));
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AICompletionRequest>): AICompletionRequest {
+ return AICompletionRequest.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<AICompletionRequest>): AICompletionRequest {
+ const message = createBaseAICompletionRequest();
+ message.messages = object.messages?.map((e) => AICompletionRequest_Message.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseAICompletionRequest_Message(): AICompletionRequest_Message {
+ return { role: "", content: "" };
+}
+
+export const AICompletionRequest_Message: MessageFns<AICompletionRequest_Message> = {
+ encode(message: AICompletionRequest_Message, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ if (message.role !== "") {
+ writer.uint32(10).string(message.role);
+ }
+ if (message.content !== "") {
+ writer.uint32(18).string(message.content);
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): AICompletionRequest_Message {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAICompletionRequest_Message();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.role = reader.string();
+ continue;
+ }
+ case 2: {
+ if (tag !== 18) {
+ break;
+ }
+
+ message.content = reader.string();
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AICompletionRequest_Message {
+ return {
+ role: isSet(object.role) ? globalThis.String(object.role) : "",
+ content: isSet(object.content) ? globalThis.String(object.content) : "",
+ };
+ },
+
+ toJSON(message: AICompletionRequest_Message): unknown {
+ const obj: any = {};
+ if (message.role !== "") {
+ obj.role = message.role;
+ }
+ if (message.content !== "") {
+ obj.content = message.content;
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AICompletionRequest_Message>): AICompletionRequest_Message {
+ return AICompletionRequest_Message.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<AICompletionRequest_Message>): AICompletionRequest_Message {
+ const message = createBaseAICompletionRequest_Message();
+ message.role = object.role ?? "";
+ message.content = object.content ?? "";
+ return message;
+ },
+};
+
+function createBaseAICompletionResponse(): AICompletionResponse {
+ return { candidates: [] };
+}
+
+export const AICompletionResponse: MessageFns<AICompletionResponse> = {
+ encode(message: AICompletionResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ for (const v of message.candidates) {
+ AICompletionResponse_Candidate.encode(v!, writer.uint32(10).fork()).join();
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): AICompletionResponse {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAICompletionResponse();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.candidates.push(AICompletionResponse_Candidate.decode(reader, reader.uint32()));
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AICompletionResponse {
+ return {
+ candidates: globalThis.Array.isArray(object?.candidates)
+ ? object.candidates.map((e: any) => AICompletionResponse_Candidate.fromJSON(e))
+ : [],
+ };
+ },
+
+ toJSON(message: AICompletionResponse): unknown {
+ const obj: any = {};
+ if (message.candidates?.length) {
+ obj.candidates = message.candidates.map((e) => AICompletionResponse_Candidate.toJSON(e));
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AICompletionResponse>): AICompletionResponse {
+ return AICompletionResponse.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<AICompletionResponse>): AICompletionResponse {
+ const message = createBaseAICompletionResponse();
+ message.candidates = object.candidates?.map((e) => AICompletionResponse_Candidate.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseAICompletionResponse_Candidate(): AICompletionResponse_Candidate {
+ return { content: undefined };
+}
+
+export const AICompletionResponse_Candidate: MessageFns<AICompletionResponse_Candidate> = {
+ encode(message: AICompletionResponse_Candidate, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ if (message.content !== undefined) {
+ AICompletionResponse_Candidate_Content.encode(message.content, writer.uint32(10).fork()).join();
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): AICompletionResponse_Candidate {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAICompletionResponse_Candidate();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.content = AICompletionResponse_Candidate_Content.decode(reader, reader.uint32());
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AICompletionResponse_Candidate {
+ return {
+ content: isSet(object.content) ? AICompletionResponse_Candidate_Content.fromJSON(object.content) : undefined,
+ };
+ },
+
+ toJSON(message: AICompletionResponse_Candidate): unknown {
+ const obj: any = {};
+ if (message.content !== undefined) {
+ obj.content = AICompletionResponse_Candidate_Content.toJSON(message.content);
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AICompletionResponse_Candidate>): AICompletionResponse_Candidate {
+ return AICompletionResponse_Candidate.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<AICompletionResponse_Candidate>): AICompletionResponse_Candidate {
+ const message = createBaseAICompletionResponse_Candidate();
+ message.content = (object.content !== undefined && object.content !== null)
+ ? AICompletionResponse_Candidate_Content.fromPartial(object.content)
+ : undefined;
+ return message;
+ },
+};
+
+function createBaseAICompletionResponse_Candidate_Content(): AICompletionResponse_Candidate_Content {
+ return { parts: [] };
+}
+
+export const AICompletionResponse_Candidate_Content: MessageFns<AICompletionResponse_Candidate_Content> = {
+ encode(message: AICompletionResponse_Candidate_Content, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ for (const v of message.parts) {
+ AICompletionResponse_Candidate_Content_Part.encode(v!, writer.uint32(10).fork()).join();
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): AICompletionResponse_Candidate_Content {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAICompletionResponse_Candidate_Content();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.parts.push(AICompletionResponse_Candidate_Content_Part.decode(reader, reader.uint32()));
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AICompletionResponse_Candidate_Content {
+ return {
+ parts: globalThis.Array.isArray(object?.parts)
+ ? object.parts.map((e: any) => AICompletionResponse_Candidate_Content_Part.fromJSON(e))
+ : [],
+ };
+ },
+
+ toJSON(message: AICompletionResponse_Candidate_Content): unknown {
+ const obj: any = {};
+ if (message.parts?.length) {
+ obj.parts = message.parts.map((e) => AICompletionResponse_Candidate_Content_Part.toJSON(e));
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AICompletionResponse_Candidate_Content>): AICompletionResponse_Candidate_Content {
+ return AICompletionResponse_Candidate_Content.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<AICompletionResponse_Candidate_Content>): AICompletionResponse_Candidate_Content {
+ const message = createBaseAICompletionResponse_Candidate_Content();
+ message.parts = object.parts?.map((e) => AICompletionResponse_Candidate_Content_Part.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseAICompletionResponse_Candidate_Content_Part(): AICompletionResponse_Candidate_Content_Part {
+ return { text: "" };
+}
+
+export const AICompletionResponse_Candidate_Content_Part: MessageFns<AICompletionResponse_Candidate_Content_Part> = {
+ encode(
+ message: AICompletionResponse_Candidate_Content_Part,
+ writer: BinaryWriter = new BinaryWriter(),
+ ): BinaryWriter {
+ if (message.text !== "") {
+ writer.uint32(10).string(message.text);
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): AICompletionResponse_Candidate_Content_Part {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAICompletionResponse_Candidate_Content_Part();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.text = reader.string();
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AICompletionResponse_Candidate_Content_Part {
+ return { text: isSet(object.text) ? globalThis.String(object.text) : "" };
+ },
+
+ toJSON(message: AICompletionResponse_Candidate_Content_Part): unknown {
+ const obj: any = {};
+ if (message.text !== "") {
+ obj.text = message.text;
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AICompletionResponse_Candidate_Content_Part>): AICompletionResponse_Candidate_Content_Part {
+ return AICompletionResponse_Candidate_Content_Part.fromPartial(base ?? {});
+ },
+ fromPartial(
+ object: DeepPartial<AICompletionResponse_Candidate_Content_Part>,
+ ): AICompletionResponse_Candidate_Content_Part {
+ const message = createBaseAICompletionResponse_Candidate_Content_Part();
+ message.text = object.text ?? "";
+ return message;
+ },
+};
+
export type SQLServiceDefinition = typeof SQLServiceDefinition;
export const SQLServiceDefinition = {
name: "SQLService",
@@ -4129,6 +4543,48 @@ export const SQLServiceDefinition = {
},
},
},
+ aICompletion: {
+ name: "AICompletion",
+ requestType: AICompletionRequest,
+ requestStream: false,
+ responseType: AICompletionResponse,
+ responseStream: false,
+ options: {
+ _unknownFields: {
+ 800016: [new Uint8Array([2])],
+ 578365826: [
+ new Uint8Array([
+ 25,
+ 58,
+ 1,
+ 42,
+ 34,
+ 20,
+ 47,
+ 118,
+ 49,
+ 47,
+ 115,
+ 113,
+ 108,
+ 47,
+ 97,
+ 105,
+ 67,
+ 111,
+ 109,
+ 112,
+ 108,
+ 101,
+ 116,
+ 105,
+ 111,
+ 110,
+ ]),
+ ],
+ },
+ },
+ },
},
} as const;
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index dcb512ddf8..e5f8a11f52 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -6943,6 +6943,30 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
+ /v1/sql/aiCompletion:
+ post:
+ tags:
+ - SQLService
+ operationId: SQLService_AICompletion
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AICompletionRequest'
+ required: true
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AICompletionResponse'
+ default:
+ description: Default error response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Status'
/v1/sql/check:
post:
tags:
@@ -7711,6 +7735,33 @@ paths:
$ref: '#/components/schemas/Status'
components:
schemas:
+ AICompletionRequest:
+ type: object
+ properties:
+ messages:
+ type: array
+ items:
+ $ref: '#/components/schemas/AICompletionRequest_Message'
+ AICompletionRequest_Message:
+ type: object
+ properties:
+ role:
+ type: string
+ content:
+ type: string
+ AICompletionResponse:
+ type: object
+ properties:
+ candidates:
+ type: array
+ items:
+ $ref: '#/components/schemas/AICompletionResponse_Candidate'
+ description: candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini.
+ AICompletionResponse_Candidate:
+ type: object
+ properties:
+ content:
+ $ref: '#/components/schemas/Candidate_Content'
AISetting:
type: object
properties:
@@ -8422,6 +8473,14 @@ components:
allOf:
- $ref: '#/components/schemas/Expr'
description: The parsed expression of the condition.
+ Candidate_Content:
+ type: object
+ properties:
+ parts:
+ type: array
+ items:
+ $ref: '#/components/schemas/Content_Part'
+ description: parts is used for a result content with multiple parts.
ChangeDatabaseConfig_PreUpdateBackupDetail:
type: object
properties:
@@ -8787,6 +8846,11 @@ components:
description: The identity_generation is for identity columns, PG only.
format: enum
description: ColumnMetadata is the metadata for columns.
+ Content_Part:
+ type: object
+ properties:
+ text:
+ type: string
CreateSheetRequest:
required:
- parent
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index ac7f702ff4..3331bdb48d 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -529,6 +529,12 @@
- [ProjectService](#bytebase-v1-ProjectService)
- [v1/sql_service.proto](#v1_sql_service-proto)
+ - [AICompletionRequest](#bytebase-v1-AICompletionRequest)
+ - [AICompletionRequest.Message](#bytebase-v1-AICompletionRequest-Message)
+ - [AICompletionResponse](#bytebase-v1-AICompletionResponse)
+ - [AICompletionResponse.Candidate](#bytebase-v1-AICompletionResponse-Candidate)
+ - [AICompletionResponse.Candidate.Content](#bytebase-v1-AICompletionResponse-Candidate-Content)
+ - [AICompletionResponse.Candidate.Content.Part](#bytebase-v1-AICompletionResponse-Candidate-Content-Part)
- [AdminExecuteRequest](#bytebase-v1-AdminExecuteRequest)
- [AdminExecuteResponse](#bytebase-v1-AdminExecuteResponse)
- [Advice](#bytebase-v1-Advice)
@@ -8554,6 +8560,97 @@ TYPE_PROJECT_REPOSITORY_PUSH represents Bytebase receiving a push event from the
+<a name="bytebase-v1-AICompletionRequest"></a>
+
+### AICompletionRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| messages | [AICompletionRequest.Message](#bytebase-v1-AICompletionRequest-Message) | repeated | |
+
+
+
+
+
+
+<a name="bytebase-v1-AICompletionRequest-Message"></a>
+
+### AICompletionRequest.Message
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| role | [string](#string) | | |
+| content | [string](#string) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-AICompletionResponse"></a>
+
+### AICompletionResponse
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| candidates | [AICompletionResponse.Candidate](#bytebase-v1-AICompletionResponse-Candidate) | repeated | candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini. |
+
+
+
+
+
+
+<a name="bytebase-v1-AICompletionResponse-Candidate"></a>
+
+### AICompletionResponse.Candidate
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| content | [AICompletionResponse.Candidate.Content](#bytebase-v1-AICompletionResponse-Candidate-Content) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-AICompletionResponse-Candidate-Content"></a>
+
+### AICompletionResponse.Candidate.Content
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| parts | [AICompletionResponse.Candidate.Content.Part](#bytebase-v1-AICompletionResponse-Candidate-Content-Part) | repeated | parts is used for a result content with multiple parts. |
+
+
+
+
+
+
+<a name="bytebase-v1-AICompletionResponse-Candidate-Content-Part"></a>
+
+### AICompletionResponse.Candidate.Content.Part
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| text | [string](#string) | | |
+
+
+
+
+
+
<a name="bytebase-v1-AdminExecuteRequest"></a>
### AdminExecuteRequest
@@ -9093,6 +9190,7 @@ for field description.
| ParseMyBatisMapper | [ParseMyBatisMapperRequest](#bytebase-v1-ParseMyBatisMapperRequest) | [ParseMyBatisMapperResponse](#bytebase-v1-ParseMyBatisMapperResponse) | |
| Pretty | [PrettyRequest](#bytebase-v1-PrettyRequest) | [PrettyResponse](#bytebase-v1-PrettyResponse) | |
| DiffMetadata | [DiffMetadataRequest](#bytebase-v1-DiffMetadataRequest) | [DiffMetadataResponse](#bytebase-v1-DiffMetadataResponse) | |
+| AICompletion | [AICompletionRequest](#bytebase-v1-AICompletionRequest) | [AICompletionResponse](#bytebase-v1-AICompletionResponse) | |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index c8b6904cdd..e9886bc621 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -2190,6 +2190,30 @@
<a href="#v1%2fsql_service.proto">v1/sql_service.proto</a>
<ul>
+ <li>
+ <a href="#bytebase.v1.AICompletionRequest"><span class="badge">M</span>AICompletionRequest</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.AICompletionRequest.Message"><span class="badge">M</span>AICompletionRequest.Message</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.AICompletionResponse"><span class="badge">M</span>AICompletionResponse</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.AICompletionResponse.Candidate"><span class="badge">M</span>AICompletionResponse.Candidate</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.AICompletionResponse.Candidate.Content"><span class="badge">M</span>AICompletionResponse.Candidate.Content</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.AICompletionResponse.Candidate.Content.Part"><span class="badge">M</span>AICompletionResponse.Candidate.Content.Part</a>
+ </li>
+
<li>
<a href="#bytebase.v1.AdminExecuteRequest"><span class="badge">M</span>AdminExecuteRequest</a>
</li>
@@ -23741,6 +23765,157 @@ TYPE_SQL_EDITOR_QUERY represents executing query in SQL Editor.</p></td>
<p></p>
+ <h3 id="bytebase.v1.AICompletionRequest">AICompletionRequest</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>messages</td>
+ <td><a href="#bytebase.v1.AICompletionRequest.Message">AICompletionRequest.Message</a></td>
+ <td>repeated</td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.AICompletionRequest.Message">AICompletionRequest.Message</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>role</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>content</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.AICompletionResponse">AICompletionResponse</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>candidates</td>
+ <td><a href="#bytebase.v1.AICompletionResponse.Candidate">AICompletionResponse.Candidate</a></td>
+ <td>repeated</td>
+ <td><p>candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.AICompletionResponse.Candidate">AICompletionResponse.Candidate</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>content</td>
+ <td><a href="#bytebase.v1.AICompletionResponse.Candidate.Content">AICompletionResponse.Candidate.Content</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.AICompletionResponse.Candidate.Content">AICompletionResponse.Candidate.Content</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>parts</td>
+ <td><a href="#bytebase.v1.AICompletionResponse.Candidate.Content.Part">AICompletionResponse.Candidate.Content.Part</a></td>
+ <td>repeated</td>
+ <td><p>parts is used for a result content with multiple parts. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.AICompletionResponse.Candidate.Content.Part">AICompletionResponse.Candidate.Content.Part</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>text</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.AdminExecuteRequest">AdminExecuteRequest</h3>
<p></p>
@@ -25201,6 +25376,13 @@ Pass this value in the page_token field in the subsequent call to
<td><p></p></td>
</tr>
+ <tr>
+ <td>AICompletion</td>
+ <td><a href="#bytebase.v1.AICompletionRequest">AICompletionRequest</a></td>
+ <td><a href="#bytebase.v1.AICompletionResponse">AICompletionResponse</a></td>
+ <td><p></p></td>
+ </tr>
+
</tbody>
</table>
@@ -25320,6 +25502,16 @@ Pass this value in the page_token field in the subsequent call to
</tr>
+
+
+ <tr>
+ <td>AICompletion</td>
+ <td>POST</td>
+ <td>/v1/sql/aiCompletion</td>
+ <td>*</td>
+ </tr>
+
+
</tbody>
</table>
diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.go
index e4d9f6b627..d71e5786ab 100644
--- a/proto/generated-go/v1/sql_service.pb.go
+++ b/proto/generated-go/v1/sql_service.pb.go
@@ -1978,6 +1978,95 @@ func (x *QueryHistory) GetType() QueryHistory_Type {
return QueryHistory_TYPE_UNSPECIFIED
}
+type AICompletionRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Messages []*AICompletionRequest_Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *AICompletionRequest) Reset() {
+ *x = AICompletionRequest{}
+ mi := &file_v1_sql_service_proto_msgTypes[22]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *AICompletionRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AICompletionRequest) ProtoMessage() {}
+
+func (x *AICompletionRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_sql_service_proto_msgTypes[22]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AICompletionRequest.ProtoReflect.Descriptor instead.
+func (*AICompletionRequest) Descriptor() ([]byte, []int) {
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{22}
+}
+
+func (x *AICompletionRequest) GetMessages() []*AICompletionRequest_Message {
+ if x != nil {
+ return x.Messages
+ }
+ return nil
+}
+
+type AICompletionResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini.
+ Candidates []*AICompletionResponse_Candidate `protobuf:"bytes,1,rep,name=candidates,proto3" json:"candidates,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *AICompletionResponse) Reset() {
+ *x = AICompletionResponse{}
+ mi := &file_v1_sql_service_proto_msgTypes[23]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *AICompletionResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AICompletionResponse) ProtoMessage() {}
+
+func (x *AICompletionResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_sql_service_proto_msgTypes[23]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AICompletionResponse.ProtoReflect.Descriptor instead.
+func (*AICompletionResponse) Descriptor() ([]byte, []int) {
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{23}
+}
+
+func (x *AICompletionResponse) GetCandidates() []*AICompletionResponse_Candidate {
+ if x != nil {
+ return x.Candidates
+ }
+ return nil
+}
+
// refer https://www.postgresql.org/docs/11/protocol-error-fields.html
// for field description.
type QueryResult_PostgresError struct {
@@ -2005,7 +2094,7 @@ type QueryResult_PostgresError struct {
func (x *QueryResult_PostgresError) Reset() {
*x = QueryResult_PostgresError{}
- mi := &file_v1_sql_service_proto_msgTypes[22]
+ mi := &file_v1_sql_service_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2017,7 +2106,7 @@ func (x *QueryResult_PostgresError) String() string {
func (*QueryResult_PostgresError) ProtoMessage() {}
func (x *QueryResult_PostgresError) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[22]
+ mi := &file_v1_sql_service_proto_msgTypes[24]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2163,7 +2252,7 @@ type RowValue_Timestamp struct {
func (x *RowValue_Timestamp) Reset() {
*x = RowValue_Timestamp{}
- mi := &file_v1_sql_service_proto_msgTypes[23]
+ mi := &file_v1_sql_service_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2175,7 +2264,7 @@ func (x *RowValue_Timestamp) String() string {
func (*RowValue_Timestamp) ProtoMessage() {}
func (x *RowValue_Timestamp) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[23]
+ mi := &file_v1_sql_service_proto_msgTypes[25]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2224,7 +2313,7 @@ type RowValue_TimestampTZ struct {
func (x *RowValue_TimestampTZ) Reset() {
*x = RowValue_TimestampTZ{}
- mi := &file_v1_sql_service_proto_msgTypes[24]
+ mi := &file_v1_sql_service_proto_msgTypes[26]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2236,7 +2325,7 @@ func (x *RowValue_TimestampTZ) String() string {
func (*RowValue_TimestampTZ) ProtoMessage() {}
func (x *RowValue_TimestampTZ) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[24]
+ mi := &file_v1_sql_service_proto_msgTypes[26]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2280,6 +2369,191 @@ func (x *RowValue_TimestampTZ) GetAccuracy() int32 {
return 0
}
+type AICompletionRequest_Message struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
+ Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *AICompletionRequest_Message) Reset() {
+ *x = AICompletionRequest_Message{}
+ mi := &file_v1_sql_service_proto_msgTypes[27]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *AICompletionRequest_Message) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AICompletionRequest_Message) ProtoMessage() {}
+
+func (x *AICompletionRequest_Message) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_sql_service_proto_msgTypes[27]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AICompletionRequest_Message.ProtoReflect.Descriptor instead.
+func (*AICompletionRequest_Message) Descriptor() ([]byte, []int) {
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{22, 0}
+}
+
+func (x *AICompletionRequest_Message) GetRole() string {
+ if x != nil {
+ return x.Role
+ }
+ return ""
+}
+
+func (x *AICompletionRequest_Message) GetContent() string {
+ if x != nil {
+ return x.Content
+ }
+ return ""
+}
+
+type AICompletionResponse_Candidate struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Content *AICompletionResponse_Candidate_Content `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *AICompletionResponse_Candidate) Reset() {
+ *x = AICompletionResponse_Candidate{}
+ mi := &file_v1_sql_service_proto_msgTypes[28]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *AICompletionResponse_Candidate) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AICompletionResponse_Candidate) ProtoMessage() {}
+
+func (x *AICompletionResponse_Candidate) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_sql_service_proto_msgTypes[28]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AICompletionResponse_Candidate.ProtoReflect.Descriptor instead.
+func (*AICompletionResponse_Candidate) Descriptor() ([]byte, []int) {
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{23, 0}
+}
+
+func (x *AICompletionResponse_Candidate) GetContent() *AICompletionResponse_Candidate_Content {
+ if x != nil {
+ return x.Content
+ }
+ return nil
+}
+
+type AICompletionResponse_Candidate_Content struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // parts is used for a result content with multiple parts.
+ Parts []*AICompletionResponse_Candidate_Content_Part `protobuf:"bytes,1,rep,name=parts,proto3" json:"parts,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *AICompletionResponse_Candidate_Content) Reset() {
+ *x = AICompletionResponse_Candidate_Content{}
+ mi := &file_v1_sql_service_proto_msgTypes[29]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *AICompletionResponse_Candidate_Content) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AICompletionResponse_Candidate_Content) ProtoMessage() {}
+
+func (x *AICompletionResponse_Candidate_Content) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_sql_service_proto_msgTypes[29]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AICompletionResponse_Candidate_Content.ProtoReflect.Descriptor instead.
+func (*AICompletionResponse_Candidate_Content) Descriptor() ([]byte, []int) {
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{23, 0, 0}
+}
+
+func (x *AICompletionResponse_Candidate_Content) GetParts() []*AICompletionResponse_Candidate_Content_Part {
+ if x != nil {
+ return x.Parts
+ }
+ return nil
+}
+
+type AICompletionResponse_Candidate_Content_Part struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *AICompletionResponse_Candidate_Content_Part) Reset() {
+ *x = AICompletionResponse_Candidate_Content_Part{}
+ mi := &file_v1_sql_service_proto_msgTypes[30]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *AICompletionResponse_Candidate_Content_Part) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AICompletionResponse_Candidate_Content_Part) ProtoMessage() {}
+
+func (x *AICompletionResponse_Candidate_Content_Part) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_sql_service_proto_msgTypes[30]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AICompletionResponse_Candidate_Content_Part.ProtoReflect.Descriptor instead.
+func (*AICompletionResponse_Candidate_Content_Part) Descriptor() ([]byte, []int) {
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{23, 0, 0, 0}
+}
+
+func (x *AICompletionResponse_Candidate_Content_Part) GetText() string {
+ if x != nil {
+ return x.Text
+ }
+ return ""
+}
+
var File_v1_sql_service_proto protoreflect.FileDescriptor
const file_v1_sql_service_proto_rawDesc = "" +
@@ -2476,7 +2750,23 @@ const file_v1_sql_service_proto_rawDesc = "" +
"\x05QUERY\x10\x01\x12\n" +
"\n" +
"\x06EXPORT\x10\x02B\b\n" +
- "\x06_error2\xb9\t\n" +
+ "\x06_error\"\x94\x01\n" +
+ "\x13AICompletionRequest\x12D\n" +
+ "\bmessages\x18\x01 \x03(\v2(.bytebase.v1.AICompletionRequest.MessageR\bmessages\x1a7\n" +
+ "\aMessage\x12\x12\n" +
+ "\x04role\x18\x01 \x01(\tR\x04role\x12\x18\n" +
+ "\acontent\x18\x02 \x01(\tR\acontent\"\xb7\x02\n" +
+ "\x14AICompletionResponse\x12K\n" +
+ "\n" +
+ "candidates\x18\x01 \x03(\v2+.bytebase.v1.AICompletionResponse.CandidateR\n" +
+ "candidates\x1a\xd1\x01\n" +
+ "\tCandidate\x12M\n" +
+ "\acontent\x18\x01 \x01(\v23.bytebase.v1.AICompletionResponse.Candidate.ContentR\acontent\x1au\n" +
+ "\aContent\x12N\n" +
+ "\x05parts\x18\x01 \x03(\v28.bytebase.v1.AICompletionResponse.Candidate.Content.PartR\x05parts\x1a\x1a\n" +
+ "\x04Part\x12\x12\n" +
+ "\x04text\x18\x01 \x01(\tR\x04text2\xb3\n" +
+ "\n" +
"\n" +
"SQLService\x12\xb2\x01\n" +
"\x05Query\x12\x19.bytebase.v1.QueryRequest\x1a\x1a.bytebase.v1.QueryResponse\"r\x8a\xea0\x10bb.databases.get\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02P:\x01*Z!:\x01*\"\x1c/v1/{name=instances/*}:query\"(/v1/{name=instances/*/databases/*}:query\x12\x89\x01\n" +
@@ -2486,7 +2776,8 @@ const file_v1_sql_service_proto_rawDesc = "" +
"\x05Check\x12\x19.bytebase.v1.CheckRequest\x1a\x1a.bytebase.v1.CheckResponse\"2\x8a\xea0\x12bb.databases.check\x90\xea0\x01\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/v1/sql/check\x12\x90\x01\n" +
"\x12ParseMyBatisMapper\x12&.bytebase.v1.ParseMyBatisMapperRequest\x1a'.bytebase.v1.ParseMyBatisMapperResponse\")\x80\xea0\x01\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/v1/sql/parseMyBatisMapper\x12`\n" +
"\x06Pretty\x12\x1a.bytebase.v1.PrettyRequest\x1a\x1b.bytebase.v1.PrettyResponse\"\x1d\x80\xea0\x01\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/v1/sql/pretty\x12\x81\x01\n" +
- "\fDiffMetadata\x12 .bytebase.v1.DiffMetadataRequest\x1a!.bytebase.v1.DiffMetadataResponse\",\x80\xea0\x01\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/v1/schemaDesign:diffMetadataB\x11Z\x0fgenerated-go/v1b\x06proto3"
+ "\fDiffMetadata\x12 .bytebase.v1.DiffMetadataRequest\x1a!.bytebase.v1.DiffMetadataResponse\",\x80\xea0\x01\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/v1/schemaDesign:diffMetadata\x12x\n" +
+ "\fAICompletion\x12 .bytebase.v1.AICompletionRequest\x1a!.bytebase.v1.AICompletionResponse\"#\x90\xea0\x02\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/v1/sql/aiCompletionB\x11Z\x0fgenerated-go/v1b\x06proto3"
var (
file_v1_sql_service_proto_rawDescOnce sync.Once
@@ -2501,46 +2792,52 @@ func file_v1_sql_service_proto_rawDescGZIP() []byte {
}
var file_v1_sql_service_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
-var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 25)
+var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 31)
var file_v1_sql_service_proto_goTypes = []any{
- (QueryOption_RedisRunCommandsOn)(0), // 0: bytebase.v1.QueryOption.RedisRunCommandsOn
- (Advice_Status)(0), // 1: bytebase.v1.Advice.Status
- (CheckRequest_ChangeType)(0), // 2: bytebase.v1.CheckRequest.ChangeType
- (QueryHistory_Type)(0), // 3: bytebase.v1.QueryHistory.Type
- (*AdminExecuteRequest)(nil), // 4: bytebase.v1.AdminExecuteRequest
- (*AdminExecuteResponse)(nil), // 5: bytebase.v1.AdminExecuteResponse
- (*QueryRequest)(nil), // 6: bytebase.v1.QueryRequest
- (*QueryResponse)(nil), // 7: bytebase.v1.QueryResponse
- (*QueryOption)(nil), // 8: bytebase.v1.QueryOption
- (*QueryResult)(nil), // 9: bytebase.v1.QueryResult
- (*QueryRow)(nil), // 10: bytebase.v1.QueryRow
- (*RowValue)(nil), // 11: bytebase.v1.RowValue
- (*Advice)(nil), // 12: bytebase.v1.Advice
- (*ExportRequest)(nil), // 13: bytebase.v1.ExportRequest
- (*ExportResponse)(nil), // 14: bytebase.v1.ExportResponse
- (*PrettyRequest)(nil), // 15: bytebase.v1.PrettyRequest
- (*PrettyResponse)(nil), // 16: bytebase.v1.PrettyResponse
- (*CheckRequest)(nil), // 17: bytebase.v1.CheckRequest
- (*CheckResponse)(nil), // 18: bytebase.v1.CheckResponse
- (*ParseMyBatisMapperRequest)(nil), // 19: bytebase.v1.ParseMyBatisMapperRequest
- (*ParseMyBatisMapperResponse)(nil), // 20: bytebase.v1.ParseMyBatisMapperResponse
- (*DiffMetadataRequest)(nil), // 21: bytebase.v1.DiffMetadataRequest
- (*DiffMetadataResponse)(nil), // 22: bytebase.v1.DiffMetadataResponse
- (*SearchQueryHistoriesRequest)(nil), // 23: bytebase.v1.SearchQueryHistoriesRequest
- (*SearchQueryHistoriesResponse)(nil), // 24: bytebase.v1.SearchQueryHistoriesResponse
- (*QueryHistory)(nil), // 25: bytebase.v1.QueryHistory
- (*QueryResult_PostgresError)(nil), // 26: bytebase.v1.QueryResult.PostgresError
- (*RowValue_Timestamp)(nil), // 27: bytebase.v1.RowValue.Timestamp
- (*RowValue_TimestampTZ)(nil), // 28: bytebase.v1.RowValue.TimestampTZ
- (*durationpb.Duration)(nil), // 29: google.protobuf.Duration
- (structpb.NullValue)(0), // 30: google.protobuf.NullValue
- (*structpb.Value)(nil), // 31: google.protobuf.Value
- (*Position)(nil), // 32: bytebase.v1.Position
- (ExportFormat)(0), // 33: bytebase.v1.ExportFormat
- (Engine)(0), // 34: bytebase.v1.Engine
- (*DatabaseMetadata)(nil), // 35: bytebase.v1.DatabaseMetadata
- (*DatabaseCatalog)(nil), // 36: bytebase.v1.DatabaseCatalog
- (*timestamppb.Timestamp)(nil), // 37: google.protobuf.Timestamp
+ (QueryOption_RedisRunCommandsOn)(0), // 0: bytebase.v1.QueryOption.RedisRunCommandsOn
+ (Advice_Status)(0), // 1: bytebase.v1.Advice.Status
+ (CheckRequest_ChangeType)(0), // 2: bytebase.v1.CheckRequest.ChangeType
+ (QueryHistory_Type)(0), // 3: bytebase.v1.QueryHistory.Type
+ (*AdminExecuteRequest)(nil), // 4: bytebase.v1.AdminExecuteRequest
+ (*AdminExecuteResponse)(nil), // 5: bytebase.v1.AdminExecuteResponse
+ (*QueryRequest)(nil), // 6: bytebase.v1.QueryRequest
+ (*QueryResponse)(nil), // 7: bytebase.v1.QueryResponse
+ (*QueryOption)(nil), // 8: bytebase.v1.QueryOption
+ (*QueryResult)(nil), // 9: bytebase.v1.QueryResult
+ (*QueryRow)(nil), // 10: bytebase.v1.QueryRow
+ (*RowValue)(nil), // 11: bytebase.v1.RowValue
+ (*Advice)(nil), // 12: bytebase.v1.Advice
+ (*ExportRequest)(nil), // 13: bytebase.v1.ExportRequest
+ (*ExportResponse)(nil), // 14: bytebase.v1.ExportResponse
+ (*PrettyRequest)(nil), // 15: bytebase.v1.PrettyRequest
+ (*PrettyResponse)(nil), // 16: bytebase.v1.PrettyResponse
+ (*CheckRequest)(nil), // 17: bytebase.v1.CheckRequest
+ (*CheckResponse)(nil), // 18: bytebase.v1.CheckResponse
+ (*ParseMyBatisMapperRequest)(nil), // 19: bytebase.v1.ParseMyBatisMapperRequest
+ (*ParseMyBatisMapperResponse)(nil), // 20: bytebase.v1.ParseMyBatisMapperResponse
+ (*DiffMetadataRequest)(nil), // 21: bytebase.v1.DiffMetadataRequest
+ (*DiffMetadataResponse)(nil), // 22: bytebase.v1.DiffMetadataResponse
+ (*SearchQueryHistoriesRequest)(nil), // 23: bytebase.v1.SearchQueryHistoriesRequest
+ (*SearchQueryHistoriesResponse)(nil), // 24: bytebase.v1.SearchQueryHistoriesResponse
+ (*QueryHistory)(nil), // 25: bytebase.v1.QueryHistory
+ (*AICompletionRequest)(nil), // 26: bytebase.v1.AICompletionRequest
+ (*AICompletionResponse)(nil), // 27: bytebase.v1.AICompletionResponse
+ (*QueryResult_PostgresError)(nil), // 28: bytebase.v1.QueryResult.PostgresError
+ (*RowValue_Timestamp)(nil), // 29: bytebase.v1.RowValue.Timestamp
+ (*RowValue_TimestampTZ)(nil), // 30: bytebase.v1.RowValue.TimestampTZ
+ (*AICompletionRequest_Message)(nil), // 31: bytebase.v1.AICompletionRequest.Message
+ (*AICompletionResponse_Candidate)(nil), // 32: bytebase.v1.AICompletionResponse.Candidate
+ (*AICompletionResponse_Candidate_Content)(nil), // 33: bytebase.v1.AICompletionResponse.Candidate.Content
+ (*AICompletionResponse_Candidate_Content_Part)(nil), // 34: bytebase.v1.AICompletionResponse.Candidate.Content.Part
+ (*durationpb.Duration)(nil), // 35: google.protobuf.Duration
+ (structpb.NullValue)(0), // 36: google.protobuf.NullValue
+ (*structpb.Value)(nil), // 37: google.protobuf.Value
+ (*Position)(nil), // 38: bytebase.v1.Position
+ (ExportFormat)(0), // 39: bytebase.v1.ExportFormat
+ (Engine)(0), // 40: bytebase.v1.Engine
+ (*DatabaseMetadata)(nil), // 41: bytebase.v1.DatabaseMetadata
+ (*DatabaseCatalog)(nil), // 42: bytebase.v1.DatabaseCatalog
+ (*timestamppb.Timestamp)(nil), // 43: google.protobuf.Timestamp
}
var file_v1_sql_service_proto_depIdxs = []int32{
9, // 0: bytebase.v1.AdminExecuteResponse.results:type_name -> bytebase.v1.QueryResult
@@ -2548,52 +2845,58 @@ var file_v1_sql_service_proto_depIdxs = []int32{
9, // 2: bytebase.v1.QueryResponse.results:type_name -> bytebase.v1.QueryResult
0, // 3: bytebase.v1.QueryOption.redis_run_commands_on:type_name -> bytebase.v1.QueryOption.RedisRunCommandsOn
10, // 4: bytebase.v1.QueryResult.rows:type_name -> bytebase.v1.QueryRow
- 29, // 5: bytebase.v1.QueryResult.latency:type_name -> google.protobuf.Duration
- 26, // 6: bytebase.v1.QueryResult.postgres_error:type_name -> bytebase.v1.QueryResult.PostgresError
+ 35, // 5: bytebase.v1.QueryResult.latency:type_name -> google.protobuf.Duration
+ 28, // 6: bytebase.v1.QueryResult.postgres_error:type_name -> bytebase.v1.QueryResult.PostgresError
11, // 7: bytebase.v1.QueryRow.values:type_name -> bytebase.v1.RowValue
- 30, // 8: bytebase.v1.RowValue.null_value:type_name -> google.protobuf.NullValue
- 31, // 9: bytebase.v1.RowValue.value_value:type_name -> google.protobuf.Value
- 27, // 10: bytebase.v1.RowValue.timestamp_value:type_name -> bytebase.v1.RowValue.Timestamp
- 28, // 11: bytebase.v1.RowValue.timestamp_tz_value:type_name -> bytebase.v1.RowValue.TimestampTZ
+ 36, // 8: bytebase.v1.RowValue.null_value:type_name -> google.protobuf.NullValue
+ 37, // 9: bytebase.v1.RowValue.value_value:type_name -> google.protobuf.Value
+ 29, // 10: bytebase.v1.RowValue.timestamp_value:type_name -> bytebase.v1.RowValue.Timestamp
+ 30, // 11: bytebase.v1.RowValue.timestamp_tz_value:type_name -> bytebase.v1.RowValue.TimestampTZ
1, // 12: bytebase.v1.Advice.status:type_name -> bytebase.v1.Advice.Status
- 32, // 13: bytebase.v1.Advice.start_position:type_name -> bytebase.v1.Position
- 32, // 14: bytebase.v1.Advice.end_position:type_name -> bytebase.v1.Position
- 33, // 15: bytebase.v1.ExportRequest.format:type_name -> bytebase.v1.ExportFormat
- 34, // 16: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine
+ 38, // 13: bytebase.v1.Advice.start_position:type_name -> bytebase.v1.Position
+ 38, // 14: bytebase.v1.Advice.end_position:type_name -> bytebase.v1.Position
+ 39, // 15: bytebase.v1.ExportRequest.format:type_name -> bytebase.v1.ExportFormat
+ 40, // 16: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine
2, // 17: bytebase.v1.CheckRequest.change_type:type_name -> bytebase.v1.CheckRequest.ChangeType
12, // 18: bytebase.v1.CheckResponse.advices:type_name -> bytebase.v1.Advice
- 35, // 19: bytebase.v1.DiffMetadataRequest.source_metadata:type_name -> bytebase.v1.DatabaseMetadata
- 35, // 20: bytebase.v1.DiffMetadataRequest.target_metadata:type_name -> bytebase.v1.DatabaseMetadata
- 36, // 21: bytebase.v1.DiffMetadataRequest.source_catalog:type_name -> bytebase.v1.DatabaseCatalog
- 36, // 22: bytebase.v1.DiffMetadataRequest.target_catalog:type_name -> bytebase.v1.DatabaseCatalog
- 34, // 23: bytebase.v1.DiffMetadataRequest.engine:type_name -> bytebase.v1.Engine
+ 41, // 19: bytebase.v1.DiffMetadataRequest.source_metadata:type_name -> bytebase.v1.DatabaseMetadata
+ 41, // 20: bytebase.v1.DiffMetadataRequest.target_metadata:type_name -> bytebase.v1.DatabaseMetadata
+ 42, // 21: bytebase.v1.DiffMetadataRequest.source_catalog:type_name -> bytebase.v1.DatabaseCatalog
+ 42, // 22: bytebase.v1.DiffMetadataRequest.target_catalog:type_name -> bytebase.v1.DatabaseCatalog
+ 40, // 23: bytebase.v1.DiffMetadataRequest.engine:type_name -> bytebase.v1.Engine
25, // 24: bytebase.v1.SearchQueryHistoriesResponse.query_histories:type_name -> bytebase.v1.QueryHistory
- 37, // 25: bytebase.v1.QueryHistory.create_time:type_name -> google.protobuf.Timestamp
- 29, // 26: bytebase.v1.QueryHistory.duration:type_name -> google.protobuf.Duration
+ 43, // 25: bytebase.v1.QueryHistory.create_time:type_name -> google.protobuf.Timestamp
+ 35, // 26: bytebase.v1.QueryHistory.duration:type_name -> google.protobuf.Duration
3, // 27: bytebase.v1.QueryHistory.type:type_name -> bytebase.v1.QueryHistory.Type
- 37, // 28: bytebase.v1.RowValue.Timestamp.google_timestamp:type_name -> google.protobuf.Timestamp
- 37, // 29: bytebase.v1.RowValue.TimestampTZ.google_timestamp:type_name -> google.protobuf.Timestamp
- 6, // 30: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest
- 4, // 31: bytebase.v1.SQLService.AdminExecute:input_type -> bytebase.v1.AdminExecuteRequest
- 23, // 32: bytebase.v1.SQLService.SearchQueryHistories:input_type -> bytebase.v1.SearchQueryHistoriesRequest
- 13, // 33: bytebase.v1.SQLService.Export:input_type -> bytebase.v1.ExportRequest
- 17, // 34: bytebase.v1.SQLService.Check:input_type -> bytebase.v1.CheckRequest
- 19, // 35: bytebase.v1.SQLService.ParseMyBatisMapper:input_type -> bytebase.v1.ParseMyBatisMapperRequest
- 15, // 36: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest
- 21, // 37: bytebase.v1.SQLService.DiffMetadata:input_type -> bytebase.v1.DiffMetadataRequest
- 7, // 38: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse
- 5, // 39: bytebase.v1.SQLService.AdminExecute:output_type -> bytebase.v1.AdminExecuteResponse
- 24, // 40: bytebase.v1.SQLService.SearchQueryHistories:output_type -> bytebase.v1.SearchQueryHistoriesResponse
- 14, // 41: bytebase.v1.SQLService.Export:output_type -> bytebase.v1.ExportResponse
- 18, // 42: bytebase.v1.SQLService.Check:output_type -> bytebase.v1.CheckResponse
- 20, // 43: bytebase.v1.SQLService.ParseMyBatisMapper:output_type -> bytebase.v1.ParseMyBatisMapperResponse
- 16, // 44: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse
- 22, // 45: bytebase.v1.SQLService.DiffMetadata:output_type -> bytebase.v1.DiffMetadataResponse
- 38, // [38:46] is the sub-list for method output_type
- 30, // [30:38] is the sub-list for method input_type
- 30, // [30:30] is the sub-list for extension type_name
- 30, // [30:30] is the sub-list for extension extendee
- 0, // [0:30] is the sub-list for field type_name
+ 31, // 28: bytebase.v1.AICompletionRequest.messages:type_name -> bytebase.v1.AICompletionRequest.Message
+ 32, // 29: bytebase.v1.AICompletionResponse.candidates:type_name -> bytebase.v1.AICompletionResponse.Candidate
+ 43, // 30: bytebase.v1.RowValue.Timestamp.google_timestamp:type_name -> google.protobuf.Timestamp
+ 43, // 31: bytebase.v1.RowValue.TimestampTZ.google_timestamp:type_name -> google.protobuf.Timestamp
+ 33, // 32: bytebase.v1.AICompletionResponse.Candidate.content:type_name -> bytebase.v1.AICompletionResponse.Candidate.Content
+ 34, // 33: bytebase.v1.AICompletionResponse.Candidate.Content.parts:type_name -> bytebase.v1.AICompletionResponse.Candidate.Content.Part
+ 6, // 34: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest
+ 4, // 35: bytebase.v1.SQLService.AdminExecute:input_type -> bytebase.v1.AdminExecuteRequest
+ 23, // 36: bytebase.v1.SQLService.SearchQueryHistories:input_type -> bytebase.v1.SearchQueryHistoriesRequest
+ 13, // 37: bytebase.v1.SQLService.Export:input_type -> bytebase.v1.ExportRequest
+ 17, // 38: bytebase.v1.SQLService.Check:input_type -> bytebase.v1.CheckRequest
+ 19, // 39: bytebase.v1.SQLService.ParseMyBatisMapper:input_type -> bytebase.v1.ParseMyBatisMapperRequest
+ 15, // 40: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest
+ 21, // 41: bytebase.v1.SQLService.DiffMetadata:input_type -> bytebase.v1.DiffMetadataRequest
+ 26, // 42: bytebase.v1.SQLService.AICompletion:input_type -> bytebase.v1.AICompletionRequest
+ 7, // 43: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse
+ 5, // 44: bytebase.v1.SQLService.AdminExecute:output_type -> bytebase.v1.AdminExecuteResponse
+ 24, // 45: bytebase.v1.SQLService.SearchQueryHistories:output_type -> bytebase.v1.SearchQueryHistoriesResponse
+ 14, // 46: bytebase.v1.SQLService.Export:output_type -> bytebase.v1.ExportResponse
+ 18, // 47: bytebase.v1.SQLService.Check:output_type -> bytebase.v1.CheckResponse
+ 20, // 48: bytebase.v1.SQLService.ParseMyBatisMapper:output_type -> bytebase.v1.ParseMyBatisMapperResponse
+ 16, // 49: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse
+ 22, // 50: bytebase.v1.SQLService.DiffMetadata:output_type -> bytebase.v1.DiffMetadataResponse
+ 27, // 51: bytebase.v1.SQLService.AICompletion:output_type -> bytebase.v1.AICompletionResponse
+ 43, // [43:52] is the sub-list for method output_type
+ 34, // [34:43] is the sub-list for method input_type
+ 34, // [34:34] is the sub-list for extension type_name
+ 34, // [34:34] is the sub-list for extension extendee
+ 0, // [0:34] is the sub-list for field type_name
}
func init() { file_v1_sql_service_proto_init() }
@@ -2632,7 +2935,7 @@ func file_v1_sql_service_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_sql_service_proto_rawDesc), len(file_v1_sql_service_proto_rawDesc)),
NumEnums: 4,
- NumMessages: 25,
+ NumMessages: 31,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/generated-go/v1/sql_service.pb.gw.go b/proto/generated-go/v1/sql_service.pb.gw.go
index 86a06817a4..1768d40815 100644
--- a/proto/generated-go/v1/sql_service.pb.gw.go
+++ b/proto/generated-go/v1/sql_service.pb.gw.go
@@ -408,6 +408,30 @@ func local_request_SQLService_DiffMetadata_0(ctx context.Context, marshaler runt
return msg, metadata, err
}
+func request_SQLService_AICompletion_0(ctx context.Context, marshaler runtime.Marshaler, client SQLServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq AICompletionRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := client.AICompletion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_SQLService_AICompletion_0(ctx context.Context, marshaler runtime.Marshaler, server SQLServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq AICompletionRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := server.AICompletion(ctx, &protoReq)
+ return msg, metadata, err
+}
+
// RegisterSQLServiceHandlerServer registers the http handlers for service SQLService to "mux".
// UnaryRPC :call SQLServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -621,6 +645,26 @@ func RegisterSQLServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
}
forward_SQLService_DiffMetadata_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_SQLService_AICompletion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SQLService/AICompletion", runtime.WithHTTPPathPattern("/v1/sql/aiCompletion"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SQLService_AICompletion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SQLService_AICompletion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
return nil
}
@@ -848,6 +892,23 @@ func RegisterSQLServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
}
forward_SQLService_DiffMetadata_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_SQLService_AICompletion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SQLService/AICompletion", runtime.WithHTTPPathPattern("/v1/sql/aiCompletion"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SQLService_AICompletion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SQLService_AICompletion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
return nil
}
@@ -863,6 +924,7 @@ var (
pattern_SQLService_ParseMyBatisMapper_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "parseMyBatisMapper"}, ""))
pattern_SQLService_Pretty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "pretty"}, ""))
pattern_SQLService_DiffMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "schemaDesign"}, "diffMetadata"))
+ pattern_SQLService_AICompletion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "aiCompletion"}, ""))
)
var (
@@ -877,4 +939,5 @@ var (
forward_SQLService_ParseMyBatisMapper_0 = runtime.ForwardResponseMessage
forward_SQLService_Pretty_0 = runtime.ForwardResponseMessage
forward_SQLService_DiffMetadata_0 = runtime.ForwardResponseMessage
+ forward_SQLService_AICompletion_0 = runtime.ForwardResponseMessage
)
diff --git a/proto/generated-go/v1/sql_service_grpc.pb.go b/proto/generated-go/v1/sql_service_grpc.pb.go
index f38dcac3ba..c02b12ccc4 100644
--- a/proto/generated-go/v1/sql_service_grpc.pb.go
+++ b/proto/generated-go/v1/sql_service_grpc.pb.go
@@ -27,6 +27,7 @@ const (
SQLService_ParseMyBatisMapper_FullMethodName = "/bytebase.v1.SQLService/ParseMyBatisMapper"
SQLService_Pretty_FullMethodName = "/bytebase.v1.SQLService/Pretty"
SQLService_DiffMetadata_FullMethodName = "/bytebase.v1.SQLService/DiffMetadata"
+ SQLService_AICompletion_FullMethodName = "/bytebase.v1.SQLService/AICompletion"
)
// SQLServiceClient is the client API for SQLService service.
@@ -42,6 +43,7 @@ type SQLServiceClient interface {
ParseMyBatisMapper(ctx context.Context, in *ParseMyBatisMapperRequest, opts ...grpc.CallOption) (*ParseMyBatisMapperResponse, error)
Pretty(ctx context.Context, in *PrettyRequest, opts ...grpc.CallOption) (*PrettyResponse, error)
DiffMetadata(ctx context.Context, in *DiffMetadataRequest, opts ...grpc.CallOption) (*DiffMetadataResponse, error)
+ AICompletion(ctx context.Context, in *AICompletionRequest, opts ...grpc.CallOption) (*AICompletionResponse, error)
}
type sQLServiceClient struct {
@@ -135,6 +137,16 @@ func (c *sQLServiceClient) DiffMetadata(ctx context.Context, in *DiffMetadataReq
return out, nil
}
+func (c *sQLServiceClient) AICompletion(ctx context.Context, in *AICompletionRequest, opts ...grpc.CallOption) (*AICompletionResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(AICompletionResponse)
+ err := c.cc.Invoke(ctx, SQLService_AICompletion_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// SQLServiceServer is the server API for SQLService service.
// All implementations must embed UnimplementedSQLServiceServer
// for forward compatibility.
@@ -148,6 +160,7 @@ type SQLServiceServer interface {
ParseMyBatisMapper(context.Context, *ParseMyBatisMapperRequest) (*ParseMyBatisMapperResponse, error)
Pretty(context.Context, *PrettyRequest) (*PrettyResponse, error)
DiffMetadata(context.Context, *DiffMetadataRequest) (*DiffMetadataResponse, error)
+ AICompletion(context.Context, *AICompletionRequest) (*AICompletionResponse, error)
mustEmbedUnimplementedSQLServiceServer()
}
@@ -182,6 +195,9 @@ func (UnimplementedSQLServiceServer) Pretty(context.Context, *PrettyRequest) (*P
func (UnimplementedSQLServiceServer) DiffMetadata(context.Context, *DiffMetadataRequest) (*DiffMetadataResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DiffMetadata not implemented")
}
+func (UnimplementedSQLServiceServer) AICompletion(context.Context, *AICompletionRequest) (*AICompletionResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method AICompletion not implemented")
+}
func (UnimplementedSQLServiceServer) mustEmbedUnimplementedSQLServiceServer() {}
func (UnimplementedSQLServiceServer) testEmbeddedByValue() {}
@@ -336,6 +352,24 @@ func _SQLService_DiffMetadata_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
+func _SQLService_AICompletion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AICompletionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SQLServiceServer).AICompletion(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SQLService_AICompletion_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SQLServiceServer).AICompletion(ctx, req.(*AICompletionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
// SQLService_ServiceDesc is the grpc.ServiceDesc for SQLService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -371,6 +405,10 @@ var SQLService_ServiceDesc = grpc.ServiceDesc{
MethodName: "DiffMetadata",
Handler: _SQLService_DiffMetadata_Handler,
},
+ {
+ MethodName: "AICompletion",
+ Handler: _SQLService_AICompletion_Handler,
+ },
},
Streams: []grpc.StreamDesc{
{
diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.proto
index a39c7fe227..bbe6583f39 100644
--- a/proto/v1/sql_service.proto
+++ b/proto/v1/sql_service.proto
@@ -100,6 +100,14 @@ service SQLService {
option (bytebase.v1.allow_without_credential) = true;
// This is a util method requiring no authentication thus no authorization.
}
+
+ rpc AICompletion(AICompletionRequest) returns (AICompletionResponse) {
+ option (google.api.http) = {
+ post: "/v1/sql/aiCompletion"
+ body: "*"
+ };
+ option (bytebase.v1.auth_method) = CUSTOM;
+ }
}
message AdminExecuteRequest {
@@ -506,3 +514,26 @@ message QueryHistory {
Type type = 8;
}
+
+message AICompletionRequest {
+ message Message {
+ string role = 1;
+ string content = 2;
+ }
+ repeated Message messages = 1;
+}
+
+message AICompletionResponse {
+ message Candidate {
+ message Content {
+ message Part {
+ string text = 1;
+ }
+ // parts is used for a result content with multiple parts.
+ repeated Part parts = 1;
+ }
+ Content content = 1;
+ }
+ // candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini.
+ repeated Candidate candidates = 1;
+}