feat: enchance prompt and code (#23633)
Co-authored-by: stream <stream@dify.ai> Co-authored-by: Stream <1542763342@qq.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
a7fe0e3f87
commit
de9c5f10b3
66 changed files with 2654 additions and 275 deletions
|
|
@ -3,12 +3,21 @@ import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessag
|
|||
import type { ChatPromptConfig, CompletionPromptConfig } from '@/models/debug'
|
||||
import type { ModelModeType } from '@/types/app'
|
||||
import type { ModelParameterRule } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
export type AutomaticRes = {
|
||||
export type BasicAppFirstRes = {
|
||||
prompt: string
|
||||
variables: string[]
|
||||
opening_statement: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type GenRes = {
|
||||
modified: string
|
||||
message?: string // tip for human
|
||||
variables?: string[] // only for basic app first time rule
|
||||
opening_statement?: string // only for basic app first time rule
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type CodeGenRes = {
|
||||
code: string
|
||||
language: string[]
|
||||
|
|
@ -71,13 +80,14 @@ export const fetchConversationMessages = (appId: string, conversation_id: string
|
|||
})
|
||||
}
|
||||
|
||||
export const generateRule = (body: Record<string, any>) => {
|
||||
return post<AutomaticRes>('/rule-generate', {
|
||||
export const generateBasicAppFistTimeRule = (body: Record<string, any>) => {
|
||||
return post<BasicAppFirstRes>('/rule-generate', {
|
||||
body,
|
||||
})
|
||||
}
|
||||
export const generateRuleCode = (body: Record<string, any>) => {
|
||||
return post<CodeGenRes>('/rule-code-generate', {
|
||||
|
||||
export const generateRule = (body: Record<string, any>) => {
|
||||
return post<GenRes>('/instruction-generate', {
|
||||
body,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { get } from './base'
|
||||
import { get, post } from './base'
|
||||
import type { App } from '@/types/app'
|
||||
import type { AppListResponse } from '@/models/app'
|
||||
import { useInvalid } from './use-base'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { GeneratorType } from '@/app/components/app/configuration/config/automatic/types'
|
||||
|
||||
const NAME_SPACE = 'apps'
|
||||
|
||||
|
|
@ -25,3 +26,16 @@ export const useAppDetail = (appID: string) => {
|
|||
queryFn: () => get<App>(`/apps/${appID}`),
|
||||
})
|
||||
}
|
||||
|
||||
export const useGenerateRuleTemplate = (type: GeneratorType, disabled?: boolean) => {
|
||||
return useQuery({
|
||||
queryKey: [NAME_SPACE, 'generate-rule-template', type],
|
||||
queryFn: () => post<{ data: string }>('instruction-generate/template', {
|
||||
body: {
|
||||
type,
|
||||
},
|
||||
}),
|
||||
enabled: !disabled,
|
||||
retry: 0,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue