Skip to content

Commit

Permalink
Feat/0.2.0 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaojin3616 committed Sep 19, 2023
2 parents 92390f5 + 34b2b12 commit a1a8833
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 36 deletions.
3 changes: 3 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:
- seccomp:unconfined
command: bash -c "uvicorn bisheng.main:app --host 0.0.0.0 --port 7860 --workers 2" # --workers 表示使用几个进程,提高并发度
restart: on-failure
depends_on:
- "mysql"
- "redis"

nginx:
image: dataelement/bisheng-frontend:latest
Expand Down
12 changes: 6 additions & 6 deletions docker/mysql/conf/my.cnf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[client]
default-character-set=utf8
default-character-set=utf8mb4

[mysql]
default-character-set=utf8
default-character-set=utf8mb4

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
init_connect='SET collation_connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
3 changes: 2 additions & 1 deletion src/backend/bisheng/chat/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ async def process_message(self,
steps = []
for s in intermediate_steps.split('\n'):
if s.startswith("Answer: {'"):
# s = 'Answer: ' + eval(s.split('Answer:')[1]).get('result')
if 'result' in s:
s = 'Answer: ' + eval(s.split('Answer:')[1]).get('result')
pass
step.append(s)
if not s:
Expand Down
15 changes: 10 additions & 5 deletions src/backend/bisheng/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ admin:
user_name: "admin"
password: "1234"

bisheng-rt:
name: "RT-Server"
server: "127.0.0.1:9001"
# bisheng-rt:
# name: "RT-Server"
# server: "127.0.0.1:9001"

# 为知识库的embedding进行模型撇脂
knowledges:
Expand All @@ -20,6 +20,11 @@ knowledges:
openai_api_base: "https://api.openai.com/v1"
openai_proxy: ""
openai_api_key: ""
embedding-host:
deployment:
embedding_ctx_length:
host_base_url:
model:
vectorstores:
# Milvus 最低要求cpu 4C 8G 推荐4C 16G
Milvus: # 如果需要切换其他vectordb,确保其他服务已经启动,然后配置对应参数
Expand Down Expand Up @@ -129,8 +134,6 @@ documentloaders:
PDFWithSemanticLoader:
documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/git"
embeddings:
OpenAIProxyEmbedding:
documentation: ""
OpenAIEmbeddings:
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/openai"
HuggingFaceEmbeddings:
Expand Down Expand Up @@ -314,6 +317,8 @@ utilities:
WolframAlphaAPIWrapper:
documentation: ""
retrievers:
MultiVectorRetriever:
documentation: ""
MultiQueryRetriever:
documentation: "https://python.langchain.com/docs/modules/data_connection/retrievers/how_to/MultiQueryRetriever"
# https://github.com/supabase-community/supabase-py/issues/482
Expand Down
11 changes: 7 additions & 4 deletions src/backend/bisheng/database/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ class MessageBase(SQLModelSerializable):
user_id: Optional[str] = Field(index=True)
intermediate_steps: Optional[str] = Field(index=False, sa_column=Column(Text))
files: Optional[str] = Field(index=False)
create_time: Optional[datetime] = Field(
sa_column=Column(DateTime, nullable=False, index=True, server_default=text('CURRENT_TIMESTAMP')))
update_time: Optional[datetime] = Field(sa_column=Column(
DateTime, nullable=False, server_default=text('CURRENT_TIMESTAMP'), onupdate=text('CURRENT_TIMESTAMP')))
create_time: Optional[datetime] = Field(sa_column=Column(
DateTime, nullable=False, index=True, server_default=text('CURRENT_TIMESTAMP')))
update_time: Optional[datetime] = Field(
sa_column=Column(DateTime,
nullable=False,
server_default=text('CURRENT_TIMESTAMP'),
onupdate=text('CURRENT_TIMESTAMP')))


class ChatMessage(MessageBase, table=True):
Expand Down
17 changes: 10 additions & 7 deletions src/backend/bisheng/database/models/model_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ class ModelDeployBase(SQLModelSerializable):
endpoint: str = Field(index=False, unique=False)
server: str = Field(index=True)
model: str = Field(index=False)
config: Optional[str] = Field(index=False, sa_column=(String(length=1024)))
config: Optional[str] = Field(index=False, sa_column=Column(String(length=1024)))
status: Optional[str] = Field(index=False)
remark: Optional[str] = Field(index=False, sa_column=(String(length=4096)))

create_time: Optional[datetime] = Field(
sa_column=Column(DateTime, nullable=False, index=True, server_default=text('CURRENT_TIMESTAMP')))
update_time: Optional[datetime] = Field(sa_column=Column(
DateTime, nullable=False, server_default=text('CURRENT_TIMESTAMP'), onupdate=text('CURRENT_TIMESTAMP')))
remark: Optional[str] = Field(index=False, sa_column=Column(String(length=4096)))

create_time: Optional[datetime] = Field(sa_column=Column(
DateTime, nullable=False, index=True, server_default=text('CURRENT_TIMESTAMP')))
update_time: Optional[datetime] = Field(
sa_column=Column(DateTime,
nullable=False,
server_default=text('CURRENT_TIMESTAMP'),
onupdate=text('CURRENT_TIMESTAMP')))


class ModelDeploy(ModelDeployBase, table=True):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from bisheng.template.field.base import TemplateField
from bisheng.template.frontend_node.constants import FORCE_SHOW_FIELDS
from bisheng.template.frontend_node.formatter.base import FieldFormatter
from bisheng.utils.constants import (ANTHROPIC_MODELS, CHAT_OPENAI_MODELS,
OPENAI_MODELS)
from bisheng.utils.constants import ANTHROPIC_MODELS, CHAT_OPENAI_MODELS, OPENAI_MODELS


class OpenAIAPIKeyFormatter(FieldFormatter):
Expand Down Expand Up @@ -97,12 +96,10 @@ class ShowFieldFormatter(FieldFormatter):
def format(self, field: TemplateField, name: Optional[str] = None) -> None:
key = field.name
required = field.required
field.show = (
(required and key not in ['input_variables'])
or key in FORCE_SHOW_FIELDS
or 'api' in key
or ('key' in key and 'input' not in key and 'output' not in key)
)
field.show = ((required and
(key not in ['input_variables'] or name == 'SequentialChain')) or
key in FORCE_SHOW_FIELDS or 'api' in key or
('key' in key and 'input' not in key and 'output' not in key))


class PasswordFieldFormatter(FieldFormatter):
Expand Down
4 changes: 1 addition & 3 deletions src/backend/bisheng/template/frontend_node/input_output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from bisheng.template.field.base import TemplateField
from bisheng.template.frontend_node.base import FrontendNode
from bisheng.template.template.base import Template
Expand Down Expand Up @@ -27,6 +25,7 @@ class InputNode(FrontendNode):
def to_dict(self):
return super().to_dict()


class InputFileNode(FrontendNode):
name: str = 'InputFileNode'
template: Template = Template(
Expand All @@ -46,7 +45,6 @@ class InputFileNode(FrontendNode):
description: str = """输入节点,用来自动对接输入"""
base_classes: list[str] = ['fileNode']


def to_dict(self):
return super().to_dict()

Expand Down
3 changes: 3 additions & 0 deletions src/backend/bisheng/template/frontend_node/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,6 @@ def format_field(field: TemplateField, name: Optional[str] = None) -> None:
elif field.name == 'connection_args':
field.show = True
field.advanced = False

elif field.name == 'collection_name' and name == 'Milvus':
field.value = ''
3 changes: 2 additions & 1 deletion src/backend/bisheng/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ def format_dict(d, name: Optional[str] = None):
value['type'] = 'int' if key in ['max_value_length'] else value['type']

# Show or not field
value['show'] = bool((value['required'] and key not in ['input_variables']) or
value['show'] = bool((value['required'] and
(key not in ['input_variables'] or name == 'SequentialChain')) or
key in FORCE_SHOW_FIELDS or 'api_key' in key)

# Add password field
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include = ["./bisheng/*", "bisheng/**/*"]
bisheng = "bisheng.__main__:main"

[tool.poetry.dependencies]
bisheng_langchain = "^0.1.3"
bisheng_langchain = "^0.1.4"
fastapi_jwt_auth = "^0.5.0"
redis = "^5.0.0"
jieba = "^0.42.1"
Expand Down
8 changes: 8 additions & 0 deletions src/bisheng-langchain/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
<<<<<<< Updated upstream
<<<<<<< Updated upstream
v0.1.3
=======
v0.1.2
>>>>>>> Stashed changes
=======
v0.1.2
>>>>>>> Stashed changes

0 comments on commit a1a8833

Please sign in to comment.