forked from tuvn86/webapp-conversation
feat: init
This commit is contained in:
parent
8acd8f6fbd
commit
97d3a6277d
77 changed files with 5299 additions and 0 deletions
37
service/index.ts
Normal file
37
service/index.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import type { IOnCompleted, IOnData, IOnError } from './base'
|
||||
import { get, post, ssePost } from './base'
|
||||
import type { Feedbacktype } from '@/types/app'
|
||||
|
||||
export const sendChatMessage = async (body: Record<string, any>, { onData, onCompleted, onError }: {
|
||||
onData: IOnData
|
||||
onCompleted: IOnCompleted
|
||||
onError: IOnError
|
||||
}) => {
|
||||
return ssePost('chat-messages', {
|
||||
body: {
|
||||
...body,
|
||||
response_mode: 'streaming',
|
||||
},
|
||||
}, { onData, onCompleted, onError })
|
||||
}
|
||||
|
||||
export const fetchAppInfo = async () => {
|
||||
return get('site')
|
||||
}
|
||||
|
||||
export const fetchConversations = async () => {
|
||||
return get('conversations', { params: { limit: 20, 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 })
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue