Explorar el Código

feat: support GPT-4o #771 and hide the add button when the folder is a knowledge base (#775)

### What problem does this PR solve?

feat: support GPT-4o  #771 

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
tags/v0.6.0
balibabu hace 1 año
padre
commit
234afb25d8
No account linked to committer's email address
Se han modificado 6 ficheros con 4143 adiciones y 2186 borrados
  1. 3
    1
      web/.umirc.ts
  2. 4070
    2182
      web/package-lock.json
  3. 1
    1
      web/package.json
  4. 4
    2
      web/src/hooks/llmHooks.ts
  5. 64
    0
      web/src/hooks/logicHooks.ts
  6. 1
    0
      web/src/pages/chat/hooks.ts

+ 3
- 1
web/.umirc.ts Ver fichero

@@ -30,8 +30,10 @@ export default defineConfig({
copy: ['src/conf.json'],
proxy: {
'/v1': {
target: 'http://123.60.95.134:9380/',
target: '',
changeOrigin: true,
ws: true,
logger: console,
// pathRewrite: { '^/v1': '/v1' },
},
},

+ 4070
- 2182
web/package-lock.json
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 1
- 1
web/package.json Ver fichero

@@ -3,7 +3,7 @@
"author": "zhaofengchao <13723060510@163.com>",
"scripts": {
"build": "umi build",
"dev": "cross-env PORT=9200 umi dev",
"dev": "cross-env PORT=9200 UMI_DEV_SERVER_COMPRESS=none umi dev",
"postinstall": "umi setup",
"lint": "umi lint --eslint-only",
"setup": "umi setup",

+ 4
- 2
web/src/hooks/llmHooks.ts Ver fichero

@@ -67,13 +67,15 @@ export const useSelectLlmOptionsByModelType = () => {
const groupOptionsByModelType = (modelType: LlmModelType) => {
return Object.entries(llmInfo)
.filter(([, value]) =>
modelType ? value.some((x) => x.model_type === modelType) : true,
modelType ? value.some((x) => x.model_type.includes(modelType)) : true,
)
.map(([key, value]) => {
return {
label: key,
options: value
.filter((x) => (modelType ? x.model_type === modelType : true))
.filter((x) =>
modelType ? x.model_type.includes(modelType) : true,
)
.map((x) => ({
label: x.llm_name,
value: x.llm_name,

+ 64
- 0
web/src/hooks/logicHooks.ts Ver fichero

@@ -1,7 +1,11 @@
import { Authorization } from '@/constants/authorization';
import { LanguageTranslationMap } from '@/constants/common';
import { Pagination } from '@/interfaces/common';
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import api from '@/utils/api';
import authorizationUtil from '@/utils/authorizationUtil';
import { getSearchValue } from '@/utils/commonUtil';
import { PaginationProps } from 'antd';
import axios from 'axios';
import { useCallback, useEffect, useMemo, useState } from 'react';
@@ -133,3 +137,63 @@ export const useFetchAppConf = () => {

return appConf;
};

export const useConnectWithSse = (url: string) => {
const [content, setContent] = useState<string>('');

const connect = useCallback(() => {
const source = new EventSource(
url || '/sse/createSseEmitter?clientId=123456',
);

source.onopen = function () {
console.log('Connection to the server was opened.');
};

source.onmessage = function (event: any) {
setContent(event.data);
};

source.onerror = function (error) {
console.error('Error occurred:', error);
};
}, [url]);

return { connect, content };
};

export const useConnectWithSseNext = () => {
const [content, setContent] = useState<string>('');
const sharedId = getSearchValue('shared_id');
const authorization = sharedId
? 'Bearer ' + sharedId
: authorizationUtil.getAuthorization();
const send = useCallback(
async (body: any) => {
const response = await fetch(api.completeConversation, {
method: 'POST',
headers: {
[Authorization]: authorization,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
const reader = response?.body
?.pipeThrough(new TextDecoderStream())
.getReader();

// const reader = response.body.getReader();

while (true) {
const { value, done } = await reader?.read();
console.log('Received', value);
setContent(value);
if (done) break;
}
return response;
},
[authorization],
);

return { send, content };
};

+ 1
- 0
web/src/pages/chat/hooks.ts Ver fichero

@@ -518,6 +518,7 @@ export const useSendMessage = (
const completeConversation = useCompleteConversation();

const { handleClickConversation } = useClickConversationCard();
// const { send } = useConnectWithSseNext();

const sendMessage = useCallback(
async (message: string, id?: string) => {

Cargando…
Cancelar
Guardar