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

export type ClientOptions = {
  baseUrl: `${string}://${string}/console/api` | (string & {})
}

export type InstalledAppListResponse = {
  installed_apps: Array<InstalledAppResponse>
}

export type InstalledAppCreatePayload = {
  app_id: string
}

export type SimpleMessageResponse = {
  message: string
}

export type InstalledAppUpdatePayload = {
  is_pinned?: boolean | null
}

export type SimpleResultMessageResponse = {
  message: string
  result: string
}

export type AudioTranscriptResponse = {
  text: string
}

export type ChatMessagePayload = {
  conversation_id?: string | null
  files?: Array<unknown> | null
  inputs: {
    [key: string]: unknown
  }
  model_config?: {
    [key: string]: unknown
  }
  parent_message_id?: string | null
  query: string
  response_mode?: 'blocking' | 'streaming'
  retriever_from?: string
}

export type GeneratedAppResponse = JsonValue

export type SimpleResultResponse = {
  result: string
}

export type CompletionMessageExplorePayload = {
  files?: Array<{
    [key: string]: unknown
  }> | null
  inputs: {
    [key: string]: unknown
  }
  query?: string
  response_mode?: 'blocking' | 'streaming' | null
  retriever_from?: string
}

export type ConversationInfiniteScrollPagination = {
  data: Array<SimpleConversation>
  has_more: boolean
  limit: number
}

export type ConversationRenamePayload = {
  auto_generate?: boolean
  name?: string | null
}

export type SimpleConversation = {
  created_at?: number | null
  id: string
  inputs: {
    [key: string]: JsonValue
  }
  introduction?: string | null
  name: string
  status: string
  updated_at?: number | null
}

export type ResultResponse = {
  result: string
}

export type MessageInfiniteScrollPagination = {
  data: Array<MessageListItem>
  has_more: boolean
  limit: number
}

export type MessageFeedbackPayload = {
  content?: string | null
  message_id: string
  rating?: 'dislike' | 'like' | null
}

export type SuggestedQuestionsResponse = {
  data: Array<string>
}

export type ExploreAppMetaResponse = {
  tool_icons?: {
    [key: string]: unknown
  }
}

export type Parameters = {
  annotation_reply: JsonObject
  file_upload: JsonObject
  more_like_this: JsonObject
  opening_statement?: string | null
  retriever_resource: JsonObject
  sensitive_word_avoidance: JsonObject
  speech_to_text: JsonObject
  suggested_questions: Array<string>
  suggested_questions_after_answer: JsonObject
  system_parameters: SystemParameters
  text_to_speech: JsonObject
  user_input_form: Array<JsonObject>
}

export type SavedMessageInfiniteScrollPagination = {
  data: Array<SavedMessageItem>
  has_more: boolean
  limit: number
}

export type SavedMessageCreatePayload = {
  message_id: string
}

export type TextToAudioPayload = {
  message_id?: string | null
  streaming?: boolean | null
  text?: string | null
  voice?: string | null
}

export type AudioBinaryResponse = Blob | File

export type WorkflowRunPayload = {
  files?: Array<{
    [key: string]: unknown
  }> | null
  inputs: {
    [key: string]: unknown
  }
}

export type InstalledAppResponse = {
  app: InstalledAppInfoResponse
  app_owner_tenant_id: string
  editable: boolean
  id: string
  is_pinned: boolean
  last_used_at?: number | null
  uninstallable: boolean
}

export type JsonValue
  = | string
    | number
    | number
    | boolean
    | {
      [key: string]: unknown
    }
    | Array<unknown>
    | null

export type MessageListItem = {
  agent_thoughts: Array<AgentThought>
  answer: string
  conversation_id: string
  created_at?: number | null
  error?: string | null
  extra_contents: Array<HumanInputContent>
  feedback?: SimpleFeedback | null
  id: string
  inputs: {
    [key: string]: JsonValueType
  }
  message_files: Array<MessageFile>
  parent_message_id?: string | null
  query: string
  retriever_resources: Array<RetrieverResource>
  status: string
}

export type JsonObject = {
  [key: string]: unknown
}

