Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.3 KB
Raw Blame
import type { ContractRouterClient } from '@orpc/contract'
import type { JsonifiedClient } from '@orpc/openapi-client'
import {
  humanInput2,
  public_ as publicHumanInputV2Contract,
} from '@dify/contracts/api/web/orpc.gen'
import { createORPCClient } from '@orpc/client'
import { OpenAPILink } from '@orpc/openapi-client/fetch'
import { PUBLIC_API_PREFIX } from '@/config'

const humanInputV2FormContract = {
  getForm: publicHumanInputV2Contract.byFormToken.get,
  requestAccess: publicHumanInputV2Contract.byFormToken.accessRequest.post,
  requestUploadToken: publicHumanInputV2Contract.byFormToken.uploadToken.post,
  submit: publicHumanInputV2Contract.byFormToken.post,
  uploadFile: humanInput2.v2.files.post,
  uploadRemoteFile: humanInput2.v2.files.remote.post,
}
export const humanInputV2FormClient: JsonifiedClient<
  ContractRouterClient<typeof humanInputV2FormContract>
> = createORPCClient(
  new OpenAPILink(humanInputV2FormContract, {
    url: () => new URL(PUBLIC_API_PREFIX, window.location.origin),
    fetch: (request, init) =>
      // oxlint-disable-next-line no-restricted-properties -- Public token-authenticated form contracts must omit Console cookies and bypass its session recovery transport.
      globalThis.fetch(request, {
        ...init,
        credentials: 'omit',
        cache: 'no-store',
      }),
  }),
)