mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat: get prompt model names (#13607)
fix AI-419 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - New API to fetch available models for a prompt, returning default, optional, and pro models with human‑readable names. - Added temperature and topP settings to prompt configuration for finer control. - Refactor - When no model is chosen, the default model is used instead of auto-picking a pro model. - Model metadata across providers now includes readable names, improving listings and selection UX. - Tests - Updated test snapshots and descriptions to reflect the new default-model behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
17
packages/common/graphql/src/graphql/copilot-models-get.gql
Normal file
17
packages/common/graphql/src/graphql/copilot-models-get.gql
Normal file
@@ -0,0 +1,17 @@
|
||||
query getPromptModels($promptName: String!) {
|
||||
currentUser {
|
||||
copilot {
|
||||
models(promptName: $promptName) {
|
||||
defaultModel
|
||||
optionalModels {
|
||||
id
|
||||
name
|
||||
}
|
||||
proModels {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1059,6 +1059,28 @@ export const createCopilotMessageMutation = {
|
||||
file: true,
|
||||
};
|
||||
|
||||
export const getPromptModelsQuery = {
|
||||
id: 'getPromptModelsQuery' as const,
|
||||
op: 'getPromptModels',
|
||||
query: `query getPromptModels($promptName: String!) {
|
||||
currentUser {
|
||||
copilot {
|
||||
models(promptName: $promptName) {
|
||||
defaultModel
|
||||
optionalModels {
|
||||
id
|
||||
name
|
||||
}
|
||||
proModels {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const copilotQuotaQuery = {
|
||||
id: 'copilotQuotaQuery' as const,
|
||||
op: 'copilotQuota',
|
||||
|
||||
@@ -263,6 +263,8 @@ export interface Copilot {
|
||||
contexts: Array<CopilotContext>;
|
||||
/** @deprecated use `chats` instead */
|
||||
histories: Array<CopilotHistories>;
|
||||
/** List available models for a prompt, with human-readable names */
|
||||
models: CopilotModelsType;
|
||||
/** Get the quota of the user in the workspace */
|
||||
quota: CopilotQuota;
|
||||
/** Get the session by id */
|
||||
@@ -296,6 +298,10 @@ export interface CopilotHistoriesArgs {
|
||||
options?: InputMaybe<QueryChatHistoriesInput>;
|
||||
}
|
||||
|
||||
export interface CopilotModelsArgs {
|
||||
promptName: Scalars['String']['input'];
|
||||
}
|
||||
|
||||
export interface CopilotSessionArgs {
|
||||
sessionId: Scalars['String']['input'];
|
||||
}
|
||||
@@ -451,6 +457,19 @@ export interface CopilotMessageNotFoundDataType {
|
||||
messageId: Scalars['String']['output'];
|
||||
}
|
||||
|
||||
export interface CopilotModelType {
|
||||
__typename?: 'CopilotModelType';
|
||||
id: Scalars['String']['output'];
|
||||
name: Scalars['String']['output'];
|
||||
}
|
||||
|
||||
export interface CopilotModelsType {
|
||||
__typename?: 'CopilotModelsType';
|
||||
defaultModel: Scalars['String']['output'];
|
||||
optionalModels: Array<CopilotModelType>;
|
||||
proModels: Array<CopilotModelType>;
|
||||
}
|
||||
|
||||
export interface CopilotPromptConfigInput {
|
||||
frequencyPenalty?: InputMaybe<Scalars['Float']['input']>;
|
||||
presencePenalty?: InputMaybe<Scalars['Float']['input']>;
|
||||
@@ -4343,6 +4362,34 @@ export type CreateCopilotMessageMutation = {
|
||||
createCopilotMessage: string;
|
||||
};
|
||||
|
||||
export type GetPromptModelsQueryVariables = Exact<{
|
||||
promptName: Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type GetPromptModelsQuery = {
|
||||
__typename?: 'Query';
|
||||
currentUser: {
|
||||
__typename?: 'UserType';
|
||||
copilot: {
|
||||
__typename?: 'Copilot';
|
||||
models: {
|
||||
__typename?: 'CopilotModelsType';
|
||||
defaultModel: string;
|
||||
optionalModels: Array<{
|
||||
__typename?: 'CopilotModelType';
|
||||
id: string;
|
||||
name: string;
|
||||
}>;
|
||||
proModels: Array<{
|
||||
__typename?: 'CopilotModelType';
|
||||
id: string;
|
||||
name: string;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type CopilotQuotaQueryVariables = Exact<{ [key: string]: never }>;
|
||||
|
||||
export type CopilotQuotaQuery = {
|
||||
@@ -6380,6 +6427,11 @@ export type Queries =
|
||||
variables: GetAudioTranscriptionQueryVariables;
|
||||
response: GetAudioTranscriptionQuery;
|
||||
}
|
||||
| {
|
||||
name: 'getPromptModelsQuery';
|
||||
variables: GetPromptModelsQueryVariables;
|
||||
response: GetPromptModelsQuery;
|
||||
}
|
||||
| {
|
||||
name: 'copilotQuotaQuery';
|
||||
variables: CopilotQuotaQueryVariables;
|
||||
|
||||
Reference in New Issue
Block a user