// This file is auto-generated by @hey-api/openapi-ts

import * as z from 'zod'

/**
 * AudioTranscriptResponse
 */
export const zAudioTranscriptResponse = z.object({
  text: z.string(),
})

/**
 * ChatRequest
 */
export const zChatRequest = z.object({
  conversation_id: z.string().nullish(),
  files: z.array(z.unknown()).nullish(),
  inputs: z.record(z.string(), z.unknown()),
  parent_message_id: z.string().nullish(),
  query: z.string(),
  retriever_from: z.string().optional().default('explore_app'),
})

/**
 * CompletionRequest
 */
export const zCompletionRequest = z.object({
  files: z.array(z.unknown()).nullish(),
  inputs: z.record(z.string(), z.unknown()),
  query: z.string().optional().default(''),
  response_mode: z.enum(['blocking', 'streaming']).nullish(),
  retriever_from: z.string().optional().default('explore_app'),
})

/**
 * FileResponse
 */
export const zFileResponse = z.object({
  conversation_id: z.string().nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  extension: z.string().nullish(),
  file_key: z.string().nullish(),
  id: z.string(),
  mime_type: z.string().nullish(),
  name: z.string(),
  original_url: z.string().nullish(),
  preview_url: z.string().nullish(),
  reference: z.string().nullish(),
  size: z.int(),
  source_url: z.string().nullish(),
  tenant_id: z.string().nullish(),
  user_id: z.string().nullish(),
})

/**
 * SuggestedQuestionsResponse
 */
export const zSuggestedQuestionsResponse = z.object({
  data: z.array(z.string()),
})

/**
 * RemoteFileUploadPayload
 */
export const zRemoteFileUploadPayload = z.object({
  url: z.string(),
})

/**
 * FileWithSignedUrl
 */
export const zFileWithSignedUrl = z.object({
  created_at: z.int().nullable(),
  created_by: z.string().nullable(),
  extension: z.string().nullable(),
  id: z.string(),
  mime_type: z.string().nullable(),
  name: z.string(),
  size: z.int(),
  url: z.string().nullable(),
})

/**
 * Site
 */
export const zSite = z.object({
  chat_color_theme: z.string().nullish(),
  chat_color_theme_inverted: z.boolean(),
  copyright: z.string().nullish(),
  custom_disclaimer: z.string().nullish(),
  default_language: z.string(),
  description: z.string().nullish(),
  icon: z.string().nullish(),
  icon_background: z.string().nullish(),
  icon_type: z.string().nullish(),
  icon_url: z.string().nullable(),
  input_placeholder: z.string().nullish(),
  privacy_policy: z.string().nullish(),
  show_workflow_steps: z.boolean(),
  title: z.string(),
  use_icon_as_answer_icon: z.boolean(),
})

/**
 * TextToSpeechRequest
 */
export const zTextToSpeechRequest = z.object({
  message_id: z.string().nullish(),
  streaming: z.boolean().nullish(),
  text: z.string().nullish(),
  voice: z.string().nullish(),
})

/**
 * AudioBinaryResponse
 */
export const zAudioBinaryResponse = z.custom<Blob | File>(
  (value) => value instanceof Blob || value instanceof File,
)

/**
 * WorkflowRunRequest
 */
export const zWorkflowRunRequest = z.object({
  files: z.array(z.unknown()).nullish(),
  inputs: z.record(z.string(), z.unknown()),
})

/**
 * SimpleResultResponse
 */
export const zSimpleResultResponse = z.object({
  result: z.string(),
})

/**
 * TrialDeletedToolResponse
 */
export const zTrialDeletedToolResponse = z.object({
  provider_id: z.string(),
  tool_name: z.string(),
  type: z.string(),
})

export const zTrialIconType = z.enum(['emoji', 'image', 'link'])

export const zTrialAppMode = z.enum([
  'advanced-chat',
  'agent-chat',
  'chat',
  'completion',
  'workflow',
])

/**
 * TrialSiteResponse
 */
export const zTrialSiteResponse = z.object({
  access_token: z.string().nullish(),
  app_base_url: z.string().nullish(),
  chat_color_theme: z.string().nullish(),
  chat_color_theme_inverted: z.boolean().nullish(),
  code: z.string().nullish(),
  copyright: z.string().nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  custom_disclaimer: z.string().nullish(),
  customize_domain: z.string().nullish(),
  customize_token_strategy: z.string().nullish(),
  default_language: z.string(),
  description: z.string().nullish(),
  icon: z.string().nullish(),
  icon_background: z.string().nullish(),
  icon_type: zTrialIconType.nullish(),
  icon_url: z.string().nullish(),
  input_placeholder: z.string().nullish(),
  privacy_policy: z.string().nullish(),
  prompt_public: z.boolean().nullish(),
  show_workflow_steps: z.boolean().nullish(),
  title: z.string(),
  updated_at: z.int().nullish(),
  updated_by: z.string().nullish(),
  use_icon_as_answer_icon: z.boolean().nullish(),
})

/**
 * TrialTagResponse
 */