export type SystemParameters = {
  audio_file_size_limit: number
  file_size_limit: number
  image_file_size_limit: number
  video_file_size_limit: number
  workflow_file_upload_limit: number
}

export type SavedMessageItem = {
  answer: string
  created_at?: number | null
  feedback?: SimpleFeedback | null
  id: string
  inputs: {
    [key: string]: JsonValueType
  }
  message_files: Array<MessageFile>
  query: string
}

export type InstalledAppInfoResponse = {
  icon?: string | null
  icon_background?: string | null
  icon_type?: string | null
  id: string
  mode?: string | null
  name?: string | null
  use_icon_as_answer_icon?: boolean | null
}

export type AgentThought = {
  chain_id?: string | null
  created_at?: number | null
  files: Array<string>
  id: string
  message_chain_id?: string | null
  message_id: string
  observation?: string | null
  position: number
  thought?: string | null
  tool?: string | null
  tool_input?: string | null
  tool_labels: JsonValue
}

export type HumanInputContent = {
  form_definition?: HumanInputFormDefinition | null
  form_submission_data?: HumanInputFormSubmissionData | null
  submitted: boolean
  type?: ExecutionContentType
  workflow_run_id: string
}

export type SimpleFeedback = {
  rating?: string | null
}

export type JsonValueType = unknown

export type MessageFile = {
  belongs_to?: string | null
  filename: string
  id: string
  mime_type?: string | null
  size?: number | null
  transfer_method: string
  type: string
  upload_file_id?: string | null
  url?: string | null
}

export type RetrieverResource = {
  content?: string | null
  created_at?: number | null
  data_source_type?: string | null
  dataset_id?: string | null
  dataset_name?: string | null
  document_id?: string | null
  document_name?: string | null
  hit_count?: number | null
  id?: string
  index_node_hash?: string | null
  message_id?: string
  position: number
  score?: number | null
  segment_id?: string | null
  segment_position?: number | null
  summary?: string | null
  word_count?: number | null
}

export type HumanInputFormDefinition = {
  actions?: Array<UserActionConfig>
  display_in_ui?: boolean
  expiration_time: number
  form_content: string
  form_id: string
  form_token?: string | null
  inputs?: Array<FormInputConfig>
  node_id: string
  node_title: string
  resolved_default_values?: {
    [key: string]: unknown
  }
}

export type HumanInputFormSubmissionData = {
  action_id: string
  action_text: string
  node_id: string
  node_title: string
  rendered_content: string
  submitted_data?: {
    [key: string]: JsonValue2
  } | null
}

export type ExecutionContentType = 'human_input'

export type UserActionConfig = {
  button_style?: ButtonStyle
  id: string
  title: string
}

export type FormInputConfig
  = | ({
    type: 'paragraph'
  } & ParagraphInputConfig)
  | ({
    type: 'select'
  } & SelectInputConfig)
  | ({
    type: 'file'
  } & FileInputConfig)
  | ({
    type: 'file-list'
  } & FileListInputConfig)

export type JsonValue2 = unknown

export type ButtonStyle = 'accent' | 'default' | 'ghost' | 'primary'

export type ParagraphInputConfig = {
  default?: StringSource | null
  output_variable_name: string
  type?: 'paragraph'
}

export type SelectInputConfig = {
  option_source: StringListSource
  output_variable_name: string
  type?: 'select'
}

export type FileInputConfig = {
  allowed_file_extensions?: Array<string>
  allowed_file_types?: Array<FileType>
  allowed_file_upload_methods?: Array<FileTransferMethod>
  output_variable_name: string
  type?: 'file'
}

export type FileListInputConfig = {
  allowed_file_extensions?: Array<string>
  allowed_file_types?: Array<FileType>
  allowed_file_upload_methods?: Array<FileTransferMethod>
  number_limits?: number
  output_variable_name: string
  type?: 'file-list'
}

export type StringSource = {
  selector?: Array<string>
  type: ValueSourceType
  value?: string
}

export type StringListSource = {
  selector?: Array<string>
  type: ValueSourceType
  value?: Array<string>
}

export type FileType = 'audio' | 'custom' | 'document' | 'image' | 'video'

