feat(model):multi llm switch (#576)

1.multi llm switch
2.web page refactor
This commit is contained in:
FangYin Cheng 2023-09-13 20:33:18 +08:00 committed by GitHub
commit 4854cbaefd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
122 changed files with 586 additions and 569 deletions

View File

@ -1,16 +1,16 @@
autodoc_pydantic
myst_parser
nbsphinx==0.8.9
sphinx==4.5.0
nbsphinx
sphinx
recommonmark
sphinx_intl
sphinx-autobuild==2021.3.14
sphinx-autobuild
sphinx_book_theme
sphinx_rtd_theme==1.0.0
sphinx-typlog-theme==0.8.0
sphinx_rtd_theme
sphinx-typlog-theme
sphinx-panels
toml
myst_nb
sphinx_copybutton
pydata-sphinx-theme==0.13.1
pydata-sphinx-theme
furo

View File

@ -149,6 +149,7 @@ async def dialogue_list(user_id: str = None):
conv_uid = item.get("conv_uid")
summary = item.get("summary")
chat_mode = item.get("chat_mode")
model_name = item.get("model_name", CFG.LLM_MODEL)
messages = json.loads(item.get("messages"))
last_round = max(messages, key=lambda x: x["chat_order"])
@ -160,6 +161,7 @@ async def dialogue_list(user_id: str = None):
conv_uid=conv_uid,
user_input=summary,
chat_mode=chat_mode,
model_name=model_name,
select_param=select_param,
)
dialogues.append(conv_vo)
@ -215,8 +217,10 @@ async def params_list(chat_mode: str = ChatScene.ChatNormal.value()):
@router.post("/v1/chat/mode/params/file/load")
async def params_load(conv_uid: str, chat_mode: str, doc_file: UploadFile = File(...)):
print(f"params_load: {conv_uid},{chat_mode}")
async def params_load(
conv_uid: str, chat_mode: str, model_name: str, doc_file: UploadFile = File(...)
):
print(f"params_load: {conv_uid},{chat_mode},{model_name}")
try:
if doc_file:
## file save
@ -235,7 +239,10 @@ async def params_load(conv_uid: str, chat_mode: str, doc_file: UploadFile = File
)
## chat prepare
dialogue = ConversationVo(
conv_uid=conv_uid, chat_mode=chat_mode, select_param=doc_file.filename
conv_uid=conv_uid,
chat_mode=chat_mode,
select_param=doc_file.filename,
model_name=model_name,
)
chat: BaseChat = get_chat_instance(dialogue)
resp = await chat.prepare()
@ -259,8 +266,11 @@ def get_hist_messages(conv_uid: str):
history_messages: List[OnceConversation] = history_mem.get_messages()
if history_messages:
for once in history_messages:
print(f"once:{once}")
model_name = once.get("model_name", CFG.LLM_MODEL)
once_message_vos = [
message2Vo(element, once["chat_order"]) for element in once["messages"]
message2Vo(element, once["chat_order"], model_name)
for element in once["messages"]
]
message_vos.extend(once_message_vos)
return message_vos
@ -287,15 +297,19 @@ def get_chat_instance(dialogue: ConversationVo = Body()) -> BaseChat:
chat_param = {
"chat_session_id": dialogue.conv_uid,
"user_input": dialogue.user_input,
"current_user_input": dialogue.user_input,
"select_param": dialogue.select_param,
"model_name": dialogue.model_name,
}
chat: BaseChat = CHAT_FACTORY.get_implementation(dialogue.chat_mode, **chat_param)
chat: BaseChat = CHAT_FACTORY.get_implementation(
dialogue.chat_mode, **{"chat_param": chat_param}
)
return chat
@router.post("/v1/chat/prepare")
async def chat_prepare(dialogue: ConversationVo = Body()):
# dialogue.model_name = CFG.LLM_MODEL
logger.info(f"chat_prepare:{dialogue}")
## check conv_uid
chat: BaseChat = get_chat_instance(dialogue)
@ -307,7 +321,9 @@ async def chat_prepare(dialogue: ConversationVo = Body()):
@router.post("/v1/chat/completions")
async def chat_completions(dialogue: ConversationVo = Body()):
print(f"chat_completions:{dialogue.chat_mode},{dialogue.select_param}")
print(
f"chat_completions:{dialogue.chat_mode},{dialogue.select_param},{dialogue.model_name}"
)
chat: BaseChat = get_chat_instance(dialogue)
# background_tasks = BackgroundTasks()
# background_tasks.add_task(release_model_semaphore)
@ -332,6 +348,30 @@ async def chat_completions(dialogue: ConversationVo = Body()):
)
@router.get("/v1/model/types")
async def model_types(request: Request):
print(f"/controller/model/types")
try:
import httpx
async with httpx.AsyncClient() as client:
base_url = request.base_url
response = await client.get(
f"{base_url}api/controller/models?healthy_only=true",
)
types = set()
if response.status_code == 200:
models = json.loads(response.text)
for model in models:
worker_type = model["model_name"].split("@")[1]
if worker_type == "llm":
types.add(model["model_name"].split("@")[0])
return Result.succ(list(types))
except Exception as e:
return Result.faild(code="E000X", msg=f"controller model types error {e}")
async def no_stream_generator(chat):
msg = await chat.nostream_call()
msg = msg.replace("\n", "\\n")
@ -356,7 +396,10 @@ async def stream_generator(chat):
chat.memory.append(chat.current_message)
def message2Vo(message: dict, order) -> MessageVo:
def message2Vo(message: dict, order, model_name) -> MessageVo:
return MessageVo(
role=message["type"], context=message["data"]["content"], order=order
role=message["type"],
context=message["data"]["content"],
order=order,
model_name=model_name,
)