export const zTrialTagResponse = z.object({
  id: z.string(),
  name: z.string(),
  type: z.string(),
})

/**
 * TrialWorkflowPartialResponse
 */
export const zTrialWorkflowPartialResponse = z.object({
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  id: z.string(),
  updated_at: z.int().nullish(),
  updated_by: z.string().nullish(),
})

/**
 * TrialDatasetResponse
 */
export const zTrialDatasetResponse = z.object({
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  data_source_type: z.string().nullish(),
  description: z.string().nullish(),
  id: z.string(),
  indexing_technique: z.string().nullish(),
  name: z.string(),
  permission: z.string().nullish(),
  permission_keys: z.array(z.string()).optional(),
})

/**
 * TrialDatasetListResponse
 */
export const zTrialDatasetListResponse = z.object({
  data: z.array(zTrialDatasetResponse),
  has_more: z.boolean(),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
})

export const zJsonObject = z.record(z.string(), z.unknown())

/**
 * SystemParameters
 */
export const zSystemParameters = z.object({
  audio_file_size_limit: z.int(),
  file_size_limit: z.int(),
  image_file_size_limit: z.int(),
  video_file_size_limit: z.int(),
  workflow_file_upload_limit: z.int(),
})

/**
 * Parameters
 */
export const zParameters = z.object({
  annotation_reply: zJsonObject,
  file_upload: zJsonObject,
  more_like_this: zJsonObject,
  opening_statement: z.string().nullish(),
  retriever_resource: zJsonObject,
  sensitive_word_avoidance: zJsonObject,
  speech_to_text: zJsonObject,
  suggested_questions: z.array(z.string()),
  suggested_questions_after_answer: zJsonObject,
  system_parameters: zSystemParameters,
  text_to_speech: zJsonObject,
  user_input_form: z.array(zJsonObject),
})

/**
 * WorkflowConversationVariableResponse
 */
export const zWorkflowConversationVariableResponse = z.object({
  description: z.string(),
  id: z.string(),
  name: z.string(),
  value: z.unknown(),
  value_type: z.string(),
})

/**
 * TrialSimpleAccount
 */
export const zTrialSimpleAccount = z.object({
  email: z.string().nullish(),
  id: z.string(),
  name: z.string().nullish(),
})

export const zJsonObject2 = z.record(z.string(), z.unknown())

/**
 * TrialWorkflowResponse
 */
export const zTrialWorkflowResponse = z.object({
  conversation_variables: z.array(zWorkflowConversationVariableResponse).optional(),
  created_at: z.int().nullish(),
  created_by: zTrialSimpleAccount.nullish(),
  environment_variables: z.array(zJsonObject2).optional(),
  features: zJsonObject2.optional(),
  graph: zJsonObject2,
  hash: z.string().nullish(),
  id: z.string(),
  marked_comment: z.string().nullish(),
  marked_name: z.string().nullish(),
  rag_pipeline_variables: z.array(zJsonObject2).optional(),
  tool_published: z.boolean().nullish(),
  updated_at: z.int().nullish(),
  updated_by: zTrialSimpleAccount.nullish(),
  version: z.string().nullish(),
})

/**
 * TrialAppAgentMode
 */
export const zTrialAppAgentMode = z.object({
  enabled: z.boolean().nullish(),
  strategy: z.string().nullish(),
  tools: z.array(zJsonObject2).optional(),
})

/**
 * TrialAppModel
 */
export const zTrialAppModel = z.object({
  completion_params: zJsonObject2.optional(),
  mode: z.string().nullish(),
  name: z.string(),
  provider: z.string(),
})

/**
 * TrialAppModelConfigResponse
 */
export const zTrialAppModelConfigResponse = z.object({
  agent_mode: zTrialAppAgentMode.nullish(),
  annotation_reply: zJsonObject2.nullish(),
  chat_prompt_config: zJsonObject2.nullish(),
  completion_prompt_config: zJsonObject2.nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  dataset_configs: zJsonObject2.nullish(),
  dataset_query_variable: z.string().nullish(),
  external_data_tools: z.array(zJsonObject2).optional(),
  file_upload: zJsonObject2.nullish(),
  model: zTrialAppModel.nullish(),
  more_like_this: zJsonObject2.nullish(),
  opening_statement: z.string().nullish(),
  pre_prompt: z.string().nullish(),
  prompt_type: z.string().nullish(),
  retriever_resource: zJsonObject2.nullish(),
  sensitive_word_avoidance: zJsonObject2.nullish(),
  speech_to_text: zJsonObject2.nullish(),
  suggested_questions: z.array(z.string()).optional(),
  suggested_questions_after_answer: zJsonObject2.nullish(),
  text_to_speech: zJsonObject2.nullish(),
  updated_at: z.int().nullish(),
  updated_by: z.string().nullish(),
  user_input_form: z.array(zJsonObject2).optional(),
})

/**
 * TrialAppDetailResponse
 */