export type FileTransferMethod = 'datasource_file' | 'local_file' | 'remote_url' | 'tool_file'

export type ValueSourceType = 'constant' | 'variable'

export type GetInstalledAppsData = {
  body?: never
  path?: never
  query?: {
    app_id?: string
  }
  url: '/installed-apps'
}

export type GetInstalledAppsResponses = {
  200: InstalledAppListResponse
}

export type GetInstalledAppsResponse = GetInstalledAppsResponses[keyof GetInstalledAppsResponses]

export type PostInstalledAppsData = {
  body: InstalledAppCreatePayload
  path?: never
  query?: never
  url: '/installed-apps'
}

export type PostInstalledAppsResponses = {
  200: SimpleMessageResponse
}

export type PostInstalledAppsResponse = PostInstalledAppsResponses[keyof PostInstalledAppsResponses]

export type DeleteInstalledAppsByInstalledAppIdData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}'
}

export type DeleteInstalledAppsByInstalledAppIdResponses = {
  204: void
}

export type DeleteInstalledAppsByInstalledAppIdResponse
  = DeleteInstalledAppsByInstalledAppIdResponses[keyof DeleteInstalledAppsByInstalledAppIdResponses]

export type PatchInstalledAppsByInstalledAppIdData = {
  body: InstalledAppUpdatePayload
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}'
}

export type PatchInstalledAppsByInstalledAppIdResponses = {
  200: SimpleResultMessageResponse
}

export type PatchInstalledAppsByInstalledAppIdResponse
  = PatchInstalledAppsByInstalledAppIdResponses[keyof PatchInstalledAppsByInstalledAppIdResponses]

export type PostInstalledAppsByInstalledAppIdAudioToTextData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/audio-to-text'
}

export type PostInstalledAppsByInstalledAppIdAudioToTextResponses = {
  200: AudioTranscriptResponse
}

export type PostInstalledAppsByInstalledAppIdAudioToTextResponse
  = PostInstalledAppsByInstalledAppIdAudioToTextResponses[keyof PostInstalledAppsByInstalledAppIdAudioToTextResponses]

export type PostInstalledAppsByInstalledAppIdChatMessagesData = {
  body: ChatMessagePayload
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/chat-messages'
}

export type PostInstalledAppsByInstalledAppIdChatMessagesResponses = {
  200: GeneratedAppResponse
}

export type PostInstalledAppsByInstalledAppIdChatMessagesResponse
  = PostInstalledAppsByInstalledAppIdChatMessagesResponses[keyof PostInstalledAppsByInstalledAppIdChatMessagesResponses]

