mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 17:32:27 +08:00
- Replace .eslintrc.json with eslint.config.mjs - Simplify configuration using @antfu/eslint-config - Add necessary ESLint plugin dependencies - Disable overly strict style rules - Set package.json type to module for ESM support - Fix ESLint disable comment format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessageReplace, IOnNodeFinished, IOnNodeStarted, IOnThought, IOnWorkflowFinished, IOnWorkflowStarted } from './base'
|
|
import { get, post, ssePost } from './base'
|
|
import type { Feedbacktype } from '@/types/app'
|
|
|
|
export const sendChatMessage = async (
|
|
body: Record<string, any>,
|
|
{
|
|
onData,
|
|
onCompleted,
|
|
onThought,
|
|
onFile,
|
|
onError,
|
|
getAbortController,
|
|
onMessageEnd,
|
|
onMessageReplace,
|
|
onWorkflowStarted,
|
|
onNodeStarted,
|
|
onNodeFinished,
|
|
onWorkflowFinished,
|
|
}: {
|
|
onData: IOnData
|
|
onCompleted: IOnCompleted
|
|
onFile: IOnFile
|
|
onThought: IOnThought
|
|
onMessageEnd: IOnMessageEnd
|
|
onMessageReplace: IOnMessageReplace
|
|
onError: IOnError
|
|
getAbortController?: (abortController: AbortController) => void
|
|
onWorkflowStarted: IOnWorkflowStarted
|
|
onNodeStarted: IOnNodeStarted
|
|
onNodeFinished: IOnNodeFinished
|
|
onWorkflowFinished: IOnWorkflowFinished
|
|
},
|
|
) => {
|
|
return ssePost('chat-messages', {
|
|
body: {
|
|
...body,
|
|
response_mode: 'streaming',
|
|
},
|
|
}, { onData, onCompleted, onThought, onFile, onError, getAbortController, onMessageEnd, onMessageReplace, onNodeStarted, onWorkflowStarted, onWorkflowFinished, onNodeFinished })
|
|
}
|
|
|
|
export const fetchConversations = async () => {
|
|
return get('conversations', { params: { limit: 100, first_id: '' } })
|
|
}
|
|
|
|
export const fetchChatList = async (conversationId: string) => {
|
|
return get('messages', { params: { conversation_id: conversationId, limit: 20, last_id: '' } })
|
|
}
|
|
|
|
// init value. wait for server update
|
|
export const fetchAppParams = async () => {
|
|
return get('parameters')
|
|
}
|
|
|
|
export const updateFeedback = async ({ url, body }: { url: string, body: Feedbacktype }) => {
|
|
return post(url, { body })
|
|
}
|
|
|
|
export const generationConversationName = async (id: string) => {
|
|
return post(`conversations/${id}/name`, { body: { auto_generate: true } })
|
|
}
|