mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: implement memo chat frontend (#1938)
* feat: implment backend function * feat: implment frontend component * stash * eslint * eslint * eslint * delete node * stash * refactor the style * eslint * eslint * eslint * fix build error * add dep * Update web/src/components/MemosChat/ConversationTab.tsx Co-authored-by: boojack <stevenlgtm@gmail.com> * Update web/src/components/MemosChat/ConversationTab.tsx Co-authored-by: boojack <stevenlgtm@gmail.com> * feat: change the name * disable for vistor --------- Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import axios from "axios";
|
||||
import { fetchEventSource } from "@microsoft/fetch-event-source";
|
||||
import { Message } from "@/store/zustand/message";
|
||||
|
||||
export function getSystemStatus() {
|
||||
return axios.get<SystemStatus>("/api/v1/status");
|
||||
@ -133,6 +135,31 @@ export function unpinMemo(memoId: MemoId) {
|
||||
export function deleteMemo(memoId: MemoId) {
|
||||
return axios.delete(`/api/v1/memo/${memoId}`);
|
||||
}
|
||||
export function checkOpenAIEnabled() {
|
||||
return axios.get<boolean>(`/api/openai/enabled`);
|
||||
}
|
||||
|
||||
export async function chatStreaming(messageList: Array<Message>, onmessage: any, onclose: any) {
|
||||
await fetchEventSource("/api/v1/openai/chat-streaming", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(messageList),
|
||||
async onopen() {
|
||||
// to do nth
|
||||
},
|
||||
onmessage(event: any) {
|
||||
onmessage(event);
|
||||
},
|
||||
onclose() {
|
||||
onclose();
|
||||
},
|
||||
onerror(error: any) {
|
||||
console.log("error", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function getShortcutList(shortcutFind?: ShortcutFind) {
|
||||
const queryList = [];
|
||||
|
Reference in New Issue
Block a user