export type PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopData = {
  body?: never
  path: {
    installed_app_id: string
    task_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/chat-messages/{task_id}/stop'
}

export type PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponses = {
  200: SimpleResultResponse
}

export type PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponse
  = PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponses[keyof PostInstalledAppsByInstalledAppIdChatMessagesByTaskIdStopResponses]

export type PostInstalledAppsByInstalledAppIdCompletionMessagesData = {
  body: CompletionMessageExplorePayload
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/completion-messages'
}

export type PostInstalledAppsByInstalledAppIdCompletionMessagesResponses = {
  200: GeneratedAppResponse
}

export type PostInstalledAppsByInstalledAppIdCompletionMessagesResponse
  = PostInstalledAppsByInstalledAppIdCompletionMessagesResponses[keyof PostInstalledAppsByInstalledAppIdCompletionMessagesResponses]

export type PostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopData = {
  body?: never
  path: {
    installed_app_id: string
    task_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/completion-messages/{task_id}/stop'
}

export type PostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopResponses = {
  200: SimpleResultResponse
}

export type PostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopResponse
  = PostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopResponses[keyof PostInstalledAppsByInstalledAppIdCompletionMessagesByTaskIdStopResponses]

export type GetInstalledAppsByInstalledAppIdConversationsData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query?: {
    last_id?: string
    limit?: number
    pinned?: boolean
  }
  url: '/installed-apps/{installed_app_id}/conversations'
}

export type GetInstalledAppsByInstalledAppIdConversationsResponses = {
  200: ConversationInfiniteScrollPagination
}

export type GetInstalledAppsByInstalledAppIdConversationsResponse
  = GetInstalledAppsByInstalledAppIdConversationsResponses[keyof GetInstalledAppsByInstalledAppIdConversationsResponses]

export type DeleteInstalledAppsByInstalledAppIdConversationsByCIdData = {
  body?: never
  path: {
    c_id: string
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/conversations/{c_id}'
}

export type DeleteInstalledAppsByInstalledAppIdConversationsByCIdResponses = {
  204: void
}

export type DeleteInstalledAppsByInstalledAppIdConversationsByCIdResponse
  = DeleteInstalledAppsByInstalledAppIdConversationsByCIdResponses[keyof DeleteInstalledAppsByInstalledAppIdConversationsByCIdResponses]

export type PostInstalledAppsByInstalledAppIdConversationsByCIdNameData = {
  body: ConversationRenamePayload
  path: {
    c_id: string
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/conversations/{c_id}/name'
}

export type PostInstalledAppsByInstalledAppIdConversationsByCIdNameResponses = {
  200: SimpleConversation
}

export type PostInstalledAppsByInstalledAppIdConversationsByCIdNameResponse
  = PostInstalledAppsByInstalledAppIdConversationsByCIdNameResponses[keyof PostInstalledAppsByInstalledAppIdConversationsByCIdNameResponses]

export type PatchInstalledAppsByInstalledAppIdConversationsByCIdPinData = {
  body?: never
  path: {
    c_id: string
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/conversations/{c_id}/pin'
}

export type PatchInstalledAppsByInstalledAppIdConversationsByCIdPinResponses = {
  200: ResultResponse
}

export type PatchInstalledAppsByInstalledAppIdConversationsByCIdPinResponse
  = PatchInstalledAppsByInstalledAppIdConversationsByCIdPinResponses[keyof PatchInstalledAppsByInstalledAppIdConversationsByCIdPinResponses]

export type PatchInstalledAppsByInstalledAppIdConversationsByCIdUnpinData = {
  body?: never
  path: {
    c_id: string
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/conversations/{c_id}/unpin'
}

export type PatchInstalledAppsByInstalledAppIdConversationsByCIdUnpinResponses = {
  200: ResultResponse
}

export type PatchInstalledAppsByInstalledAppIdConversationsByCIdUnpinResponse
  = PatchInstalledAppsByInstalledAppIdConversationsByCIdUnpinResponses[keyof PatchInstalledAppsByInstalledAppIdConversationsByCIdUnpinResponses]

export type GetInstalledAppsByInstalledAppIdMessagesData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query: {
    conversation_id: string
    first_id?: string
    limit?: number
  }
  url: '/installed-apps/{installed_app_id}/messages'
}

export type GetInstalledAppsByInstalledAppIdMessagesResponses = {
  200: MessageInfiniteScrollPagination
}

export type GetInstalledAppsByInstalledAppIdMessagesResponse
  = GetInstalledAppsByInstalledAppIdMessagesResponses[keyof GetInstalledAppsByInstalledAppIdMessagesResponses]

export type PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksData = {
  body: MessageFeedbackPayload
  path: {
    installed_app_id: string
    message_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/messages/{message_id}/feedbacks'
}

export type PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponses = {
  200: ResultResponse
}

export type PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponse
  = PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponses[keyof PostInstalledAppsByInstalledAppIdMessagesByMessageIdFeedbacksResponses]

export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisData = {
  body?: never
  path: {
    installed_app_id: string
    message_id: string
  }
  query: {
    response_mode: 'blocking' | 'streaming'
  }
  url: '/installed-apps/{installed_app_id}/messages/{message_id}/more-like-this'
}

export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponses = {
  200: GeneratedAppResponse
}

export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponse
  = GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponses[keyof GetInstalledAppsByInstalledAppIdMessagesByMessageIdMoreLikeThisResponses]

export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsData = {
  body?: never
  path: {
    installed_app_id: string
    message_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/messages/{message_id}/suggested-questions'
}

export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsResponses = {
  200: SuggestedQuestionsResponse
}

export type GetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsResponse
  = GetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsResponses[keyof GetInstalledAppsByInstalledAppIdMessagesByMessageIdSuggestedQuestionsResponses]

export type GetInstalledAppsByInstalledAppIdMetaData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/meta'
}

export type GetInstalledAppsByInstalledAppIdMetaResponses = {
  200: ExploreAppMetaResponse
}

export type GetInstalledAppsByInstalledAppIdMetaResponse
  = GetInstalledAppsByInstalledAppIdMetaResponses[keyof GetInstalledAppsByInstalledAppIdMetaResponses]

export type GetInstalledAppsByInstalledAppIdParametersData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/parameters'
}

export type GetInstalledAppsByInstalledAppIdParametersResponses = {
  200: Parameters
}

export type GetInstalledAppsByInstalledAppIdParametersResponse
  = GetInstalledAppsByInstalledAppIdParametersResponses[keyof GetInstalledAppsByInstalledAppIdParametersResponses]

export type GetInstalledAppsByInstalledAppIdSavedMessagesData = {
  body?: never
  path: {
    installed_app_id: string
  }
  query?: {
    last_id?: string
    limit?: number
  }
  url: '/installed-apps/{installed_app_id}/saved-messages'
}

export type GetInstalledAppsByInstalledAppIdSavedMessagesResponses = {
  200: SavedMessageInfiniteScrollPagination
}

export type GetInstalledAppsByInstalledAppIdSavedMessagesResponse
  = GetInstalledAppsByInstalledAppIdSavedMessagesResponses[keyof GetInstalledAppsByInstalledAppIdSavedMessagesResponses]

export type PostInstalledAppsByInstalledAppIdSavedMessagesData = {
  body: SavedMessageCreatePayload
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/saved-messages'
}

export type PostInstalledAppsByInstalledAppIdSavedMessagesResponses = {
  200: ResultResponse
}

export type PostInstalledAppsByInstalledAppIdSavedMessagesResponse
  = PostInstalledAppsByInstalledAppIdSavedMessagesResponses[keyof PostInstalledAppsByInstalledAppIdSavedMessagesResponses]

export type DeleteInstalledAppsByInstalledAppIdSavedMessagesByMessageIdData = {
  body?: never
  path: {
    installed_app_id: string
    message_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/saved-messages/{message_id}'
}

export type DeleteInstalledAppsByInstalledAppIdSavedMessagesByMessageIdResponses = {
  204: void
}

export type DeleteInstalledAppsByInstalledAppIdSavedMessagesByMessageIdResponse
  = DeleteInstalledAppsByInstalledAppIdSavedMessagesByMessageIdResponses[keyof DeleteInstalledAppsByInstalledAppIdSavedMessagesByMessageIdResponses]

export type PostInstalledAppsByInstalledAppIdTextToAudioData = {
  body: TextToAudioPayload
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/text-to-audio'
}

export type PostInstalledAppsByInstalledAppIdTextToAudioResponses = {
  200: AudioBinaryResponse
}

export type PostInstalledAppsByInstalledAppIdTextToAudioResponse
  = PostInstalledAppsByInstalledAppIdTextToAudioResponses[keyof PostInstalledAppsByInstalledAppIdTextToAudioResponses]

export type PostInstalledAppsByInstalledAppIdWorkflowsRunData = {
  body: WorkflowRunPayload
  path: {
    installed_app_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/workflows/run'
}

export type PostInstalledAppsByInstalledAppIdWorkflowsRunResponses = {
  200: GeneratedAppResponse
}

export type PostInstalledAppsByInstalledAppIdWorkflowsRunResponse
  = PostInstalledAppsByInstalledAppIdWorkflowsRunResponses[keyof PostInstalledAppsByInstalledAppIdWorkflowsRunResponses]

export type PostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopData = {
  body?: never
  path: {
    installed_app_id: string
    task_id: string
  }
  query?: never
  url: '/installed-apps/{installed_app_id}/workflows/tasks/{task_id}/stop'
}

export type PostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopResponses = {
  200: SimpleResultResponse
}

export type PostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopResponse
  = PostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopResponses[keyof PostInstalledAppsByInstalledAppIdWorkflowsTasksByTaskIdStopResponses]
