repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/chat/feedback.py
libs/chatchat-server/chatchat/server/chat/feedback.py
from fastapi import Body from chatchat.utils import build_logger from chatchat.server.db.repository import feedback_message_to_db from chatchat.server.utils import BaseResponse logger = build_logger() def chat_feedback( message_id: str = Body("", max_length=32, description="聊天记录id"), score: int = Body(0, ma...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/chat/chat.py
libs/chatchat-server/chatchat/server/chat/chat.py
import asyncio import json import uuid import os from chatchat.server.db.repository.message_repository import filter_message from typing import AsyncIterable, List, Union, Tuple from langchain_core.load import dumpd, dumps, load, loads from fastapi import Body from langchain.chains import LLMChain from langchain.promp...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/chat/utils.py
libs/chatchat-server/chatchat/server/chat/utils.py
import logging from functools import lru_cache from typing import Dict, List, Tuple, Union from langchain.prompts.chat import ChatMessagePromptTemplate from chatchat.server.pydantic_v2 import BaseModel, Field from chatchat.utils import build_logger logger = build_logger() class History(BaseModel): """ 对话历...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/chat/completion.py
libs/chatchat-server/chatchat/server/chat/completion.py
import asyncio from typing import AsyncIterable, Optional from fastapi import Body from langchain.callbacks import AsyncIteratorCallbackHandler from langchain.chains import LLMChain from langchain.prompts import PromptTemplate from sse_starlette.sse import EventSourceResponse from chatchat.server.utils import get_Ope...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/chat/kb_chat.py
libs/chatchat-server/chatchat/server/chat/kb_chat.py
from __future__ import annotations import asyncio, json import uuid from typing import AsyncIterable, List, Optional, Literal from fastapi import Body, Request from fastapi.concurrency import run_in_threadpool from sse_starlette.sse import EventSourceResponse from langchain.callbacks import AsyncIteratorCallbackHandl...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/tool_routes.py
libs/chatchat-server/chatchat/server/api_server/tool_routes.py
from __future__ import annotations import logging from typing import List from fastapi import APIRouter, Body, Request from chatchat.server.utils import BaseResponse, get_tool, get_tool_config from chatchat.utils import build_logger logger = build_logger() tool_router = APIRouter(prefix="/tools", tags=["Toolkits"...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/api_schemas.py
libs/chatchat-server/chatchat/server/api_server/api_schemas.py
from __future__ import annotations import json import time from typing import Dict, List, Literal, Optional, Union from fastapi import UploadFile from openai.types.chat import ( ChatCompletionMessageParam, ChatCompletionToolChoiceOptionParam, ChatCompletionToolParam, completion_create_params, ) from ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/mcp_routes.py
libs/chatchat-server/chatchat/server/api_server/mcp_routes.py
from datetime import datetime from typing import List from fastapi import APIRouter, Depends, HTTPException, Query from fastapi.responses import JSONResponse from chatchat.server.api_server.api_schemas import ( MCPConnectionCreate, MCPConnectionUpdate, MCPConnectionResponse, MCPConnectionListResponse,...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/server_routes.py
libs/chatchat-server/chatchat/server/api_server/server_routes.py
from typing import Literal from fastapi import APIRouter, Body from chatchat.server.types.server.response.base import BaseResponse from chatchat.settings import Settings from chatchat.server.utils import get_prompt_template, get_server_configs server_router = APIRouter(prefix="/server", tags=["Server State"]) avail...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/kb_routes.py
libs/chatchat-server/chatchat/server/api_server/kb_routes.py
from __future__ import annotations from typing import List, Literal from fastapi import APIRouter, Request from chatchat.settings import Settings from chatchat.server.api_server.api_schemas import OpenAIChatInput, OpenAIChatOutput from chatchat.server.chat.file_chat import upload_temp_docs from chatchat.server.chat....
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/chat_routes.py
libs/chatchat-server/chatchat/server/api_server/chat_routes.py
from __future__ import annotations from typing import Dict, List from fastapi import APIRouter, Request from langchain.prompts.prompt import PromptTemplate from sse_starlette import EventSourceResponse from chatchat.server.api_server.api_schemas import OpenAIChatInput from chatchat.server.chat.chat import chat from ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/server_app.py
libs/chatchat-server/chatchat/server/api_server/server_app.py
import argparse import os from typing import Literal import uvicorn from fastapi import Body, FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles from starlette.responses import RedirectResponse from chatchat import __version__ from chatchat.settings import Settings ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/api_server/openai_routes.py
libs/chatchat-server/chatchat/server/api_server/openai_routes.py
from __future__ import annotations import asyncio import base64 import os import shutil from contextlib import asynccontextmanager from datetime import datetime from pathlib import Path from typing import AsyncGenerator, Dict, Iterable, Tuple from fastapi import APIRouter, Request, HTTPException from fastapi.response...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/constant/response_code.py
libs/chatchat-server/chatchat/server/constant/response_code.py
class ResponseCode: SUCCESS = 200 BAD_REQUEST = 400 NOT_FOUND = 404 INTERNAL_SERVER_ERROR = 500
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/constant/__init__.py
libs/chatchat-server/chatchat/server/constant/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/reranker/reranker.py
libs/chatchat-server/chatchat/server/reranker/reranker.py
import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) from typing import Any, List, Optional, Sequence from langchain.callbacks.manager import Callbacks from langchain.retrievers.document_compressors.base import BaseDocumentCompressor from langchain_core.documents import Do...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/__init__.py
libs/chatchat-server/chatchat/server/db/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/session.py
libs/chatchat-server/chatchat/server/db/session.py
from contextlib import contextmanager from functools import wraps from sqlalchemy.orm import Session from chatchat.server.db.base import SessionLocal @contextmanager def session_scope() -> Session: """上下文管理器用于自动获取 Session, 避免错误""" session = SessionLocal() try: yield session session.commi...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/base.py
libs/chatchat-server/chatchat/server/db/base.py
import json from sqlalchemy import create_engine from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base from sqlalchemy.orm import sessionmaker from chatchat.settings import Settings engine = create_engine( Settings.basic_settings.SQLALCHEMY_DATABASE_URI, json_serializer=lambda obj: json.d...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/message_model.py
libs/chatchat-server/chatchat/server/db/models/message_model.py
from sqlalchemy import JSON, Column, DateTime, Integer, String, func from chatchat.server.db.base import Base class MessageModel(Base): """ 聊天记录模型 """ __tablename__ = "message" id = Column(String(32), primary_key=True, comment="聊天记录ID") conversation_id = Column(String(32), default=None, inde...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/human_message_event.py
libs/chatchat-server/chatchat/server/db/models/human_message_event.py
from sqlalchemy import JSON, Column, DateTime, Integer, String, func from chatchat.server.db.base import Base class HumanMessageEvent(Base): """ 人类反馈消息事件模型 """ __tablename__ = "human_message_event" call_id = Column(String(32), primary_key=True, comment="聊天记录ID") conversation_id = Column(Stri...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/conversation_model.py
libs/chatchat-server/chatchat/server/db/models/conversation_model.py
from sqlalchemy import JSON, Column, DateTime, Integer, String, func from chatchat.server.db.base import Base class ConversationModel(Base): """ 聊天记录模型 """ __tablename__ = "conversation" id = Column(String(32), primary_key=True, comment="对话框ID") name = Column(String(50), comment="对话框名称") ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/knowledge_metadata_model.py
libs/chatchat-server/chatchat/server/db/models/knowledge_metadata_model.py
from sqlalchemy import JSON, Boolean, Column, DateTime, Float, Integer, String, func from chatchat.server.db.base import Base class SummaryChunkModel(Base): """ chunk summary模型,用于存储file_doc中每个doc_id的chunk 片段, 数据来源: 用户输入: 用户上传文件,可填写文件的描述,生成的file_doc中的doc_id,存入summary_chunk中 程序自动切分 对file_do...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/knowledge_base_model.py
libs/chatchat-server/chatchat/server/db/models/knowledge_base_model.py
from datetime import datetime from typing import Optional from pydantic import BaseModel from sqlalchemy import Column, DateTime, Integer, String, func from chatchat.server.db.base import Base class KnowledgeBaseModel(Base): """ 知识库模型 """ __tablename__ = "knowledge_base" id = Column(Integer, pr...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/__init__.py
libs/chatchat-server/chatchat/server/db/models/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/mcp_connection_model.py
libs/chatchat-server/chatchat/server/db/models/mcp_connection_model.py
from datetime import datetime from typing import Dict, List, Optional, Union from sqlalchemy import Boolean, Column, DateTime, Integer, String, JSON, Text, func from chatchat.server.db.base import Base class MCPConnectionModel(Base): """ MCP 连接配置模型 - 支持 StdioConnection 和 SSEConnection 类型 """ __table...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/base.py
libs/chatchat-server/chatchat/server/db/models/base.py
from datetime import datetime from sqlalchemy import Column, DateTime, Integer, String class BaseModel: """ 基础模型 """ id = Column(Integer, primary_key=True, index=True, comment="主键ID") create_time = Column(DateTime, default=datetime.utcnow, comment="创建时间") update_time = Column( DateTi...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/models/knowledge_file_model.py
libs/chatchat-server/chatchat/server/db/models/knowledge_file_model.py
from sqlalchemy import JSON, Boolean, Column, DateTime, Float, Integer, String, func from chatchat.server.db.base import Base class KnowledgeFileModel(Base): """ 知识文件模型 """ __tablename__ = "knowledge_file" id = Column(Integer, primary_key=True, autoincrement=True, comment="知识文件ID") file_name...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/human_message_event_repository.py
libs/chatchat-server/chatchat/server/db/repository/human_message_event_repository.py
import uuid from typing import Dict, List from chatchat.server.db.models.human_message_event import HumanMessageEvent from chatchat.server.db.session import with_session @with_session def add_human_message_event_to_db( session, call_id: str, conversation_id: str, function_name: str, ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/mcp_connection_repository.py
libs/chatchat-server/chatchat/server/db/repository/mcp_connection_repository.py
import uuid from typing import Dict, List, Optional from chatchat.server.db.models.mcp_connection_model import MCPConnectionModel, MCPProfileModel from chatchat.server.db.session import with_session @with_session def add_mcp_connection( session, server_name: str, args: List[str] = None, env: Dict[str...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/conversation_repository.py
libs/chatchat-server/chatchat/server/db/repository/conversation_repository.py
import uuid from chatchat.server.db.models.conversation_model import ConversationModel from chatchat.server.db.session import with_session @with_session def add_conversation_to_db(session, chat_type, name="", conversation_id=None): """ 新增聊天记录 """ if not conversation_id: conversation_id = uuid...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/knowledge_base_repository.py
libs/chatchat-server/chatchat/server/db/repository/knowledge_base_repository.py
from chatchat.server.db.models.knowledge_base_model import ( KnowledgeBaseModel, KnowledgeBaseSchema, ) from chatchat.server.db.session import with_session @with_session def add_kb_to_db(session, kb_name, kb_info, vs_type, embed_model): # 创建知识库实例 kb = ( session.query(KnowledgeBaseModel) ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/knowledge_metadata_repository.py
libs/chatchat-server/chatchat/server/db/repository/knowledge_metadata_repository.py
from typing import Dict, List from chatchat.server.db.models.knowledge_metadata_model import SummaryChunkModel from chatchat.server.db.session import with_session @with_session def list_summary_from_db( session, kb_name: str, metadata: Dict = {}, ) -> List[Dict]: """ 列出某知识库chunk summary。 返回形式...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/__init__.py
libs/chatchat-server/chatchat/server/db/repository/__init__.py
from .conversation_repository import * from .knowledge_base_repository import * from .knowledge_file_repository import * from .message_repository import * from .human_message_event_repository import *
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/knowledge_file_repository.py
libs/chatchat-server/chatchat/server/db/repository/knowledge_file_repository.py
from typing import Dict, List from chatchat.server.db.models.knowledge_base_model import KnowledgeBaseModel from chatchat.server.db.models.knowledge_file_model import ( FileDocModel, KnowledgeFileModel, ) from chatchat.server.db.session import with_session from chatchat.server.knowledge_base.utils import Knowl...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/db/repository/message_repository.py
libs/chatchat-server/chatchat/server/db/repository/message_repository.py
import uuid from typing import Dict, List from chatchat.server.db.models.message_model import MessageModel from chatchat.server.db.session import with_session @with_session def add_message_to_db( session, conversation_id: str, chat_type, query, response="", message_id=None, metadata: Dict...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agents_registry/agents_registry.py
libs/chatchat-server/chatchat/server/agents_registry/agents_registry.py
# -*- coding: utf-8 -*- import asyncio import sys from contextlib import AsyncExitStack from langchain.agents.agent import RunnableMultiActionAgent from langchain_core.messages import SystemMessage, AIMessage from langchain_core.prompts import ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder from py...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agents_registry/__init__.py
libs/chatchat-server/chatchat/server/agents_registry/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/types/__init__.py
libs/chatchat-server/chatchat/server/types/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/types/server/__init__.py
libs/chatchat-server/chatchat/server/types/server/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/types/server/response/__init__.py
libs/chatchat-server/chatchat/server/types/server/response/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/types/server/response/base.py
libs/chatchat-server/chatchat/server/types/server/response/base.py
from typing import Any, List, Optional, Union from pydantic import BaseModel, Field from chatchat.server.constant.response_code import ResponseCode def default_data(): return "" class BaseResponse(BaseModel): code: int = Field(200, description="API status code") msg: str = Field("success", description...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/utils.py
libs/chatchat-server/chatchat/server/file_rag/utils.py
from chatchat.server.file_rag.retrievers import ( BaseRetrieverService, EnsembleRetrieverService, VectorstoreRetrieverService, MilvusVectorstoreRetrieverService, ) Retrivals = { "milvusvectorstore": MilvusVectorstoreRetrieverService, "vectorstore": VectorstoreRetrieverService, "ensemble": E...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/__init__.py
libs/chatchat-server/chatchat/server/file_rag/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/myimgloader.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/myimgloader.py
from typing import List from langchain_community.document_loaders.unstructured import UnstructuredFileLoader from chatchat.server.file_rag.document_loaders.ocr import get_ocr class RapidOCRLoader(UnstructuredFileLoader): def _get_elements(self) -> List: def img2text(filepath): resp = "" ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/mypptloader.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/mypptloader.py
from typing import List import tqdm from langchain_community.document_loaders.unstructured import UnstructuredFileLoader class RapidOCRPPTLoader(UnstructuredFileLoader): def _get_elements(self) -> List: def ppt2text(filepath): from io import BytesIO import numpy as np ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/mydocloader.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/mydocloader.py
from typing import List import tqdm from langchain_community.document_loaders.unstructured import UnstructuredFileLoader class RapidOCRDocLoader(UnstructuredFileLoader): def _get_elements(self) -> List: def doc2text(filepath): from io import BytesIO import numpy as np ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/ocr.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/ocr.py
from typing import TYPE_CHECKING if TYPE_CHECKING: try: from rapidocr_paddle import RapidOCR except ImportError: from rapidocr_onnxruntime import RapidOCR def get_ocr(use_cuda: bool = True) -> "RapidOCR": try: from rapidocr_paddle import RapidOCR ocr = RapidOCR( ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/__init__.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/__init__.py
from .mydocloader import RapidOCRDocLoader from .myimgloader import RapidOCRLoader from .mypdfloader import RapidOCRPDFLoader from .mypptloader import RapidOCRPPTLoader
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/mypdfloader.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/mypdfloader.py
from typing import List import cv2 import numpy as np import tqdm from langchain_community.document_loaders.unstructured import UnstructuredFileLoader from PIL import Image from chatchat.settings import Settings from chatchat.server.file_rag.document_loaders.ocr import get_ocr class RapidOCRPDFLoader(UnstructuredFi...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/document_loaders/FilteredCSVloader.py
libs/chatchat-server/chatchat/server/file_rag/document_loaders/FilteredCSVloader.py
## 指定制定列的csv文件加载器 import csv from io import TextIOWrapper from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain_community.document_loaders import CSVLoader from langchain_community.document_loaders.helpers import detect_file_encodings class FilteredCSVLoader(CSVLoad...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/retrievers/vectorstore.py
libs/chatchat-server/chatchat/server/file_rag/retrievers/vectorstore.py
from __future__ import annotations from langchain.vectorstores import VectorStore from langchain_core.retrievers import BaseRetriever from chatchat.server.file_rag.retrievers.base import BaseRetrieverService class VectorstoreRetrieverService(BaseRetrieverService): def do_init( self, retriever: ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/retrievers/milvus_vectorstore.py
libs/chatchat-server/chatchat/server/file_rag/retrievers/milvus_vectorstore.py
import warnings from langchain.vectorstores import VectorStore from langchain_core.retrievers import BaseRetriever from langchain_core.vectorstores import VectorStoreRetriever from chatchat.server.file_rag.retrievers.base import BaseRetrieverService from langchain.docstore.document import Document from langchain_cor...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/retrievers/ensemble.py
libs/chatchat-server/chatchat/server/file_rag/retrievers/ensemble.py
from __future__ import annotations from langchain.retrievers import EnsembleRetriever from langchain.vectorstores import VectorStore from langchain_community.retrievers import BM25Retriever from langchain_core.retrievers import BaseRetriever from chatchat.server.file_rag.retrievers.base import BaseRetrieverService ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/retrievers/__init__.py
libs/chatchat-server/chatchat/server/file_rag/retrievers/__init__.py
from chatchat.server.file_rag.retrievers.base import BaseRetrieverService from chatchat.server.file_rag.retrievers.ensemble import EnsembleRetrieverService from chatchat.server.file_rag.retrievers.vectorstore import VectorstoreRetrieverService from chatchat.server.file_rag.retrievers.milvus_vectorstore import MilvusVec...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/retrievers/base.py
libs/chatchat-server/chatchat/server/file_rag/retrievers/base.py
from __future__ import annotations from abc import ABCMeta, abstractmethod from langchain.vectorstores import VectorStore class BaseRetrieverService(metaclass=ABCMeta): def __init__(self, **kwargs): self.do_init(**kwargs) @abstractmethod def do_init(self, **kwargs): pass @abstract...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/text_splitter/ali_text_splitter.py
libs/chatchat-server/chatchat/server/file_rag/text_splitter/ali_text_splitter.py
import re from typing import List from langchain.text_splitter import CharacterTextSplitter class AliTextSplitter(CharacterTextSplitter): def __init__(self, pdf: bool = False, **kwargs): super().__init__(**kwargs) self.pdf = pdf def split_text(self, text: str) -> List[str]: # use_doc...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/text_splitter/zh_title_enhance.py
libs/chatchat-server/chatchat/server/file_rag/text_splitter/zh_title_enhance.py
import re from langchain.docstore.document import Document def under_non_alpha_ratio(text: str, threshold: float = 0.5): """Checks if the proportion of non-alpha characters in the text snippet exceeds a given threshold. This helps prevent text like "-----------BREAK---------" from being tagged as a title...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/text_splitter/chinese_text_splitter.py
libs/chatchat-server/chatchat/server/file_rag/text_splitter/chinese_text_splitter.py
import re from typing import List from langchain.text_splitter import CharacterTextSplitter class ChineseTextSplitter(CharacterTextSplitter): def __init__(self, pdf: bool = False, sentence_size: int = 250, **kwargs): super().__init__(**kwargs) self.pdf = pdf self.sentence_size = sentence_...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/text_splitter/chinese_recursive_text_splitter.py
libs/chatchat-server/chatchat/server/file_rag/text_splitter/chinese_recursive_text_splitter.py
import logging import re from typing import Any, List, Optional from langchain.text_splitter import RecursiveCharacterTextSplitter from chatchat.utils import build_logger logger = build_logger() def _split_text_with_regex_from_end( text: str, separator: str, keep_separator: bool ) -> List[str]: # Now that...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/file_rag/text_splitter/__init__.py
libs/chatchat-server/chatchat/server/file_rag/text_splitter/__init__.py
from .ali_text_splitter import AliTextSplitter from .chinese_recursive_text_splitter import ChineseRecursiveTextSplitter from .chinese_text_splitter import ChineseTextSplitter from .zh_title_enhance import zh_title_enhance
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_doc_api.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_doc_api.py
import asyncio import json import os import urllib from typing import Dict, List from fastapi import Body, File, Form, Query, UploadFile from fastapi.responses import FileResponse from langchain.docstore.document import Document from sse_starlette import EventSourceResponse from chatchat.settings import Settings from...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_summary_api.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_summary_api.py
import asyncio import json from typing import List, Optional from fastapi import Body from sse_starlette import EventSourceResponse from chatchat.settings import Settings from chatchat.server.knowledge_base.kb_service.base import KBServiceFactory from chatchat.server.knowledge_base.kb_summary.base import KBSummarySer...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/migrate.py
libs/chatchat-server/chatchat/server/knowledge_base/migrate.py
import os from datetime import datetime from typing import List, Literal from dateutil.parser import parse from chatchat.settings import Settings from chatchat.server.db.base import Base, engine from chatchat.server.db.models.conversation_model import ConversationModel from chatchat.server.db.models.message_model imp...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_api.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_api.py
import urllib from fastapi import Body from chatchat.settings import Settings from chatchat.server.db.repository.knowledge_base_repository import list_kbs_from_db from chatchat.server.knowledge_base.kb_service.base import KBServiceFactory from chatchat.server.knowledge_base.utils import validate_kb_name from chatchat...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/utils.py
libs/chatchat-server/chatchat/server/knowledge_base/utils.py
import importlib import json import os from functools import lru_cache from pathlib import Path from urllib.parse import urlencode from typing import Dict, Generator, List, Tuple, Union import chardet import langchain_community.document_loaders from langchain.docstore.document import Document from langchain.text_split...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/__init__.py
libs/chatchat-server/chatchat/server/knowledge_base/__init__.py
# from .kb_api import list_kbs, create_kb, delete_kb # from .kb_doc_api import list_docs, upload_doc, delete_doc, update_doc, download_doc, recreate_vector_store # from .utils import KnowledgeFile, KBServiceFactory
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_cache/faiss_cache.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_cache/faiss_cache.py
import os from langchain.docstore.in_memory import InMemoryDocstore from langchain.schema import Document from langchain.vectorstores.faiss import FAISS from chatchat.settings import Settings from chatchat.server.knowledge_base.kb_cache.base import * from chatchat.server.knowledge_base.utils import get_vs_path from c...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_cache/base.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_cache/base.py
import threading from collections import OrderedDict from contextlib import contextmanager from typing import Any, List, Tuple, Union, Generator from langchain.embeddings.base import Embeddings from langchain.vectorstores.faiss import FAISS from chatchat.utils import build_logger logger = build_logger() class Thr...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/model/kb_document_model.py
libs/chatchat-server/chatchat/server/knowledge_base/model/kb_document_model.py
from langchain.docstore.document import Document class DocumentWithVSId(Document): """ 矢量化后的文档 """ id: str = None score: float = 3.0
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_summary/summary_chunk.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_summary/summary_chunk.py
import asyncio import logging import sys from typing import List, Optional from langchain.chains import LLMChain, StuffDocumentsChain from langchain.chains.combine_documents.map_reduce import ( MapReduceDocumentsChain, ReduceDocumentsChain, ) from langchain.docstore.document import Document from langchain.outp...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_summary/__init__.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_summary/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_summary/base.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_summary/base.py
import os import shutil from abc import ABC, abstractmethod from typing import List from langchain.docstore.document import Document from chatchat.settings import Settings from chatchat.server.utils import get_default_embedding from chatchat.server.db.repository.knowledge_metadata_repository import ( add_summary_...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/chromadb_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/chromadb_kb_service.py
import uuid from typing import Any, Dict, List, Tuple import chromadb from chromadb.api.types import GetResult, QueryResult from langchain.docstore.document import Document from langchain_chroma import Chroma from chatchat.settings import Settings from chatchat.server.file_rag.utils import get_Retriever from chatchat...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/zilliz_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/zilliz_kb_service.py
from typing import Dict, List from langchain.schema import Document from langchain.vectorstores import Zilliz from chatchat.settings import Settings from chatchat.server.file_rag.utils import get_Retriever from chatchat.server.knowledge_base.kb_service.base import ( KBService, SupportedVSType, score_thres...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/relyt_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/relyt_kb_service.py
from typing import Dict, List from configs import kbs_config from langchain.schema import Document from langchain_community.vectorstores.pgvecto_rs import PGVecto_rs from sqlalchemy import create_engine, text from sqlalchemy.orm import Session from server.knowledge_base.kb_service.base import ( EmbeddingsFunAdapt...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/pg_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/pg_kb_service.py
import json import shutil from typing import Dict, List, Optional import sqlalchemy from langchain.schema import Document from langchain.vectorstores.pgvector import DistanceStrategy, PGVector from sqlalchemy import text from sqlalchemy.engine.base import Engine from sqlalchemy.orm import Session from chatchat.settin...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/milvus_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/milvus_kb_service.py
import os from typing import Dict, List, Optional from langchain.schema import Document from langchain.vectorstores.milvus import Milvus from chatchat.settings import Settings from chatchat.server.db.repository import list_file_num_docs_id_by_kb_name_and_file_name from chatchat.server.utils import get_Embeddings from...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/default_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/default_kb_service.py
from typing import List from langchain.embeddings.base import Embeddings from langchain.schema import Document from chatchat.server.knowledge_base.kb_service.base import KBService class DefaultKBService(KBService): def do_create_kb(self): pass def do_drop_kb(self): pass def do_add_doc(...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/es_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/es_kb_service.py
import logging import os import shutil from typing import List from elasticsearch import BadRequestError, Elasticsearch from langchain.schema import Document from langchain_community.vectorstores.elasticsearch import ( ApproxRetrievalStrategy, ElasticsearchStore, ) from chatchat.settings import Settings from ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/__init__.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/__init__.py
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/base.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/base.py
import operator import os from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from langchain.docstore.document import Document from chatchat.settings import Settings from chatchat.utils import build_logger from chatchat.server.db.models.knowledge_base_mod...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/knowledge_base/kb_service/faiss_kb_service.py
libs/chatchat-server/chatchat/server/knowledge_base/kb_service/faiss_kb_service.py
import os import shutil from typing import Dict, List, Tuple from langchain.docstore.document import Document from chatchat.settings import Settings from chatchat.server.file_rag.utils import get_Retriever from chatchat.server.knowledge_base.kb_cache.faiss_cache import ( ThreadSafeFaiss, kb_faiss_pool, ) from...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/amap_poi_search.py
libs/chatchat-server/chatchat/server/agent/tools_factory/amap_poi_search.py
import requests from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) from chatchat.server.utils import get_tool_config BASE_URL = "https://restapi.amap.com/v5/place/text" def amap_poi_search_engine(k...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/shell.py
libs/chatchat-server/chatchat/server/agent/tools_factory/shell.py
# LangChain 的 Shell 工具 from langchain_community.tools import ShellTool from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) @regist_tool(title="系统命令") def shell(query: str = Field(description="The c...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/url_reader.py
libs/chatchat-server/chatchat/server/agent/tools_factory/url_reader.py
""" 通过jina-ai/reader项目,将url内容处理为llm易于理解的文本形式 """ import requests import re from chatchat.server.pydantic_v1 import Field from chatchat.server.utils import get_tool_config from chatchat.server.agent.tools_factory.tools_registry import format_context from .tools_registry import regist_tool from langchain_chatchat.ag...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/text2sql.py
libs/chatchat-server/chatchat/server/agent/tools_factory/text2sql.py
from langchain.chains import LLMChain from langchain_community.utilities import SQLDatabase from langchain_core.prompts.prompt import PromptTemplate from langchain_experimental.sql import SQLDatabaseChain, SQLDatabaseSequentialChain from sqlalchemy import event from sqlalchemy.exc import OperationalError from chatchat...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/search_internet.py
libs/chatchat-server/chatchat/server/agent/tools_factory/search_internet.py
from typing import Dict, List from langchain.docstore.document import Document from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.utilities.bing_search import BingSearchAPIWrapper from langchain.utilities.duckduckgo_search import DuckDuckGoSearchAPIWrapper from langchain.utilities.searx_...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/search_youtube.py
libs/chatchat-server/chatchat/server/agent/tools_factory/search_youtube.py
from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) @regist_tool(title="油管视频") def search_youtube(query: str = Field(description="Query for Videos search")): """use this tools_factory to search ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/text2image.py
libs/chatchat-server/chatchat/server/agent/tools_factory/text2image.py
import base64 from datetime import datetime import os import uuid from typing import List, Literal import openai from PIL import Image from chatchat.settings import Settings from chatchat.server.pydantic_v1 import Field from chatchat.server.utils import MsgType, get_tool_config, get_model_info from .tools_registry i...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/text2promql.py
libs/chatchat-server/chatchat/server/agent/tools_factory/text2promql.py
import logging import requests from requests.auth import HTTPBasicAuth from urllib.parse import parse_qs from typing import Optional from langchain_core.prompts import ChatPromptTemplate from langchain_core.output_parsers import StrOutputParser from langchain_core.runnables import RunnablePassthrough from chatchat.se...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/__init__.py
libs/chatchat-server/chatchat/server/agent/tools_factory/__init__.py
from .arxiv import arxiv from .calculate import calculate from .search_internet import search_internet from .search_local_knowledgebase import search_local_knowledgebase from .search_youtube import search_youtube from .shell import shell from .text2image import text2images from .text2sql import text2sql from .weather_c...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/wolfram.py
libs/chatchat-server/chatchat/server/agent/tools_factory/wolfram.py
# Langchain 自带的 Wolfram Alpha API 封装 from chatchat.server.pydantic_v1 import Field from chatchat.server.utils import get_tool_config from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) @regist_tool def wolfram(query: str = Field(description="T...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/search_local_knowledgebase.py
libs/chatchat-server/chatchat/server/agent/tools_factory/search_local_knowledgebase.py
from urllib.parse import urlencode from chatchat.settings import Settings from chatchat.server.agent.tools_factory.tools_registry import ( regist_tool, format_context, ) from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) from chatchat.server.knowledge_base.kb_api import list_...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/arxiv.py
libs/chatchat-server/chatchat/server/agent/tools_factory/arxiv.py
# LangChain 的 ArxivQueryRun 工具 from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) @regist_tool(title="ARXIV论文") def arxiv(query: str = Field(description="The search query title")): """A wrapper...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/weather_check.py
libs/chatchat-server/chatchat/server/agent/tools_factory/weather_check.py
""" 简单的单参数输入工具实现,用于查询现在天气的情况 """ import requests from chatchat.server.pydantic_v1 import Field from chatchat.server.utils import get_tool_config from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) @regist_tool(title="天气查询") def weather_check( ...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/amap_weather.py
libs/chatchat-server/chatchat/server/agent/tools_factory/amap_weather.py
import requests from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) from chatchat.server.utils import get_tool_config BASE_DISTRICT_URL = "https://restapi.amap.com/v3/config/district" BASE_WEATHER_UR...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/calculate.py
libs/chatchat-server/chatchat/server/agent/tools_factory/calculate.py
from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOutput, ) @regist_tool(title="数学计算器") def calculate(text: str = Field(description="a math expression")) -> float: """ Useful to answer questions ab...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/tools_registry.py
libs/chatchat-server/chatchat/server/agent/tools_factory/tools_registry.py
from __future__ import annotations import json import re from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, List from langchain.agents import tool from langchain_core.tools import BaseTool from chatchat.server.knowledge_base.kb_doc_api import DocumentWithVSId from chatchat.server.pydantic_v1 impor...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false
chatchat-space/Langchain-Chatchat
https://github.com/chatchat-space/Langchain-Chatchat/blob/49165d6af4438aa7e8a1f71ce276db55f4405151/libs/chatchat-server/chatchat/server/agent/tools_factory/wikipedia_search.py
libs/chatchat-server/chatchat/server/agent/tools_factory/wikipedia_search.py
# LangChain 的 WikipediaQueryRun 工具 from langchain_community.tools import WikipediaQueryRun from langchain_community.utilities import WikipediaAPIWrapper from chatchat.server.pydantic_v1 import Field from .tools_registry import regist_tool from langchain_chatchat.agent_toolkits.all_tools.tool import ( BaseToolOu...
python
Apache-2.0
49165d6af4438aa7e8a1f71ce276db55f4405151
2026-01-04T14:41:43.908377Z
false