From b42a77465b8f5d5f36a92e82d834c539e732cb9c Mon Sep 17 00:00:00 2001 From: yhjun1026 <460342015@qq.com> Date: Thu, 19 Oct 2023 19:19:41 +0800 Subject: [PATCH] feat(ChatExcel): ChatExcel example file add example excel file use to test ChatExcel --- pilot/base_modules/agent/db/my_plugin_db.py | 7 +++++-- pilot/base_modules/agent/db/plugin_hub_db.py | 14 +++++++++----- pilot/memory/chat_history/chat_history_db.py | 15 +++++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pilot/base_modules/agent/db/my_plugin_db.py b/pilot/base_modules/agent/db/my_plugin_db.py index b021088db..acfb70e23 100644 --- a/pilot/base_modules/agent/db/my_plugin_db.py +++ b/pilot/base_modules/agent/db/my_plugin_db.py @@ -9,7 +9,10 @@ from pilot.base_modules.meta_data.meta_data import Base, engine, session class MyPluginEntity(Base): __tablename__ = "my_plugin" - + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } id = Column(Integer, primary_key=True, comment="autoincrement id") tenant = Column(String(255), nullable=True, comment="user's tenant") user_code = Column(String(255), nullable=False, comment="user code") @@ -27,7 +30,7 @@ class MyPluginEntity(Base): created_at = Column( DateTime, default=datetime.utcnow, comment="plugin install time" ) - __table_args__ = (UniqueConstraint("user_code", "name", name="uk_name"),) + UniqueConstraint("user_code", "name", name="uk_name") class MyPluginDao(BaseDao[MyPluginEntity]): diff --git a/pilot/base_modules/agent/db/plugin_hub_db.py b/pilot/base_modules/agent/db/plugin_hub_db.py index 8507bcc8e..872324e33 100644 --- a/pilot/base_modules/agent/db/plugin_hub_db.py +++ b/pilot/base_modules/agent/db/plugin_hub_db.py @@ -1,7 +1,7 @@ from datetime import datetime import pytz from typing import List -from sqlalchemy import Column, Integer, String, Index, DateTime, func, Boolean +from sqlalchemy import Column, Integer, String, Index, DateTime, func, Boolean, DDL from sqlalchemy import UniqueConstraint from pilot.base_modules.meta_data.meta_data import Base @@ -9,8 +9,13 @@ from pilot.base_modules.meta_data.base_dao import BaseDao from pilot.base_modules.meta_data.meta_data import Base, engine, session +char_set_sql = DDL("ALTER TABLE plugin_hub CONVERT TO CHARACTER SET utf8mb4") class PluginHubEntity(Base): __tablename__ = "plugin_hub" + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } id = Column( Integer, primary_key=True, autoincrement=True, comment="autoincrement id" ) @@ -26,10 +31,9 @@ class PluginHubEntity(Base): created_at = Column(DateTime, default=datetime.utcnow, comment="plugin upload time") installed = Column(Integer, default=False, comment="plugin already installed count") - __table_args__ = ( - UniqueConstraint("name", name="uk_name"), - Index("idx_q_type", "type"), - ) + UniqueConstraint("name", name="uk_name") + Index("idx_q_type", "type") + class PluginHubDao(BaseDao[PluginHubEntity]): diff --git a/pilot/memory/chat_history/chat_history_db.py b/pilot/memory/chat_history/chat_history_db.py index 2b1a57c28..6d66d5d4c 100644 --- a/pilot/memory/chat_history/chat_history_db.py +++ b/pilot/memory/chat_history/chat_history_db.py @@ -10,6 +10,10 @@ class ChatHistoryEntity(Base): id = Column( Integer, primary_key=True, autoincrement=True, comment="autoincrement id" ) + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } conv_uid = Column( String(255), unique=False, @@ -21,12 +25,11 @@ class ChatHistoryEntity(Base): user_name = Column(String(255), nullable=True, comment="interlocutor") messages = Column(Text, nullable=True, comment="Conversation details") - __table_args__ = ( - UniqueConstraint("conv_uid", name="uk_conversation"), - Index("idx_q_user", "user_name"), - Index("idx_q_mode", "chat_mode"), - Index("idx_q_conv", "summary"), - ) + UniqueConstraint("conv_uid", name="uk_conversation") + Index("idx_q_user", "user_name") + Index("idx_q_mode", "chat_mode") + Index("idx_q_conv", "summary") + class ChatHistoryDao(BaseDao[ChatHistoryEntity]):