debug.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. export type Inputs = Record<string, string | number | object>
  2. export type PromptVariable = {
  3. key: string,
  4. name: string,
  5. type: string, // "string" | "number" | "select",
  6. default?: string | number,
  7. required: boolean,
  8. options?: string[]
  9. max_length?: number
  10. }
  11. export type CompletionParams = {
  12. max_tokens: number,
  13. temperature: number,
  14. top_p: number,
  15. presence_penalty: number,
  16. frequency_penalty: number,
  17. }
  18. export type ModelId = "gpt-3.5-turbo" | "text-davinci-003"
  19. export type PromptConfig = {
  20. prompt_template: string,
  21. prompt_variables: PromptVariable[],
  22. }
  23. export type MoreLikeThisConfig = {
  24. enabled: boolean
  25. }
  26. export type SuggestedQuestionsAfterAnswerConfig = MoreLikeThisConfig
  27. // frontend use. Not the same as backend
  28. export type ModelConfig = {
  29. provider: string, // LLM Provider: for example "OPENAI"
  30. model_id: string,
  31. configs: PromptConfig
  32. }
  33. export type DebugRequestBody = {
  34. inputs: Inputs,
  35. query: string,
  36. completion_params: CompletionParams,
  37. model_config: ModelConfig
  38. }
  39. export type DebugResponse = {
  40. id: string,
  41. answer: string,
  42. created_at: string,
  43. }
  44. export type DebugResponseStream = {
  45. id: string,
  46. data: string,
  47. created_at: string,
  48. }
  49. export type FeedBackRequestBody = {
  50. message_id: string,
  51. rating: 'like' | 'dislike',
  52. content?: string,
  53. from_source: 'api' | 'log'
  54. }
  55. export type FeedBackResponse = {
  56. message_id: string,
  57. rating: 'like' | 'dislike'
  58. }
  59. // Log session list
  60. export type LogSessionListQuery = {
  61. keyword?: string,
  62. start?: string, // format datetime(YYYY-mm-dd HH:ii)
  63. end?: string, // format datetime(YYYY-mm-dd HH:ii)
  64. page: number,
  65. limit: number, // default 20. 1-100
  66. }
  67. export type LogSessionListResponse = {
  68. data: {
  69. id: string,
  70. conversation_id: string,
  71. query: string, // user's query question
  72. message: string, // prompt send to LLM
  73. answer: string,
  74. creat_at: string,
  75. }[],
  76. total: number,
  77. page: number,
  78. }
  79. // log session detail and debug
  80. export type LogSessionDetailResponse = {
  81. id: string,
  82. cnversation_id: string,
  83. model_provider: string,
  84. query: string,
  85. inputs: Record<string, string | number | object>[],
  86. message: string,
  87. message_tokens: number, // number of tokens in message
  88. answer: string,
  89. answer_tokens: number, // number of tokens in answer
  90. provider_response_latency: number, // used time in ms
  91. from_source: 'api' | 'log',
  92. }
  93. export type SavedMessage = {
  94. id: string,
  95. answer: string
  96. }