log.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import type { Fetcher } from 'swr'
  2. import { get, post } from './base'
  3. import type {
  4. AgentLogDetailRequest,
  5. AgentLogDetailResponse,
  6. AnnotationsCountResponse,
  7. ChatConversationFullDetailResponse,
  8. ChatConversationsRequest,
  9. ChatConversationsResponse,
  10. ChatMessagesRequest,
  11. ChatMessagesResponse,
  12. CompletionConversationFullDetailResponse,
  13. CompletionConversationsRequest,
  14. CompletionConversationsResponse,
  15. ConversationListResponse,
  16. LogMessageAnnotationsRequest,
  17. LogMessageAnnotationsResponse,
  18. LogMessageFeedbacksRequest,
  19. LogMessageFeedbacksResponse,
  20. WorkflowLogsRequest,
  21. WorkflowLogsResponse,
  22. WorkflowRunDetailResponse,
  23. } from '@/models/log'
  24. import type { NodeTracingListResponse } from '@/types/workflow'
  25. export const fetchConversationList: Fetcher<ConversationListResponse, { name: string; appId: string; params?: Record<string, any> }> = ({ appId, params }) => {
  26. return get<ConversationListResponse>(`/console/api/apps/${appId}/messages`, params)
  27. }
  28. // (Text Generation Application) Session List
  29. export const fetchCompletionConversations: Fetcher<CompletionConversationsResponse, { url: string; params?: CompletionConversationsRequest }> = ({ url, params }) => {
  30. return get<CompletionConversationsResponse>(url, { params })
  31. }
  32. // (Text Generation Application) Session Detail
  33. export const fetchCompletionConversationDetail: Fetcher<CompletionConversationFullDetailResponse, { url: string }> = ({ url }) => {
  34. return get<CompletionConversationFullDetailResponse>(url, {})
  35. }
  36. // (Chat Application) Session List
  37. export const fetchChatConversations: Fetcher<ChatConversationsResponse, { url: string; params?: ChatConversationsRequest }> = ({ url, params }) => {
  38. return get<ChatConversationsResponse>(url, { params })
  39. }
  40. // (Chat Application) Session Detail
  41. export const fetchChatConversationDetail: Fetcher<ChatConversationFullDetailResponse, { url: string }> = ({ url }) => {
  42. return get<ChatConversationFullDetailResponse>(url, {})
  43. }
  44. // (Chat Application) Message list in one session
  45. export const fetchChatMessages: Fetcher<ChatMessagesResponse, { url: string; params: ChatMessagesRequest }> = ({ url, params }) => {
  46. return get<ChatMessagesResponse>(url, { params })
  47. }
  48. export const updateLogMessageFeedbacks: Fetcher<LogMessageFeedbacksResponse, { url: string; body: LogMessageFeedbacksRequest }> = ({ url, body }) => {
  49. return post<LogMessageFeedbacksResponse>(url, { body })
  50. }
  51. export const updateLogMessageAnnotations: Fetcher<LogMessageAnnotationsResponse, { url: string; body: LogMessageAnnotationsRequest }> = ({ url, body }) => {
  52. return post<LogMessageAnnotationsResponse>(url, { body })
  53. }
  54. export const fetchAnnotationsCount: Fetcher<AnnotationsCountResponse, { url: string }> = ({ url }) => {
  55. return get<AnnotationsCountResponse>(url)
  56. }
  57. export const fetchWorkflowLogs: Fetcher<WorkflowLogsResponse, { url: string; params?: WorkflowLogsRequest }> = ({ url, params }) => {
  58. return get<WorkflowLogsResponse>(url, { params })
  59. }
  60. export const fetchRunDetail = ({ appID, runID }: { appID: string; runID: string }) => {
  61. return get<WorkflowRunDetailResponse>(`/apps/${appID}/workflow-runs/${runID}`)
  62. }
  63. export const fetchTracingList: Fetcher<NodeTracingListResponse, { url: string }> = ({ url }) => {
  64. return get<NodeTracingListResponse>(url)
  65. }
  66. export const fetchAgentLogDetail = ({ appID, params }: { appID: string; params: AgentLogDetailRequest }) => {
  67. return get<AgentLogDetailResponse>(`/apps/${appID}/agent/logs`, { params })
  68. }