Skip to content

Commit d1478dc

Browse files
committed
Merge branch 'main_upstream'
# Conflicts: # Dockerfile # biz/llm/client/deepseek.py # biz/llm/client/openai.py # biz/llm/client/zhipuai.py # biz/llm/factory.py # biz/utils/code_reviewer.py # biz/utils/reporter.py # conf/prompt_templates.yml # docker-compose.prod.yml # docker-compose.yml # locales/zh_CN/prompt_templates.yml # prompt_templates.yml # requirements.txt # ui.py
2 parents 1c2a334 + 5f1cf53 commit d1478dc

36 files changed

+407
-228
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
venv/
33
test/
44
.idea/
5-
docker
65

76
log/*
87
!log/.gitkeep
98
data/*
109
!data/.gitkeep
1110

12-
.env
11+
conf/.env
1312
.pyc
1413
__pycache__/
1514
.cursorignore

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,24 @@ COPY requirements.txt .
1313
# 安装依赖
1414
RUN pip install --no-cache-dir -r requirements.txt
1515

16+
RUN mkdir -p log data
1617
COPY biz ./biz
17-
COPY core ./core
1818
COPY locales ./locales
1919
COPY api.py ./api.py
2020
COPY ui.py ./ui.py
21-
RUN mkdir -p log data
2221

2322
# 使用 supervisord 作为启动命令
2423
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
2524

2625
FROM base AS dev
27-
COPY supervisord.dev.conf /etc/supervisor/conf.d/supervisord.conf
26+
COPY ./conf/supervisord.dev.conf /etc/supervisor/conf.d/supervisord.conf
2827
# 暴露 Flask 和 Streamlit 的端口
2928
EXPOSE 5001 5002
3029

3130
FROM base AS prod
32-
COPY supervisord.prod.conf /etc/supervisor/conf.d/supervisord.conf
31+
COPY ./conf/supervisord.prod.conf /etc/supervisor/conf.d/supervisord.conf
3332
# 暴露 Flask 和 Streamlit 的端口
3433
EXPOSE 5001 5002
3534

3635
FROM base AS worker
37-
COPY supervisord.worker.conf /etc/supervisor/conf.d/supervisord.conf
36+
COPY ./conf/supervisord.worker.conf /etc/supervisor/conf.d/supervisord.conf

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
![MR图片](./doc/img/mr.png)
1919

20-
![Note图片](./doc/img/note.jpeg)
20+
![Note图片](./doc/img/note.jpg)
2121

22-
![Dashboard图片](./doc/img/dashboard.png)
22+
![Dashboard图片](./doc/img/dashboard.jpg)
2323

2424
## 原理
2525

api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from biz.utils.queue import handle_queue
1919
from biz.utils.reporter import Reporter
2020

21-
load_dotenv()
21+
load_dotenv("conf/.env")
2222
api_app = Flask(__name__)
2323

2424
from biz.utils.i18n import get_translator
File renamed without changes.
File renamed without changes.

core/llm/client/base.py renamed to biz/llm/client/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from abc import abstractmethod
22
from typing import List, Dict, Optional
33

4-
from core.llm.types import NotGiven, NOT_GIVEN, CompletionMessage
4+
from biz.llm.types import NotGiven, NOT_GIVEN
55

66

77
class BaseClient:

core/llm/client/deepseek.py renamed to biz/llm/client/deepseek.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
import os
22
from typing import Dict, List, Optional
33

4-
from dotenv import load_dotenv
54
from openai import OpenAI
6-
from biz.utils.log import logger
75

8-
from core.llm.client.base import BaseClient
9-
from core.llm.types import NotGiven, NOT_GIVEN
6+
from biz.llm.client.base import BaseClient
7+
from biz.llm.types import NotGiven, NOT_GIVEN
108
from biz.utils.i18n import get_translator
9+
from biz.utils.log import logger
10+
1111
_ = get_translator()
1212

13+
1314
class DeepSeekClient(BaseClient):
1415
def __init__(self, api_key: str = None):
15-
if not os.getenv("DEEPSEEK_API_KEY"):
16-
load_dotenv()
1716
self.api_key = api_key or os.getenv("DEEPSEEK_API_KEY")
1817
self.base_url = os.getenv("DEEPSEEK_API_BASE_URL", "https://api.deepseek.com")
1918
if not self.api_key:
2019
raise ValueError(_("API key is required. Please provide it or set it in the environment variables."))
2120

22-
self.client = OpenAI(api_key=self.api_key, base_url=self.base_url) # DeepSeek supports OpenAI API SDK
21+
self.client = OpenAI(api_key=self.api_key, base_url=self.base_url) # DeepSeek supports OpenAI API SDK
2322
self.default_model = os.getenv("DEEPSEEK_API_MODEL", "deepseek-chat")
2423

2524
def completions(self,
@@ -28,19 +27,20 @@ def completions(self,
2827
) -> str:
2928
try:
3029
model = model or self.default_model
31-
logger.debug(_("Sending request to DeepSeek API. Model: {model}, Messages: {messages}").format(model=model, messages=messages))
32-
30+
logger.debug(_("Sending request to DeepSeek API. Model: {model}, Messages: {messages}").format(model=model,
31+
messages=messages))
32+
3333
completion = self.client.chat.completions.create(
3434
model=model,
3535
messages=messages
3636
)
37-
37+
3838
if not completion or not completion.choices:
3939
logger.error(_("Empty response from DeepSeek API"))
4040
return _("AI服务返回为空,请稍后重试")
41-
41+
4242
return completion.choices[0].message.content
43-
43+
4444
except Exception as e:
4545
logger.error(_("DeepSeek API error: {e}").format(e=str(e)))
4646
# 检查是否是认证错误

core/llm/client/ollama_client.py renamed to biz/llm/client/ollama_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from ollama import ChatResponse
66
from ollama import Client
77

8-
from core.llm.client.base import BaseClient
9-
from core.llm.types import NotGiven, NOT_GIVEN
8+
from biz.llm.client.base import BaseClient
9+
from biz.llm.types import NotGiven, NOT_GIVEN
1010

1111

1212
class OllamaClient(BaseClient):

core/llm/client/openai.py renamed to biz/llm/client/openai.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import os
22
from typing import Dict, List, Optional
33

4-
from dotenv import load_dotenv
54
from openai import OpenAI
65

7-
from core.llm.client.base import BaseClient
8-
from core.llm.types import NotGiven, NOT_GIVEN
6+
from biz.llm.client.base import BaseClient
7+
from biz.llm.types import NotGiven, NOT_GIVEN
98
from biz.utils.i18n import get_translator
9+
1010
_ = get_translator()
1111

12+
1213
class OpenAIClient(BaseClient):
1314
def __init__(self, api_key: str = None):
14-
if not os.getenv("OPENAI_API_KEY"):
15-
load_dotenv()
1615
self.api_key = api_key or os.getenv("OPENAI_API_KEY")
1716
self.base_url = os.getenv("OPENAI_API_BASE_URL", "https://api.openai.com")
1817
if not self.api_key:

0 commit comments

Comments
 (0)