mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-08 23:06:03 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd10db3c75 | ||
|
|
db4c658980 | ||
|
|
0ee88674f8 | ||
|
|
3540759682 | ||
|
|
44cc8f15b4 | ||
|
|
59f821bf0a | ||
|
|
80858672b0 | ||
|
|
3258d5b255 | ||
|
|
e8c8cc0a9c | ||
|
|
570c19f29f | ||
|
|
ee93fd8636 | ||
|
|
1e6c32ffc7 |
42
.github/workflows/build-docker-image.yml
vendored
42
.github/workflows/build-docker-image.yml
vendored
@@ -17,22 +17,32 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if [ -z "$GITHUB_REF" ]; then
|
if [ -z "$GITHUB_REF" ]; then
|
||||||
export GITHUB_REF=${{ github.ref }}
|
export GITHUB_REF=${{ github.ref }}
|
||||||
|
echo $GITHUB_REF
|
||||||
|
fi
|
||||||
|
# - name: Check GITHUB_REF env
|
||||||
|
# run: echo $GITHUB_REF
|
||||||
|
# - name: Get version # 在 GitHub Actions 运行环境
|
||||||
|
# id: get_version
|
||||||
|
# if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||||||
|
# run: export GITHUB_REF=${GITHUB_REF/refs\/tags\//}
|
||||||
|
- name: Check version
|
||||||
|
id: check_version
|
||||||
|
run: |
|
||||||
|
echo $GITHUB_REF
|
||||||
|
# 如果是tag,则去掉refs/tags/前缀
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
echo "It's a tag"
|
||||||
|
echo $GITHUB_REF
|
||||||
|
echo $GITHUB_REF | awk -F '/' '{print $3}'
|
||||||
|
echo ::set-output name=version::$(echo $GITHUB_REF | awk -F '/' '{print $3}')
|
||||||
|
else
|
||||||
|
echo "It's not a tag"
|
||||||
|
echo $GITHUB_REF
|
||||||
|
echo ::set-output name=version::${GITHUB_REF}
|
||||||
fi
|
fi
|
||||||
- name: Check GITHUB_REF env
|
|
||||||
run: echo $GITHUB_REF
|
|
||||||
- name: Get version
|
|
||||||
id: get_version
|
|
||||||
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
|
||||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
|
||||||
- name: Build # image name: rockchin/qchatgpt:<VERSION>
|
|
||||||
run: docker build --network=host -t rockchin/qchatgpt:${{ steps.get_version.outputs.VERSION }} -t rockchin/qchatgpt:latest .
|
|
||||||
- name: Login to Registry
|
- name: Login to Registry
|
||||||
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
|
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
- name: Create Buildx
|
||||||
- name: Push image
|
run: docker buildx create --name mybuilder --use
|
||||||
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
- name: Build # image name: rockchin/qchatgpt:<VERSION>
|
||||||
run: docker push rockchin/qchatgpt:${{ steps.get_version.outputs.VERSION }}
|
run: docker buildx build --platform linux/arm64,linux/amd64 -t rockchin/qchatgpt:${{ steps.check_version.outputs.version }} -t rockchin/qchatgpt:latest . --push
|
||||||
|
|
||||||
- name: Push latest image
|
|
||||||
if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
|
||||||
run: docker push rockchin/qchatgpt:latest
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN python -m pip install -r requirements.txt
|
RUN apt update \
|
||||||
|
&& apt install gcc -y \
|
||||||
|
&& python -m pip install -r requirements.txt
|
||||||
|
|
||||||
CMD [ "python", "main.py" ]
|
CMD [ "python", "main.py" ]
|
||||||
@@ -53,7 +53,7 @@ class CommandOperator(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
usage: str = None
|
usage: str = None
|
||||||
|
|
||||||
parent_class: typing.Type[CommandOperator] | None = None
|
parent_class: typing.Union[typing.Type[CommandOperator], None] = None
|
||||||
"""父节点类。标记以供管理器在初始化时编织父子关系。"""
|
"""父节点类。标记以供管理器在初始化时编织父子关系。"""
|
||||||
|
|
||||||
lowest_privilege: int = 0
|
lowest_privilege: int = 0
|
||||||
|
|||||||
@@ -23,3 +23,12 @@ class MessageHandler(metaclass=abc.ABCMeta):
|
|||||||
query: core_entities.Query,
|
query: core_entities.Query,
|
||||||
) -> entities.StageProcessResult:
|
) -> entities.StageProcessResult:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def cut_str(self, s: str) -> str:
|
||||||
|
"""
|
||||||
|
取字符串第一行,最多20个字符,若有多行,或超过20个字符,则加省略号
|
||||||
|
"""
|
||||||
|
s0 = s.split('\n')[0]
|
||||||
|
if len(s0) > 20 or '\n' in s:
|
||||||
|
s0 = s0[:20] + '...'
|
||||||
|
return s0
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ class ChatMessageHandler(handler.MessageHandler):
|
|||||||
async for result in query.use_model.requester.request(query):
|
async for result in query.use_model.requester.request(query):
|
||||||
query.resp_messages.append(result)
|
query.resp_messages.append(result)
|
||||||
|
|
||||||
|
self.ap.logger.info(f'对话({query.query_id})响应: {self.cut_str(result.readable_str())}')
|
||||||
|
|
||||||
if result.content is not None:
|
if result.content is not None:
|
||||||
text_length += len(result.content)
|
text_length += len(result.content)
|
||||||
|
|
||||||
@@ -86,6 +88,9 @@ class ChatMessageHandler(handler.MessageHandler):
|
|||||||
new_query=query
|
new_query=query
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
self.ap.logger.error(f'对话({query.query_id})请求失败: {str(e)}')
|
||||||
|
|
||||||
yield entities.StageProcessResult(
|
yield entities.StageProcessResult(
|
||||||
result_type=entities.ResultType.INTERRUPT,
|
result_type=entities.ResultType.INTERRUPT,
|
||||||
new_query=query,
|
new_query=query,
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ class CommandHandler(handler.MessageHandler):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.ap.logger.info(f'命令({query.query_id})报错: {self.cut_str(str(ret.error))}')
|
||||||
|
|
||||||
yield entities.StageProcessResult(
|
yield entities.StageProcessResult(
|
||||||
result_type=entities.ResultType.CONTINUE,
|
result_type=entities.ResultType.CONTINUE,
|
||||||
new_query=query
|
new_query=query
|
||||||
@@ -106,6 +108,8 @@ class CommandHandler(handler.MessageHandler):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.ap.logger.info(f'命令返回: {self.cut_str(ret.text)}')
|
||||||
|
|
||||||
yield entities.StageProcessResult(
|
yield entities.StageProcessResult(
|
||||||
result_type=entities.ResultType.CONTINUE,
|
result_type=entities.ResultType.CONTINUE,
|
||||||
new_query=query
|
new_query=query
|
||||||
|
|||||||
@@ -34,7 +34,12 @@ class Processor(stage.PipelineStage):
|
|||||||
|
|
||||||
self.ap.logger.info(f"处理 {query.launcher_type.value}_{query.launcher_id} 的请求({query.query_id}): {message_text}")
|
self.ap.logger.info(f"处理 {query.launcher_type.value}_{query.launcher_id} 的请求({query.query_id}): {message_text}")
|
||||||
|
|
||||||
if message_text.startswith('!') or message_text.startswith('!'):
|
async def generator():
|
||||||
return self.cmd_handler.handle(query)
|
if message_text.startswith('!') or message_text.startswith('!'):
|
||||||
else:
|
async for result in self.cmd_handler.handle(query):
|
||||||
return self.chat_handler.handle(query)
|
yield result
|
||||||
|
else:
|
||||||
|
async for result in self.chat_handler.handle(query):
|
||||||
|
yield result
|
||||||
|
|
||||||
|
return generator()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from ..provider import entities as llm_entities
|
|||||||
|
|
||||||
class BaseEventModel(pydantic.BaseModel):
|
class BaseEventModel(pydantic.BaseModel):
|
||||||
|
|
||||||
query: core_entities.Query | None
|
query: typing.Union[core_entities.Query, None]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
arbitrary_types_allowed = True
|
arbitrary_types_allowed = True
|
||||||
|
|||||||
@@ -31,3 +31,13 @@ class Message(pydantic.BaseModel):
|
|||||||
tool_calls: typing.Optional[list[ToolCall]] = None
|
tool_calls: typing.Optional[list[ToolCall]] = None
|
||||||
|
|
||||||
tool_call_id: typing.Optional[str] = None
|
tool_call_id: typing.Optional[str] = None
|
||||||
|
|
||||||
|
def readable_str(self) -> str:
|
||||||
|
if self.content is not None:
|
||||||
|
return self.content
|
||||||
|
elif self.function_call is not None:
|
||||||
|
return f'{self.function_call.name}({self.function_call.arguments})'
|
||||||
|
elif self.tool_calls is not None:
|
||||||
|
return f'调用工具: {self.tool_calls[0].id}'
|
||||||
|
else:
|
||||||
|
return '未知消息'
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -31,6 +31,18 @@ class VersionManager:
|
|||||||
|
|
||||||
return current_tag
|
return current_tag
|
||||||
|
|
||||||
|
async def get_release_list(self) -> list:
|
||||||
|
"""获取发行列表"""
|
||||||
|
rls_list_resp = requests.get(
|
||||||
|
url="https://api.github.com/repos/RockChinQ/QChatGPT/releases",
|
||||||
|
proxies=self.ap.proxy_mgr.get_forward_proxies(),
|
||||||
|
timeout=5
|
||||||
|
)
|
||||||
|
|
||||||
|
rls_list = rls_list_resp.json()
|
||||||
|
|
||||||
|
return rls_list
|
||||||
|
|
||||||
async def update_all(self):
|
async def update_all(self):
|
||||||
"""检查更新并下载源码"""
|
"""检查更新并下载源码"""
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
requests
|
requests
|
||||||
openai
|
openai>1.0.0
|
||||||
colorlog~=6.6.0
|
colorlog~=6.6.0
|
||||||
yiri-mirai-rc
|
yiri-mirai-rc
|
||||||
aiocqhttp
|
aiocqhttp
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
{
|
{
|
||||||
"adapter": "aiocqhttp",
|
"adapter": "aiocqhttp",
|
||||||
"enable": false,
|
"enable": false,
|
||||||
"host": "127.0.0.1",
|
"host": "0.0.0.0",
|
||||||
"port": 8080
|
"port": 8080
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user