View File

@ -54,6 +54,10 @@ class ConversationVo(BaseModel):
chat scene select param
"""
select_param: str = None
"""
llm model name
"""
model_name: str = None
class MessageVo(BaseModel):
@ -74,3 +78,8 @@ class MessageVo(BaseModel):
time the current message was sent
"""
time_stamp: Any = None
"""
model_name
"""
model_name: str

View File

@ -2,7 +2,7 @@ import datetime
import traceback
import warnings
from abc import ABC, abstractmethod
from typing import Any, List
from typing import Any, List, Dict
from pilot.configs.config import Config
from pilot.configs.model_config import LOGDIR
@ -32,13 +32,13 @@ class BaseChat(ABC):
arbitrary_types_allowed = True
def __init__(
self, chat_mode, chat_session_id, current_user_input, select_param: Any = None
):
self.chat_session_id = chat_session_id
self.chat_mode = chat_mode
self.current_user_input: str = current_user_input
self.llm_model = CFG.LLM_MODEL
def __init__(self, chat_param: Dict):
self.chat_session_id = chat_param["chat_session_id"]
self.chat_mode = chat_param["chat_mode"]
self.current_user_input: str = chat_param["current_user_input"]
self.llm_model = (
chat_param["model_name"] if chat_param["model_name"] else CFG.LLM_MODEL
)
self.llm_echo = False
### load prompt template
@ -55,14 +55,17 @@ class BaseChat(ABC):
)
### can configurable storage methods
self.memory = DuckdbHistoryMemory(chat_session_id)
self.memory = DuckdbHistoryMemory(chat_param["chat_session_id"])
self.history_message: List[OnceConversation] = self.memory.messages()
self.current_message: OnceConversation = OnceConversation(chat_mode.value())
if select_param:
if len(chat_mode.param_types()) > 0:
self.current_message.param_type = chat_mode.param_types()[0]
self.current_message.param_value = select_param
self.current_message: OnceConversation = OnceConversation(
self.chat_mode.value()
)
self.current_message.model_name = self.llm_model
if chat_param["select_param"]:
if len(self.chat_mode.param_types()) > 0:
self.current_message.param_type = self.chat_mode.param_types()[0]
self.current_message.param_value = chat_param["select_param"]
self.current_tokens_used: int = 0
class Config:

View File

