mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
feat(admin): add prompt management page (#7611)
close AF-907 Supports online modification of prompt, but does not support custom ai key yet 
This commit is contained in:
19
packages/frontend/graphql/src/graphql/get-prompts.gql
Normal file
19
packages/frontend/graphql/src/graphql/get-prompts.gql
Normal file
@@ -0,0 +1,19 @@
|
||||
query getPrompts {
|
||||
listCopilotPrompts {
|
||||
name
|
||||
model
|
||||
action
|
||||
config {
|
||||
jsonMode
|
||||
frequencyPenalty
|
||||
presencePenalty
|
||||
temperature
|
||||
topP
|
||||
}
|
||||
messages {
|
||||
role
|
||||
content
|
||||
params
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,6 +496,33 @@ query oauthProviders {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const getPromptsQuery = {
|
||||
id: 'getPromptsQuery' as const,
|
||||
operationName: 'getPrompts',
|
||||
definitionName: 'listCopilotPrompts',
|
||||
containsFile: false,
|
||||
query: `
|
||||
query getPrompts {
|
||||
listCopilotPrompts {
|
||||
name
|
||||
model
|
||||
action
|
||||
config {
|
||||
jsonMode
|
||||
frequencyPenalty
|
||||
presencePenalty
|
||||
temperature
|
||||
topP
|
||||
}
|
||||
messages {
|
||||
role
|
||||
content
|
||||
params
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const getServerRuntimeConfigQuery = {
|
||||
id: 'getServerRuntimeConfigQuery' as const,
|
||||
operationName: 'getServerRuntimeConfig',
|
||||
@@ -1057,6 +1084,33 @@ mutation updateAccount($id: String!, $input: ManageUserInput!) {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const updatePromptMutation = {
|
||||
id: 'updatePromptMutation' as const,
|
||||
operationName: 'updatePrompt',
|
||||
definitionName: 'updateCopilotPrompt',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation updatePrompt($name: String!, $messages: [CopilotPromptMessageInput!]!) {
|
||||
updateCopilotPrompt(name: $name, messages: $messages) {
|
||||
name
|
||||
model
|
||||
action
|
||||
config {
|
||||
jsonMode
|
||||
frequencyPenalty
|
||||
presencePenalty
|
||||
temperature
|
||||
topP
|
||||
}
|
||||
messages {
|
||||
role
|
||||
content
|
||||
params
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const updateServerRuntimeConfigsMutation = {
|
||||
id: 'updateServerRuntimeConfigsMutation' as const,
|
||||
operationName: 'updateServerRuntimeConfigs',
|
||||
|
||||
22
packages/frontend/graphql/src/graphql/update-prompt.gql
Normal file
22
packages/frontend/graphql/src/graphql/update-prompt.gql
Normal file
@@ -0,0 +1,22 @@
|
||||
mutation updatePrompt(
|
||||
$name: String!
|
||||
$messages: [CopilotPromptMessageInput!]!
|
||||
) {
|
||||
updateCopilotPrompt(name: $name, messages: $messages) {
|
||||
name
|
||||
model
|
||||
action
|
||||
config {
|
||||
jsonMode
|
||||
frequencyPenalty
|
||||
presencePenalty
|
||||
temperature
|
||||
topP
|
||||
}
|
||||
messages {
|
||||
role
|
||||
content
|
||||
params
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,20 +104,20 @@ export enum CopilotModels {
|
||||
}
|
||||
|
||||
export interface CopilotPromptConfigInput {
|
||||
frequencyPenalty: InputMaybe<Scalars['Int']['input']>;
|
||||
frequencyPenalty: InputMaybe<Scalars['Float']['input']>;
|
||||
jsonMode: InputMaybe<Scalars['Boolean']['input']>;
|
||||
presencePenalty: InputMaybe<Scalars['Int']['input']>;
|
||||
temperature: InputMaybe<Scalars['Int']['input']>;
|
||||
topP: InputMaybe<Scalars['Int']['input']>;
|
||||
presencePenalty: InputMaybe<Scalars['Float']['input']>;
|
||||
temperature: InputMaybe<Scalars['Float']['input']>;
|
||||
topP: InputMaybe<Scalars['Float']['input']>;
|
||||
}
|
||||
|
||||
export interface CopilotPromptConfigType {
|
||||
__typename?: 'CopilotPromptConfigType';
|
||||
frequencyPenalty: Maybe<Scalars['Int']['output']>;
|
||||
frequencyPenalty: Maybe<Scalars['Float']['output']>;
|
||||
jsonMode: Maybe<Scalars['Boolean']['output']>;
|
||||
presencePenalty: Maybe<Scalars['Int']['output']>;
|
||||
temperature: Maybe<Scalars['Int']['output']>;
|
||||
topP: Maybe<Scalars['Int']['output']>;
|
||||
presencePenalty: Maybe<Scalars['Float']['output']>;
|
||||
temperature: Maybe<Scalars['Float']['output']>;
|
||||
topP: Maybe<Scalars['Float']['output']>;
|
||||
}
|
||||
|
||||
export interface CopilotPromptMessageInput {
|
||||
@@ -149,7 +149,7 @@ export interface CopilotPromptType {
|
||||
action: Maybe<Scalars['String']['output']>;
|
||||
config: Maybe<CopilotPromptConfigType>;
|
||||
messages: Array<CopilotPromptMessageType>;
|
||||
model: CopilotModels;
|
||||
model: Scalars['String']['output'];
|
||||
name: Scalars['String']['output'];
|
||||
}
|
||||
|
||||
@@ -1684,6 +1684,32 @@ export type OauthProvidersQuery = {
|
||||
};
|
||||
};
|
||||
|
||||
export type GetPromptsQueryVariables = Exact<{ [key: string]: never }>;
|
||||
|
||||
export type GetPromptsQuery = {
|
||||
__typename?: 'Query';
|
||||
listCopilotPrompts: Array<{
|
||||
__typename?: 'CopilotPromptType';
|
||||
name: string;
|
||||
model: string;
|
||||
action: string | null;
|
||||
config: {
|
||||
__typename?: 'CopilotPromptConfigType';
|
||||
jsonMode: boolean | null;
|
||||
frequencyPenalty: number | null;
|
||||
presencePenalty: number | null;
|
||||
temperature: number | null;
|
||||
topP: number | null;
|
||||
} | null;
|
||||
messages: Array<{
|
||||
__typename?: 'CopilotPromptMessageType';
|
||||
role: CopilotPromptMessageRole;
|
||||
content: string;
|
||||
params: Record<string, string> | null;
|
||||
}>;
|
||||
}>;
|
||||
};
|
||||
|
||||
export type GetServerRuntimeConfigQueryVariables = Exact<{
|
||||
[key: string]: never;
|
||||
}>;
|
||||
@@ -2186,6 +2212,35 @@ export type UpdateAccountMutation = {
|
||||
};
|
||||
};
|
||||
|
||||
export type UpdatePromptMutationVariables = Exact<{
|
||||
name: Scalars['String']['input'];
|
||||
messages: Array<CopilotPromptMessageInput> | CopilotPromptMessageInput;
|
||||
}>;
|
||||
|
||||
export type UpdatePromptMutation = {
|
||||
__typename?: 'Mutation';
|
||||
updateCopilotPrompt: {
|
||||
__typename?: 'CopilotPromptType';
|
||||
name: string;
|
||||
model: string;
|
||||
action: string | null;
|
||||
config: {
|
||||
__typename?: 'CopilotPromptConfigType';
|
||||
jsonMode: boolean | null;
|
||||
frequencyPenalty: number | null;
|
||||
presencePenalty: number | null;
|
||||
temperature: number | null;
|
||||
topP: number | null;
|
||||
} | null;
|
||||
messages: Array<{
|
||||
__typename?: 'CopilotPromptMessageType';
|
||||
role: CopilotPromptMessageRole;
|
||||
content: string;
|
||||
params: Record<string, string> | null;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
|
||||
export type UpdateServerRuntimeConfigsMutationVariables = Exact<{
|
||||
updates: Scalars['JSONObject']['input'];
|
||||
}>;
|
||||
@@ -2432,6 +2487,11 @@ export type Queries =
|
||||
variables: OauthProvidersQueryVariables;
|
||||
response: OauthProvidersQuery;
|
||||
}
|
||||
| {
|
||||
name: 'getPromptsQuery';
|
||||
variables: GetPromptsQueryVariables;
|
||||
response: GetPromptsQuery;
|
||||
}
|
||||
| {
|
||||
name: 'getServerRuntimeConfigQuery';
|
||||
variables: GetServerRuntimeConfigQueryVariables;
|
||||
@@ -2729,6 +2789,11 @@ export type Mutations =
|
||||
variables: UpdateAccountMutationVariables;
|
||||
response: UpdateAccountMutation;
|
||||
}
|
||||
| {
|
||||
name: 'updatePromptMutation';
|
||||
variables: UpdatePromptMutationVariables;
|
||||
response: UpdatePromptMutation;
|
||||
}
|
||||
| {
|
||||
name: 'updateServerRuntimeConfigsMutation';
|
||||
variables: UpdateServerRuntimeConfigsMutationVariables;
|
||||
|
||||
Reference in New Issue
Block a user