export const zTrialAppDetailResponse = z.object({
  access_mode: z.string().nullish(),
  api_base_url: z.string().nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  deleted_tools: z.array(zTrialDeletedToolResponse).optional(),
  description: z.string().nullish(),
  enable_api: z.boolean(),
  enable_site: z.boolean(),
  icon: z.string().nullish(),
  icon_background: z.string().nullish(),
  icon_type: zTrialIconType.nullish(),
  icon_url: z.string().nullish(),
  id: z.string(),
  max_active_requests: z.int().nullish(),
  mode: zTrialAppMode,
  model_config: zTrialAppModelConfigResponse.nullish(),
  name: z.string(),
  permission_keys: z.array(z.string()).optional(),
  site: zTrialSiteResponse,
  tags: z.array(zTrialTagResponse).optional(),
  updated_at: z.int().nullish(),
  updated_by: z.string().nullish(),
  use_icon_as_answer_icon: z.boolean().nullish(),
  workflow: zTrialWorkflowPartialResponse.nullish(),
})

/**
 * Site
 */
export const zSiteWritable = z.object({
  chat_color_theme: z.string().nullish(),
  chat_color_theme_inverted: z.boolean(),
  copyright: z.string().nullish(),
  custom_disclaimer: z.string().nullish(),
  default_language: z.string(),
  description: z.string().nullish(),
  icon: z.string().nullish(),
  icon_background: z.string().nullish(),
  icon_type: z.string().nullish(),
  input_placeholder: z.string().nullish(),
  privacy_policy: z.string().nullish(),
  show_workflow_steps: z.boolean(),
  title: z.string(),
  use_icon_as_answer_icon: z.boolean(),
})

export const zGetTrialAppsByAppIdPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zGetTrialAppsByAppIdResponse = zTrialAppDetailResponse

export const zPostTrialAppsByAppIdAudioToTextPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zPostTrialAppsByAppIdAudioToTextResponse = zAudioTranscriptResponse

export const zPostTrialAppsByAppIdChatMessagesBody = zChatRequest

export const zPostTrialAppsByAppIdChatMessagesPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zPostTrialAppsByAppIdChatMessagesResponse = z.record(z.string(), z.unknown())

export const zPostTrialAppsByAppIdCompletionMessagesBody = zCompletionRequest

export const zPostTrialAppsByAppIdCompletionMessagesPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zPostTrialAppsByAppIdCompletionMessagesResponse = z.record(z.string(), z.unknown())

export const zGetTrialAppsByAppIdDatasetsPath = z.object({
  app_id: z.uuid(),
})

export const zGetTrialAppsByAppIdDatasetsQuery = z.object({
  ids: z.array(z.string()).optional(),
  limit: z.int().gte(1).optional().default(20),
  page: z.int().gte(1).optional().default(1),
})

/**
 * Success
 */
export const zGetTrialAppsByAppIdDatasetsResponse = zTrialDatasetListResponse

export const zPostTrialAppsByAppIdFilesUploadBody = z.object({
  file: z.custom<Blob | File>((value) => value instanceof Blob || value instanceof File),
  source: z.enum(['datasets']).optional(),
})

export const zPostTrialAppsByAppIdFilesUploadPath = z.object({
  app_id: z.uuid(),
})

/**
 * File uploaded successfully
 */
export const zPostTrialAppsByAppIdFilesUploadResponse = zFileResponse

export const zGetTrialAppsByAppIdMessagesByMessageIdSuggestedQuestionsPath = z.object({
  app_id: z.uuid(),
  message_id: z.uuid(),
})

/**
 * Success
 */
export const zGetTrialAppsByAppIdMessagesByMessageIdSuggestedQuestionsResponse =
  zSuggestedQuestionsResponse

export const zGetTrialAppsByAppIdParametersPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zGetTrialAppsByAppIdParametersResponse = zParameters

export const zPostTrialAppsByAppIdRemoteFilesUploadBody = zRemoteFileUploadPayload

export const zPostTrialAppsByAppIdRemoteFilesUploadPath = z.object({
  app_id: z.uuid(),
})

/**
 * File uploaded successfully
 */
export const zPostTrialAppsByAppIdRemoteFilesUploadResponse = zFileWithSignedUrl

export const zGetTrialAppsByAppIdSitePath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zGetTrialAppsByAppIdSiteResponse = zSite

export const zPostTrialAppsByAppIdTextToAudioBody = zTextToSpeechRequest

export const zPostTrialAppsByAppIdTextToAudioPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zPostTrialAppsByAppIdTextToAudioResponse = zAudioBinaryResponse

export const zGetTrialAppsByAppIdWorkflowsPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zGetTrialAppsByAppIdWorkflowsResponse = zTrialWorkflowResponse

export const zPostTrialAppsByAppIdWorkflowsRunBody = zWorkflowRunRequest

export const zPostTrialAppsByAppIdWorkflowsRunPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zPostTrialAppsByAppIdWorkflowsRunResponse = z.record(z.string(), z.unknown())

export const zPostTrialAppsByAppIdWorkflowsTasksByTaskIdStopPath = z.object({
  app_id: z.uuid(),
  task_id: z.string(),
})

/**
 * Success
 */
export const zPostTrialAppsByAppIdWorkflowsTasksByTaskIdStopResponse = zSimpleResultResponse