@ -1,7 +1,7 @@
import json
import os
import uuid
from typing import List
from typing import List, Dict
from pilot.scene.base_chat import BaseChat
from pilot.scene.base import ChatScene
@ -21,30 +21,20 @@ class ChatDashboard(BaseChat):
report_name: str
"""Number of results to return from the query"""
def __init__(
self,
chat_session_id,
user_input,
select_param: str = "",
report_name: str = "report",
):
def __init__(self, chat_param: Dict):
""" """
self.db_name = select_param
super().__init__(
chat_mode=ChatScene.ChatDashboard,
chat_session_id=chat_session_id,
current_user_input=user_input,
select_param=self.db_name,
)
self.db_name = chat_param["select_param"]
chat_param["chat_mode"] = ChatScene.ChatDashboard
super().__init__(chat_param=chat_param)
if not self.db_name:
raise ValueError(f"{ChatScene.ChatDashboard.value} mode should choose db!")
self.db_name = self.db_name
self.report_name = report_name
self.report_name = chat_param["report_name"] or "report"
self.database = CFG.LOCAL_DB_MANAGE.get_connect(self.db_name)
self.top_k: int = 5
self.dashboard_template = self.__load_dashboard_template(report_name)
self.dashboard_template = self.__load_dashboard_template(self.report_name)
def __load_dashboard_template(self, template_name):
current_dir = os.getcwd()

View File

