-
Notifications
You must be signed in to change notification settings - Fork 61
feat: Added AI extension support and SQL generation APIs #804
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
Changes from 1 commit
1f4d036
14edd88
e955c68
e0bdb76
4eddc7b
eff1d43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,6 +330,18 @@ service ThemeExtension { | |
| } | ||
| } | ||
|
|
||
| // AIExtension service provides AI-powered capabilities for atest. | ||
| service AIExtension { | ||
| // Translates a natural language query into an SQL query, providing | ||
| // context and explanations for better accuracy and user trust. | ||
| rpc GenerateSQLFromNaturalLanguage (GenerateSQLRequest) returns (GenerateSQLResponse) { | ||
| option (google.api.http) = { | ||
| post: "/api/v1/ai/sql/generate" | ||
| body: "*" | ||
| }; | ||
| } | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 接口测试用例的编写、Mock 服务的编写后续也要有 AI 的支持,到时候该怎么做呢?新增接口?还是可以提供一个更加通用的接口呢?本质上都是根据提示(prompt)生成 thinking 和最终的反馈(SQL,或者是其他的)。
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 收到. 考虑到后续的延展性, 我选择升级提供一个更加通用的接口GenerateContent来处理此类任务. |
||
|
|
||
| message Suites { | ||
| map<string, Items> data = 1; | ||
| } | ||
|
|
@@ -697,3 +709,82 @@ message DataMeta { | |
| string duration = 4; | ||
| repeated Pair labels = 5; | ||
| } | ||
|
|
||
| // AI Extension related messages | ||
|
|
||
| // Enum for supported database dialects to ensure type safety. | ||
| enum DatabaseType { | ||
| // DATABASE_TYPE_UNSPECIFIED indicates a missing or unknown database type. | ||
| DATABASE_TYPE_UNSPECIFIED = 0; | ||
| MYSQL = 1; | ||
| POSTGRESQL = 2; | ||
| SQLITE = 3; | ||
| } | ||
|
|
||
| // Represents an example pair of natural language to SQL for few-shot prompting. | ||
| message QueryExample { | ||
| // A natural language query example. | ||
| string natural_language_prompt = 1; | ||
| // The corresponding correct SQL query for the prompt. | ||
| string sql_query = 2; | ||
| } | ||
|
|
||
| // Request message for generating an SQL query from natural language. | ||
| message GenerateSQLRequest { | ||
| // The user's query in natural language. (e.g., "show me all users from California") | ||
| string natural_language_input = 1; | ||
|
||
| // Target database dialect for SQL generation. | ||
| DatabaseType database_type = 2; | ||
| // Optional: A list of DDL statements (e.g., CREATE TABLE …) for relevant tables. | ||
| // Providing schemas helps the AI generate more accurate queries. | ||
| repeated string schemas = 3; | ||
| // Optional: A session identifier to maintain context across multiple requests, | ||
| // enabling conversational query refinement. | ||
| optional string session_id = 4; | ||
| // Optional: A list of examples to guide the AI, improving accuracy for | ||
| // specific or complex domains. | ||
| repeated QueryExample examples = 5; | ||
| } | ||
|
|
||
| // Response message containing the result of the SQL generation. | ||
| message GenerateSQLResponse { | ||
| // The response can be one of the following types. | ||
| oneof result { | ||
| // Contains the successful SQL generation details. | ||
| SuccessResponse success = 1; | ||
| // Contains details about why the generation failed. | ||
| ErrorResponse error = 2; | ||
| } | ||
| } | ||
|
|
||
| // Represents a successful SQL generation. | ||
| message SuccessResponse { | ||
| // The generated SQL query. | ||
| string sql_query = 1; | ||
| // An explanation of how the AI interpreted the request and generated the SQL. | ||
| // This builds user trust and aids in debugging. | ||
| optional string explanation = 2; | ||
| // A score between 0.0 and 1.0 indicating the AI's confidence in the generated query. | ||
| optional float confidence_score = 3; | ||
| } | ||
|
|
||
| // Enum for structured error codes. | ||
| enum ErrorCode { | ||
| ERROR_CODE_UNSPECIFIED = 0; | ||
| // The input was invalid (e.g., empty prompt). | ||
| INVALID_ARGUMENT = 1; | ||
| // The AI model failed to translate the query. | ||
| TRANSLATION_FAILED = 2; | ||
| // The requested database type is not supported. | ||
| UNSUPPORTED_DATABASE = 3; | ||
| // An internal error occurred in the service. | ||
| INTERNAL_ERROR = 4; | ||
| } | ||
|
|
||
| // Represents a failed SQL generation attempt. | ||
| message ErrorResponse { | ||
| // A structured error code for programmatic handling. | ||
| ErrorCode code = 1; | ||
| // A human-readable message describing the error. | ||
| string message = 2; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个变量该怎么用呢?下面的接口里没有体现到。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外,接口的定义后续会重构。大体的思路是:
LinuxSuRen/atest-ext-data-swagger#1
#803
重构完成后再调整即可。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExtensionKindAI 变量定义了AI扩展的配置参数:
这些参数通过 GenerateContentRequest.parameters 字段传递给AI服务,用于配置AI模型的行为。在接口中作为 parameters 映射传递给AI扩展服务。