Files
MemoryBear/web/src/api/memory.ts
Ke Sun 5b13b4a949 GitHub release (#20)
* feat(web): remove mock data
* feat(knowledgeBase): Refactor document list API and improve polling logic

- Update getDocumentList API to accept kb_id as separate parameter instead of extracting from query object
- Fix parameter name from auto_question to auto_questions in parser config
- Add progress field initialization in document update params
- Improve polling logic to handle both auto-return and manual stay scenarios with proper loading state management
- Add console logging for debugging polling status and document processing
- Reduce polling interval from 5000ms to 3000ms for faster status updates
- Enhance cleanup logic with route change detection to prevent memory leaks
- Add record parameter to progress render function for better data access
- Refactor confirm dialog callbacks to properly manage loading state timing
- Ensure loading indicator displays correctly when user chooses to stay on page

* feat(web): Add Workflow

* feat(web): Workflow

* feat(web): node show id; update reflection engine example

* feat(components): Add markdown editing capability and enhance component styling

- Add editable mode to Markdown component with edit/save/cancel buttons
- Import EditOutlined, SaveOutlined, CloseOutlined icons from ant-design
- Add useState, useRef, useEffect hooks for managing edit state
- Add editable, onContentChange, and onSave props to RbMarkdownProps interface
- Create RbModal component with new index.css stylesheet for modal styling
- Add index.css stylesheet to KnowledgeBase components for consistent styling
- Update i18n translations in en.ts and zh.ts for new UI elements
- Refactor Markdown component handlers to accept and spread additional props
- Update InsertModal and RecallTestResult components for improved UX
- Fix prop spreading in component handlers to maintain compatibility with Ant Design components

* feat(web): Graph user memory update

* feat(web): update routes.json

* fix(web): workflow bug

* fix(web): workflow variable

* fix(web): workflow properties

* feat(web): workflow support lexical editor

* feat(web): workflow support lexical editor

* feat(web): update reflection engine result

* feat(web): workflow's chat support abort output

* fix:git commit

* fix:vite config

* fix:breadcrumbs

* feat(i18n): add document processing confirmation dialog translations

- Add "processingDocuments" translation key for loading state message in English and Chinese
- Add "startUploadConfirmTitle" translation for confirmation dialog title
- Add "startUploadConfirmContent" translation for confirmation dialog description
- Add "returnToList" translation for returning to list page action
- Add "stayOnPage" translation for staying on current page action
- Support user choice to either return to list or stay on page during background document processing

* fix(web): user memory detail

* feat(web): order

* fix:面包屑修改

* feat(web): 1. user memory; 2. update workspace's model config

* feat(web): update zh.ts / en.ts

* fix(web): update user profile

* feat(web): Agent add ai prompt

* feat(web): Agent add ai prompt

* feat(web): add pricing menu

* feat(knowledgeBase): add media file validation and PDF enhancement method selection

- Add i18n translations for file size and duration validation errors in English and Chinese
- Implement media file validation with 256MB size limit and 150-second duration limit
- Add support for audio and video file formats (mp3, mp4, mov, wav) in dataset creation
- Add checkMediaDuration helper function to validate media file duration using HTML5 media API
- Add PDF enhancement method selection dropdown with options (DeepDoc, MinerU, TextLN)
- Change default PDF enhancement setting from disabled to enabled
- Update file type array to include media formats
- Add error messaging for file size and duration validation failures
- Improve UI spacing for file parsing settings section

* feat(knowledgeBase): add media dataset support and improve file handling

- Add media dataset translations in English and Chinese locales
- Add "mediaDataSet" and "uploadMedia" i18n keys for UI labels
- Enable media dataset creation option in Private component by uncommenting menu item
- Import and display image icon for media dataset menu option
- Refactor file ID handling in CreateDataset to support both string and array types
- Improve fileIds initialization logic to handle mixed input types
- Update CreateImageDataset component to use file chunking workflow
- Add navigation to parameter settings step after file upload
- Pass file IDs to dataset creation flow for media processing
- Add message API and navigate hook for improved UX feedback

* fix(knowledgeBase): improve navigation and folder tree refresh logic

- Add path comparison check in breadcrumb navigation to avoid unnecessary route changes when already on target page
- Implement delayed folder tree refresh with setTimeout to ensure state reset completes before refreshing
- Add manual table refresh trigger to ensure data updates after navigation
- Reset expanded keys in FolderTree component during load to ensure consistent state from root directory
- Add expanded keys reset in breadcrumb navigation to prevent stale expansion state
- Improve navigation state handling by using replace flag only when on target path to reduce history stack pollution

* fix:pdfEnhancementEnabled

* feat(web): add tool management

* fix(web): get the parent domain name adaptation IP

* fix(web): Conversation add initialValue

* feat(web): workflow’s Editor Variable support Tag

* fix(web): pricing UI

* feat(web): JSON Tool update

* fix(web): update get llm,chat model list function

* fix(web): time tool / cluster chat

* fix(web): time tool add time zone

* feat(web): neo4j type user memory detail

* fix(web): update parseSchema api param

* feat: workflow add knowledge-retrieval node

* feat(knowledgeBase): enhance file upload and dataset creation with abort support and improved UX

- Add AbortSignal support to uploadFile API for cancellable uploads
- Implement custom onRemove callback in UploadFiles component with confirmation dialog
- Add i18n translations for file removal confirmation and error messages
- Update supported file types documentation to include IMAGE and MEDIA formats
- Improve file removal UI with cursor pointer styling
- Refactor getModelList API to remove unused type parameter
- Add Form import and UploadFile type for better type safety in CreateDataset
- Enhance error handling and user feedback for file operations

* feat(web): MCP add bearer token auth type

* fix(web): UI update

---------

Co-authored-by: zhaoying <yzhao96@best-inc.com>
Co-authored-by: yujiangping <yujiangping@taofen8.com>
Co-authored-by: 赵莹 <zhaoying@redbearai.com>
Co-authored-by: vrhs@163.com <accounts_660b6454a0eb398d3f8d2c76@mail.teambition.com>
2025-12-30 18:37:40 +08:00

206 lines
8.0 KiB
TypeScript

import { request } from '@/utils/request'
import type {
MemoryFormData,
} from '@/views/MemoryManagement/types'
import type {
ConfigForm as ForgetConfigForm
} from '@/views/ForgettingEngine/types'
import type {
ConfigForm as ExtractionConfigForm
} from '@/views/MemoryExtractionEngine/types'
import type {
ConfigForm as EmotionConfig
} from '@/views/EmotionEngine/types'
import type {
ConfigForm as SelfReflectionEngineConfig
} from '@/views/SelfReflectionEngine/types'
import type { TestParams } from '@/views/MemoryConversation'
import type { EndUser } from '@/views/UserMemoryDetail/types'
import { handleSSE, type SSEMessage } from '@/utils/stream'
// 记忆对话
export const readService = (query: TestParams) => {
return request.post('/memory/read_service', query)
}
/****************** 记忆看板 相关接口 *******************************/
// 记忆看板-记忆总量
export const getTotalMemoryCount = () => {
return request.get(`/dashboard/total_memory_count`)
}
// 记忆看板-知识库类型分布
export const getKbTypes = () => {
return request.get(`/memory/stats/types`)
}
// 记忆看板-热门记忆标签
export const getHotMemoryTags = () => {
return request.get(`/memory-storage/analytics/hot_memory_tags`)
}
// 记忆看板-最近活动统计
export const getRecentActivityStats = () => {
return request.get(`/memory-storage/analytics/recent_activity_stats`)
}
// 记忆看板-记忆增长趋势
export const getMemoryIncrement = (limit: number) => {
return request.get(`/dashboard/memory_increment`, { limit })
}
// 记忆看板-API调用趋势
export const getApiTrend = () => {
return request.get(`/dashboard/api_increment`)
}
// 记忆看板-总数据
export const getDashboardData = () => {
return request.get(`/dashboard/dashboard_data`)
}
/*************** end 记忆看板 相关接口 ******************************/
/****************** 用户记忆 相关接口 *******************************/
export const userMemoryListUrl = '/dashboard/end_users'
export const getUserMemoryList = () => {
return request.get(userMemoryListUrl)
}
// 用户记忆-用户记忆总量
export const getTotalEndUsers = () => {
return request.get(`/dashboard/total_end_users`)
}
// 用户记忆-用户详情
export const getUserProfile = (end_user_id: string) => {
return request.get(`/memory/analytics/user_profile`, { end_user_id })
}
// 用户记忆-记忆洞察
export const getMemoryInsightReport = (end_user_id: string) => {
return request.get(`/memory-storage/analytics/memory_insight/report`, { end_user_id })
}
// 用户记忆-用户摘要
export const getUserSummary = (end_user_id: string) => {
return request.get(`/memory-storage/analytics/user_summary`, { end_user_id })
}
// 记忆分类
export const getNodeStatistics = (end_user_id: string) => {
return request.get(`/memory-storage/analytics/node_statistics`, { end_user_id })
}
// 基本信息
export const getEndUserProfile = (end_user_id: string) => {
return request.get(`/memory-storage/read_end_user/profile`, { end_user_id })
}
export const updatedEndUserProfile = (values: EndUser) => {
return request.post(`/memory-storage/updated_end_user/profile`, values)
}
// 用户记忆-关系网络
export const getMemorySearchEdges = (end_user_id: string) => {
return request.get(`/memory-storage/analytics/graph_data`, { end_user_id })
}
// 用户记忆-用户兴趣分布
export const getHotMemoryTagsByUser = (end_user_id: string) => {
return request.get(`/memory/analytics/hot_memory_tags/by_user`, { end_user_id })
}
// 用户记忆-记忆总量
export const getTotalMemoryCountByUser = (end_user_id: string) => {
return request.get(`/memory-storage/search`, { end_user_id })
}
// RAG 用户记忆-记忆总量
export const getTotalRagMemoryCountByUser = (end_user_id: string) => {
return request.get(`/dashboard/current_user_rag_total_num`, { end_user_id })
}
// RAG 用户记忆-用户摘要
export const getChunkSummaryTag = (end_user_id: string) => {
return request.get(`/dashboard/chunk_summary_tag`, { end_user_id })
}
// RAG 用户记忆-记忆洞察
export const getChunkInsight = (end_user_id: string) => {
return request.get(`/dashboard/chunk_insight`, { end_user_id })
}
// RAG 用户记忆-存储内容
export const getRagContent = (end_user_id: string) => {
return request.get(`/dashboard/rag_content`, { end_user_id, limit: 20 })
}
// 情感分布分析
export const getWordCloud = (group_id: string) => {
return request.post(`/memory/emotion/wordcloud`, { group_id, limit: 20 })
}
// 高频情绪关键词
export const getEmotionTags = (group_id: string) => {
return request.post(`/memory/emotion/tags`, { group_id, limit: 20 })
}
// 情绪健康指数
export const getEmotionHealth = (group_id: string) => {
return request.post(`/memory/emotion/health`, { group_id, limit: 20 })
}
// 个性化建议
export const getEmotionSuggestions = (group_id: string) => {
return request.post(`/memory/emotion/suggestions`, { group_id, limit: 20 })
}
export const analyticsRefresh = (end_user_id: string) => {
return request.post('/memory-storage/analytics/generate_cache', { end_user_id })
}
/*************** end 用户记忆 相关接口 ******************************/
/****************** 记忆管理 相关接口 *******************************/
// 记忆管理-获取所有配置
export const memoryConfigListUrl = '/memory-storage/read_all_config'
export const getMemoryConfigList = () => {
return request.get(memoryConfigListUrl)
}
// 记忆管理-创建配置
export const createMemoryConfig = (values: MemoryFormData) => {
return request.post('/memory-storage/create_config', values)
}
// 记忆管理-更新配置
export const updateMemoryConfig = (values: MemoryFormData) => {
return request.post('/memory-storage/update_config', values)
}
// 记忆管理-删除配置
export const deleteMemoryConfig = (config_id: number) => {
return request.delete(`/memory-storage/delete_config?config_id=${config_id}`)
}
// 遗忘引擎-获取配置
export const getMemoryForgetConfig = (config_id: number | string) => {
return request.get('/memory-storage/read_config_forget', { config_id })
}
// 遗忘引擎-更新配置
export const updateMemoryForgetConfig = (values: ForgetConfigForm) => {
return request.post('/memory-storage/update_config_forget', values)
}
// 记忆萃取引擎-获取配置
export const getMemoryExtractionConfig = (config_id: number | string) => {
return request.get('/memory-storage/read_config_extracted', { config_id: config_id })
}
// 记忆萃取引擎-更新配置
export const updateMemoryExtractionConfig = (values: ExtractionConfigForm) => {
return request.post('/memory-storage/update_config_extracted', values)
}
// 记忆萃取引擎-试运行
export const pilotRunMemoryExtractionConfig = (values: { config_id: number | string; dialogue_text: string; }, onMessage?: (data: SSEMessage[]) => void) => {
return handleSSE('/memory-storage/pilot_run', values, onMessage)
}
// 情绪引擎-获取配置
export const getMemoryEmotionConfig = (config_id: number | string) => {
return request.get('/memory/emotion/read_config', { config_id: config_id })
}
// 情绪引擎-更新配置
export const updateMemoryEmotionConfig = (values: EmotionConfig) => {
return request.post('/memory/emotion/updated_config', values)
}
// 反思引擎-获取配置
export const getMemoryReflectionConfig = (config_id: number | string) => {
return request.get('/memory/reflection/configs', { config_id: config_id })
}
// 反思引擎-更新配置
export const updateMemoryReflectionConfig = (values: SelfReflectionEngineConfig) => {
return request.post('/memory/reflection/save', values)
}
// 反思引擎-试运行
export const pilotRunMemoryReflectionConfig = (values: { config_id: number | string; language_type: string; }) => {
return request.get('/memory/reflection/run', values)
}
/*************** end 记忆管理 相关接口 ******************************/
/****************** API参数 相关接口 *******************************/
export const getMemoryApi = () => {
return request.get('/memory/docs/api')
}
/*************** end API参数 相关接口 ******************************/