@ -22,25 +22,22 @@ class ChatExcel(BaseChat):
chat_scene: str = ChatScene.ChatExcel.value()
chat_retention_rounds = 1
def __init__(self, chat_session_id, user_input, select_param: str = ""):
def __init__(self, chat_param: Dict):
chat_mode = ChatScene.ChatExcel
self.select_param = select_param
if has_path(select_param):
self.excel_reader = ExcelReader(select_param)
self.select_param = chat_param["select_param"]
self.model_name = chat_param["model_name"]
chat_param["chat_mode"] = ChatScene.ChatExcel
if has_path(self.select_param):
self.excel_reader = ExcelReader(self.select_param)
else:
self.excel_reader = ExcelReader(
os.path.join(
KNOWLEDGE_UPLOAD_ROOT_PATH, chat_mode.value(), select_param
KNOWLEDGE_UPLOAD_ROOT_PATH, chat_mode.value(), self.select_param
)
)
super().__init__(
chat_mode=chat_mode,
chat_session_id=chat_session_id,
current_user_input=user_input,
select_param=select_param,
)
super().__init__(chat_param=chat_param)
def _generate_command_string(self, command: Dict[str, Any]) -> str:
"""
@ -85,6 +82,7 @@ class ChatExcel(BaseChat):
"parent_mode": self.chat_mode,
"select_param": self.excel_reader.excel_file_name,
"excel_reader": self.excel_reader,
"model_name": self.model_name,
}
learn_chat = ExcelLearning(**chat_param)
result = await learn_chat.nostream_call()

View File

@ -30,17 +30,20 @@ class ExcelLearning(BaseChat):
parent_mode: Any = None,
select_param: str = None,
excel_reader: Any = None,
model_name: str = None,
):
chat_mode = ChatScene.ExcelLearning
""" """
self.excel_file_path = select_param
self.excel_reader = excel_reader
super().__init__(
chat_mode=chat_mode,
chat_session_id=chat_session_id,
current_user_input=user_input,
select_param=select_param,
)
chat_param = {
"chat_mode": chat_mode,
"chat_session_id": chat_session_id,
"current_user_input": user_input,
"select_param": select_param,
"model_name": model_name,
}
super().__init__(chat_param=chat_param)
if parent_mode:
self.current_message.chat_mode = parent_mode.value()

View File

@ -1,3 +1,5 @@
from typing import Dict
from pilot.scene.base_chat import BaseChat
from pilot.scene.base import ChatScene
from pilot.common.sql_database import Database
@ -12,15 +14,13 @@ class ChatWithDbAutoExecute(BaseChat):
"""Number of results to return from the query"""
def __init__(self, chat_session_id, user_input, select_param: str = ""):
def __init__(self, chat_param: Dict):
chat_mode = ChatScene.ChatWithDbExecute
self.db_name = select_param
self.db_name = chat_param["select_param"]
chat_param["chat_mode"] = chat_mode
""" """
super().__init__(
chat_mode=chat_mode,
chat_session_id=chat_session_id,
current_user_input=user_input,
select_param=self.db_name,
chat_param=chat_param,
)
if not self.db_name:
raise ValueError(

View File

@ -1,3 +1,5 @@
from typing import Dict
from pilot.scene.base_chat import BaseChat
from pilot.scene.base import ChatScene
from pilot.common.sql_database import Database
@ -12,15 +14,11 @@ class ChatWithDbQA(BaseChat):
"""Number of results to return from the query"""
def __init__(self, chat_session_id, user_input, select_param: str = ""):
def __init__(self, chat_param: Dict):
""" """
self.db_name = select_param
super().__init__(
chat_mode=ChatScene.ChatWithDbQA,
chat_session_id=chat_session_id,
current_user_input=user_input,
select_param=self.db_name,
)
self.db_name = chat_param["select_param"]
chat_param["chat_mode"] = ChatScene.ChatWithDbQA
super().__init__(chat_param=chat_param)
if self.db_name:
self.database = CFG.LOCAL_DB_MANAGE.get_connect(self.db_name)

View File

@ -1,4 +1,4 @@
from typing import List
from typing import List, Dict
from pilot.scene.base_chat import BaseChat
from pilot.scene.base import ChatScene
@ -15,14 +15,10 @@ class ChatWithPlugin(BaseChat):
plugins_prompt_generator: PluginPromptGenerator
select_plugin: str = None
def __init__(self, chat_session_id, user_input, select_param: str = None):
self.plugin_selector = select_param
super().__init__(
chat_mode=ChatScene.ChatExecution,
chat_session_id=chat_session_id,
current_user_input=user_input,
select_param=self.plugin_selector,
)
def __init__(self, chat_param: Dict):
self.plugin_selector = chat_param.select_param
chat_param["chat_mode"] = ChatScene.ChatExecution
super().__init__(chat_param=chat_param)
self.plugins_prompt_generator = PluginPromptGenerator()
self.plugins_prompt_generator.command_registry = CFG.command_registry
# 加载插件中可用命令

View File

@ -1,3 +1,5 @@
from typing import Dict
from chromadb.errors import NoIndexException
from pilot.scene.base_chat import BaseChat
@ -20,16 +22,15 @@ class ChatKnowledge(BaseChat):
"""Number of results to return from the query"""
def __init__(self, chat_session_id, user_input, select_param: str = None):
def __init__(self, chat_param: Dict):
""" """
from pilot.embedding_engine.embedding_engine import EmbeddingEngine
from pilot.embedding_engine.embedding_factory import EmbeddingFactory
self.knowledge_space = select_param
self.knowledge_space = chat_param["select_param"]
chat_param["chat_mode"] = ChatScene.ChatKnowledge
super().__init__(
chat_mode=ChatScene.ChatKnowledge,
chat_session_id=chat_session_id,
current_user_input=user_input,
chat_param=chat_param,
)
self.space_context = self.get_space_context(self.knowledge_space)
self.top_k = (

View File

@ -1,3 +1,5 @@
from typing import Dict
from pilot.scene.base_chat import BaseChat
from pilot.scene.base import ChatScene
from pilot.configs.config import Config
@ -12,12 +14,11 @@ class ChatNormal(BaseChat):
"""Number of results to return from the query"""
def __init__(self, chat_session_id, user_input, select_param: str = None):
def __init__(self, chat_param: Dict):
""" """
chat_param["chat_mode"] = ChatScene.ChatNormal
super().__init__(
chat_mode=ChatScene.ChatNormal,
chat_session_id=chat_session_id,
current_user_input=user_input,
chat_param=chat_param,
)
def generate_input_values(self):

View File

@ -23,6 +23,7 @@ class OnceConversation:
self.messages: List[BaseMessage] = []
self.start_date: str = ""
self.chat_order: int = 0
self.model_name: str = ""
self.param_type: str = ""
self.param_value: str = ""
self.cost: int = 0
@ -104,6 +105,7 @@ def _conversation_to_dic(once: OnceConversation) -> dict:
return {
"chat_mode": once.chat_mode,
"model_name": once.model_name,
"chat_order": once.chat_order,
"start_date": start_str,
"cost": once.cost if once.cost else 0,
@ -127,6 +129,7 @@ def conversation_from_dict(once: dict) -> OnceConversation:
conversation.chat_order = int(once.get("chat_order"))
conversation.param_type = once.get("param_type", "")
conversation.param_value = once.get("param_value", "")
conversation.model_name = once.get("model_name", "proxyllm")
print(once.get("messages"))
conversation.messages = messages_from_dict(once.get("messages", []))
return conversation

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
self.__BUILD_MANIFEST=function(s,a,c,t,e,d,n,u,f,i){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[a,"static/chunks/673-9f0ceb79f1535087.js","static/chunks/pages/index-ad9fe4b8efe06ace.js"],"/_error":["static/chunks/pages/_error-dee72aff9b2e2c12.js"],"/chat":["static/chunks/pages/chat-cf7d95f63f5aacee.js"],"/database":[s,c,d,t,"static/chunks/566-493c6126d6ac9745.js","static/chunks/196-48d8c6ab3e99146c.js","static/chunks/pages/database-670b4fa76152da89.js"],"/datastores":[e,s,a,n,u,"static/chunks/241-4117dd68a591b7fa.js","static/chunks/pages/datastores-cc1916d2425430ee.js"],"/datastores/documents":[e,"static/chunks/75fc9c18-a784766a129ec5fb.js",s,a,n,c,f,d,t,i,u,"static/chunks/749-f876c99e30a851b8.js","static/chunks/pages/datastores/documents-6dd307574a33f39c.js"],"/datastores/documents/chunklist":[e,s,c,f,t,i,"static/chunks/pages/datastores/documents/chunklist-0fae5e5132233223.js"],sortedPages:["/","/_app","/_error","/chat","/database","/datastores","/datastores/documents","/datastores/documents/chunklist"]}}("static/chunks/215-c0761f73cb28fff6.js","static/chunks/913-e3ab2daf183d352e.js","static/chunks/902-4b12ce531524546f.js","static/chunks/455-597a8a48388a0d9b.js","static/chunks/29107295-90b90cb30c825230.js","static/chunks/908-33709e71961cb7a1.js","static/chunks/718-ae767ae95bca674e.js","static/chunks/589-8dfb35868cafc00b.js","static/chunks/289-06c0d9f538f77a71.js","static/chunks/34-c924e44753dd2c5b.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();

View File

@ -1 +0,0 @@
self.__BUILD_MANIFEST={__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/_error":["static/chunks/pages/_error-f5357f382422dd96.js"],sortedPages:["/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[744],{59617:function(e,n,t){Promise.resolve().then(t.t.bind(t,68802,23)),Promise.resolve().then(t.t.bind(t,13211,23)),Promise.resolve().then(t.t.bind(t,5767,23)),Promise.resolve().then(t.t.bind(t,14299,23)),Promise.resolve().then(t.t.bind(t,37396,23))}},function(e){var n=function(n){return e(e.s=n)};e.O(0,[253,769],function(){return n(29070),n(59617)}),_N_E=e.O()}]);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[888],{41597:function(n,_,u){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_app",function(){return u(55366)}])}},function(n){var _=function(_){return n(n.s=_)};n.O(0,[774,179],function(){return _(41597),_(75919)}),_N_E=n.O()}]);

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[820],{81981:function(n,_,u){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_error",function(){return u(14600)}])}},function(n){n.O(0,[888,774,179],function(){return n(n.s=81981)}),_N_E=n.O()}]);
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[820],{81981:function(n,_,u){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_error",function(){return u(14600)}])}},function(n){n.O(0,[774,888,179],function(){return n(n.s=81981)}),_N_E=n.O()}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[41],{13264:function(e,t,n){"use strict";var r=n(70182);let a=(0,r.ZP)();t.Z=a},57838:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(67294);function a(){let[,e]=r.useReducer(e=>e+1,0);return e}},53116:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/datastores/documents/chunklist",function(){return n(49114)}])},49114:function(e,t,n){"use strict";n.r(t);var r=n(85893),a=n(39332),c=n(67294),s=n(56385),i=n(48665),o=n(70702),l=n(84229),d=n(2166),u=n(40911),h=n(61685),f=n(74627),g=n(60122),j=n(30119),m=n(67421);t.default=()=>{let e=(0,a.useRouter)(),{mode:t}=(0,s.tv)(),n=(0,a.useSearchParams)(),p=n&&n.get("spacename"),x=n&&n.get("documentid"),[_,Z]=(0,c.useState)(0),[w,P]=(0,c.useState)(0),[b,k]=(0,c.useState)([]),{t:v}=(0,m.$G)();return(0,c.useEffect)(()=>{(async function(){let e=await (0,j.PR)("/knowledge/".concat(p,"/chunk/list"),{document_id:x,page:1,page_size:20});e.success&&(k(e.data.data),Z(e.data.total),P(e.data.page))})()},[]),(0,r.jsxs)(i.Z,{className:"p-4 h-[90%]",children:[(0,r.jsx)(o.Z,{className:"mb-5",direction:"row",justifyContent:"flex-start",alignItems:"center",children:(0,r.jsxs)(l.Z,{"aria-label":"breadcrumbs",children:[(0,r.jsx)(d.Z,{onClick:()=>{e.push("/datastores")},underline:"hover",color:"neutral",fontSize:"inherit",children:v("Knowledge_Space")},"Knowledge Space"),(0,r.jsx)(d.Z,{onClick:()=>{e.push("/datastores/documents?name=".concat(p))},underline:"hover",color:"neutral",fontSize:"inherit",children:v("Documents")},"Knowledge Space"),(0,r.jsx)(u.ZP,{fontSize:"inherit",children:v("Chunks")})]})}),(0,r.jsx)(i.Z,{className:"p-4 overflow-auto h-[90%]",sx:{"&::-webkit-scrollbar":{display:"none"}},children:b.length?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(h.Z,{color:"primary",variant:"plain",size:"lg",sx:{"& tbody tr: hover":{backgroundColor:"light"===t?"rgb(246, 246, 246)":"rgb(33, 33, 40)"},"& tbody tr: hover a":{textDecoration:"underline"}},children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:v("Name")}),(0,r.jsx)("th",{children:v("Content")}),(0,r.jsx)("th",{children:v("Meta_Data")})]})}),(0,r.jsx)("tbody",{children:b.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.doc_name}),(0,r.jsx)("td",{children:(0,r.jsx)(f.Z,{content:e.content,trigger:"hover",children:e.content.length>10?"".concat(e.content.slice(0,10),"..."):e.content})}),(0,r.jsx)("td",{children:(0,r.jsx)(f.Z,{content:JSON.stringify(e.meta_info||"{}",null,2),trigger:"hover",children:e.meta_info.length>10?"".concat(e.meta_info.slice(0,10),"..."):e.meta_info})})]},e.id))})]})}):(0,r.jsx)(r.Fragment,{})}),(0,r.jsx)(o.Z,{className:"mt-5",direction:"row",justifyContent:"flex-end",children:(0,r.jsx)(g.Z,{defaultPageSize:20,showSizeChanger:!1,current:w,total:_,onChange:async e=>{let t=await (0,j.PR)("/knowledge/".concat(p,"/chunk/list"),{document_id:x,page:e,page_size:20});t.success&&(k(t.data.data),Z(t.data.total),P(t.data.page))},hideOnSinglePage:!0})})]})}},30119:function(e,t,n){"use strict";n.d(t,{Tk:function(){return i},PR:function(){return o},Ej:function(){return l}});var r=n(58301),a=n(6154);let c=a.Z.create({baseURL:"http://127.0.0.1:5000"});c.defaults.timeout=1e4,c.interceptors.response.use(e=>e.data,e=>Promise.reject(e)),n(96486);let s={"content-type":"application/json"},i=(e,t)=>{if(t){let n=Object.keys(t).filter(e=>void 0!==t[e]&&""!==t[e]).map(e=>"".concat(e,"=").concat(t[e])).join("&");n&&(e+="?".concat(n))}return c.get("/api"+e,{headers:s}).then(e=>e).catch(e=>{r.ZP.error(e),Promise.reject(e)})},o=(e,t)=>c.post(e,t,{headers:s}).then(e=>e).catch(e=>{r.ZP.error(e),Promise.reject(e)}),l=(e,t)=>c.post(e,t).then(e=>e).catch(e=>{r.ZP.error(e),Promise.reject(e)})}},function(e){e.O(0,[662,215,902,289,455,34,774,888,179],function(){return e(e.s=53116)}),_N_E=e.O()}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
!function(){"use strict";var e,t,n,r,o,u,i,c,f,a={},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={id:e,loaded:!1,exports:{}},r=!0;try{a[e].call(n.exports,n,n.exports,d),r=!1}finally{r&&delete l[e]}return n.loaded=!0,n.exports}d.m=a,e=[],d.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u<e.length;u++){for(var n=e[u][0],r=e[u][1],o=e[u][2],c=!0,f=0;f<n.length;f++)i>=o&&Object.keys(d.O).every(function(e){return d.O[e](n[f])})?n.splice(f--,1):(c=!1,o<i&&(i=o));if(c){e.splice(u--,1);var a=r();void 0!==a&&(t=a)}}return t},d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},d.t=function(e,r){if(1&r&&(e=this(e)),8&r||"object"==typeof e&&e&&(4&r&&e.__esModule||16&r&&"function"==typeof e.then))return e;var o=Object.create(null);d.r(o);var u={};t=t||[null,n({}),n([]),n(n)];for(var i=2&r&&e;"object"==typeof i&&!~t.indexOf(i);i=n(i))Object.getOwnPropertyNames(i).forEach(function(t){u[t]=function(){return e[t]}});return u.default=function(){return e},d.d(o,u),o},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(t,n){return d.f[n](e,t),t},[]))},d.u=function(e){},d.miniCssF=function(e){return"static/css/"+({185:"5ccf1b8330a1b392",929:"4047a8310a399ceb"})[e]+".css"},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="_N_E:",d.l=function(e,t,n,u){if(r[e]){r[e].push(t);return}if(void 0!==n)for(var i,c,f=document.getElementsByTagName("script"),a=0;a<f.length;a++){var l=f[a];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==o+n){i=l;break}}i||(c=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,d.nc&&i.setAttribute("nonce",d.nc),i.setAttribute("data-webpack",o+n),i.src=d.tu(e)),r[e]=[t];var s=function(t,n){i.onerror=i.onload=null,clearTimeout(p);var o=r[e];if(delete r[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=s.bind(null,i.onerror),i.onload=s.bind(null,i.onload),c&&document.head.appendChild(i)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},d.tt=function(){return void 0===u&&(u={createScriptURL:function(e){return e}},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(u=trustedTypes.createPolicy("nextjs#bundler",u))),u},d.tu=function(e){return d.tt().createScriptURL(e)},d.p="/_next/",i={272:0},d.f.j=function(e,t){var n=d.o(i,e)?i[e]:void 0;if(0!==n){if(n)t.push(n[2]);else if(272!=e){var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=d.p+d.u(e),u=Error();d.l(o,function(t){if(d.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",u.name="ChunkLoadError",u.type=r,u.request=o,n[1](u)}},"chunk-"+e,e)}else i[e]=0}},d.O.j=function(e){return 0===i[e]},c=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],f=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)d.o(u,n)&&(d.m[n]=u[n]);if(c)var a=c(d)}for(e&&e(t);f<o.length;f++)r=o[f],d.o(i,r)&&i[r]&&i[r][0](),i[r]=0;return d.O(a)},(f=self.webpackChunk_N_E=self.webpackChunk_N_E||[]).forEach(c.bind(null,0)),f.push=c.bind(null,f.push.bind(f))}();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +0,0 @@
1:HL["/_next/static/css/5ccf1b8330a1b392.css",{"as":"style"}]
0:["c9JPLFJPIFJZCqrC_XlGA",[[["",{"children":["chat",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/5ccf1b8330a1b392.css","precedence":"next"}]],["$L3",null]]]]]
4:HL["/_next/static/css/4047a8310a399ceb.css",{"as":"style"}]
5:I{"id":"16763","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","15:static/chunks/15-9581813bc8d52fcc.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","686:static/chunks/686-7d88801a440dd051.js","741:static/chunks/741-9654a56afdea9ccd.js","83:static/chunks/83-c015e345dfcb64fb.js","185:static/chunks/app/layout-ead8b22d15e328b1.js"],"name":"","async":false}
6:I{"id":"13211","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
7:I{"id":"5767","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
8:I{"id":"37396","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
9:I{"id":"50229","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","757:static/chunks/f60284a2-6891068c9ea7ce77.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","649:static/chunks/649-85000b933734ec92.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","569:static/chunks/569-2c5ba6e4012e0ef6.js","196:static/chunks/196-876de32c0e3c3c98.js","86:static/chunks/86-07eeba2a9867dc2c.js","579:static/chunks/579-109b8ef1060dc09f.js","868:static/chunks/868-4fb3b88c6a344205.js","767:static/chunks/767-b93280f4b5b5e975.js","686:static/chunks/686-7d88801a440dd051.js","822:static/chunks/822-2f35ce51fd101c79.js","959:static/chunks/959-28f2e1d44ad53ceb.js","332:static/chunks/332-ec398b4402e46d25.js","929:static/chunks/app/chat/page-de3cfaa8003bf23d.js"],"name":"","async":false}
2:[["$","$L5",null,{"children":["$","$L6",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L7",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$L6",null,{"parallelRouterKey":"children","segmentPath":["children","chat","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L7",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":[["$","$L8",null,{"propsForComponent":{"params":{}},"Component":"$9"}],null],"segment":"__PAGE__"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/4047a8310a399ceb.css","precedence":"next"}]]}],"segment":"chat"},"styles":[]}],"params":{}}],null]
3:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","link","2",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"any"}]]

File diff suppressed because one or more lines are too long

View File

@ -1,9 +0,0 @@
1:HL["/_next/static/css/5ccf1b8330a1b392.css",{"as":"style"}]
0:["c9JPLFJPIFJZCqrC_XlGA",[[["",{"children":["database",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/5ccf1b8330a1b392.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"16763","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","15:static/chunks/15-9581813bc8d52fcc.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","686:static/chunks/686-7d88801a440dd051.js","741:static/chunks/741-9654a56afdea9ccd.js","83:static/chunks/83-c015e345dfcb64fb.js","185:static/chunks/app/layout-ead8b22d15e328b1.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
7:I{"id":"37396","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
8:I{"id":"25224","chunks":["355:static/chunks/355-f67a136d901a8c5f.js","358:static/chunks/358-a690ea06b8189dc6.js","649:static/chunks/649-85000b933734ec92.js","191:static/chunks/191-977bd4e61595fb21.js","715:static/chunks/715-50c67108307c55aa.js","569:static/chunks/569-2c5ba6e4012e0ef6.js","579:static/chunks/579-109b8ef1060dc09f.js","743:static/chunks/743-f1de3e59aea4b7c6.js","959:static/chunks/959-28f2e1d44ad53ceb.js","741:static/chunks/741-9654a56afdea9ccd.js","375:static/chunks/375-096a2ebcb46d13b2.js","504:static/chunks/app/database/page-8ec81104aaf179eb.js"],"name":"","async":false}
2:[["$","$L4",null,{"children":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L6",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children","database","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L6",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":[["$","$L7",null,{"propsForComponent":{"params":{}},"Component":"$8"}],null],"segment":"__PAGE__"},"styles":[]}],"segment":"database"},"styles":[]}],"params":{}}],null]
3:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","link","2",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"any"}]]

File diff suppressed because one or more lines are too long

View File

@ -1,9 +0,0 @@
1:HL["/_next/static/css/5ccf1b8330a1b392.css",{"as":"style"}]
0:["c9JPLFJPIFJZCqrC_XlGA",[[["",{"children":["datastores",{"children":["documents",{"children":["chunklist",{"children":["__PAGE__",{}]}]}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/5ccf1b8330a1b392.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"16763","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","15:static/chunks/15-9581813bc8d52fcc.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","686:static/chunks/686-7d88801a440dd051.js","741:static/chunks/741-9654a56afdea9ccd.js","83:static/chunks/83-c015e345dfcb64fb.js","185:static/chunks/app/layout-ead8b22d15e328b1.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
7:I{"id":"37396","chunks":["272:static/chunks/webpack-de65dbaa858cf21b.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
8:I{"id":"26257","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","649:static/chunks/649-85000b933734ec92.js","191:static/chunks/191-977bd4e61595fb21.js","569:static/chunks/569-2c5ba6e4012e0ef6.js","15:static/chunks/15-9581813bc8d52fcc.js","743:static/chunks/743-f1de3e59aea4b7c6.js","767:static/chunks/767-b93280f4b5b5e975.js","635:static/chunks/635-485e0e15fe1137c1.js","548:static/chunks/548-5e93f9e4383441e4.js","538:static/chunks/app/datastores/documents/chunklist/page-92af71423560a516.js"],"name":"","async":false}
2:[["$","$L4",null,{"children":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L6",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children","datastores","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L6",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children","datastores","children","documents","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L6",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children","datastores","children","documents","children","chunklist","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L6",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":[["$","$L7",null,{"propsForComponent":{"params":{}},"Component":"$8"}],null],"segment":"__PAGE__"},"styles":[]}],"segment":"chunklist"},"styles":[]}],"segment":"documents"},"styles":[]}],"segment":"datastores"},"styles":[]}],"params":{}}],null]
3:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","link","2",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"any"}]]

Some files were not shown because too many files have changed in this diff Show More