chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
// This file is auto-generated by scripts/add-orpc-error-maps.ts
|
||||
import * as z from 'zod'
|
||||
|
||||
const zErrorResponse = /* @__PURE__ */ (() =>
|
||||
z.object({
|
||||
code: z.string(),
|
||||
details: z.record(z.string(), z.unknown()).optional(),
|
||||
message: z.string(),
|
||||
params: z.string().optional(),
|
||||
status: z.int(),
|
||||
}))()
|
||||
|
||||
const zCompletionRequestError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('completion_request_error'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zModelCurrentlyNotSupportError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('model_currently_not_support'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zProviderNotInitializeError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('provider_not_initialize'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zProviderQuotaExceededError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('provider_quota_exceeded'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
))()
|
||||
|
||||
export const postErrors = {
|
||||
completion_request_error: { status: 400, data: zCompletionRequestError },
|
||||
model_currently_not_support: { status: 400, data: zModelCurrentlyNotSupportError },
|
||||
provider_not_initialize: { status: 400, data: zProviderNotInitializeError },
|
||||
provider_quota_exceeded: { status: 400, data: zProviderQuotaExceededError },
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { oc } from '@orpc/contract'
|
||||
import * as z from 'zod'
|
||||
import {
|
||||
zCompletionRequestError,
|
||||
zModelCurrentlyNotSupportError,
|
||||
zProviderNotInitializeError,
|
||||
zProviderQuotaExceededError,
|
||||
} from './zod.gen.ts'
|
||||
import { zPostRuleCodeGenerateBody, zPostRuleCodeGenerateResponse } from './zod.gen.ts'
|
||||
|
||||
/**
|
||||
* Generate code rules using LLM
|
||||
*/
|
||||
export const post = oc
|
||||
.route({
|
||||
description: 'Generate code rules using LLM',
|
||||
inputStructure: 'detailed',
|
||||
method: 'POST',
|
||||
operationId: 'postRuleCodeGenerate',
|
||||
path: '/rule-code-generate',
|
||||
tags: ['console'],
|
||||
})
|
||||
.input(z.object({ body: zPostRuleCodeGenerateBody }))
|
||||
.output(zPostRuleCodeGenerateResponse)
|
||||
.errors({
|
||||
completion_request_error: { status: 400, data: zCompletionRequestError },
|
||||
model_currently_not_support: { status: 400, data: zModelCurrentlyNotSupportError },
|
||||
provider_not_initialize: { status: 400, data: zProviderNotInitializeError },
|
||||
provider_quota_exceeded: { status: 400, data: zProviderQuotaExceededError },
|
||||
})
|
||||
|
||||
export const ruleCodeGenerate = {
|
||||
post,
|
||||
}
|
||||
|
||||
export const contract = {
|
||||
ruleCodeGenerate,
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type ClientOptions = {
|
||||
baseUrl: `${string}://${string}/console/api` | (string & {})
|
||||
}
|
||||
|
||||
export type RuleCodeGeneratePayload = {
|
||||
code_language?: string
|
||||
instruction: string
|
||||
model_config: ModelConfig
|
||||
no_variable?: boolean
|
||||
}
|
||||
|
||||
export type GeneratorResponse = unknown
|
||||
|
||||
export type CompletionRequestError = ErrorResponse & {
|
||||
code: 'completion_request_error'
|
||||
status: 400
|
||||
}
|
||||
|
||||
export type ModelCurrentlyNotSupportError = ErrorResponse & {
|
||||
code: 'model_currently_not_support'
|
||||
status: 400
|
||||
}
|
||||
|
||||
export type ProviderNotInitializeError = ErrorResponse & {
|
||||
code: 'provider_not_initialize'
|
||||
status: 400
|
||||
}
|
||||
|
||||
export type ProviderQuotaExceededError = ErrorResponse & {
|
||||
code: 'provider_quota_exceeded'
|
||||
status: 400
|
||||
}
|
||||
|
||||
export type ErrorResponse = {
|
||||
code: string
|
||||
details?: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
message: string
|
||||
params?: string
|
||||
status: number
|
||||
}
|
||||
|
||||
export type ModelConfig = {
|
||||
completion_params?: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
mode: LlmMode
|
||||
name: string
|
||||
provider: string
|
||||
}
|
||||
|
||||
export type LlmMode = 'chat' | 'completion'
|
||||
|
||||
export type PostRuleCodeGenerateData = {
|
||||
body: RuleCodeGeneratePayload
|
||||
path?: never
|
||||
query?: never
|
||||
url: '/rule-code-generate'
|
||||
}
|
||||
|
||||
export type PostRuleCodeGenerateErrors = {
|
||||
400:
|
||||
| CompletionRequestError
|
||||
| ModelCurrentlyNotSupportError
|
||||
| ProviderNotInitializeError
|
||||
| ProviderQuotaExceededError
|
||||
| ErrorResponse
|
||||
default: ErrorResponse
|
||||
}
|
||||
|
||||
export type PostRuleCodeGenerateError = PostRuleCodeGenerateErrors[keyof PostRuleCodeGenerateErrors]
|
||||
|
||||
export type PostRuleCodeGenerateResponses = {
|
||||
200: GeneratorResponse
|
||||
}
|
||||
|
||||
export type PostRuleCodeGenerateResponse =
|
||||
PostRuleCodeGenerateResponses[keyof PostRuleCodeGenerateResponses]
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import * as z from 'zod'
|
||||
|
||||
/**
|
||||
* GeneratorResponse
|
||||
*/
|
||||
export const zGeneratorResponse = z.unknown()
|
||||
|
||||
/**
|
||||
* ErrorResponse
|
||||
*
|
||||
* Documented non-2xx body emitted by ``register_external_error_handlers``.
|
||||
*
|
||||
* ``params`` and ``details`` appear only on the errors that set them. The schema
|
||||
* stays open because ``HTTPException.data`` may carry extra keys.
|
||||
*/
|
||||
export const zErrorResponse = z.object({
|
||||
code: z.string(),
|
||||
details: z.record(z.string(), z.unknown()).optional(),
|
||||
message: z.string(),
|
||||
params: z.string().optional(),
|
||||
status: z.int(),
|
||||
})
|
||||
|
||||
/**
|
||||
* CompletionRequestError
|
||||
*
|
||||
* Completion request failed.
|
||||
*/
|
||||
export const zCompletionRequestError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('completion_request_error'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ModelCurrentlyNotSupportError
|
||||
*
|
||||
* Dify Hosted OpenAI trial currently not support the GPT-4 model.
|
||||
*/
|
||||
export const zModelCurrentlyNotSupportError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('model_currently_not_support'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ProviderNotInitializeError
|
||||
*
|
||||
* No valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials.
|
||||
*/
|
||||
export const zProviderNotInitializeError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('provider_not_initialize'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ProviderQuotaExceededError
|
||||
*
|
||||
* Your quota for Dify Hosted Model Provider has been exhausted. Please go to Settings -> Model Provider to complete your own provider credentials.
|
||||
*/
|
||||
export const zProviderQuotaExceededError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('provider_quota_exceeded'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* LLMMode
|
||||
*
|
||||
* Enum class for large language model mode.
|
||||
*/
|
||||
export const zLlmMode = z.enum(['chat', 'completion'])
|
||||
|
||||
/**
|
||||
* ModelConfig
|
||||
*/
|
||||
export const zModelConfig = z.object({
|
||||
completion_params: z.record(z.string(), z.unknown()).optional(),
|
||||
mode: zLlmMode,
|
||||
name: z.string(),
|
||||
provider: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* RuleCodeGeneratePayload
|
||||
*/
|
||||
export const zRuleCodeGeneratePayload = z.object({
|
||||
code_language: z.string().optional().default('javascript'),
|
||||
instruction: z.string(),
|
||||
model_config: zModelConfig,
|
||||
no_variable: z.boolean().optional().default(false),
|
||||
})
|
||||
|
||||
export const zPostRuleCodeGenerateBody = zRuleCodeGeneratePayload
|
||||
|
||||
/**
|
||||
* Code rules generated successfully
|
||||
*/
|
||||
export const zPostRuleCodeGenerateResponse = zGeneratorResponse
|
||||
Reference in new issue
Block a user