Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
debug.ts247 linesDownload Raw Back to models
1import type { AgentStrategy, ModelModeType, RETRIEVE_TYPE, ToolItem, TtsAutoPlay } from '@/types/app'2import type {3  RerankingModeEnum,4} from '@/models/datasets'5import type { FileUpload } from '@/app/components/base/features/types'6export type Inputs = Record<string, string | number | object>7 8export enum PromptMode {9  simple = 'simple',10  advanced = 'advanced',11}12 13export type PromptItem = {14  role?: PromptRole15  text: string16}17 18export type ChatPromptConfig = {19  prompt: PromptItem[]20}21 22export type ConversationHistoriesRole = {23  user_prefix: string24  assistant_prefix: string25}26export type CompletionPromptConfig = {27  prompt: PromptItem28  conversation_histories_role: ConversationHistoriesRole29}30 31export type BlockStatus = {32  context: boolean33  history: boolean34  query: boolean35}36 37export enum PromptRole {38  system = 'system',39  user = 'user',40  assistant = 'assistant',41}42 43export type PromptVariable = {44  key: string45  name: string46  type: string // "string" | "number" | "select",47  default?: string | number48  required?: boolean49  options?: string[]50  max_length?: number51  is_context_var?: boolean52  enabled?: boolean53  config?: Record<string, any>54  icon?: string55  icon_background?: string56}57 58export type CompletionParams = {59  max_tokens: number60  temperature: number61  top_p: number62  presence_penalty: number63  frequency_penalty: number64  stop?: string[]65}66 67export type ModelId = 'gpt-3.5-turbo' | 'text-davinci-003'68 69export type PromptConfig = {70  prompt_template: string71  prompt_variables: PromptVariable[]72}73 74export type MoreLikeThisConfig = {75  enabled: boolean76}77 78export type SuggestedQuestionsAfterAnswerConfig = MoreLikeThisConfig79 80export type SpeechToTextConfig = MoreLikeThisConfig81 82export type TextToSpeechConfig = {83  enabled: boolean84  voice?: string85  language?: string86  autoPlay?: TtsAutoPlay87}88 89export type CitationConfig = MoreLikeThisConfig90 91export type AnnotationReplyConfig = {92  id: string93  enabled: boolean94  score_threshold: number95  embedding_model: {96    embedding_provider_name: string97    embedding_model_name: string98  }99}100 101export type ModerationContentConfig = {102  enabled: boolean103  preset_response?: string104}105export type ModerationConfig = MoreLikeThisConfig & {106  type?: string107  config?: {108    keywords?: string109    api_based_extension_id?: string110    inputs_config?: ModerationContentConfig111    outputs_config?: ModerationContentConfig112  } & Partial<Record<string, any>>113}114 115export type RetrieverResourceConfig = MoreLikeThisConfig116export type AgentConfig = {117  enabled: boolean118  strategy: AgentStrategy119  max_iteration: number120  tools: ToolItem[]121}122// frontend use. Not the same as backend123export type ModelConfig = {124  provider: string // LLM Provider: for example "OPENAI"125  model_id: string126  mode: ModelModeType127  configs: PromptConfig128  opening_statement: string | null129  more_like_this: MoreLikeThisConfig | null130  suggested_questions: string[] | null131  suggested_questions_after_answer: SuggestedQuestionsAfterAnswerConfig | null132  speech_to_text: SpeechToTextConfig | null133  text_to_speech: TextToSpeechConfig | null134  file_upload: FileUpload | null135  retriever_resource: RetrieverResourceConfig | null136  sensitive_word_avoidance: ModerationConfig | null137  annotation_reply: AnnotationReplyConfig | null138  dataSets: any[]139  agentConfig: AgentConfig140}141export type DatasetConfigItem = {142  enable: boolean143  value: number144}145 146export type DatasetConfigs = {147  retrieval_model: RETRIEVE_TYPE148  reranking_model: {149    reranking_provider_name: string150    reranking_model_name: string151  }152  top_k: number153  score_threshold_enabled: boolean154  score_threshold: number | null | undefined155  datasets: {156    datasets: {157      enabled: boolean158      id: string159    }[]160  }161  reranking_mode?: RerankingModeEnum162  weights?: {163    vector_setting: {164      vector_weight: number165      embedding_provider_name: string166      embedding_model_name: string167    }168    keyword_setting: {169      keyword_weight: number170    }171  }172  reranking_enable?: boolean173}174 175export type DebugRequestBody = {176  inputs: Inputs177  query: string178  completion_params: CompletionParams179  model_config: ModelConfig180}181 182export type DebugResponse = {183  id: string184  answer: string185  created_at: string186}187 188export type DebugResponseStream = {189  id: string190  data: string191  created_at: string192}193 194export type FeedBackRequestBody = {195  message_id: string196  rating: 'like' | 'dislike'197  content?: string198  from_source: 'api' | 'log'199}200 201export type FeedBackResponse = {202  message_id: string203  rating: 'like' | 'dislike'204}205 206// Log session list207export type LogSessionListQuery = {208  keyword?: string209  start?: string // format datetime(YYYY-mm-dd HH:ii)210  end?: string // format datetime(YYYY-mm-dd HH:ii)211  page: number212  limit: number // default 20. 1-100213}214 215export type LogSessionListResponse = {216  data: {217    id: string218    conversation_id: string219    query: string // user's query question220    message: string // prompt send to LLM221    answer: string222    created_at: string223  }[]224  total: number225  page: number226}227 228// log session detail and debug229export type LogSessionDetailResponse = {230  id: string231  conversation_id: string232  model_provider: string233  query: string234  inputs: Record<string, string | number | object>[]235  message: string236  message_tokens: number // number of tokens in message237  answer: string238  answer_tokens: number // number of tokens in answer239  provider_response_latency: number // used time in ms240  from_source: 'api' | 'log'241}242 243export type SavedMessage = {244  id: string245  answer: string246}247