diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml deleted file mode 100644 index 3e824322..00000000 --- a/.github/workflows/test-pr.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Test Pull Request - -on: - pull_request: - types: [ready_for_review] - paths: - # 任何py文件改动都会触发 - - '**.py' - pull_request_review: - types: [submitted] - issue_comment: - types: [created] - # 允许手动触发 - workflow_dispatch: - -jobs: - perform-test: - runs-on: ubuntu-latest - # 如果事件为pull_request_review且review状态为approved,则执行 - if: > - github.event_name == 'pull_request' || - (github.event_name == 'pull_request_review' && github.event.review.state == 'APPROVED') || - github.event_name == 'workflow_dispatch' || - (github.event_name == 'issue_comment' && github.event.issue.pull_request != '' && contains(github.event.comment.body, '/test') && github.event.comment.user.login == 'RockChinQ') - steps: - # 签出测试工程仓库代码 - - name: Checkout - uses: actions/checkout@v2 - with: - # 仓库地址 - repository: RockChinQ/qcg-tester - # 仓库路径 - path: qcg-tester - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install dependencies - run: | - cd qcg-tester - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Get PR details - id: get-pr - if: github.event_name == 'issue_comment' - uses: octokit/request-action@v2.x - with: - route: GET /repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Set PR source branch as env variable - if: github.event_name == 'issue_comment' - run: | - PR_SOURCE_BRANCH=$(echo '${{ steps.get-pr.outputs.data }}' | jq -r '.head.ref') - echo "BRANCH=$PR_SOURCE_BRANCH" >> $GITHUB_ENV - - - name: Set PR Branch as bash env - if: github.event_name != 'issue_comment' - run: | - echo "BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV - - name: Set OpenAI API Key from Secrets - run: | - echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> $GITHUB_ENV - - name: Set OpenAI Reverse Proxy URL from Secrets - run: | - echo "OPENAI_REVERSE_PROXY=${{ secrets.OPENAI_REVERSE_PROXY }}" >> $GITHUB_ENV - - name: Run test - run: | - cd qcg-tester - python main.py - - - name: Upload coverage reports to Codecov - run: | - cd qcg-tester/resource/QChatGPT - curl -Os https://uploader.codecov.io/latest/linux/codecov - chmod +x codecov - ./codecov -t ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index db3cfc7d..dd19aa5a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .idea/ __pycache__/ database.db -qchatgpt.log langbot.log /banlist.py /plugins/ @@ -17,8 +16,7 @@ scenario/ !scenario/default-template.json override.json cookies.json -res/announcement_saved -res/announcement_saved.json +data/labels/announcement_saved.json cmdpriv.json tips.py .venv @@ -32,7 +30,7 @@ claude.json bard.json /*yaml !/docker-compose.yaml -res/instance_id.json +data/labels/instance_id.json .DS_Store /data botpy.log* diff --git a/pkg/audit/identifier.py b/pkg/audit/identifier.py index 7c197c14..3e2ec57d 100644 --- a/pkg/audit/identifier.py +++ b/pkg/audit/identifier.py @@ -13,14 +13,14 @@ identifier = { 'instance_create_ts': 0, } -HOST_ID_FILE = os.path.expanduser('~/.qchatgpt/host_id.json') -INSTANCE_ID_FILE = 'res/instance_id.json' +HOST_ID_FILE = os.path.expanduser('~/.langbot/host_id.json') +INSTANCE_ID_FILE = 'data/labels/instance_id.json' def init(): global identifier - if not os.path.exists(os.path.expanduser('~/.qchatgpt')): - os.mkdir(os.path.expanduser('~/.qchatgpt')) + if not os.path.exists(os.path.expanduser('~/.langbot')): + os.mkdir(os.path.expanduser('~/.langbot')) if not os.path.exists(HOST_ID_FILE): new_host_id = 'host_'+str(uuid.uuid4()) diff --git a/pkg/core/bootutils/files.py b/pkg/core/bootutils/files.py index 9bab3826..f52f7b09 100644 --- a/pkg/core/bootutils/files.py +++ b/pkg/core/bootutils/files.py @@ -24,6 +24,7 @@ required_paths = [ "data/scenario", "data/logs", "data/config", + "data/labels", "plugins" ] diff --git a/pkg/pipeline/process/handlers/chat.py b/pkg/pipeline/process/handlers/chat.py index 975b18cc..83bb3335 100644 --- a/pkg/pipeline/process/handlers/chat.py +++ b/pkg/pipeline/process/handlers/chat.py @@ -105,7 +105,7 @@ class ChatMessageHandler(handler.MessageHandler): await self.ap.ctr_mgr.usage.post_query_record( session_type=query.session.launcher_type.value, session_id=str(query.session.launcher_id), - query_ability_provider="QChatGPT.Chat", + query_ability_provider="LangBot.Chat", usage=text_length, model_name=query.use_model.name, response_seconds=int(time.time() - start_time), diff --git a/pkg/plugin/context.py b/pkg/plugin/context.py index 65abc862..55f51040 100644 --- a/pkg/plugin/context.py +++ b/pkg/plugin/context.py @@ -127,16 +127,16 @@ class APIHost: Returns: bool: 是否满足要求, False时为无法获取版本号,True时为满足要求,报错为不满足要求 """ - qchatgpt_version = "" + langbot_version = "" try: - qchatgpt_version = self.ap.ver_mgr.get_current_version() # 从updater模块获取版本号 + langbot_version = self.ap.ver_mgr.get_current_version() # 从updater模块获取版本号 except: return False - if self.ap.ver_mgr.compare_version_str(qchatgpt_version, ge) < 0 or \ - (self.ap.ver_mgr.compare_version_str(qchatgpt_version, le) > 0): - raise Exception("LangBot 版本不满足要求,某些功能(可能是由插件提供的)无法正常使用。(要求版本:{}-{},但当前版本:{})".format(ge, le, qchatgpt_version)) + if self.ap.ver_mgr.compare_version_str(langbot_version, ge) < 0 or \ + (self.ap.ver_mgr.compare_version_str(langbot_version, le) > 0): + raise Exception("LangBot 版本不满足要求,某些功能(可能是由插件提供的)无法正常使用。(要求版本:{}-{},但当前版本:{})".format(ge, le, langbot_version)) return True diff --git a/pkg/utils/announce.py b/pkg/utils/announce.py index d3297c29..1fb6e166 100644 --- a/pkg/utils/announce.py +++ b/pkg/utils/announce.py @@ -62,11 +62,11 @@ class AnnouncementManager: async def fetch_saved( self ) -> list[Announcement]: - if not os.path.exists("res/announcement_saved.json"): - with open("res/announcement_saved.json", "w", encoding="utf-8") as f: + if not os.path.exists("data/labels/announcement_saved.json"): + with open("data/labels/announcement_saved.json", "w", encoding="utf-8") as f: f.write("[]") - with open("res/announcement_saved.json", "r", encoding="utf-8") as f: + with open("data/labels/announcement_saved.json", "r", encoding="utf-8") as f: content = f.read() if not content: @@ -79,7 +79,7 @@ class AnnouncementManager: content: list[Announcement] ): - with open("res/announcement_saved.json", "w", encoding="utf-8") as f: + with open("data/labels/announcement_saved.json", "w", encoding="utf-8") as f: f.write(json.dumps([ item.to_dict() for item in content ], indent=4, ensure_ascii=False))