commit 7914b452efeb76c903831fea3c2a5d78bda7b699 Author: Developer Date: Thu May 28 15:15:25 2026 +0000 docs: add VITE_API_BASE_URL documentation for remote/VPS deployment Signed-off-by: god032396-del diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..0e84a5ac --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +.git +.github +.gitignore +.cursor +.DS_Store +.env + +node_modules +frontend/node_modules +backend/.venv +.venv +.python-version + +__pycache__ +*.pyc +.pytest_cache +.mypy_cache +.ruff_cache + +frontend/dist +frontend/.vite + +backend/uploads diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..517921c8 --- /dev/null +++ b/.env.example @@ -0,0 +1,20 @@ +# LLM API配置(支持 OpenAI SDK 格式的任意 LLM API) +# 推荐使用阿里百炼平台qwen-plus模型:https://bailian.console.aliyun.com/ +# 注意消耗较大,可先进行小于40轮的模拟尝试 +LLM_API_KEY=your_api_key_here +LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1 +LLM_MODEL_NAME=qwen-plus + +# ===== ZEP记忆图谱配置 ===== +# 每月免费额度即可支撑简单使用:https://app.getzep.com/ +ZEP_API_KEY=your_zep_api_key_here + +# ===== 加速 LLM 配置(可选)===== +# 注意如果不使用加速配置,env文件中就不要出现下面的配置项 +LLM_BOOST_API_KEY=your_api_key_here +LLM_BOOST_BASE_URL=your_base_url_here +LLM_BOOST_MODEL_NAME=your_model_name_here + +# ===== 前端 API 地址配置(远程/VPS 部署时需要) ===== +# 默认前端请求 http://localhost:5001;部署到远程服务器时需设置后端 API 的实际地址 +# VITE_API_BASE_URL=http://your-server-ip:5001 \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..becbdec5 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,49 @@ +name: Build and push Docker image + +on: + push: + tags: ["*"] + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/mirofish + tags: | + type=ref,event=tag + type=sha + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..55d3ef19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,60 @@ +# OS +.DS_Store +Thumbs.db + +# 环境变量(保护敏感信息) +.env +.env.local +.env.*.local +.env.development +.env.test +.env.production + +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +.venv/ +venv/ +ENV/ +.eggs/ +*.egg-info/ +dist/ +build/ + +# Node.js +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# 测试 +.pytest_cache/ +.coverage +htmlcov/ + +# Cursor +.cursor/ +.claude/ + +# 文档与测试程序 +mydoc/ +mytest/ + +# 日志文件 +backend/logs/ +*.log + +# 上传文件 +backend/uploads/ + +# Docker 数据 +data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e6564686 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM python:3.11 + +# 安装 Node.js (满足 >=18)及必要工具 +RUN apt-get update \ + && apt-get install -y --no-install-recommends nodejs npm \ + && rm -rf /var/lib/apt/lists/* + +# 从 uv 官方镜像复制 uv +COPY --from=ghcr.io/astral-sh/uv:0.9.26 /uv /uvx /bin/ + +WORKDIR /app + +# 先复制依赖描述文件以利用缓存 +COPY package.json package-lock.json ./ +COPY frontend/package.json frontend/package-lock.json ./frontend/ +COPY backend/pyproject.toml backend/uv.lock ./backend/ + +# 安装依赖(Node + Python) +RUN npm ci \ + && npm ci --prefix frontend \ + && cd backend && uv sync --frozen + +# 复制项目源码 +COPY . . + +EXPOSE 3000 5001 + +# 同时启动前后端(开发模式) +CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..0ad25db4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README-ZH.md b/README-ZH.md new file mode 100644 index 00000000..13fbcb4d --- /dev/null +++ b/README-ZH.md @@ -0,0 +1,203 @@ +
+ +MiroFish Logo + +666ghj%2FMiroFish | Trendshift + +简洁通用的群体智能引擎,预测万物 +
+A Simple and Universal Swarm Intelligence Engine, Predicting Anything + +666ghj%2FMiroFish | Shanda + +[![GitHub Stars](https://img.shields.io/github/stars/666ghj/MiroFish?style=flat-square&color=DAA520)](https://github.com/666ghj/MiroFish/stargazers) +[![GitHub Watchers](https://img.shields.io/github/watchers/666ghj/MiroFish?style=flat-square)](https://github.com/666ghj/MiroFish/watchers) +[![GitHub Forks](https://img.shields.io/github/forks/666ghj/MiroFish?style=flat-square)](https://github.com/666ghj/MiroFish/network) +[![Docker](https://img.shields.io/badge/Docker-Build-2496ED?style=flat-square&logo=docker&logoColor=white)](https://hub.docker.com/) +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/666ghj/MiroFish) + +[![Discord](https://img.shields.io/badge/Discord-Join-5865F2?style=flat-square&logo=discord&logoColor=white)](http://discord.gg/ePf5aPaHnA) +[![X](https://img.shields.io/badge/X-Follow-000000?style=flat-square&logo=x&logoColor=white)](https://x.com/mirofish_ai) +[![Instagram](https://img.shields.io/badge/Instagram-Follow-E4405F?style=flat-square&logo=instagram&logoColor=white)](https://www.instagram.com/mirofish_ai/) + +[English](./README.md) | [中文文档](./README-ZH.md) + +
+ +## ⚡ 项目概述 + +**MiroFish** 是一款基于多智能体技术的新一代 AI 预测引擎。通过提取现实世界的种子信息(如突发新闻、政策草案、金融信号),自动构建出高保真的平行数字世界。在此空间内,成千上万个具备独立人格、长期记忆与行为逻辑的智能体进行自由交互与社会演化。你可透过「上帝视角」动态注入变量,精准推演未来走向——**让未来在数字沙盘中预演,助决策在百战模拟后胜出**。 + +> 你只需:上传种子材料(数据分析报告或者有趣的小说故事),并用自然语言描述预测需求
+> MiroFish 将返回:一份详尽的预测报告,以及一个可深度交互的高保真数字世界 + +### 我们的愿景 + +MiroFish 致力于打造映射现实的群体智能镜像,通过捕捉个体互动引发的群体涌现,突破传统预测的局限: + +- **于宏观**:我们是决策者的预演实验室,让政策与公关在零风险中试错 +- **于微观**:我们是个人用户的创意沙盘,无论是推演小说结局还是探索脑洞,皆可有趣、好玩、触手可及 + +从严肃预测到趣味仿真,我们让每一个如果都能看见结果,让预测万物成为可能。 + +## 🌐 在线体验 + +欢迎访问在线 Demo 演示环境,体验我们为你准备的一次关于热点舆情事件的推演预测:[mirofish-live-demo](https://666ghj.github.io/mirofish-demo/) + +## 📸 系统截图 + +
+ + + + + + + + + + + + + +
截图1截图2
截图3截图4
截图5截图6
+
+ +## 🎬 演示视频 + +### 1. 武汉大学舆情推演预测 + MiroFish项目讲解 + +
+MiroFish Demo Video + +点击图片查看使用微舆BettaFish生成的《武大舆情报告》进行预测的完整演示视频 +
+ +### 2. 《红楼梦》失传结局推演预测 + +
+MiroFish Demo Video + +点击图片查看基于《红楼梦》前80回数十万字,MiroFish深度预测失传结局 +
+ +> **金融方向推演预测**、**时政要闻推演预测**等示例陆续更新中... + +## 🔄 工作流程 + +1. **图谱构建**:现实种子提取 & 个体与群体记忆注入 & GraphRAG构建 +2. **环境搭建**:实体关系抽取 & 人设生成 & 环境配置Agent注入仿真参数 +3. **开始模拟**:双平台并行模拟 & 自动解析预测需求 & 动态更新时序记忆 +4. **报告生成**:ReportAgent拥有丰富的工具集与模拟后环境进行深度交互 +5. **深度互动**:与模拟世界中的任意一位进行对话 & 与ReportAgent进行对话 + +## 🚀 快速开始 + +### 一、源码部署(推荐) + +#### 前置要求 + +| 工具 | 版本要求 | 说明 | 安装检查 | +|------|---------|------|---------| +| **Node.js** | 18+ | 前端运行环境,包含 npm | `node -v` | +| **Python** | ≥3.11, ≤3.12 | 后端运行环境 | `python --version` | +| **uv** | 最新版 | Python 包管理器 | `uv --version` | + +#### 1. 配置环境变量 + +```bash +# 复制示例配置文件 +cp .env.example .env + +# 编辑 .env 文件,填入必要的 API 密钥 +``` + +**必需的环境变量:** + +```env +# LLM API配置(支持 OpenAI SDK 格式的任意 LLM API) +# 推荐使用阿里百炼平台qwen-plus模型:https://bailian.console.aliyun.com/ +# 注意消耗较大,可先进行小于40轮的模拟尝试 +LLM_API_KEY=your_api_key +LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1 +LLM_MODEL_NAME=qwen-plus + +# Zep Cloud 配置 +# 每月免费额度即可支撑简单使用:https://app.getzep.com/ +ZEP_API_KEY=your_zep_api_key +``` + +#### 2. 安装依赖 + +```bash +# 一键安装所有依赖(根目录 + 前端 + 后端) +npm run setup:all +``` + +或者分步安装: + +```bash +# 安装 Node 依赖(根目录 + 前端) +npm run setup + +# 安装 Python 依赖(后端,自动创建虚拟环境) +npm run setup:backend +``` + +#### 3. 启动服务 + +```bash +# 同时启动前后端(在项目根目录执行) +npm run dev +``` + +**服务地址:** +- 前端:`http://localhost:3000` +- 后端 API:`http://localhost:5001` + +**单独启动:** + +```bash +npm run backend # 仅启动后端 +npm run frontend # 仅启动前端 +``` + +### 二、Docker 部署 + +```bash +# 1. 配置环境变量(同源码部署) +cp .env.example .env + +# 2. 拉取镜像并启动 +docker compose up -d +``` + +默认会读取根目录下的 `.env`,并映射端口 `3000(前端)/5001(后端)` + +> 在 `docker-compose.yml` 中已通过注释提供加速镜像地址,可按需替换 + +## 📬 更多交流 + +
+QQ交流群 +
+ +  + +MiroFish团队长期招募全职/实习,如果你对多Agent应用感兴趣,欢迎投递简历至:**mirofish@shanda.com** + +## 📄 致谢 + +**MiroFish 得到了盛大集团的战略支持和孵化!** + +MiroFish 的仿真引擎由 **[OASIS](https://github.com/camel-ai/oasis)** 驱动,我们衷心感谢 CAMEL-AI 团队的开源贡献! + +## 📈 项目统计 + + + + + + Star History Chart + + diff --git a/README.md b/README.md new file mode 100644 index 00000000..fca6bd76 --- /dev/null +++ b/README.md @@ -0,0 +1,207 @@ +
+ +MiroFish Logo + +666ghj%2FMiroFish | Trendshift + +简洁通用的群体智能引擎,预测万物 +
+A Simple and Universal Swarm Intelligence Engine, Predicting Anything + +666ghj%2FMiroFish | Shanda + +[![GitHub Stars](https://img.shields.io/github/stars/666ghj/MiroFish?style=flat-square&color=DAA520)](https://github.com/666ghj/MiroFish/stargazers) +[![GitHub Watchers](https://img.shields.io/github/watchers/666ghj/MiroFish?style=flat-square)](https://github.com/666ghj/MiroFish/watchers) +[![GitHub Forks](https://img.shields.io/github/forks/666ghj/MiroFish?style=flat-square)](https://github.com/666ghj/MiroFish/network) +[![Docker](https://img.shields.io/badge/Docker-Build-2496ED?style=flat-square&logo=docker&logoColor=white)](https://hub.docker.com/) +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/666ghj/MiroFish) + +[![Discord](https://img.shields.io/badge/Discord-Join-5865F2?style=flat-square&logo=discord&logoColor=white)](http://discord.gg/ePf5aPaHnA) +[![X](https://img.shields.io/badge/X-Follow-000000?style=flat-square&logo=x&logoColor=white)](https://x.com/mirofish_ai) +[![Instagram](https://img.shields.io/badge/Instagram-Follow-E4405F?style=flat-square&logo=instagram&logoColor=white)](https://www.instagram.com/mirofish_ai/) + +[English](./README.md) | [中文文档](./README-ZH.md) + +
+ +## ⚡ Overview + +**MiroFish** is a next-generation AI prediction engine powered by multi-agent technology. By extracting seed information from the real world (such as breaking news, policy drafts, or financial signals), it automatically constructs a high-fidelity parallel digital world. Within this space, thousands of intelligent agents with independent personalities, long-term memory, and behavioral logic freely interact and undergo social evolution. You can inject variables dynamically from a "God's-eye view" to precisely deduce future trajectories — **rehearse the future in a digital sandbox, and win decisions after countless simulations**. + +> You only need to: Upload seed materials (data analysis reports or interesting novel stories) and describe your prediction requirements in natural language
+> MiroFish will return: A detailed prediction report and a deeply interactive high-fidelity digital world + +### Our Vision + +MiroFish is dedicated to creating a swarm intelligence mirror that maps reality. By capturing the collective emergence triggered by individual interactions, we break through the limitations of traditional prediction: + +- **At the Macro Level**: We are a rehearsal laboratory for decision-makers, allowing policies and public relations to be tested at zero risk +- **At the Micro Level**: We are a creative sandbox for individual users — whether deducing novel endings or exploring imaginative scenarios, everything can be fun, playful, and accessible + +From serious predictions to playful simulations, we let every "what if" see its outcome, making it possible to predict anything. + +## 🌐 Live Demo + +Welcome to visit our online demo environment and experience a prediction simulation on trending public opinion events we've prepared for you: [mirofish-live-demo](https://666ghj.github.io/mirofish-demo/) + +## 📸 Screenshots + +
+ + + + + + + + + + + + + +
Screenshot 1Screenshot 2
Screenshot 3Screenshot 4
Screenshot 5Screenshot 6
+
+ +## 🎬 Demo Videos + +### 1. Wuhan University Public Opinion Simulation + MiroFish Project Introduction + +
+MiroFish Demo Video + +Click the image to watch the complete demo video for prediction using BettaFish-generated "Wuhan University Public Opinion Report" +
+ +### 2. Dream of the Red Chamber Lost Ending Simulation + +
+MiroFish Demo Video + +Click the image to watch MiroFish's deep prediction of the lost ending based on hundreds of thousands of words from the first 80 chapters of "Dream of the Red Chamber" +
+ +> **Financial Prediction**, **Political News Prediction** and more examples coming soon... + +## 🔄 Workflow + +1. **Graph Building**: Seed extraction & Individual/collective memory injection & GraphRAG construction +2. **Environment Setup**: Entity relationship extraction & Persona generation & Agent configuration injection +3. **Simulation**: Dual-platform parallel simulation & Auto-parse prediction requirements & Dynamic temporal memory updates +4. **Report Generation**: ReportAgent with rich toolset for deep interaction with post-simulation environment +5. **Deep Interaction**: Chat with any agent in the simulated world & Interact with ReportAgent + +## 🚀 Quick Start + +### Option 1: Source Code Deployment (Recommended) + +#### Prerequisites + +| Tool | Version | Description | Check Installation | +|------|---------|-------------|-------------------| +| **Node.js** | 18+ | Frontend runtime, includes npm | `node -v` | +| **Python** | ≥3.11, ≤3.12 | Backend runtime | `python --version` | +| **uv** | Latest | Python package manager | `uv --version` | + +#### 1. Configure Environment Variables + +```bash +# Copy the example configuration file +cp .env.example .env + +# Edit the .env file and fill in the required API keys +``` + +**Required Environment Variables:** + +```env +# LLM API Configuration (supports any LLM API with OpenAI SDK format) +# Recommended: Alibaba Qwen-plus model via Bailian Platform: https://bailian.console.aliyun.com/ +# High consumption, try simulations with fewer than 40 rounds first +LLM_API_KEY=your_api_key +LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1 +LLM_MODEL_NAME=qwen-plus + +# Zep Cloud Configuration +# Free monthly quota is sufficient for simple usage: https://app.getzep.com/ +ZEP_API_KEY=your_zep_api_key + +# Frontend API URL (required for remote/VPS deployment) +# Defaults to http://localhost:5001; set to the public backend URL when deploying to a remote server +# VITE_API_BASE_URL=http://your-server-ip:5001 +``` + +#### 2. Install Dependencies + +```bash +# One-click installation of all dependencies (root + frontend + backend) +npm run setup:all +``` + +Or install step by step: + +```bash +# Install Node dependencies (root + frontend) +npm run setup + +# Install Python dependencies (backend, auto-creates virtual environment) +npm run setup:backend +``` + +#### 3. Start Services + +```bash +# Start both frontend and backend (run from project root) +npm run dev +``` + +**Service URLs:** +- Frontend: `http://localhost:3000` +- Backend API: `http://localhost:5001` + +**Start Individually:** + +```bash +npm run backend # Start backend only +npm run frontend # Start frontend only +``` + +### Option 2: Docker Deployment + +```bash +# 1. Configure environment variables (same as source deployment) +cp .env.example .env + +# 2. Pull image and start +docker compose up -d +``` + +Reads `.env` from root directory by default, maps ports `3000 (frontend) / 5001 (backend)` + +> Mirror address for faster pulling is provided as comments in `docker-compose.yml`, replace if needed. + +## 📬 Join the Conversation + +
+QQ Group +
+ +  + +The MiroFish team is recruiting full-time/internship positions. If you're interested in multi-agent simulation and LLM applications, feel free to send your resume to: **mirofish@shanda.com** + +## 📄 Acknowledgments + +**MiroFish has received strategic support and incubation from Shanda Group!** + +MiroFish's simulation engine is powered by **[OASIS (Open Agent Social Interaction Simulations)](https://github.com/camel-ai/oasis)**, We sincerely thank the CAMEL-AI team for their open-source contributions! + +## 📈 Project Statistics + + + + + + Star History Chart + + \ No newline at end of file diff --git a/backend/app/__init__.py b/backend/app/__init__.py new file mode 100644 index 00000000..aba624bb --- /dev/null +++ b/backend/app/__init__.py @@ -0,0 +1,80 @@ +""" +MiroFish Backend - Flask应用工厂 +""" + +import os +import warnings + +# 抑制 multiprocessing resource_tracker 的警告(来自第三方库如 transformers) +# 需要在所有其他导入之前设置 +warnings.filterwarnings("ignore", message=".*resource_tracker.*") + +from flask import Flask, request +from flask_cors import CORS + +from .config import Config +from .utils.logger import setup_logger, get_logger + + +def create_app(config_class=Config): + """Flask应用工厂函数""" + app = Flask(__name__) + app.config.from_object(config_class) + + # 设置JSON编码:确保中文直接显示(而不是 \uXXXX 格式) + # Flask >= 2.3 使用 app.json.ensure_ascii,旧版本使用 JSON_AS_ASCII 配置 + if hasattr(app, 'json') and hasattr(app.json, 'ensure_ascii'): + app.json.ensure_ascii = False + + # 设置日志 + logger = setup_logger('mirofish') + + # 只在 reloader 子进程中打印启动信息(避免 debug 模式下打印两次) + is_reloader_process = os.environ.get('WERKZEUG_RUN_MAIN') == 'true' + debug_mode = app.config.get('DEBUG', False) + should_log_startup = not debug_mode or is_reloader_process + + if should_log_startup: + logger.info("=" * 50) + logger.info("MiroFish Backend 启动中...") + logger.info("=" * 50) + + # 启用CORS + CORS(app, resources={r"/api/*": {"origins": "*"}}) + + # 注册模拟进程清理函数(确保服务器关闭时终止所有模拟进程) + from .services.simulation_runner import SimulationRunner + SimulationRunner.register_cleanup() + if should_log_startup: + logger.info("已注册模拟进程清理函数") + + # 请求日志中间件 + @app.before_request + def log_request(): + logger = get_logger('mirofish.request') + logger.debug(f"请求: {request.method} {request.path}") + if request.content_type and 'json' in request.content_type: + logger.debug(f"请求体: {request.get_json(silent=True)}") + + @app.after_request + def log_response(response): + logger = get_logger('mirofish.request') + logger.debug(f"响应: {response.status_code}") + return response + + # 注册蓝图 + from .api import graph_bp, simulation_bp, report_bp + app.register_blueprint(graph_bp, url_prefix='/api/graph') + app.register_blueprint(simulation_bp, url_prefix='/api/simulation') + app.register_blueprint(report_bp, url_prefix='/api/report') + + # 健康检查 + @app.route('/health') + def health(): + return {'status': 'ok', 'service': 'MiroFish Backend'} + + if should_log_startup: + logger.info("MiroFish Backend 启动完成") + + return app + diff --git a/backend/app/api/__init__.py b/backend/app/api/__init__.py new file mode 100644 index 00000000..ffda743a --- /dev/null +++ b/backend/app/api/__init__.py @@ -0,0 +1,14 @@ +""" +API路由模块 +""" + +from flask import Blueprint + +graph_bp = Blueprint('graph', __name__) +simulation_bp = Blueprint('simulation', __name__) +report_bp = Blueprint('report', __name__) + +from . import graph # noqa: E402, F401 +from . import simulation # noqa: E402, F401 +from . import report # noqa: E402, F401 + diff --git a/backend/app/api/graph.py b/backend/app/api/graph.py new file mode 100644 index 00000000..759ff48b --- /dev/null +++ b/backend/app/api/graph.py @@ -0,0 +1,622 @@ +""" +图谱相关API路由 +采用项目上下文机制,服务端持久化状态 +""" + +import os +import traceback +import threading +from flask import request, jsonify + +from . import graph_bp +from ..config import Config +from ..services.ontology_generator import OntologyGenerator +from ..services.graph_builder import GraphBuilderService +from ..services.text_processor import TextProcessor +from ..utils.file_parser import FileParser +from ..utils.logger import get_logger +from ..utils.locale import t, get_locale, set_locale +from ..models.task import TaskManager, TaskStatus +from ..models.project import ProjectManager, ProjectStatus + +# 获取日志器 +logger = get_logger('mirofish.api') + + +def allowed_file(filename: str) -> bool: + """检查文件扩展名是否允许""" + if not filename or '.' not in filename: + return False + ext = os.path.splitext(filename)[1].lower().lstrip('.') + return ext in Config.ALLOWED_EXTENSIONS + + +# ============== 项目管理接口 ============== + +@graph_bp.route('/project/', methods=['GET']) +def get_project(project_id: str): + """ + 获取项目详情 + """ + project = ProjectManager.get_project(project_id) + + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=project_id) + }), 404 + + return jsonify({ + "success": True, + "data": project.to_dict() + }) + + +@graph_bp.route('/project/list', methods=['GET']) +def list_projects(): + """ + 列出所有项目 + """ + limit = request.args.get('limit', 50, type=int) + projects = ProjectManager.list_projects(limit=limit) + + return jsonify({ + "success": True, + "data": [p.to_dict() for p in projects], + "count": len(projects) + }) + + +@graph_bp.route('/project/', methods=['DELETE']) +def delete_project(project_id: str): + """ + 删除项目 + """ + success = ProjectManager.delete_project(project_id) + + if not success: + return jsonify({ + "success": False, + "error": t('api.projectDeleteFailed', id=project_id) + }), 404 + + return jsonify({ + "success": True, + "message": t('api.projectDeleted', id=project_id) + }) + + +@graph_bp.route('/project//reset', methods=['POST']) +def reset_project(project_id: str): + """ + 重置项目状态(用于重新构建图谱) + """ + project = ProjectManager.get_project(project_id) + + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=project_id) + }), 404 + + # 重置到本体已生成状态 + if project.ontology: + project.status = ProjectStatus.ONTOLOGY_GENERATED + else: + project.status = ProjectStatus.CREATED + + project.graph_id = None + project.graph_build_task_id = None + project.error = None + ProjectManager.save_project(project) + + return jsonify({ + "success": True, + "message": t('api.projectReset', id=project_id), + "data": project.to_dict() + }) + + +# ============== 接口1:上传文件并生成本体 ============== + +@graph_bp.route('/ontology/generate', methods=['POST']) +def generate_ontology(): + """ + 接口1:上传文件,分析生成本体定义 + + 请求方式:multipart/form-data + + 参数: + files: 上传的文件(PDF/MD/TXT),可多个 + simulation_requirement: 模拟需求描述(必填) + project_name: 项目名称(可选) + additional_context: 额外说明(可选) + + 返回: + { + "success": true, + "data": { + "project_id": "proj_xxxx", + "ontology": { + "entity_types": [...], + "edge_types": [...], + "analysis_summary": "..." + }, + "files": [...], + "total_text_length": 12345 + } + } + """ + try: + logger.info("=== 开始生成本体定义 ===") + + # 获取参数 + simulation_requirement = request.form.get('simulation_requirement', '') + project_name = request.form.get('project_name', 'Unnamed Project') + additional_context = request.form.get('additional_context', '') + + logger.debug(f"项目名称: {project_name}") + logger.debug(f"模拟需求: {simulation_requirement[:100]}...") + + if not simulation_requirement: + return jsonify({ + "success": False, + "error": t('api.requireSimulationRequirement') + }), 400 + + # 获取上传的文件 + uploaded_files = request.files.getlist('files') + if not uploaded_files or all(not f.filename for f in uploaded_files): + return jsonify({ + "success": False, + "error": t('api.requireFileUpload') + }), 400 + + # 创建项目 + project = ProjectManager.create_project(name=project_name) + project.simulation_requirement = simulation_requirement + logger.info(f"创建项目: {project.project_id}") + + # 保存文件并提取文本 + document_texts = [] + all_text = "" + + for file in uploaded_files: + if file and file.filename and allowed_file(file.filename): + # 保存文件到项目目录 + file_info = ProjectManager.save_file_to_project( + project.project_id, + file, + file.filename + ) + project.files.append({ + "filename": file_info["original_filename"], + "size": file_info["size"] + }) + + # 提取文本 + text = FileParser.extract_text(file_info["path"]) + text = TextProcessor.preprocess_text(text) + document_texts.append(text) + all_text += f"\n\n=== {file_info['original_filename']} ===\n{text}" + + if not document_texts: + ProjectManager.delete_project(project.project_id) + return jsonify({ + "success": False, + "error": t('api.noDocProcessed') + }), 400 + + # 保存提取的文本 + project.total_text_length = len(all_text) + ProjectManager.save_extracted_text(project.project_id, all_text) + logger.info(f"文本提取完成,共 {len(all_text)} 字符") + + # 生成本体 + logger.info("调用 LLM 生成本体定义...") + generator = OntologyGenerator() + ontology = generator.generate( + document_texts=document_texts, + simulation_requirement=simulation_requirement, + additional_context=additional_context if additional_context else None + ) + + # 保存本体到项目 + entity_count = len(ontology.get("entity_types", [])) + edge_count = len(ontology.get("edge_types", [])) + logger.info(f"本体生成完成: {entity_count} 个实体类型, {edge_count} 个关系类型") + + project.ontology = { + "entity_types": ontology.get("entity_types", []), + "edge_types": ontology.get("edge_types", []) + } + project.analysis_summary = ontology.get("analysis_summary", "") + project.status = ProjectStatus.ONTOLOGY_GENERATED + ProjectManager.save_project(project) + logger.info(f"=== 本体生成完成 === 项目ID: {project.project_id}") + + return jsonify({ + "success": True, + "data": { + "project_id": project.project_id, + "project_name": project.name, + "ontology": project.ontology, + "analysis_summary": project.analysis_summary, + "files": project.files, + "total_text_length": project.total_text_length + } + }) + + except Exception as e: + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 接口2:构建图谱 ============== + +@graph_bp.route('/build', methods=['POST']) +def build_graph(): + """ + 接口2:根据project_id构建图谱 + + 请求(JSON): + { + "project_id": "proj_xxxx", // 必填,来自接口1 + "graph_name": "图谱名称", // 可选 + "chunk_size": 500, // 可选,默认500 + "chunk_overlap": 50 // 可选,默认50 + } + + 返回: + { + "success": true, + "data": { + "project_id": "proj_xxxx", + "task_id": "task_xxxx", + "message": "图谱构建任务已启动" + } + } + """ + try: + logger.info("=== 开始构建图谱 ===") + + # 检查配置 + errors = [] + if not Config.ZEP_API_KEY: + errors.append(t('api.zepApiKeyMissing')) + if errors: + logger.error(f"配置错误: {errors}") + return jsonify({ + "success": False, + "error": t('api.configError', details="; ".join(errors)) + }), 500 + + # 解析请求 + data = request.get_json() or {} + project_id = data.get('project_id') + logger.debug(f"请求参数: project_id={project_id}") + + if not project_id: + return jsonify({ + "success": False, + "error": t('api.requireProjectId') + }), 400 + + # 获取项目 + project = ProjectManager.get_project(project_id) + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=project_id) + }), 404 + + # 检查项目状态 + force = data.get('force', False) # 强制重新构建 + + if project.status == ProjectStatus.CREATED: + return jsonify({ + "success": False, + "error": t('api.ontologyNotGenerated') + }), 400 + + if project.status == ProjectStatus.GRAPH_BUILDING and not force: + return jsonify({ + "success": False, + "error": t('api.graphBuilding'), + "task_id": project.graph_build_task_id + }), 400 + + # 如果强制重建,重置状态 + if force and project.status in [ProjectStatus.GRAPH_BUILDING, ProjectStatus.FAILED, ProjectStatus.GRAPH_COMPLETED]: + project.status = ProjectStatus.ONTOLOGY_GENERATED + project.graph_id = None + project.graph_build_task_id = None + project.error = None + + # 获取配置 + graph_name = data.get('graph_name', project.name or 'MiroFish Graph') + chunk_size = data.get('chunk_size', project.chunk_size or Config.DEFAULT_CHUNK_SIZE) + chunk_overlap = data.get('chunk_overlap', project.chunk_overlap or Config.DEFAULT_CHUNK_OVERLAP) + + # 更新项目配置 + project.chunk_size = chunk_size + project.chunk_overlap = chunk_overlap + + # 获取提取的文本 + text = ProjectManager.get_extracted_text(project_id) + if not text: + return jsonify({ + "success": False, + "error": t('api.textNotFound') + }), 400 + + # 获取本体 + ontology = project.ontology + if not ontology: + return jsonify({ + "success": False, + "error": t('api.ontologyNotFound') + }), 400 + + # 创建异步任务 + task_manager = TaskManager() + task_id = task_manager.create_task(f"构建图谱: {graph_name}") + logger.info(f"创建图谱构建任务: task_id={task_id}, project_id={project_id}") + + # 更新项目状态 + project.status = ProjectStatus.GRAPH_BUILDING + project.graph_build_task_id = task_id + ProjectManager.save_project(project) + + # Capture locale before spawning background thread + current_locale = get_locale() + + # 启动后台任务 + def build_task(): + set_locale(current_locale) + build_logger = get_logger('mirofish.build') + try: + build_logger.info(f"[{task_id}] 开始构建图谱...") + task_manager.update_task( + task_id, + status=TaskStatus.PROCESSING, + message=t('progress.initGraphService') + ) + + # 创建图谱构建服务 + builder = GraphBuilderService(api_key=Config.ZEP_API_KEY) + + # 分块 + task_manager.update_task( + task_id, + message=t('progress.textChunking'), + progress=5 + ) + chunks = TextProcessor.split_text( + text, + chunk_size=chunk_size, + overlap=chunk_overlap + ) + total_chunks = len(chunks) + + # 创建图谱 + task_manager.update_task( + task_id, + message=t('progress.creatingZepGraph'), + progress=10 + ) + graph_id = builder.create_graph(name=graph_name) + + # 更新项目的graph_id + project.graph_id = graph_id + ProjectManager.save_project(project) + + # 设置本体 + task_manager.update_task( + task_id, + message=t('progress.settingOntology'), + progress=15 + ) + builder.set_ontology(graph_id, ontology) + + # 添加文本(progress_callback 签名是 (msg, progress_ratio)) + def add_progress_callback(msg, progress_ratio): + progress = 15 + int(progress_ratio * 40) # 15% - 55% + task_manager.update_task( + task_id, + message=msg, + progress=progress + ) + + task_manager.update_task( + task_id, + message=t('progress.addingChunks', count=total_chunks), + progress=15 + ) + + episode_uuids = builder.add_text_batches( + graph_id, + chunks, + batch_size=3, + progress_callback=add_progress_callback + ) + + # 等待Zep处理完成(查询每个episode的processed状态) + task_manager.update_task( + task_id, + message=t('progress.waitingZepProcess'), + progress=55 + ) + + def wait_progress_callback(msg, progress_ratio): + progress = 55 + int(progress_ratio * 35) # 55% - 90% + task_manager.update_task( + task_id, + message=msg, + progress=progress + ) + + builder._wait_for_episodes(episode_uuids, wait_progress_callback) + + # 获取图谱数据 + task_manager.update_task( + task_id, + message=t('progress.fetchingGraphData'), + progress=95 + ) + graph_data = builder.get_graph_data(graph_id) + + # 更新项目状态 + project.status = ProjectStatus.GRAPH_COMPLETED + ProjectManager.save_project(project) + + node_count = graph_data.get("node_count", 0) + edge_count = graph_data.get("edge_count", 0) + build_logger.info(f"[{task_id}] 图谱构建完成: graph_id={graph_id}, 节点={node_count}, 边={edge_count}") + + # 完成 + task_manager.update_task( + task_id, + status=TaskStatus.COMPLETED, + message=t('progress.graphBuildComplete'), + progress=100, + result={ + "project_id": project_id, + "graph_id": graph_id, + "node_count": node_count, + "edge_count": edge_count, + "chunk_count": total_chunks + } + ) + + except Exception as e: + # 更新项目状态为失败 + build_logger.error(f"[{task_id}] 图谱构建失败: {str(e)}") + build_logger.debug(traceback.format_exc()) + + project.status = ProjectStatus.FAILED + project.error = str(e) + ProjectManager.save_project(project) + + task_manager.update_task( + task_id, + status=TaskStatus.FAILED, + message=t('progress.buildFailed', error=str(e)), + error=traceback.format_exc() + ) + + # 启动后台线程 + thread = threading.Thread(target=build_task, daemon=True) + thread.start() + + return jsonify({ + "success": True, + "data": { + "project_id": project_id, + "task_id": task_id, + "message": t('api.graphBuildStarted', taskId=task_id) + } + }) + + except Exception as e: + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 任务查询接口 ============== + +@graph_bp.route('/task/', methods=['GET']) +def get_task(task_id: str): + """ + 查询任务状态 + """ + task = TaskManager().get_task(task_id) + + if not task: + return jsonify({ + "success": False, + "error": t('api.taskNotFound', id=task_id) + }), 404 + + return jsonify({ + "success": True, + "data": task.to_dict() + }) + + +@graph_bp.route('/tasks', methods=['GET']) +def list_tasks(): + """ + 列出所有任务 + """ + tasks = TaskManager().list_tasks() + + return jsonify({ + "success": True, + "data": [t.to_dict() for t in tasks], + "count": len(tasks) + }) + + +# ============== 图谱数据接口 ============== + +@graph_bp.route('/data/', methods=['GET']) +def get_graph_data(graph_id: str): + """ + 获取图谱数据(节点和边) + """ + try: + if not Config.ZEP_API_KEY: + return jsonify({ + "success": False, + "error": t('api.zepApiKeyMissing') + }), 500 + + builder = GraphBuilderService(api_key=Config.ZEP_API_KEY) + graph_data = builder.get_graph_data(graph_id) + + return jsonify({ + "success": True, + "data": graph_data + }) + + except Exception as e: + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@graph_bp.route('/delete/', methods=['DELETE']) +def delete_graph(graph_id: str): + """ + 删除Zep图谱 + """ + try: + if not Config.ZEP_API_KEY: + return jsonify({ + "success": False, + "error": t('api.zepApiKeyMissing') + }), 500 + + builder = GraphBuilderService(api_key=Config.ZEP_API_KEY) + builder.delete_graph(graph_id) + + return jsonify({ + "success": True, + "message": t('api.graphDeleted', id=graph_id) + }) + + except Exception as e: + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 diff --git a/backend/app/api/report.py b/backend/app/api/report.py new file mode 100644 index 00000000..d7f2a4d0 --- /dev/null +++ b/backend/app/api/report.py @@ -0,0 +1,1020 @@ +""" +Report API路由 +提供模拟报告生成、获取、对话等接口 +""" + +import os +import traceback +import threading +from flask import request, jsonify, send_file + +from . import report_bp +from ..config import Config +from ..services.report_agent import ReportAgent, ReportManager, ReportStatus +from ..services.simulation_manager import SimulationManager +from ..models.project import ProjectManager +from ..models.task import TaskManager, TaskStatus +from ..utils.logger import get_logger +from ..utils.locale import t, get_locale, set_locale + +logger = get_logger('mirofish.api.report') + + +# ============== 报告生成接口 ============== + +@report_bp.route('/generate', methods=['POST']) +def generate_report(): + """ + 生成模拟分析报告(异步任务) + + 这是一个耗时操作,接口会立即返回task_id, + 使用 GET /api/report/generate/status 查询进度 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "force_regenerate": false // 可选,强制重新生成 + } + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "task_id": "task_xxxx", + "status": "generating", + "message": "报告生成任务已启动" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + force_regenerate = data.get('force_regenerate', False) + + # 获取模拟信息 + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + + if not state: + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + # 检查是否已有报告 + if not force_regenerate: + existing_report = ReportManager.get_report_by_simulation(simulation_id) + if existing_report and existing_report.status == ReportStatus.COMPLETED: + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "report_id": existing_report.report_id, + "status": "completed", + "message": t('api.reportAlreadyExists'), + "already_generated": True + } + }) + + # 获取项目信息 + project = ProjectManager.get_project(state.project_id) + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=state.project_id) + }), 404 + + graph_id = state.graph_id or project.graph_id + if not graph_id: + return jsonify({ + "success": False, + "error": t('api.missingGraphIdEnsure') + }), 400 + + simulation_requirement = project.simulation_requirement + if not simulation_requirement: + return jsonify({ + "success": False, + "error": t('api.missingSimRequirement') + }), 400 + + # 提前生成 report_id,以便立即返回给前端 + import uuid + report_id = f"report_{uuid.uuid4().hex[:12]}" + + # 创建异步任务 + task_manager = TaskManager() + task_id = task_manager.create_task( + task_type="report_generate", + metadata={ + "simulation_id": simulation_id, + "graph_id": graph_id, + "report_id": report_id + } + ) + + # Capture locale before spawning background thread + current_locale = get_locale() + + # 定义后台任务 + def run_generate(): + set_locale(current_locale) + try: + task_manager.update_task( + task_id, + status=TaskStatus.PROCESSING, + progress=0, + message=t('api.initReportAgent') + ) + + # 创建Report Agent + agent = ReportAgent( + graph_id=graph_id, + simulation_id=simulation_id, + simulation_requirement=simulation_requirement + ) + + # 进度回调 + def progress_callback(stage, progress, message): + task_manager.update_task( + task_id, + progress=progress, + message=f"[{stage}] {message}" + ) + + # 生成报告(传入预先生成的 report_id) + report = agent.generate_report( + progress_callback=progress_callback, + report_id=report_id + ) + + # 保存报告 + ReportManager.save_report(report) + + if report.status == ReportStatus.COMPLETED: + task_manager.complete_task( + task_id, + result={ + "report_id": report.report_id, + "simulation_id": simulation_id, + "status": "completed" + } + ) + else: + task_manager.fail_task(task_id, report.error or t('api.reportGenerateFailed')) + + except Exception as e: + logger.error(f"报告生成失败: {str(e)}") + task_manager.fail_task(task_id, str(e)) + + # 启动后台线程 + thread = threading.Thread(target=run_generate, daemon=True) + thread.start() + + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "report_id": report_id, + "task_id": task_id, + "status": "generating", + "message": t('api.reportGenerateStarted'), + "already_generated": False + } + }) + + except Exception as e: + logger.error(f"启动报告生成任务失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('/generate/status', methods=['POST']) +def get_generate_status(): + """ + 查询报告生成任务进度 + + 请求(JSON): + { + "task_id": "task_xxxx", // 可选,generate返回的task_id + "simulation_id": "sim_xxxx" // 可选,模拟ID + } + + 返回: + { + "success": true, + "data": { + "task_id": "task_xxxx", + "status": "processing|completed|failed", + "progress": 45, + "message": "..." + } + } + """ + try: + data = request.get_json() or {} + + task_id = data.get('task_id') + simulation_id = data.get('simulation_id') + + # 如果提供了simulation_id,先检查是否已有完成的报告 + if simulation_id: + existing_report = ReportManager.get_report_by_simulation(simulation_id) + if existing_report and existing_report.status == ReportStatus.COMPLETED: + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "report_id": existing_report.report_id, + "status": "completed", + "progress": 100, + "message": t('api.reportGenerated'), + "already_completed": True + } + }) + + if not task_id: + return jsonify({ + "success": False, + "error": t('api.requireTaskOrSimId') + }), 400 + + task_manager = TaskManager() + task = task_manager.get_task(task_id) + + if not task: + return jsonify({ + "success": False, + "error": t('api.taskNotFound', id=task_id) + }), 404 + + return jsonify({ + "success": True, + "data": task.to_dict() + }) + + except Exception as e: + logger.error(f"查询任务状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e) + }), 500 + + +# ============== 报告获取接口 ============== + +@report_bp.route('/', methods=['GET']) +def get_report(report_id: str): + """ + 获取报告详情 + + 返回: + { + "success": true, + "data": { + "report_id": "report_xxxx", + "simulation_id": "sim_xxxx", + "status": "completed", + "outline": {...}, + "markdown_content": "...", + "created_at": "...", + "completed_at": "..." + } + } + """ + try: + report = ReportManager.get_report(report_id) + + if not report: + return jsonify({ + "success": False, + "error": t('api.reportNotFound', id=report_id) + }), 404 + + return jsonify({ + "success": True, + "data": report.to_dict() + }) + + except Exception as e: + logger.error(f"获取报告失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('/by-simulation/', methods=['GET']) +def get_report_by_simulation(simulation_id: str): + """ + 根据模拟ID获取报告 + + 返回: + { + "success": true, + "data": { + "report_id": "report_xxxx", + ... + } + } + """ + try: + report = ReportManager.get_report_by_simulation(simulation_id) + + if not report: + return jsonify({ + "success": False, + "error": t('api.noReportForSim', id=simulation_id), + "has_report": False + }), 404 + + return jsonify({ + "success": True, + "data": report.to_dict(), + "has_report": True + }) + + except Exception as e: + logger.error(f"获取报告失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('/list', methods=['GET']) +def list_reports(): + """ + 列出所有报告 + + Query参数: + simulation_id: 按模拟ID过滤(可选) + limit: 返回数量限制(默认50) + + 返回: + { + "success": true, + "data": [...], + "count": 10 + } + """ + try: + simulation_id = request.args.get('simulation_id') + limit = request.args.get('limit', 50, type=int) + + reports = ReportManager.list_reports( + simulation_id=simulation_id, + limit=limit + ) + + return jsonify({ + "success": True, + "data": [r.to_dict() for r in reports], + "count": len(reports) + }) + + except Exception as e: + logger.error(f"列出报告失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('//download', methods=['GET']) +def download_report(report_id: str): + """ + 下载报告(Markdown格式) + + 返回Markdown文件 + """ + try: + report = ReportManager.get_report(report_id) + + if not report: + return jsonify({ + "success": False, + "error": t('api.reportNotFound', id=report_id) + }), 404 + + md_path = ReportManager._get_report_markdown_path(report_id) + + if not os.path.exists(md_path): + # 如果MD文件不存在,生成一个临时文件 + import tempfile + with tempfile.NamedTemporaryFile(mode='w', suffix='.md', delete=False) as f: + f.write(report.markdown_content) + temp_path = f.name + + return send_file( + temp_path, + as_attachment=True, + download_name=f"{report_id}.md" + ) + + return send_file( + md_path, + as_attachment=True, + download_name=f"{report_id}.md" + ) + + except Exception as e: + logger.error(f"下载报告失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('/', methods=['DELETE']) +def delete_report(report_id: str): + """删除报告""" + try: + success = ReportManager.delete_report(report_id) + + if not success: + return jsonify({ + "success": False, + "error": t('api.reportNotFound', id=report_id) + }), 404 + + return jsonify({ + "success": True, + "message": t('api.reportDeleted', id=report_id) + }) + + except Exception as e: + logger.error(f"删除报告失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== Report Agent对话接口 ============== + +@report_bp.route('/chat', methods=['POST']) +def chat_with_report_agent(): + """ + 与Report Agent对话 + + Report Agent可以在对话中自主调用检索工具来回答问题 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "message": "请解释一下舆情走向", // 必填,用户消息 + "chat_history": [ // 可选,对话历史 + {"role": "user", "content": "..."}, + {"role": "assistant", "content": "..."} + ] + } + + 返回: + { + "success": true, + "data": { + "response": "Agent回复...", + "tool_calls": [调用的工具列表], + "sources": [信息来源] + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + message = data.get('message') + chat_history = data.get('chat_history', []) + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + if not message: + return jsonify({ + "success": False, + "error": t('api.requireMessage') + }), 400 + + # 获取模拟和项目信息 + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + + if not state: + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + project = ProjectManager.get_project(state.project_id) + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=state.project_id) + }), 404 + + graph_id = state.graph_id or project.graph_id + if not graph_id: + return jsonify({ + "success": False, + "error": t('api.missingGraphId') + }), 400 + + simulation_requirement = project.simulation_requirement or "" + + # 创建Agent并进行对话 + agent = ReportAgent( + graph_id=graph_id, + simulation_id=simulation_id, + simulation_requirement=simulation_requirement + ) + + result = agent.chat(message=message, chat_history=chat_history) + + return jsonify({ + "success": True, + "data": result + }) + + except Exception as e: + logger.error(f"对话失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 报告进度与分章节接口 ============== + +@report_bp.route('//progress', methods=['GET']) +def get_report_progress(report_id: str): + """ + 获取报告生成进度(实时) + + 返回: + { + "success": true, + "data": { + "status": "generating", + "progress": 45, + "message": "正在生成章节: 关键发现", + "current_section": "关键发现", + "completed_sections": ["执行摘要", "模拟背景"], + "updated_at": "2025-12-09T..." + } + } + """ + try: + progress = ReportManager.get_progress(report_id) + + if not progress: + return jsonify({ + "success": False, + "error": t('api.reportProgressNotAvail', id=report_id) + }), 404 + + return jsonify({ + "success": True, + "data": progress + }) + + except Exception as e: + logger.error(f"获取报告进度失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('//sections', methods=['GET']) +def get_report_sections(report_id: str): + """ + 获取已生成的章节列表(分章节输出) + + 前端可以轮询此接口获取已生成的章节内容,无需等待整个报告完成 + + 返回: + { + "success": true, + "data": { + "report_id": "report_xxxx", + "sections": [ + { + "filename": "section_01.md", + "section_index": 1, + "content": "## 执行摘要\\n\\n..." + }, + ... + ], + "total_sections": 3, + "is_complete": false + } + } + """ + try: + sections = ReportManager.get_generated_sections(report_id) + + # 获取报告状态 + report = ReportManager.get_report(report_id) + is_complete = report is not None and report.status == ReportStatus.COMPLETED + + return jsonify({ + "success": True, + "data": { + "report_id": report_id, + "sections": sections, + "total_sections": len(sections), + "is_complete": is_complete + } + }) + + except Exception as e: + logger.error(f"获取章节列表失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('//section/', methods=['GET']) +def get_single_section(report_id: str, section_index: int): + """ + 获取单个章节内容 + + 返回: + { + "success": true, + "data": { + "filename": "section_01.md", + "content": "## 执行摘要\\n\\n..." + } + } + """ + try: + section_path = ReportManager._get_section_path(report_id, section_index) + + if not os.path.exists(section_path): + return jsonify({ + "success": False, + "error": t('api.sectionNotFound', index=f"{section_index:02d}") + }), 404 + + with open(section_path, 'r', encoding='utf-8') as f: + content = f.read() + + return jsonify({ + "success": True, + "data": { + "filename": f"section_{section_index:02d}.md", + "section_index": section_index, + "content": content + } + }) + + except Exception as e: + logger.error(f"获取章节内容失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 报告状态检查接口 ============== + +@report_bp.route('/check/', methods=['GET']) +def check_report_status(simulation_id: str): + """ + 检查模拟是否有报告,以及报告状态 + + 用于前端判断是否解锁Interview功能 + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "has_report": true, + "report_status": "completed", + "report_id": "report_xxxx", + "interview_unlocked": true + } + } + """ + try: + report = ReportManager.get_report_by_simulation(simulation_id) + + has_report = report is not None + report_status = report.status.value if report else None + report_id = report.report_id if report else None + + # 只有报告完成后才解锁interview + interview_unlocked = has_report and report.status == ReportStatus.COMPLETED + + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "has_report": has_report, + "report_status": report_status, + "report_id": report_id, + "interview_unlocked": interview_unlocked + } + }) + + except Exception as e: + logger.error(f"检查报告状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== Agent 日志接口 ============== + +@report_bp.route('//agent-log', methods=['GET']) +def get_agent_log(report_id: str): + """ + 获取 Report Agent 的详细执行日志 + + 实时获取报告生成过程中的每一步动作,包括: + - 报告开始、规划开始/完成 + - 每个章节的开始、工具调用、LLM响应、完成 + - 报告完成或失败 + + Query参数: + from_line: 从第几行开始读取(可选,默认0,用于增量获取) + + 返回: + { + "success": true, + "data": { + "logs": [ + { + "timestamp": "2025-12-13T...", + "elapsed_seconds": 12.5, + "report_id": "report_xxxx", + "action": "tool_call", + "stage": "generating", + "section_title": "执行摘要", + "section_index": 1, + "details": { + "tool_name": "insight_forge", + "parameters": {...}, + ... + } + }, + ... + ], + "total_lines": 25, + "from_line": 0, + "has_more": false + } + } + """ + try: + from_line = request.args.get('from_line', 0, type=int) + + log_data = ReportManager.get_agent_log(report_id, from_line=from_line) + + return jsonify({ + "success": True, + "data": log_data + }) + + except Exception as e: + logger.error(f"获取Agent日志失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('//agent-log/stream', methods=['GET']) +def stream_agent_log(report_id: str): + """ + 获取完整的 Agent 日志(一次性获取全部) + + 返回: + { + "success": true, + "data": { + "logs": [...], + "count": 25 + } + } + """ + try: + logs = ReportManager.get_agent_log_stream(report_id) + + return jsonify({ + "success": True, + "data": { + "logs": logs, + "count": len(logs) + } + }) + + except Exception as e: + logger.error(f"获取Agent日志失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 控制台日志接口 ============== + +@report_bp.route('//console-log', methods=['GET']) +def get_console_log(report_id: str): + """ + 获取 Report Agent 的控制台输出日志 + + 实时获取报告生成过程中的控制台输出(INFO、WARNING等), + 这与 agent-log 接口返回的结构化 JSON 日志不同, + 是纯文本格式的控制台风格日志。 + + Query参数: + from_line: 从第几行开始读取(可选,默认0,用于增量获取) + + 返回: + { + "success": true, + "data": { + "logs": [ + "[19:46:14] INFO: 搜索完成: 找到 15 条相关事实", + "[19:46:14] INFO: 图谱搜索: graph_id=xxx, query=...", + ... + ], + "total_lines": 100, + "from_line": 0, + "has_more": false + } + } + """ + try: + from_line = request.args.get('from_line', 0, type=int) + + log_data = ReportManager.get_console_log(report_id, from_line=from_line) + + return jsonify({ + "success": True, + "data": log_data + }) + + except Exception as e: + logger.error(f"获取控制台日志失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('//console-log/stream', methods=['GET']) +def stream_console_log(report_id: str): + """ + 获取完整的控制台日志(一次性获取全部) + + 返回: + { + "success": true, + "data": { + "logs": [...], + "count": 100 + } + } + """ + try: + logs = ReportManager.get_console_log_stream(report_id) + + return jsonify({ + "success": True, + "data": { + "logs": logs, + "count": len(logs) + } + }) + + except Exception as e: + logger.error(f"获取控制台日志失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 工具调用接口(供调试使用)============== + +@report_bp.route('/tools/search', methods=['POST']) +def search_graph_tool(): + """ + 图谱搜索工具接口(供调试使用) + + 请求(JSON): + { + "graph_id": "mirofish_xxxx", + "query": "搜索查询", + "limit": 10 + } + """ + try: + data = request.get_json() or {} + + graph_id = data.get('graph_id') + query = data.get('query') + limit = data.get('limit', 10) + + if not graph_id or not query: + return jsonify({ + "success": False, + "error": t('api.requireGraphIdAndQuery') + }), 400 + + from ..services.zep_tools import ZepToolsService + + tools = ZepToolsService() + result = tools.search_graph( + graph_id=graph_id, + query=query, + limit=limit + ) + + return jsonify({ + "success": True, + "data": result.to_dict() + }) + + except Exception as e: + logger.error(f"图谱搜索失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@report_bp.route('/tools/statistics', methods=['POST']) +def get_graph_statistics_tool(): + """ + 图谱统计工具接口(供调试使用) + + 请求(JSON): + { + "graph_id": "mirofish_xxxx" + } + """ + try: + data = request.get_json() or {} + + graph_id = data.get('graph_id') + + if not graph_id: + return jsonify({ + "success": False, + "error": t('api.requireGraphId') + }), 400 + + from ..services.zep_tools import ZepToolsService + + tools = ZepToolsService() + result = tools.get_graph_statistics(graph_id) + + return jsonify({ + "success": True, + "data": result + }) + + except Exception as e: + logger.error(f"获取图谱统计失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 diff --git a/backend/app/api/simulation.py b/backend/app/api/simulation.py new file mode 100644 index 00000000..3a8e1e3f --- /dev/null +++ b/backend/app/api/simulation.py @@ -0,0 +1,2716 @@ +""" +模拟相关API路由 +Step2: Zep实体读取与过滤、OASIS模拟准备与运行(全程自动化) +""" + +import os +import traceback +from flask import request, jsonify, send_file + +from . import simulation_bp +from ..config import Config +from ..services.zep_entity_reader import ZepEntityReader +from ..services.oasis_profile_generator import OasisProfileGenerator +from ..services.simulation_manager import SimulationManager, SimulationStatus +from ..services.simulation_runner import SimulationRunner, RunnerStatus +from ..utils.logger import get_logger +from ..utils.locale import t, get_locale, set_locale +from ..models.project import ProjectManager + +logger = get_logger('mirofish.api.simulation') + + +# Interview prompt 优化前缀 +# 添加此前缀可以避免Agent调用工具,直接用文本回复 +INTERVIEW_PROMPT_PREFIX = "结合你的人设、所有的过往记忆与行动,不调用任何工具直接用文本回复我:" + + +def optimize_interview_prompt(prompt: str) -> str: + """ + 优化Interview提问,添加前缀避免Agent调用工具 + + Args: + prompt: 原始提问 + + Returns: + 优化后的提问 + """ + if not prompt: + return prompt + # 避免重复添加前缀 + if prompt.startswith(INTERVIEW_PROMPT_PREFIX): + return prompt + return f"{INTERVIEW_PROMPT_PREFIX}{prompt}" + + +# ============== 实体读取接口 ============== + +@simulation_bp.route('/entities/', methods=['GET']) +def get_graph_entities(graph_id: str): + """ + 获取图谱中的所有实体(已过滤) + + 只返回符合预定义实体类型的节点(Labels不只是Entity的节点) + + Query参数: + entity_types: 逗号分隔的实体类型列表(可选,用于进一步过滤) + enrich: 是否获取相关边信息(默认true) + """ + try: + if not Config.ZEP_API_KEY: + return jsonify({ + "success": False, + "error": t('api.zepApiKeyMissing') + }), 500 + + entity_types_str = request.args.get('entity_types', '') + entity_types = [t.strip() for t in entity_types_str.split(',') if t.strip()] if entity_types_str else None + enrich = request.args.get('enrich', 'true').lower() == 'true' + + logger.info(f"获取图谱实体: graph_id={graph_id}, entity_types={entity_types}, enrich={enrich}") + + reader = ZepEntityReader() + result = reader.filter_defined_entities( + graph_id=graph_id, + defined_entity_types=entity_types, + enrich_with_edges=enrich + ) + + return jsonify({ + "success": True, + "data": result.to_dict() + }) + + except Exception as e: + logger.error(f"获取图谱实体失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/entities//', methods=['GET']) +def get_entity_detail(graph_id: str, entity_uuid: str): + """获取单个实体的详细信息""" + try: + if not Config.ZEP_API_KEY: + return jsonify({ + "success": False, + "error": t('api.zepApiKeyMissing') + }), 500 + + reader = ZepEntityReader() + entity = reader.get_entity_with_context(graph_id, entity_uuid) + + if not entity: + return jsonify({ + "success": False, + "error": t('api.entityNotFound', id=entity_uuid) + }), 404 + + return jsonify({ + "success": True, + "data": entity.to_dict() + }) + + except Exception as e: + logger.error(f"获取实体详情失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/entities//by-type/', methods=['GET']) +def get_entities_by_type(graph_id: str, entity_type: str): + """获取指定类型的所有实体""" + try: + if not Config.ZEP_API_KEY: + return jsonify({ + "success": False, + "error": t('api.zepApiKeyMissing') + }), 500 + + enrich = request.args.get('enrich', 'true').lower() == 'true' + + reader = ZepEntityReader() + entities = reader.get_entities_by_type( + graph_id=graph_id, + entity_type=entity_type, + enrich_with_edges=enrich + ) + + return jsonify({ + "success": True, + "data": { + "entity_type": entity_type, + "count": len(entities), + "entities": [e.to_dict() for e in entities] + } + }) + + except Exception as e: + logger.error(f"获取实体失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 模拟管理接口 ============== + +@simulation_bp.route('/create', methods=['POST']) +def create_simulation(): + """ + 创建新的模拟 + + 注意:max_rounds等参数由LLM智能生成,无需手动设置 + + 请求(JSON): + { + "project_id": "proj_xxxx", // 必填 + "graph_id": "mirofish_xxxx", // 可选,如不提供则从project获取 + "enable_twitter": true, // 可选,默认true + "enable_reddit": true // 可选,默认true + } + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "project_id": "proj_xxxx", + "graph_id": "mirofish_xxxx", + "status": "created", + "enable_twitter": true, + "enable_reddit": true, + "created_at": "2025-12-01T10:00:00" + } + } + """ + try: + data = request.get_json() or {} + + project_id = data.get('project_id') + if not project_id: + return jsonify({ + "success": False, + "error": t('api.requireProjectId') + }), 400 + + project = ProjectManager.get_project(project_id) + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=project_id) + }), 404 + + graph_id = data.get('graph_id') or project.graph_id + if not graph_id: + return jsonify({ + "success": False, + "error": t('api.graphNotBuilt') + }), 400 + + manager = SimulationManager() + state = manager.create_simulation( + project_id=project_id, + graph_id=graph_id, + enable_twitter=data.get('enable_twitter', True), + enable_reddit=data.get('enable_reddit', True), + ) + + return jsonify({ + "success": True, + "data": state.to_dict() + }) + + except Exception as e: + logger.error(f"创建模拟失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +def _check_simulation_prepared(simulation_id: str) -> tuple: + """ + 检查模拟是否已经准备完成 + + 检查条件: + 1. state.json 存在且 status 为 "ready" + 2. 必要文件存在:reddit_profiles.json, twitter_profiles.csv, simulation_config.json + + 注意:运行脚本(run_*.py)保留在 backend/scripts/ 目录,不再复制到模拟目录 + + Args: + simulation_id: 模拟ID + + Returns: + (is_prepared: bool, info: dict) + """ + import os + from ..config import Config + + simulation_dir = os.path.join(Config.OASIS_SIMULATION_DATA_DIR, simulation_id) + + # 检查目录是否存在 + if not os.path.exists(simulation_dir): + return False, {"reason": "模拟目录不存在"} + + # 必要文件列表(不包括脚本,脚本位于 backend/scripts/) + required_files = [ + "state.json", + "simulation_config.json", + "reddit_profiles.json", + "twitter_profiles.csv" + ] + + # 检查文件是否存在 + existing_files = [] + missing_files = [] + for f in required_files: + file_path = os.path.join(simulation_dir, f) + if os.path.exists(file_path): + existing_files.append(f) + else: + missing_files.append(f) + + if missing_files: + return False, { + "reason": "缺少必要文件", + "missing_files": missing_files, + "existing_files": existing_files + } + + # 检查state.json中的状态 + state_file = os.path.join(simulation_dir, "state.json") + try: + import json + with open(state_file, 'r', encoding='utf-8') as f: + state_data = json.load(f) + + status = state_data.get("status", "") + config_generated = state_data.get("config_generated", False) + + # 详细日志 + logger.debug(f"检测模拟准备状态: {simulation_id}, status={status}, config_generated={config_generated}") + + # 如果 config_generated=True 且文件存在,认为准备完成 + # 以下状态都说明准备工作已完成: + # - ready: 准备完成,可以运行 + # - preparing: 如果 config_generated=True 说明已完成 + # - running: 正在运行,说明准备早就完成了 + # - completed: 运行完成,说明准备早就完成了 + # - stopped: 已停止,说明准备早就完成了 + # - failed: 运行失败(但准备是完成的) + prepared_statuses = ["ready", "preparing", "running", "completed", "stopped", "failed"] + if status in prepared_statuses and config_generated: + # 获取文件统计信息 + profiles_file = os.path.join(simulation_dir, "reddit_profiles.json") + config_file = os.path.join(simulation_dir, "simulation_config.json") + + profiles_count = 0 + if os.path.exists(profiles_file): + with open(profiles_file, 'r', encoding='utf-8') as f: + profiles_data = json.load(f) + profiles_count = len(profiles_data) if isinstance(profiles_data, list) else 0 + + # 如果状态是preparing但文件已完成,自动更新状态为ready + if status == "preparing": + try: + state_data["status"] = "ready" + from datetime import datetime + state_data["updated_at"] = datetime.now().isoformat() + with open(state_file, 'w', encoding='utf-8') as f: + json.dump(state_data, f, ensure_ascii=False, indent=2) + logger.info(f"自动更新模拟状态: {simulation_id} preparing -> ready") + status = "ready" + except Exception as e: + logger.warning(f"自动更新状态失败: {e}") + + logger.info(f"模拟 {simulation_id} 检测结果: 已准备完成 (status={status}, config_generated={config_generated})") + return True, { + "status": status, + "entities_count": state_data.get("entities_count", 0), + "profiles_count": profiles_count, + "entity_types": state_data.get("entity_types", []), + "config_generated": config_generated, + "created_at": state_data.get("created_at"), + "updated_at": state_data.get("updated_at"), + "existing_files": existing_files + } + else: + logger.warning(f"模拟 {simulation_id} 检测结果: 未准备完成 (status={status}, config_generated={config_generated})") + return False, { + "reason": f"状态不在已准备列表中或config_generated为false: status={status}, config_generated={config_generated}", + "status": status, + "config_generated": config_generated + } + + except Exception as e: + return False, {"reason": f"读取状态文件失败: {str(e)}"} + + +@simulation_bp.route('/prepare', methods=['POST']) +def prepare_simulation(): + """ + 准备模拟环境(异步任务,LLM智能生成所有参数) + + 这是一个耗时操作,接口会立即返回task_id, + 使用 GET /api/simulation/prepare/status 查询进度 + + 特性: + - 自动检测已完成的准备工作,避免重复生成 + - 如果已准备完成,直接返回已有结果 + - 支持强制重新生成(force_regenerate=true) + + 步骤: + 1. 检查是否已有完成的准备工作 + 2. 从Zep图谱读取并过滤实体 + 3. 为每个实体生成OASIS Agent Profile(带重试机制) + 4. LLM智能生成模拟配置(带重试机制) + 5. 保存配置文件和预设脚本 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "entity_types": ["Student", "PublicFigure"], // 可选,指定实体类型 + "use_llm_for_profiles": true, // 可选,是否用LLM生成人设 + "parallel_profile_count": 5, // 可选,并行生成人设数量,默认5 + "force_regenerate": false // 可选,强制重新生成,默认false + } + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "task_id": "task_xxxx", // 新任务时返回 + "status": "preparing|ready", + "message": "准备任务已启动|已有完成的准备工作", + "already_prepared": true|false // 是否已准备完成 + } + } + """ + import threading + import os + from ..models.task import TaskManager, TaskStatus + from ..config import Config + + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + + if not state: + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + # 检查是否强制重新生成 + force_regenerate = data.get('force_regenerate', False) + logger.info(f"开始处理 /prepare 请求: simulation_id={simulation_id}, force_regenerate={force_regenerate}") + + # 检查是否已经准备完成(避免重复生成) + if not force_regenerate: + logger.debug(f"检查模拟 {simulation_id} 是否已准备完成...") + is_prepared, prepare_info = _check_simulation_prepared(simulation_id) + logger.debug(f"检查结果: is_prepared={is_prepared}, prepare_info={prepare_info}") + if is_prepared: + logger.info(f"模拟 {simulation_id} 已准备完成,跳过重复生成") + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "status": "ready", + "message": t('api.alreadyPrepared'), + "already_prepared": True, + "prepare_info": prepare_info + } + }) + else: + logger.info(f"模拟 {simulation_id} 未准备完成,将启动准备任务") + + # 从项目获取必要信息 + project = ProjectManager.get_project(state.project_id) + if not project: + return jsonify({ + "success": False, + "error": t('api.projectNotFound', id=state.project_id) + }), 404 + + # 获取模拟需求 + simulation_requirement = project.simulation_requirement or "" + if not simulation_requirement: + return jsonify({ + "success": False, + "error": t('api.projectMissingRequirement') + }), 400 + + # 获取文档文本 + document_text = ProjectManager.get_extracted_text(state.project_id) or "" + + entity_types_list = data.get('entity_types') + use_llm_for_profiles = data.get('use_llm_for_profiles', True) + parallel_profile_count = data.get('parallel_profile_count', 5) + + # ========== 同步获取实体数量(在后台任务启动前) ========== + # 这样前端在调用prepare后立即就能获取到预期Agent总数 + try: + logger.info(f"同步获取实体数量: graph_id={state.graph_id}") + reader = ZepEntityReader() + # 快速读取实体(不需要边信息,只统计数量) + filtered_preview = reader.filter_defined_entities( + graph_id=state.graph_id, + defined_entity_types=entity_types_list, + enrich_with_edges=False # 不获取边信息,加快速度 + ) + # 保存实体数量到状态(供前端立即获取) + state.entities_count = filtered_preview.filtered_count + state.entity_types = list(filtered_preview.entity_types) + logger.info(f"预期实体数量: {filtered_preview.filtered_count}, 类型: {filtered_preview.entity_types}") + except Exception as e: + logger.warning(f"同步获取实体数量失败(将在后台任务中重试): {e}") + # 失败不影响后续流程,后台任务会重新获取 + + # 创建异步任务 + task_manager = TaskManager() + task_id = task_manager.create_task( + task_type="simulation_prepare", + metadata={ + "simulation_id": simulation_id, + "project_id": state.project_id + } + ) + + # 更新模拟状态(包含预先获取的实体数量) + state.status = SimulationStatus.PREPARING + manager._save_simulation_state(state) + + # Capture locale before spawning background thread + current_locale = get_locale() + + # 定义后台任务 + def run_prepare(): + set_locale(current_locale) + try: + task_manager.update_task( + task_id, + status=TaskStatus.PROCESSING, + progress=0, + message=t('progress.startPreparingEnv') + ) + + # 准备模拟(带进度回调) + # 存储阶段进度详情 + stage_details = {} + + def progress_callback(stage, progress, message, **kwargs): + # 计算总进度 + stage_weights = { + "reading": (0, 20), # 0-20% + "generating_profiles": (20, 70), # 20-70% + "generating_config": (70, 90), # 70-90% + "copying_scripts": (90, 100) # 90-100% + } + + start, end = stage_weights.get(stage, (0, 100)) + current_progress = int(start + (end - start) * progress / 100) + + # 构建详细进度信息 + stage_names = { + "reading": t('progress.readingGraphEntities'), + "generating_profiles": t('progress.generatingProfiles'), + "generating_config": t('progress.generatingSimConfig'), + "copying_scripts": t('progress.preparingScripts') + } + + stage_index = list(stage_weights.keys()).index(stage) + 1 if stage in stage_weights else 1 + total_stages = len(stage_weights) + + # 更新阶段详情 + stage_details[stage] = { + "stage_name": stage_names.get(stage, stage), + "stage_progress": progress, + "current": kwargs.get("current", 0), + "total": kwargs.get("total", 0), + "item_name": kwargs.get("item_name", "") + } + + # 构建详细进度信息 + detail = stage_details[stage] + progress_detail_data = { + "current_stage": stage, + "current_stage_name": stage_names.get(stage, stage), + "stage_index": stage_index, + "total_stages": total_stages, + "stage_progress": progress, + "current_item": detail["current"], + "total_items": detail["total"], + "item_description": message + } + + # 构建简洁消息 + if detail["total"] > 0: + detailed_message = ( + f"[{stage_index}/{total_stages}] {stage_names.get(stage, stage)}: " + f"{detail['current']}/{detail['total']} - {message}" + ) + else: + detailed_message = f"[{stage_index}/{total_stages}] {stage_names.get(stage, stage)}: {message}" + + task_manager.update_task( + task_id, + progress=current_progress, + message=detailed_message, + progress_detail=progress_detail_data + ) + + result_state = manager.prepare_simulation( + simulation_id=simulation_id, + simulation_requirement=simulation_requirement, + document_text=document_text, + defined_entity_types=entity_types_list, + use_llm_for_profiles=use_llm_for_profiles, + progress_callback=progress_callback, + parallel_profile_count=parallel_profile_count + ) + + # 任务完成 + task_manager.complete_task( + task_id, + result=result_state.to_simple_dict() + ) + + except Exception as e: + logger.error(f"准备模拟失败: {str(e)}") + task_manager.fail_task(task_id, str(e)) + + # 更新模拟状态为失败 + state = manager.get_simulation(simulation_id) + if state: + state.status = SimulationStatus.FAILED + state.error = str(e) + manager._save_simulation_state(state) + + # 启动后台线程 + thread = threading.Thread(target=run_prepare, daemon=True) + thread.start() + + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "task_id": task_id, + "status": "preparing", + "message": t('api.prepareStarted'), + "already_prepared": False, + "expected_entities_count": state.entities_count, # 预期的Agent总数 + "entity_types": state.entity_types # 实体类型列表 + } + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 404 + + except Exception as e: + logger.error(f"启动准备任务失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/prepare/status', methods=['POST']) +def get_prepare_status(): + """ + 查询准备任务进度 + + 支持两种查询方式: + 1. 通过task_id查询正在进行的任务进度 + 2. 通过simulation_id检查是否已有完成的准备工作 + + 请求(JSON): + { + "task_id": "task_xxxx", // 可选,prepare返回的task_id + "simulation_id": "sim_xxxx" // 可选,模拟ID(用于检查已完成的准备) + } + + 返回: + { + "success": true, + "data": { + "task_id": "task_xxxx", + "status": "processing|completed|ready", + "progress": 45, + "message": "...", + "already_prepared": true|false, // 是否已有完成的准备 + "prepare_info": {...} // 已准备完成时的详细信息 + } + } + """ + from ..models.task import TaskManager + + try: + data = request.get_json() or {} + + task_id = data.get('task_id') + simulation_id = data.get('simulation_id') + + # 如果提供了simulation_id,先检查是否已准备完成 + if simulation_id: + is_prepared, prepare_info = _check_simulation_prepared(simulation_id) + if is_prepared: + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "status": "ready", + "progress": 100, + "message": t('api.alreadyPrepared'), + "already_prepared": True, + "prepare_info": prepare_info + } + }) + + # 如果没有task_id,返回错误 + if not task_id: + if simulation_id: + # 有simulation_id但未准备完成 + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "status": "not_started", + "progress": 0, + "message": t('api.notStartedPrepare'), + "already_prepared": False + } + }) + return jsonify({ + "success": False, + "error": t('api.requireTaskOrSimId') + }), 400 + + task_manager = TaskManager() + task = task_manager.get_task(task_id) + + if not task: + # 任务不存在,但如果有simulation_id,检查是否已准备完成 + if simulation_id: + is_prepared, prepare_info = _check_simulation_prepared(simulation_id) + if is_prepared: + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "task_id": task_id, + "status": "ready", + "progress": 100, + "message": t('api.taskCompletedPrepared'), + "already_prepared": True, + "prepare_info": prepare_info + } + }) + + return jsonify({ + "success": False, + "error": t('api.taskNotFound', id=task_id) + }), 404 + + task_dict = task.to_dict() + task_dict["already_prepared"] = False + + return jsonify({ + "success": True, + "data": task_dict + }) + + except Exception as e: + logger.error(f"查询任务状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e) + }), 500 + + +@simulation_bp.route('/', methods=['GET']) +def get_simulation(simulation_id: str): + """获取模拟状态""" + try: + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + + if not state: + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + result = state.to_dict() + + # 如果模拟已准备好,附加运行说明 + if state.status == SimulationStatus.READY: + result["run_instructions"] = manager.get_run_instructions(simulation_id) + + return jsonify({ + "success": True, + "data": result + }) + + except Exception as e: + logger.error(f"获取模拟状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/list', methods=['GET']) +def list_simulations(): + """ + 列出所有模拟 + + Query参数: + project_id: 按项目ID过滤(可选) + """ + try: + project_id = request.args.get('project_id') + + manager = SimulationManager() + simulations = manager.list_simulations(project_id=project_id) + + return jsonify({ + "success": True, + "data": [s.to_dict() for s in simulations], + "count": len(simulations) + }) + + except Exception as e: + logger.error(f"列出模拟失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +def _get_report_id_for_simulation(simulation_id: str) -> str: + """ + 获取 simulation 对应的最新 report_id + + 遍历 reports 目录,找出 simulation_id 匹配的 report, + 如果有多个则返回最新的(按 created_at 排序) + + Args: + simulation_id: 模拟ID + + Returns: + report_id 或 None + """ + import json + from datetime import datetime + + # reports 目录路径:backend/uploads/reports + # __file__ 是 app/api/simulation.py,需要向上两级到 backend/ + reports_dir = os.path.join(os.path.dirname(__file__), '../../uploads/reports') + if not os.path.exists(reports_dir): + return None + + matching_reports = [] + + try: + for report_folder in os.listdir(reports_dir): + report_path = os.path.join(reports_dir, report_folder) + if not os.path.isdir(report_path): + continue + + meta_file = os.path.join(report_path, "meta.json") + if not os.path.exists(meta_file): + continue + + try: + with open(meta_file, 'r', encoding='utf-8') as f: + meta = json.load(f) + + if meta.get("simulation_id") == simulation_id: + matching_reports.append({ + "report_id": meta.get("report_id"), + "created_at": meta.get("created_at", ""), + "status": meta.get("status", "") + }) + except Exception: + continue + + if not matching_reports: + return None + + # 按创建时间倒序排序,返回最新的 + matching_reports.sort(key=lambda x: x.get("created_at", ""), reverse=True) + return matching_reports[0].get("report_id") + + except Exception as e: + logger.warning(f"查找 simulation {simulation_id} 的 report 失败: {e}") + return None + + +@simulation_bp.route('/history', methods=['GET']) +def get_simulation_history(): + """ + 获取历史模拟列表(带项目详情) + + 用于首页历史项目展示,返回包含项目名称、描述等丰富信息的模拟列表 + + Query参数: + limit: 返回数量限制(默认20) + + 返回: + { + "success": true, + "data": [ + { + "simulation_id": "sim_xxxx", + "project_id": "proj_xxxx", + "project_name": "武大舆情分析", + "simulation_requirement": "如果武汉大学发布...", + "status": "completed", + "entities_count": 68, + "profiles_count": 68, + "entity_types": ["Student", "Professor", ...], + "created_at": "2024-12-10", + "updated_at": "2024-12-10", + "total_rounds": 120, + "current_round": 120, + "report_id": "report_xxxx", + "version": "v1.0.2" + }, + ... + ], + "count": 7 + } + """ + try: + limit = request.args.get('limit', 20, type=int) + + manager = SimulationManager() + simulations = manager.list_simulations()[:limit] + + # 增强模拟数据,只从 Simulation 文件读取 + enriched_simulations = [] + for sim in simulations: + sim_dict = sim.to_dict() + + # 获取模拟配置信息(从 simulation_config.json 读取 simulation_requirement) + config = manager.get_simulation_config(sim.simulation_id) + if config: + sim_dict["simulation_requirement"] = config.get("simulation_requirement", "") + time_config = config.get("time_config", {}) + sim_dict["total_simulation_hours"] = time_config.get("total_simulation_hours", 0) + # 推荐轮数(后备值) + recommended_rounds = int( + time_config.get("total_simulation_hours", 0) * 60 / + max(time_config.get("minutes_per_round", 60), 1) + ) + else: + sim_dict["simulation_requirement"] = "" + sim_dict["total_simulation_hours"] = 0 + recommended_rounds = 0 + + # 获取运行状态(从 run_state.json 读取用户设置的实际轮数) + run_state = SimulationRunner.get_run_state(sim.simulation_id) + if run_state: + sim_dict["current_round"] = run_state.current_round + sim_dict["runner_status"] = run_state.runner_status.value + # 使用用户设置的 total_rounds,若无则使用推荐轮数 + sim_dict["total_rounds"] = run_state.total_rounds if run_state.total_rounds > 0 else recommended_rounds + else: + sim_dict["current_round"] = 0 + sim_dict["runner_status"] = "idle" + sim_dict["total_rounds"] = recommended_rounds + + # 获取关联项目的文件列表(最多3个) + project = ProjectManager.get_project(sim.project_id) + if project and hasattr(project, 'files') and project.files: + sim_dict["files"] = [ + {"filename": f.get("filename", "未知文件")} + for f in project.files[:3] + ] + else: + sim_dict["files"] = [] + + # 获取关联的 report_id(查找该 simulation 最新的 report) + sim_dict["report_id"] = _get_report_id_for_simulation(sim.simulation_id) + + # 添加版本号 + sim_dict["version"] = "v1.0.2" + + # 格式化日期 + try: + created_date = sim_dict.get("created_at", "")[:10] + sim_dict["created_date"] = created_date + except: + sim_dict["created_date"] = "" + + enriched_simulations.append(sim_dict) + + return jsonify({ + "success": True, + "data": enriched_simulations, + "count": len(enriched_simulations) + }) + + except Exception as e: + logger.error(f"获取历史模拟失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//profiles', methods=['GET']) +def get_simulation_profiles(simulation_id: str): + """ + 获取模拟的Agent Profile + + Query参数: + platform: 平台类型(reddit/twitter,默认reddit) + """ + try: + platform = request.args.get('platform', 'reddit') + + manager = SimulationManager() + profiles = manager.get_profiles(simulation_id, platform=platform) + + return jsonify({ + "success": True, + "data": { + "platform": platform, + "count": len(profiles), + "profiles": profiles + } + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 404 + + except Exception as e: + logger.error(f"获取Profile失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//profiles/realtime', methods=['GET']) +def get_simulation_profiles_realtime(simulation_id: str): + """ + 实时获取模拟的Agent Profile(用于在生成过程中实时查看进度) + + 与 /profiles 接口的区别: + - 直接读取文件,不经过 SimulationManager + - 适用于生成过程中的实时查看 + - 返回额外的元数据(如文件修改时间、是否正在生成等) + + Query参数: + platform: 平台类型(reddit/twitter,默认reddit) + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "platform": "reddit", + "count": 15, + "total_expected": 93, // 预期总数(如果有) + "is_generating": true, // 是否正在生成 + "file_exists": true, + "file_modified_at": "2025-12-04T18:20:00", + "profiles": [...] + } + } + """ + import json + import csv + from datetime import datetime + + try: + platform = request.args.get('platform', 'reddit') + + # 获取模拟目录 + sim_dir = os.path.join(Config.OASIS_SIMULATION_DATA_DIR, simulation_id) + + if not os.path.exists(sim_dir): + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + # 确定文件路径 + if platform == "reddit": + profiles_file = os.path.join(sim_dir, "reddit_profiles.json") + else: + profiles_file = os.path.join(sim_dir, "twitter_profiles.csv") + + # 检查文件是否存在 + file_exists = os.path.exists(profiles_file) + profiles = [] + file_modified_at = None + + if file_exists: + # 获取文件修改时间 + file_stat = os.stat(profiles_file) + file_modified_at = datetime.fromtimestamp(file_stat.st_mtime).isoformat() + + try: + if platform == "reddit": + with open(profiles_file, 'r', encoding='utf-8') as f: + profiles = json.load(f) + else: + with open(profiles_file, 'r', encoding='utf-8') as f: + reader = csv.DictReader(f) + profiles = list(reader) + except (json.JSONDecodeError, Exception) as e: + logger.warning(f"读取 profiles 文件失败(可能正在写入中): {e}") + profiles = [] + + # 检查是否正在生成(通过 state.json 判断) + is_generating = False + total_expected = None + + state_file = os.path.join(sim_dir, "state.json") + if os.path.exists(state_file): + try: + with open(state_file, 'r', encoding='utf-8') as f: + state_data = json.load(f) + status = state_data.get("status", "") + is_generating = status == "preparing" + total_expected = state_data.get("entities_count") + except Exception: + pass + + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "platform": platform, + "count": len(profiles), + "total_expected": total_expected, + "is_generating": is_generating, + "file_exists": file_exists, + "file_modified_at": file_modified_at, + "profiles": profiles + } + }) + + except Exception as e: + logger.error(f"实时获取Profile失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//config/realtime', methods=['GET']) +def get_simulation_config_realtime(simulation_id: str): + """ + 实时获取模拟配置(用于在生成过程中实时查看进度) + + 与 /config 接口的区别: + - 直接读取文件,不经过 SimulationManager + - 适用于生成过程中的实时查看 + - 返回额外的元数据(如文件修改时间、是否正在生成等) + - 即使配置还没生成完也能返回部分信息 + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "file_exists": true, + "file_modified_at": "2025-12-04T18:20:00", + "is_generating": true, // 是否正在生成 + "generation_stage": "generating_config", // 当前生成阶段 + "config": {...} // 配置内容(如果存在) + } + } + """ + import json + from datetime import datetime + + try: + # 获取模拟目录 + sim_dir = os.path.join(Config.OASIS_SIMULATION_DATA_DIR, simulation_id) + + if not os.path.exists(sim_dir): + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + # 配置文件路径 + config_file = os.path.join(sim_dir, "simulation_config.json") + + # 检查文件是否存在 + file_exists = os.path.exists(config_file) + config = None + file_modified_at = None + + if file_exists: + # 获取文件修改时间 + file_stat = os.stat(config_file) + file_modified_at = datetime.fromtimestamp(file_stat.st_mtime).isoformat() + + try: + with open(config_file, 'r', encoding='utf-8') as f: + config = json.load(f) + except (json.JSONDecodeError, Exception) as e: + logger.warning(f"读取 config 文件失败(可能正在写入中): {e}") + config = None + + # 检查是否正在生成(通过 state.json 判断) + is_generating = False + generation_stage = None + config_generated = False + + state_file = os.path.join(sim_dir, "state.json") + if os.path.exists(state_file): + try: + with open(state_file, 'r', encoding='utf-8') as f: + state_data = json.load(f) + status = state_data.get("status", "") + is_generating = status == "preparing" + config_generated = state_data.get("config_generated", False) + + # 判断当前阶段 + if is_generating: + if state_data.get("profiles_generated", False): + generation_stage = "generating_config" + else: + generation_stage = "generating_profiles" + elif status == "ready": + generation_stage = "completed" + except Exception: + pass + + # 构建返回数据 + response_data = { + "simulation_id": simulation_id, + "file_exists": file_exists, + "file_modified_at": file_modified_at, + "is_generating": is_generating, + "generation_stage": generation_stage, + "config_generated": config_generated, + "config": config + } + + # 如果配置存在,提取一些关键统计信息 + if config: + response_data["summary"] = { + "total_agents": len(config.get("agent_configs", [])), + "simulation_hours": config.get("time_config", {}).get("total_simulation_hours"), + "initial_posts_count": len(config.get("event_config", {}).get("initial_posts", [])), + "hot_topics_count": len(config.get("event_config", {}).get("hot_topics", [])), + "has_twitter_config": "twitter_config" in config, + "has_reddit_config": "reddit_config" in config, + "generated_at": config.get("generated_at"), + "llm_model": config.get("llm_model") + } + + return jsonify({ + "success": True, + "data": response_data + }) + + except Exception as e: + logger.error(f"实时获取Config失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//config', methods=['GET']) +def get_simulation_config(simulation_id: str): + """ + 获取模拟配置(LLM智能生成的完整配置) + + 返回包含: + - time_config: 时间配置(模拟时长、轮次、高峰/低谷时段) + - agent_configs: 每个Agent的活动配置(活跃度、发言频率、立场等) + - event_config: 事件配置(初始帖子、热点话题) + - platform_configs: 平台配置 + - generation_reasoning: LLM的配置推理说明 + """ + try: + manager = SimulationManager() + config = manager.get_simulation_config(simulation_id) + + if not config: + return jsonify({ + "success": False, + "error": t('api.configNotFound') + }), 404 + + return jsonify({ + "success": True, + "data": config + }) + + except Exception as e: + logger.error(f"获取配置失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//config/download', methods=['GET']) +def download_simulation_config(simulation_id: str): + """下载模拟配置文件""" + try: + manager = SimulationManager() + sim_dir = manager._get_simulation_dir(simulation_id) + config_path = os.path.join(sim_dir, "simulation_config.json") + + if not os.path.exists(config_path): + return jsonify({ + "success": False, + "error": t('api.configFileNotFound') + }), 404 + + return send_file( + config_path, + as_attachment=True, + download_name="simulation_config.json" + ) + + except Exception as e: + logger.error(f"下载配置失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/script//download', methods=['GET']) +def download_simulation_script(script_name: str): + """ + 下载模拟运行脚本文件(通用脚本,位于 backend/scripts/) + + script_name可选值: + - run_twitter_simulation.py + - run_reddit_simulation.py + - run_parallel_simulation.py + - action_logger.py + """ + try: + # 脚本位于 backend/scripts/ 目录 + scripts_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../scripts')) + + # 验证脚本名称 + allowed_scripts = [ + "run_twitter_simulation.py", + "run_reddit_simulation.py", + "run_parallel_simulation.py", + "action_logger.py" + ] + + if script_name not in allowed_scripts: + return jsonify({ + "success": False, + "error": t('api.unknownScript', name=script_name, allowed=allowed_scripts) + }), 400 + + script_path = os.path.join(scripts_dir, script_name) + + if not os.path.exists(script_path): + return jsonify({ + "success": False, + "error": t('api.scriptFileNotFound', name=script_name) + }), 404 + + return send_file( + script_path, + as_attachment=True, + download_name=script_name + ) + + except Exception as e: + logger.error(f"下载脚本失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== Profile生成接口(独立使用) ============== + +@simulation_bp.route('/generate-profiles', methods=['POST']) +def generate_profiles(): + """ + 直接从图谱生成OASIS Agent Profile(不创建模拟) + + 请求(JSON): + { + "graph_id": "mirofish_xxxx", // 必填 + "entity_types": ["Student"], // 可选 + "use_llm": true, // 可选 + "platform": "reddit" // 可选 + } + """ + try: + data = request.get_json() or {} + + graph_id = data.get('graph_id') + if not graph_id: + return jsonify({ + "success": False, + "error": t('api.requireGraphId') + }), 400 + + entity_types = data.get('entity_types') + use_llm = data.get('use_llm', True) + platform = data.get('platform', 'reddit') + + reader = ZepEntityReader() + filtered = reader.filter_defined_entities( + graph_id=graph_id, + defined_entity_types=entity_types, + enrich_with_edges=True + ) + + if filtered.filtered_count == 0: + return jsonify({ + "success": False, + "error": t('api.noMatchingEntities') + }), 400 + + generator = OasisProfileGenerator() + profiles = generator.generate_profiles_from_entities( + entities=filtered.entities, + use_llm=use_llm + ) + + if platform == "reddit": + profiles_data = [p.to_reddit_format() for p in profiles] + elif platform == "twitter": + profiles_data = [p.to_twitter_format() for p in profiles] + else: + profiles_data = [p.to_dict() for p in profiles] + + return jsonify({ + "success": True, + "data": { + "platform": platform, + "entity_types": list(filtered.entity_types), + "count": len(profiles_data), + "profiles": profiles_data + } + }) + + except Exception as e: + logger.error(f"生成Profile失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 模拟运行控制接口 ============== + +@simulation_bp.route('/start', methods=['POST']) +def start_simulation(): + """ + 开始运行模拟 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "platform": "parallel", // 可选: twitter / reddit / parallel (默认) + "max_rounds": 100, // 可选: 最大模拟轮数,用于截断过长的模拟 + "enable_graph_memory_update": false, // 可选: 是否将Agent活动动态更新到Zep图谱记忆 + "force": false // 可选: 强制重新开始(会停止运行中的模拟并清理日志) + } + + 关于 force 参数: + - 启用后,如果模拟正在运行或已完成,会先停止并清理运行日志 + - 清理的内容包括:run_state.json, actions.jsonl, simulation.log 等 + - 不会清理配置文件(simulation_config.json)和 profile 文件 + - 适用于需要重新运行模拟的场景 + + 关于 enable_graph_memory_update: + - 启用后,模拟中所有Agent的活动(发帖、评论、点赞等)都会实时更新到Zep图谱 + - 这可以让图谱"记住"模拟过程,用于后续分析或AI对话 + - 需要模拟关联的项目有有效的 graph_id + - 采用批量更新机制,减少API调用次数 + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "runner_status": "running", + "process_pid": 12345, + "twitter_running": true, + "reddit_running": true, + "started_at": "2025-12-01T10:00:00", + "graph_memory_update_enabled": true, // 是否启用了图谱记忆更新 + "force_restarted": true // 是否是强制重新开始 + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + platform = data.get('platform', 'parallel') + max_rounds = data.get('max_rounds') # 可选:最大模拟轮数 + enable_graph_memory_update = data.get('enable_graph_memory_update', False) # 可选:是否启用图谱记忆更新 + force = data.get('force', False) # 可选:强制重新开始 + + # 验证 max_rounds 参数 + if max_rounds is not None: + try: + max_rounds = int(max_rounds) + if max_rounds <= 0: + return jsonify({ + "success": False, + "error": t('api.maxRoundsPositive') + }), 400 + except (ValueError, TypeError): + return jsonify({ + "success": False, + "error": t('api.maxRoundsInvalid') + }), 400 + + if platform not in ['twitter', 'reddit', 'parallel']: + return jsonify({ + "success": False, + "error": t('api.invalidPlatform', platform=platform) + }), 400 + + # 检查模拟是否已准备好 + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + + if not state: + return jsonify({ + "success": False, + "error": t('api.simulationNotFound', id=simulation_id) + }), 404 + + force_restarted = False + + # 智能处理状态:如果准备工作已完成,允许重新启动 + if state.status != SimulationStatus.READY: + # 检查准备工作是否已完成 + is_prepared, prepare_info = _check_simulation_prepared(simulation_id) + + if is_prepared: + # 准备工作已完成,检查是否有正在运行的进程 + if state.status == SimulationStatus.RUNNING: + # 检查模拟进程是否真的在运行 + run_state = SimulationRunner.get_run_state(simulation_id) + if run_state and run_state.runner_status.value == "running": + # 进程确实在运行 + if force: + # 强制模式:停止运行中的模拟 + logger.info(f"强制模式:停止运行中的模拟 {simulation_id}") + try: + SimulationRunner.stop_simulation(simulation_id) + except Exception as e: + logger.warning(f"停止模拟时出现警告: {str(e)}") + else: + return jsonify({ + "success": False, + "error": t('api.simRunningForceHint') + }), 400 + + # 如果是强制模式,清理运行日志 + if force: + logger.info(f"强制模式:清理模拟日志 {simulation_id}") + cleanup_result = SimulationRunner.cleanup_simulation_logs(simulation_id) + if not cleanup_result.get("success"): + logger.warning(f"清理日志时出现警告: {cleanup_result.get('errors')}") + force_restarted = True + + # 进程不存在或已结束,重置状态为 ready + logger.info(f"模拟 {simulation_id} 准备工作已完成,重置状态为 ready(原状态: {state.status.value})") + state.status = SimulationStatus.READY + manager._save_simulation_state(state) + else: + # 准备工作未完成 + return jsonify({ + "success": False, + "error": t('api.simNotReady', status=state.status.value) + }), 400 + + # 获取图谱ID(用于图谱记忆更新) + graph_id = None + if enable_graph_memory_update: + # 从模拟状态或项目中获取 graph_id + graph_id = state.graph_id + if not graph_id: + # 尝试从项目中获取 + project = ProjectManager.get_project(state.project_id) + if project: + graph_id = project.graph_id + + if not graph_id: + return jsonify({ + "success": False, + "error": t('api.graphIdRequiredForMemory') + }), 400 + + logger.info(f"启用图谱记忆更新: simulation_id={simulation_id}, graph_id={graph_id}") + + # 启动模拟 + run_state = SimulationRunner.start_simulation( + simulation_id=simulation_id, + platform=platform, + max_rounds=max_rounds, + enable_graph_memory_update=enable_graph_memory_update, + graph_id=graph_id + ) + + # 更新模拟状态 + state.status = SimulationStatus.RUNNING + manager._save_simulation_state(state) + + response_data = run_state.to_dict() + if max_rounds: + response_data['max_rounds_applied'] = max_rounds + response_data['graph_memory_update_enabled'] = enable_graph_memory_update + response_data['force_restarted'] = force_restarted + if enable_graph_memory_update: + response_data['graph_id'] = graph_id + + return jsonify({ + "success": True, + "data": response_data + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 400 + + except Exception as e: + logger.error(f"启动模拟失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/stop', methods=['POST']) +def stop_simulation(): + """ + 停止模拟 + + 请求(JSON): + { + "simulation_id": "sim_xxxx" // 必填,模拟ID + } + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "runner_status": "stopped", + "completed_at": "2025-12-01T12:00:00" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + run_state = SimulationRunner.stop_simulation(simulation_id) + + # 更新模拟状态 + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + if state: + state.status = SimulationStatus.PAUSED + manager._save_simulation_state(state) + + return jsonify({ + "success": True, + "data": run_state.to_dict() + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 400 + + except Exception as e: + logger.error(f"停止模拟失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 实时状态监控接口 ============== + +@simulation_bp.route('//run-status', methods=['GET']) +def get_run_status(simulation_id: str): + """ + 获取模拟运行实时状态(用于前端轮询) + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "runner_status": "running", + "current_round": 5, + "total_rounds": 144, + "progress_percent": 3.5, + "simulated_hours": 2, + "total_simulation_hours": 72, + "twitter_running": true, + "reddit_running": true, + "twitter_actions_count": 150, + "reddit_actions_count": 200, + "total_actions_count": 350, + "started_at": "2025-12-01T10:00:00", + "updated_at": "2025-12-01T10:30:00" + } + } + """ + try: + run_state = SimulationRunner.get_run_state(simulation_id) + + if not run_state: + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "runner_status": "idle", + "current_round": 0, + "total_rounds": 0, + "progress_percent": 0, + "twitter_actions_count": 0, + "reddit_actions_count": 0, + "total_actions_count": 0, + } + }) + + return jsonify({ + "success": True, + "data": run_state.to_dict() + }) + + except Exception as e: + logger.error(f"获取运行状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//run-status/detail', methods=['GET']) +def get_run_status_detail(simulation_id: str): + """ + 获取模拟运行详细状态(包含所有动作) + + 用于前端展示实时动态 + + Query参数: + platform: 过滤平台(twitter/reddit,可选) + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "runner_status": "running", + "current_round": 5, + ... + "all_actions": [ + { + "round_num": 5, + "timestamp": "2025-12-01T10:30:00", + "platform": "twitter", + "agent_id": 3, + "agent_name": "Agent Name", + "action_type": "CREATE_POST", + "action_args": {"content": "..."}, + "result": null, + "success": true + }, + ... + ], + "twitter_actions": [...], # Twitter 平台的所有动作 + "reddit_actions": [...] # Reddit 平台的所有动作 + } + } + """ + try: + run_state = SimulationRunner.get_run_state(simulation_id) + platform_filter = request.args.get('platform') + + if not run_state: + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "runner_status": "idle", + "all_actions": [], + "twitter_actions": [], + "reddit_actions": [] + } + }) + + # 获取完整的动作列表 + all_actions = SimulationRunner.get_all_actions( + simulation_id=simulation_id, + platform=platform_filter + ) + + # 分平台获取动作 + twitter_actions = SimulationRunner.get_all_actions( + simulation_id=simulation_id, + platform="twitter" + ) if not platform_filter or platform_filter == "twitter" else [] + + reddit_actions = SimulationRunner.get_all_actions( + simulation_id=simulation_id, + platform="reddit" + ) if not platform_filter or platform_filter == "reddit" else [] + + # 获取当前轮次的动作(recent_actions 只展示最新一轮) + current_round = run_state.current_round + recent_actions = SimulationRunner.get_all_actions( + simulation_id=simulation_id, + platform=platform_filter, + round_num=current_round + ) if current_round > 0 else [] + + # 获取基础状态信息 + result = run_state.to_dict() + result["all_actions"] = [a.to_dict() for a in all_actions] + result["twitter_actions"] = [a.to_dict() for a in twitter_actions] + result["reddit_actions"] = [a.to_dict() for a in reddit_actions] + result["rounds_count"] = len(run_state.rounds) + # recent_actions 只展示当前最新一轮两个平台的内容 + result["recent_actions"] = [a.to_dict() for a in recent_actions] + + return jsonify({ + "success": True, + "data": result + }) + + except Exception as e: + logger.error(f"获取详细状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//actions', methods=['GET']) +def get_simulation_actions(simulation_id: str): + """ + 获取模拟中的Agent动作历史 + + Query参数: + limit: 返回数量(默认100) + offset: 偏移量(默认0) + platform: 过滤平台(twitter/reddit) + agent_id: 过滤Agent ID + round_num: 过滤轮次 + + 返回: + { + "success": true, + "data": { + "count": 100, + "actions": [...] + } + } + """ + try: + limit = request.args.get('limit', 100, type=int) + offset = request.args.get('offset', 0, type=int) + platform = request.args.get('platform') + agent_id = request.args.get('agent_id', type=int) + round_num = request.args.get('round_num', type=int) + + actions = SimulationRunner.get_actions( + simulation_id=simulation_id, + limit=limit, + offset=offset, + platform=platform, + agent_id=agent_id, + round_num=round_num + ) + + return jsonify({ + "success": True, + "data": { + "count": len(actions), + "actions": [a.to_dict() for a in actions] + } + }) + + except Exception as e: + logger.error(f"获取动作历史失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//timeline', methods=['GET']) +def get_simulation_timeline(simulation_id: str): + """ + 获取模拟时间线(按轮次汇总) + + 用于前端展示进度条和时间线视图 + + Query参数: + start_round: 起始轮次(默认0) + end_round: 结束轮次(默认全部) + + 返回每轮的汇总信息 + """ + try: + start_round = request.args.get('start_round', 0, type=int) + end_round = request.args.get('end_round', type=int) + + timeline = SimulationRunner.get_timeline( + simulation_id=simulation_id, + start_round=start_round, + end_round=end_round + ) + + return jsonify({ + "success": True, + "data": { + "rounds_count": len(timeline), + "timeline": timeline + } + }) + + except Exception as e: + logger.error(f"获取时间线失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//agent-stats', methods=['GET']) +def get_agent_stats(simulation_id: str): + """ + 获取每个Agent的统计信息 + + 用于前端展示Agent活跃度排行、动作分布等 + """ + try: + stats = SimulationRunner.get_agent_stats(simulation_id) + + return jsonify({ + "success": True, + "data": { + "agents_count": len(stats), + "stats": stats + } + }) + + except Exception as e: + logger.error(f"获取Agent统计失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== 数据库查询接口 ============== + +@simulation_bp.route('//posts', methods=['GET']) +def get_simulation_posts(simulation_id: str): + """ + 获取模拟中的帖子 + + Query参数: + platform: 平台类型(twitter/reddit) + limit: 返回数量(默认50) + offset: 偏移量 + + 返回帖子列表(从SQLite数据库读取) + """ + try: + platform = request.args.get('platform', 'reddit') + limit = request.args.get('limit', 50, type=int) + offset = request.args.get('offset', 0, type=int) + + sim_dir = os.path.join( + os.path.dirname(__file__), + f'../../uploads/simulations/{simulation_id}' + ) + + db_file = f"{platform}_simulation.db" + db_path = os.path.join(sim_dir, db_file) + + if not os.path.exists(db_path): + return jsonify({ + "success": True, + "data": { + "platform": platform, + "count": 0, + "posts": [], + "message": t('api.dbNotExist') + } + }) + + import sqlite3 + conn = sqlite3.connect(db_path) + conn.row_factory = sqlite3.Row + cursor = conn.cursor() + + try: + cursor.execute(""" + SELECT * FROM post + ORDER BY created_at DESC + LIMIT ? OFFSET ? + """, (limit, offset)) + + posts = [dict(row) for row in cursor.fetchall()] + + cursor.execute("SELECT COUNT(*) FROM post") + total = cursor.fetchone()[0] + + except sqlite3.OperationalError: + posts = [] + total = 0 + + conn.close() + + return jsonify({ + "success": True, + "data": { + "platform": platform, + "total": total, + "count": len(posts), + "posts": posts + } + }) + + except Exception as e: + logger.error(f"获取帖子失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('//comments', methods=['GET']) +def get_simulation_comments(simulation_id: str): + """ + 获取模拟中的评论(仅Reddit) + + Query参数: + post_id: 过滤帖子ID(可选) + limit: 返回数量 + offset: 偏移量 + """ + try: + post_id = request.args.get('post_id') + limit = request.args.get('limit', 50, type=int) + offset = request.args.get('offset', 0, type=int) + + sim_dir = os.path.join( + os.path.dirname(__file__), + f'../../uploads/simulations/{simulation_id}' + ) + + db_path = os.path.join(sim_dir, "reddit_simulation.db") + + if not os.path.exists(db_path): + return jsonify({ + "success": True, + "data": { + "count": 0, + "comments": [] + } + }) + + import sqlite3 + conn = sqlite3.connect(db_path) + conn.row_factory = sqlite3.Row + cursor = conn.cursor() + + try: + if post_id: + cursor.execute(""" + SELECT * FROM comment + WHERE post_id = ? + ORDER BY created_at DESC + LIMIT ? OFFSET ? + """, (post_id, limit, offset)) + else: + cursor.execute(""" + SELECT * FROM comment + ORDER BY created_at DESC + LIMIT ? OFFSET ? + """, (limit, offset)) + + comments = [dict(row) for row in cursor.fetchall()] + + except sqlite3.OperationalError: + comments = [] + + conn.close() + + return jsonify({ + "success": True, + "data": { + "count": len(comments), + "comments": comments + } + }) + + except Exception as e: + logger.error(f"获取评论失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +# ============== Interview 采访接口 ============== + +@simulation_bp.route('/interview', methods=['POST']) +def interview_agent(): + """ + 采访单个Agent + + 注意:此功能需要模拟环境处于运行状态(完成模拟循环后进入等待命令模式) + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "agent_id": 0, // 必填,Agent ID + "prompt": "你对这件事有什么看法?", // 必填,采访问题 + "platform": "twitter", // 可选,指定平台(twitter/reddit) + // 不指定时:双平台模拟同时采访两个平台 + "timeout": 60 // 可选,超时时间(秒),默认60 + } + + 返回(不指定platform,双平台模式): + { + "success": true, + "data": { + "agent_id": 0, + "prompt": "你对这件事有什么看法?", + "result": { + "agent_id": 0, + "prompt": "...", + "platforms": { + "twitter": {"agent_id": 0, "response": "...", "platform": "twitter"}, + "reddit": {"agent_id": 0, "response": "...", "platform": "reddit"} + } + }, + "timestamp": "2025-12-08T10:00:01" + } + } + + 返回(指定platform): + { + "success": true, + "data": { + "agent_id": 0, + "prompt": "你对这件事有什么看法?", + "result": { + "agent_id": 0, + "response": "我认为...", + "platform": "twitter", + "timestamp": "2025-12-08T10:00:00" + }, + "timestamp": "2025-12-08T10:00:01" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + agent_id = data.get('agent_id') + prompt = data.get('prompt') + platform = data.get('platform') # 可选:twitter/reddit/None + timeout = data.get('timeout', 60) + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + if agent_id is None: + return jsonify({ + "success": False, + "error": t('api.requireAgentId') + }), 400 + + if not prompt: + return jsonify({ + "success": False, + "error": t('api.requirePrompt') + }), 400 + + # 验证platform参数 + if platform and platform not in ("twitter", "reddit"): + return jsonify({ + "success": False, + "error": t('api.invalidInterviewPlatform') + }), 400 + + # 检查环境状态 + if not SimulationRunner.check_env_alive(simulation_id): + return jsonify({ + "success": False, + "error": t('api.envNotRunning') + }), 400 + + # 优化prompt,添加前缀避免Agent调用工具 + optimized_prompt = optimize_interview_prompt(prompt) + + result = SimulationRunner.interview_agent( + simulation_id=simulation_id, + agent_id=agent_id, + prompt=optimized_prompt, + platform=platform, + timeout=timeout + ) + + return jsonify({ + "success": result.get("success", False), + "data": result + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 400 + + except TimeoutError as e: + return jsonify({ + "success": False, + "error": t('api.interviewTimeout', error=str(e)) + }), 504 + + except Exception as e: + logger.error(f"Interview失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/interview/batch', methods=['POST']) +def interview_agents_batch(): + """ + 批量采访多个Agent + + 注意:此功能需要模拟环境处于运行状态 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "interviews": [ // 必填,采访列表 + { + "agent_id": 0, + "prompt": "你对A有什么看法?", + "platform": "twitter" // 可选,指定该Agent的采访平台 + }, + { + "agent_id": 1, + "prompt": "你对B有什么看法?" // 不指定platform则使用默认值 + } + ], + "platform": "reddit", // 可选,默认平台(被每项的platform覆盖) + // 不指定时:双平台模拟每个Agent同时采访两个平台 + "timeout": 120 // 可选,超时时间(秒),默认120 + } + + 返回: + { + "success": true, + "data": { + "interviews_count": 2, + "result": { + "interviews_count": 4, + "results": { + "twitter_0": {"agent_id": 0, "response": "...", "platform": "twitter"}, + "reddit_0": {"agent_id": 0, "response": "...", "platform": "reddit"}, + "twitter_1": {"agent_id": 1, "response": "...", "platform": "twitter"}, + "reddit_1": {"agent_id": 1, "response": "...", "platform": "reddit"} + } + }, + "timestamp": "2025-12-08T10:00:01" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + interviews = data.get('interviews') + platform = data.get('platform') # 可选:twitter/reddit/None + timeout = data.get('timeout', 120) + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + if not interviews or not isinstance(interviews, list): + return jsonify({ + "success": False, + "error": t('api.requireInterviews') + }), 400 + + # 验证platform参数 + if platform and platform not in ("twitter", "reddit"): + return jsonify({ + "success": False, + "error": t('api.invalidInterviewPlatform') + }), 400 + + # 验证每个采访项 + for i, interview in enumerate(interviews): + if 'agent_id' not in interview: + return jsonify({ + "success": False, + "error": t('api.interviewListMissingAgentId', index=i+1) + }), 400 + if 'prompt' not in interview: + return jsonify({ + "success": False, + "error": t('api.interviewListMissingPrompt', index=i+1) + }), 400 + # 验证每项的platform(如果有) + item_platform = interview.get('platform') + if item_platform and item_platform not in ("twitter", "reddit"): + return jsonify({ + "success": False, + "error": t('api.interviewListInvalidPlatform', index=i+1) + }), 400 + + # 检查环境状态 + if not SimulationRunner.check_env_alive(simulation_id): + return jsonify({ + "success": False, + "error": t('api.envNotRunning') + }), 400 + + # 优化每个采访项的prompt,添加前缀避免Agent调用工具 + optimized_interviews = [] + for interview in interviews: + optimized_interview = interview.copy() + optimized_interview['prompt'] = optimize_interview_prompt(interview.get('prompt', '')) + optimized_interviews.append(optimized_interview) + + result = SimulationRunner.interview_agents_batch( + simulation_id=simulation_id, + interviews=optimized_interviews, + platform=platform, + timeout=timeout + ) + + return jsonify({ + "success": result.get("success", False), + "data": result + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 400 + + except TimeoutError as e: + return jsonify({ + "success": False, + "error": t('api.batchInterviewTimeout', error=str(e)) + }), 504 + + except Exception as e: + logger.error(f"批量Interview失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/interview/all', methods=['POST']) +def interview_all_agents(): + """ + 全局采访 - 使用相同问题采访所有Agent + + 注意:此功能需要模拟环境处于运行状态 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "prompt": "你对这件事整体有什么看法?", // 必填,采访问题(所有Agent使用相同问题) + "platform": "reddit", // 可选,指定平台(twitter/reddit) + // 不指定时:双平台模拟每个Agent同时采访两个平台 + "timeout": 180 // 可选,超时时间(秒),默认180 + } + + 返回: + { + "success": true, + "data": { + "interviews_count": 50, + "result": { + "interviews_count": 100, + "results": { + "twitter_0": {"agent_id": 0, "response": "...", "platform": "twitter"}, + "reddit_0": {"agent_id": 0, "response": "...", "platform": "reddit"}, + ... + } + }, + "timestamp": "2025-12-08T10:00:01" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + prompt = data.get('prompt') + platform = data.get('platform') # 可选:twitter/reddit/None + timeout = data.get('timeout', 180) + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + if not prompt: + return jsonify({ + "success": False, + "error": t('api.requirePrompt') + }), 400 + + # 验证platform参数 + if platform and platform not in ("twitter", "reddit"): + return jsonify({ + "success": False, + "error": t('api.invalidInterviewPlatform') + }), 400 + + # 检查环境状态 + if not SimulationRunner.check_env_alive(simulation_id): + return jsonify({ + "success": False, + "error": t('api.envNotRunning') + }), 400 + + # 优化prompt,添加前缀避免Agent调用工具 + optimized_prompt = optimize_interview_prompt(prompt) + + result = SimulationRunner.interview_all_agents( + simulation_id=simulation_id, + prompt=optimized_prompt, + platform=platform, + timeout=timeout + ) + + return jsonify({ + "success": result.get("success", False), + "data": result + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 400 + + except TimeoutError as e: + return jsonify({ + "success": False, + "error": t('api.globalInterviewTimeout', error=str(e)) + }), 504 + + except Exception as e: + logger.error(f"全局Interview失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/interview/history', methods=['POST']) +def get_interview_history(): + """ + 获取Interview历史记录 + + 从模拟数据库中读取所有Interview记录 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "platform": "reddit", // 可选,平台类型(reddit/twitter) + // 不指定则返回两个平台的所有历史 + "agent_id": 0, // 可选,只获取该Agent的采访历史 + "limit": 100 // 可选,返回数量,默认100 + } + + 返回: + { + "success": true, + "data": { + "count": 10, + "history": [ + { + "agent_id": 0, + "response": "我认为...", + "prompt": "你对这件事有什么看法?", + "timestamp": "2025-12-08T10:00:00", + "platform": "reddit" + }, + ... + ] + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + platform = data.get('platform') # 不指定则返回两个平台的历史 + agent_id = data.get('agent_id') + limit = data.get('limit', 100) + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + history = SimulationRunner.get_interview_history( + simulation_id=simulation_id, + platform=platform, + agent_id=agent_id, + limit=limit + ) + + return jsonify({ + "success": True, + "data": { + "count": len(history), + "history": history + } + }) + + except Exception as e: + logger.error(f"获取Interview历史失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/env-status', methods=['POST']) +def get_env_status(): + """ + 获取模拟环境状态 + + 检查模拟环境是否存活(可以接收Interview命令) + + 请求(JSON): + { + "simulation_id": "sim_xxxx" // 必填,模拟ID + } + + 返回: + { + "success": true, + "data": { + "simulation_id": "sim_xxxx", + "env_alive": true, + "twitter_available": true, + "reddit_available": true, + "message": "环境正在运行,可以接收Interview命令" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + env_alive = SimulationRunner.check_env_alive(simulation_id) + + # 获取更详细的状态信息 + env_status = SimulationRunner.get_env_status_detail(simulation_id) + + if env_alive: + message = t('api.envRunning') + else: + message = t('api.envNotRunningShort') + + return jsonify({ + "success": True, + "data": { + "simulation_id": simulation_id, + "env_alive": env_alive, + "twitter_available": env_status.get("twitter_available", False), + "reddit_available": env_status.get("reddit_available", False), + "message": message + } + }) + + except Exception as e: + logger.error(f"获取环境状态失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 + + +@simulation_bp.route('/close-env', methods=['POST']) +def close_simulation_env(): + """ + 关闭模拟环境 + + 向模拟发送关闭环境命令,使其优雅退出等待命令模式。 + + 注意:这不同于 /stop 接口,/stop 会强制终止进程, + 而此接口会让模拟优雅地关闭环境并退出。 + + 请求(JSON): + { + "simulation_id": "sim_xxxx", // 必填,模拟ID + "timeout": 30 // 可选,超时时间(秒),默认30 + } + + 返回: + { + "success": true, + "data": { + "message": "环境关闭命令已发送", + "result": {...}, + "timestamp": "2025-12-08T10:00:01" + } + } + """ + try: + data = request.get_json() or {} + + simulation_id = data.get('simulation_id') + timeout = data.get('timeout', 30) + + if not simulation_id: + return jsonify({ + "success": False, + "error": t('api.requireSimulationId') + }), 400 + + result = SimulationRunner.close_simulation_env( + simulation_id=simulation_id, + timeout=timeout + ) + + # 更新模拟状态 + manager = SimulationManager() + state = manager.get_simulation(simulation_id) + if state: + state.status = SimulationStatus.COMPLETED + manager._save_simulation_state(state) + + return jsonify({ + "success": result.get("success", False), + "data": result + }) + + except ValueError as e: + return jsonify({ + "success": False, + "error": str(e) + }), 400 + + except Exception as e: + logger.error(f"关闭环境失败: {str(e)}") + return jsonify({ + "success": False, + "error": str(e), + "traceback": traceback.format_exc() + }), 500 diff --git a/backend/app/config.py b/backend/app/config.py new file mode 100644 index 00000000..de63e2b4 --- /dev/null +++ b/backend/app/config.py @@ -0,0 +1,75 @@ +""" +配置管理 +统一从项目根目录的 .env 文件加载配置 +""" + +import os +from dotenv import load_dotenv + +# 加载项目根目录的 .env 文件 +# 路径: MiroFish/.env (相对于 backend/app/config.py) +project_root_env = os.path.join(os.path.dirname(__file__), '../../.env') + +if os.path.exists(project_root_env): + load_dotenv(project_root_env, override=True) +else: + # 如果根目录没有 .env,尝试加载环境变量(用于生产环境) + load_dotenv(override=True) + + +class Config: + """Flask配置类""" + + # Flask配置 + SECRET_KEY = os.environ.get('SECRET_KEY', 'mirofish-secret-key') + DEBUG = os.environ.get('FLASK_DEBUG', 'True').lower() == 'true' + + # JSON配置 - 禁用ASCII转义,让中文直接显示(而不是 \uXXXX 格式) + JSON_AS_ASCII = False + + # LLM配置(统一使用OpenAI格式) + LLM_API_KEY = os.environ.get('LLM_API_KEY') + LLM_BASE_URL = os.environ.get('LLM_BASE_URL', 'https://api.openai.com/v1') + LLM_MODEL_NAME = os.environ.get('LLM_MODEL_NAME', 'gpt-4o-mini') + + # Zep配置 + ZEP_API_KEY = os.environ.get('ZEP_API_KEY') + + # 文件上传配置 + MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50MB + UPLOAD_FOLDER = os.path.join(os.path.dirname(__file__), '../uploads') + ALLOWED_EXTENSIONS = {'pdf', 'md', 'txt', 'markdown'} + + # 文本处理配置 + DEFAULT_CHUNK_SIZE = 500 # 默认切块大小 + DEFAULT_CHUNK_OVERLAP = 50 # 默认重叠大小 + + # OASIS模拟配置 + OASIS_DEFAULT_MAX_ROUNDS = int(os.environ.get('OASIS_DEFAULT_MAX_ROUNDS', '10')) + OASIS_SIMULATION_DATA_DIR = os.path.join(os.path.dirname(__file__), '../uploads/simulations') + + # OASIS平台可用动作配置 + OASIS_TWITTER_ACTIONS = [ + 'CREATE_POST', 'LIKE_POST', 'REPOST', 'FOLLOW', 'DO_NOTHING', 'QUOTE_POST' + ] + OASIS_REDDIT_ACTIONS = [ + 'LIKE_POST', 'DISLIKE_POST', 'CREATE_POST', 'CREATE_COMMENT', + 'LIKE_COMMENT', 'DISLIKE_COMMENT', 'SEARCH_POSTS', 'SEARCH_USER', + 'TREND', 'REFRESH', 'DO_NOTHING', 'FOLLOW', 'MUTE' + ] + + # Report Agent配置 + REPORT_AGENT_MAX_TOOL_CALLS = int(os.environ.get('REPORT_AGENT_MAX_TOOL_CALLS', '5')) + REPORT_AGENT_MAX_REFLECTION_ROUNDS = int(os.environ.get('REPORT_AGENT_MAX_REFLECTION_ROUNDS', '2')) + REPORT_AGENT_TEMPERATURE = float(os.environ.get('REPORT_AGENT_TEMPERATURE', '0.5')) + + @classmethod + def validate(cls) -> list[str]: + """验证必要配置""" + errors: list[str] = [] + if not cls.LLM_API_KEY: + errors.append("LLM_API_KEY 未配置") + if not cls.ZEP_API_KEY: + errors.append("ZEP_API_KEY 未配置") + return errors + diff --git a/backend/app/models/__init__.py b/backend/app/models/__init__.py new file mode 100644 index 00000000..55bec619 --- /dev/null +++ b/backend/app/models/__init__.py @@ -0,0 +1,9 @@ +""" +数据模型模块 +""" + +from .task import TaskManager, TaskStatus +from .project import Project, ProjectStatus, ProjectManager + +__all__ = ['TaskManager', 'TaskStatus', 'Project', 'ProjectStatus', 'ProjectManager'] + diff --git a/backend/app/models/project.py b/backend/app/models/project.py new file mode 100644 index 00000000..08978937 --- /dev/null +++ b/backend/app/models/project.py @@ -0,0 +1,305 @@ +""" +项目上下文管理 +用于在服务端持久化项目状态,避免前端在接口间传递大量数据 +""" + +import os +import json +import uuid +import shutil +from datetime import datetime +from typing import Dict, Any, List, Optional +from enum import Enum +from dataclasses import dataclass, field, asdict +from ..config import Config + + +class ProjectStatus(str, Enum): + """项目状态""" + CREATED = "created" # 刚创建,文件已上传 + ONTOLOGY_GENERATED = "ontology_generated" # 本体已生成 + GRAPH_BUILDING = "graph_building" # 图谱构建中 + GRAPH_COMPLETED = "graph_completed" # 图谱构建完成 + FAILED = "failed" # 失败 + + +@dataclass +class Project: + """项目数据模型""" + project_id: str + name: str + status: ProjectStatus + created_at: str + updated_at: str + + # 文件信息 + files: List[Dict[str, str]] = field(default_factory=list) # [{filename, path, size}] + total_text_length: int = 0 + + # 本体信息(接口1生成后填充) + ontology: Optional[Dict[str, Any]] = None + analysis_summary: Optional[str] = None + + # 图谱信息(接口2完成后填充) + graph_id: Optional[str] = None + graph_build_task_id: Optional[str] = None + + # 配置 + simulation_requirement: Optional[str] = None + chunk_size: int = 500 + chunk_overlap: int = 50 + + # 错误信息 + error: Optional[str] = None + + def to_dict(self) -> Dict[str, Any]: + """转换为字典""" + return { + "project_id": self.project_id, + "name": self.name, + "status": self.status.value if isinstance(self.status, ProjectStatus) else self.status, + "created_at": self.created_at, + "updated_at": self.updated_at, + "files": self.files, + "total_text_length": self.total_text_length, + "ontology": self.ontology, + "analysis_summary": self.analysis_summary, + "graph_id": self.graph_id, + "graph_build_task_id": self.graph_build_task_id, + "simulation_requirement": self.simulation_requirement, + "chunk_size": self.chunk_size, + "chunk_overlap": self.chunk_overlap, + "error": self.error + } + + @classmethod + def from_dict(cls, data: Dict[str, Any]) -> 'Project': + """从字典创建""" + status = data.get('status', 'created') + if isinstance(status, str): + status = ProjectStatus(status) + + return cls( + project_id=data['project_id'], + name=data.get('name', 'Unnamed Project'), + status=status, + created_at=data.get('created_at', ''), + updated_at=data.get('updated_at', ''), + files=data.get('files', []), + total_text_length=data.get('total_text_length', 0), + ontology=data.get('ontology'), + analysis_summary=data.get('analysis_summary'), + graph_id=data.get('graph_id'), + graph_build_task_id=data.get('graph_build_task_id'), + simulation_requirement=data.get('simulation_requirement'), + chunk_size=data.get('chunk_size', 500), + chunk_overlap=data.get('chunk_overlap', 50), + error=data.get('error') + ) + + +class ProjectManager: + """项目管理器 - 负责项目的持久化存储和检索""" + + # 项目存储根目录 + PROJECTS_DIR = os.path.join(Config.UPLOAD_FOLDER, 'projects') + + @classmethod + def _ensure_projects_dir(cls): + """确保项目目录存在""" + os.makedirs(cls.PROJECTS_DIR, exist_ok=True) + + @classmethod + def _get_project_dir(cls, project_id: str) -> str: + """获取项目目录路径""" + return os.path.join(cls.PROJECTS_DIR, project_id) + + @classmethod + def _get_project_meta_path(cls, project_id: str) -> str: + """获取项目元数据文件路径""" + return os.path.join(cls._get_project_dir(project_id), 'project.json') + + @classmethod + def _get_project_files_dir(cls, project_id: str) -> str: + """获取项目文件存储目录""" + return os.path.join(cls._get_project_dir(project_id), 'files') + + @classmethod + def _get_project_text_path(cls, project_id: str) -> str: + """获取项目提取文本存储路径""" + return os.path.join(cls._get_project_dir(project_id), 'extracted_text.txt') + + @classmethod + def create_project(cls, name: str = "Unnamed Project") -> Project: + """ + 创建新项目 + + Args: + name: 项目名称 + + Returns: + 新创建的Project对象 + """ + cls._ensure_projects_dir() + + project_id = f"proj_{uuid.uuid4().hex[:12]}" + now = datetime.now().isoformat() + + project = Project( + project_id=project_id, + name=name, + status=ProjectStatus.CREATED, + created_at=now, + updated_at=now + ) + + # 创建项目目录结构 + project_dir = cls._get_project_dir(project_id) + files_dir = cls._get_project_files_dir(project_id) + os.makedirs(project_dir, exist_ok=True) + os.makedirs(files_dir, exist_ok=True) + + # 保存项目元数据 + cls.save_project(project) + + return project + + @classmethod + def save_project(cls, project: Project) -> None: + """保存项目元数据""" + project.updated_at = datetime.now().isoformat() + meta_path = cls._get_project_meta_path(project.project_id) + + with open(meta_path, 'w', encoding='utf-8') as f: + json.dump(project.to_dict(), f, ensure_ascii=False, indent=2) + + @classmethod + def get_project(cls, project_id: str) -> Optional[Project]: + """ + 获取项目 + + Args: + project_id: 项目ID + + Returns: + Project对象,如果不存在返回None + """ + meta_path = cls._get_project_meta_path(project_id) + + if not os.path.exists(meta_path): + return None + + with open(meta_path, 'r', encoding='utf-8') as f: + data = json.load(f) + + return Project.from_dict(data) + + @classmethod + def list_projects(cls, limit: int = 50) -> List[Project]: + """ + 列出所有项目 + + Args: + limit: 返回数量限制 + + Returns: + 项目列表,按创建时间倒序 + """ + cls._ensure_projects_dir() + + projects = [] + for project_id in os.listdir(cls.PROJECTS_DIR): + project = cls.get_project(project_id) + if project: + projects.append(project) + + # 按创建时间倒序排序 + projects.sort(key=lambda p: p.created_at, reverse=True) + + return projects[:limit] + + @classmethod + def delete_project(cls, project_id: str) -> bool: + """ + 删除项目及其所有文件 + + Args: + project_id: 项目ID + + Returns: + 是否删除成功 + """ + project_dir = cls._get_project_dir(project_id) + + if not os.path.exists(project_dir): + return False + + shutil.rmtree(project_dir) + return True + + @classmethod + def save_file_to_project(cls, project_id: str, file_storage, original_filename: str) -> Dict[str, str]: + """ + 保存上传的文件到项目目录 + + Args: + project_id: 项目ID + file_storage: Flask的FileStorage对象 + original_filename: 原始文件名 + + Returns: + 文件信息字典 {filename, path, size} + """ + files_dir = cls._get_project_files_dir(project_id) + os.makedirs(files_dir, exist_ok=True) + + # 生成安全的文件名 + ext = os.path.splitext(original_filename)[1].lower() + safe_filename = f"{uuid.uuid4().hex[:8]}{ext}" + file_path = os.path.join(files_dir, safe_filename) + + # 保存文件 + file_storage.save(file_path) + + # 获取文件大小 + file_size = os.path.getsize(file_path) + + return { + "original_filename": original_filename, + "saved_filename": safe_filename, + "path": file_path, + "size": file_size + } + + @classmethod + def save_extracted_text(cls, project_id: str, text: str) -> None: + """保存提取的文本""" + text_path = cls._get_project_text_path(project_id) + with open(text_path, 'w', encoding='utf-8') as f: + f.write(text) + + @classmethod + def get_extracted_text(cls, project_id: str) -> Optional[str]: + """获取提取的文本""" + text_path = cls._get_project_text_path(project_id) + + if not os.path.exists(text_path): + return None + + with open(text_path, 'r', encoding='utf-8') as f: + return f.read() + + @classmethod + def get_project_files(cls, project_id: str) -> List[str]: + """获取项目的所有文件路径""" + files_dir = cls._get_project_files_dir(project_id) + + if not os.path.exists(files_dir): + return [] + + return [ + os.path.join(files_dir, f) + for f in os.listdir(files_dir) + if os.path.isfile(os.path.join(files_dir, f)) + ] + diff --git a/backend/app/models/task.py b/backend/app/models/task.py new file mode 100644 index 00000000..dfebed23 --- /dev/null +++ b/backend/app/models/task.py @@ -0,0 +1,186 @@ +""" +任务状态管理 +用于跟踪长时间运行的任务(如图谱构建) +""" + +import uuid +import threading +from datetime import datetime +from enum import Enum +from typing import Dict, Any, Optional +from dataclasses import dataclass, field + +from ..utils.locale import t + + +class TaskStatus(str, Enum): + """任务状态枚举""" + PENDING = "pending" # 等待中 + PROCESSING = "processing" # 处理中 + COMPLETED = "completed" # 已完成 + FAILED = "failed" # 失败 + + +@dataclass +class Task: + """任务数据类""" + task_id: str + task_type: str + status: TaskStatus + created_at: datetime + updated_at: datetime + progress: int = 0 # 总进度百分比 0-100 + message: str = "" # 状态消息 + result: Optional[Dict] = None # 任务结果 + error: Optional[str] = None # 错误信息 + metadata: Dict = field(default_factory=dict) # 额外元数据 + progress_detail: Dict = field(default_factory=dict) # 详细进度信息 + + def to_dict(self) -> Dict[str, Any]: + """转换为字典""" + return { + "task_id": self.task_id, + "task_type": self.task_type, + "status": self.status.value, + "created_at": self.created_at.isoformat(), + "updated_at": self.updated_at.isoformat(), + "progress": self.progress, + "message": self.message, + "progress_detail": self.progress_detail, + "result": self.result, + "error": self.error, + "metadata": self.metadata, + } + + +class TaskManager: + """ + 任务管理器 + 线程安全的任务状态管理 + """ + + _instance = None + _lock = threading.Lock() + + def __new__(cls): + """单例模式""" + if cls._instance is None: + with cls._lock: + if cls._instance is None: + cls._instance = super().__new__(cls) + cls._instance._tasks: Dict[str, Task] = {} + cls._instance._task_lock = threading.Lock() + return cls._instance + + def create_task(self, task_type: str, metadata: Optional[Dict] = None) -> str: + """ + 创建新任务 + + Args: + task_type: 任务类型 + metadata: 额外元数据 + + Returns: + 任务ID + """ + task_id = str(uuid.uuid4()) + now = datetime.now() + + task = Task( + task_id=task_id, + task_type=task_type, + status=TaskStatus.PENDING, + created_at=now, + updated_at=now, + metadata=metadata or {} + ) + + with self._task_lock: + self._tasks[task_id] = task + + return task_id + + def get_task(self, task_id: str) -> Optional[Task]: + """获取任务""" + with self._task_lock: + return self._tasks.get(task_id) + + def update_task( + self, + task_id: str, + status: Optional[TaskStatus] = None, + progress: Optional[int] = None, + message: Optional[str] = None, + result: Optional[Dict] = None, + error: Optional[str] = None, + progress_detail: Optional[Dict] = None + ): + """ + 更新任务状态 + + Args: + task_id: 任务ID + status: 新状态 + progress: 进度 + message: 消息 + result: 结果 + error: 错误信息 + progress_detail: 详细进度信息 + """ + with self._task_lock: + task = self._tasks.get(task_id) + if task: + task.updated_at = datetime.now() + if status is not None: + task.status = status + if progress is not None: + task.progress = progress + if message is not None: + task.message = message + if result is not None: + task.result = result + if error is not None: + task.error = error + if progress_detail is not None: + task.progress_detail = progress_detail + + def complete_task(self, task_id: str, result: Dict): + """标记任务完成""" + self.update_task( + task_id, + status=TaskStatus.COMPLETED, + progress=100, + message=t('progress.taskComplete'), + result=result + ) + + def fail_task(self, task_id: str, error: str): + """标记任务失败""" + self.update_task( + task_id, + status=TaskStatus.FAILED, + message=t('progress.taskFailed'), + error=error + ) + + def list_tasks(self, task_type: Optional[str] = None) -> list: + """列出任务""" + with self._task_lock: + tasks = list(self._tasks.values()) + if task_type: + tasks = [t for t in tasks if t.task_type == task_type] + return [t.to_dict() for t in sorted(tasks, key=lambda x: x.created_at, reverse=True)] + + def cleanup_old_tasks(self, max_age_hours: int = 24): + """清理旧任务""" + from datetime import timedelta + cutoff = datetime.now() - timedelta(hours=max_age_hours) + + with self._task_lock: + old_ids = [ + tid for tid, task in self._tasks.items() + if task.created_at < cutoff and task.status in [TaskStatus.COMPLETED, TaskStatus.FAILED] + ] + for tid in old_ids: + del self._tasks[tid] + diff --git a/backend/app/services/__init__.py b/backend/app/services/__init__.py new file mode 100644 index 00000000..8db85d86 --- /dev/null +++ b/backend/app/services/__init__.py @@ -0,0 +1,73 @@ +""" +业务服务模块 +""" + +from .ontology_generator import OntologyGenerator +from .graph_builder import GraphBuilderService +from .text_processor import TextProcessor +from .zep_entity_reader import ZepEntityReader, EntityNode, FilteredEntities +from .oasis_profile_generator import OasisProfileGenerator, OasisAgentProfile +from .simulation_manager import SimulationManager, SimulationState, SimulationStatus +from .simulation_config_generator import ( + SimulationConfigGenerator, + SimulationParameters, + AgentActivityConfig, + TimeSimulationConfig, + EventConfig, + PlatformConfig +) +from .simulation_runner import ( + SimulationRunner, + SimulationRunState, + RunnerStatus, + AgentAction, + RoundSummary +) +from .zep_graph_memory_updater import ( + ZepGraphMemoryUpdater, + ZepGraphMemoryManager, + AgentActivity +) +from .simulation_ipc import ( + SimulationIPCClient, + SimulationIPCServer, + IPCCommand, + IPCResponse, + CommandType, + CommandStatus +) + +__all__ = [ + 'OntologyGenerator', + 'GraphBuilderService', + 'TextProcessor', + 'ZepEntityReader', + 'EntityNode', + 'FilteredEntities', + 'OasisProfileGenerator', + 'OasisAgentProfile', + 'SimulationManager', + 'SimulationState', + 'SimulationStatus', + 'SimulationConfigGenerator', + 'SimulationParameters', + 'AgentActivityConfig', + 'TimeSimulationConfig', + 'EventConfig', + 'PlatformConfig', + 'SimulationRunner', + 'SimulationRunState', + 'RunnerStatus', + 'AgentAction', + 'RoundSummary', + 'ZepGraphMemoryUpdater', + 'ZepGraphMemoryManager', + 'AgentActivity', + 'SimulationIPCClient', + 'SimulationIPCServer', + 'IPCCommand', + 'IPCResponse', + 'CommandType', + 'CommandStatus', +] + diff --git a/backend/app/services/graph_builder.py b/backend/app/services/graph_builder.py new file mode 100644 index 00000000..37c9969c --- /dev/null +++ b/backend/app/services/graph_builder.py @@ -0,0 +1,506 @@ +""" +图谱构建服务 +接口2:使用Zep API构建Standalone Graph +""" + +import os +import uuid +import time +import threading +from typing import Dict, Any, List, Optional, Callable +from dataclasses import dataclass + +from zep_cloud.client import Zep +from zep_cloud import EpisodeData, EntityEdgeSourceTarget + +from ..config import Config +from ..models.task import TaskManager, TaskStatus +from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges +from .text_processor import TextProcessor +from ..utils.locale import t, get_locale, set_locale + + +@dataclass +class GraphInfo: + """图谱信息""" + graph_id: str + node_count: int + edge_count: int + entity_types: List[str] + + def to_dict(self) -> Dict[str, Any]: + return { + "graph_id": self.graph_id, + "node_count": self.node_count, + "edge_count": self.edge_count, + "entity_types": self.entity_types, + } + + +class GraphBuilderService: + """ + 图谱构建服务 + 负责调用Zep API构建知识图谱 + """ + + def __init__(self, api_key: Optional[str] = None): + self.api_key = api_key or Config.ZEP_API_KEY + if not self.api_key: + raise ValueError("ZEP_API_KEY 未配置") + + self.client = Zep(api_key=self.api_key) + self.task_manager = TaskManager() + + def build_graph_async( + self, + text: str, + ontology: Dict[str, Any], + graph_name: str = "MiroFish Graph", + chunk_size: int = 500, + chunk_overlap: int = 50, + batch_size: int = 3 + ) -> str: + """ + 异步构建图谱 + + Args: + text: 输入文本 + ontology: 本体定义(来自接口1的输出) + graph_name: 图谱名称 + chunk_size: 文本块大小 + chunk_overlap: 块重叠大小 + batch_size: 每批发送的块数量 + + Returns: + 任务ID + """ + # 创建任务 + task_id = self.task_manager.create_task( + task_type="graph_build", + metadata={ + "graph_name": graph_name, + "chunk_size": chunk_size, + "text_length": len(text), + } + ) + + # Capture locale before spawning background thread + current_locale = get_locale() + + # 在后台线程中执行构建 + thread = threading.Thread( + target=self._build_graph_worker, + args=(task_id, text, ontology, graph_name, chunk_size, chunk_overlap, batch_size, current_locale) + ) + thread.daemon = True + thread.start() + + return task_id + + def _build_graph_worker( + self, + task_id: str, + text: str, + ontology: Dict[str, Any], + graph_name: str, + chunk_size: int, + chunk_overlap: int, + batch_size: int, + locale: str = 'zh' + ): + """图谱构建工作线程""" + set_locale(locale) + try: + self.task_manager.update_task( + task_id, + status=TaskStatus.PROCESSING, + progress=5, + message=t('progress.startBuildingGraph') + ) + + # 1. 创建图谱 + graph_id = self.create_graph(graph_name) + self.task_manager.update_task( + task_id, + progress=10, + message=t('progress.graphCreated', graphId=graph_id) + ) + + # 2. 设置本体 + self.set_ontology(graph_id, ontology) + self.task_manager.update_task( + task_id, + progress=15, + message=t('progress.ontologySet') + ) + + # 3. 文本分块 + chunks = TextProcessor.split_text(text, chunk_size, chunk_overlap) + total_chunks = len(chunks) + self.task_manager.update_task( + task_id, + progress=20, + message=t('progress.textSplit', count=total_chunks) + ) + + # 4. 分批发送数据 + episode_uuids = self.add_text_batches( + graph_id, chunks, batch_size, + lambda msg, prog: self.task_manager.update_task( + task_id, + progress=20 + int(prog * 0.4), # 20-60% + message=msg + ) + ) + + # 5. 等待Zep处理完成 + self.task_manager.update_task( + task_id, + progress=60, + message=t('progress.waitingZepProcess') + ) + + self._wait_for_episodes( + episode_uuids, + lambda msg, prog: self.task_manager.update_task( + task_id, + progress=60 + int(prog * 0.3), # 60-90% + message=msg + ) + ) + + # 6. 获取图谱信息 + self.task_manager.update_task( + task_id, + progress=90, + message=t('progress.fetchingGraphInfo') + ) + + graph_info = self._get_graph_info(graph_id) + + # 完成 + self.task_manager.complete_task(task_id, { + "graph_id": graph_id, + "graph_info": graph_info.to_dict(), + "chunks_processed": total_chunks, + }) + + except Exception as e: + import traceback + error_msg = f"{str(e)}\n{traceback.format_exc()}" + self.task_manager.fail_task(task_id, error_msg) + + def create_graph(self, name: str) -> str: + """创建Zep图谱(公开方法)""" + graph_id = f"mirofish_{uuid.uuid4().hex[:16]}" + + self.client.graph.create( + graph_id=graph_id, + name=name, + description="MiroFish Social Simulation Graph" + ) + + return graph_id + + def set_ontology(self, graph_id: str, ontology: Dict[str, Any]): + """设置图谱本体(公开方法)""" + import warnings + from typing import Optional + from pydantic import Field + from zep_cloud.external_clients.ontology import EntityModel, EntityText, EdgeModel + + # 抑制 Pydantic v2 关于 Field(default=None) 的警告 + # 这是 Zep SDK 要求的用法,警告来自动态类创建,可以安全忽略 + warnings.filterwarnings('ignore', category=UserWarning, module='pydantic') + + # Zep 保留名称,不能作为属性名 + RESERVED_NAMES = {'uuid', 'name', 'group_id', 'name_embedding', 'summary', 'created_at'} + + def safe_attr_name(attr_name: str) -> str: + """将保留名称转换为安全名称""" + if attr_name.lower() in RESERVED_NAMES: + return f"entity_{attr_name}" + return attr_name + + # 动态创建实体类型 + entity_types = {} + for entity_def in ontology.get("entity_types", []): + name = entity_def["name"] + description = entity_def.get("description", f"A {name} entity.") + + # 创建属性字典和类型注解(Pydantic v2 需要) + attrs = {"__doc__": description} + annotations = {} + + for attr_def in entity_def.get("attributes", []): + attr_name = safe_attr_name(attr_def["name"]) # 使用安全名称 + attr_desc = attr_def.get("description", attr_name) + # Zep API 需要 Field 的 description,这是必需的 + attrs[attr_name] = Field(description=attr_desc, default=None) + annotations[attr_name] = Optional[EntityText] # 类型注解 + + attrs["__annotations__"] = annotations + + # 动态创建类 + entity_class = type(name, (EntityModel,), attrs) + entity_class.__doc__ = description + entity_types[name] = entity_class + + # 动态创建边类型 + edge_definitions = {} + for edge_def in ontology.get("edge_types", []): + name = edge_def["name"] + description = edge_def.get("description", f"A {name} relationship.") + + # 创建属性字典和类型注解 + attrs = {"__doc__": description} + annotations = {} + + for attr_def in edge_def.get("attributes", []): + attr_name = safe_attr_name(attr_def["name"]) # 使用安全名称 + attr_desc = attr_def.get("description", attr_name) + # Zep API 需要 Field 的 description,这是必需的 + attrs[attr_name] = Field(description=attr_desc, default=None) + annotations[attr_name] = Optional[str] # 边属性用str类型 + + attrs["__annotations__"] = annotations + + # 动态创建类 + class_name = ''.join(word.capitalize() for word in name.split('_')) + edge_class = type(class_name, (EdgeModel,), attrs) + edge_class.__doc__ = description + + # 构建source_targets + source_targets = [] + for st in edge_def.get("source_targets", []): + source_targets.append( + EntityEdgeSourceTarget( + source=st.get("source", "Entity"), + target=st.get("target", "Entity") + ) + ) + + if source_targets: + edge_definitions[name] = (edge_class, source_targets) + + # 调用Zep API设置本体 + if entity_types or edge_definitions: + self.client.graph.set_ontology( + graph_ids=[graph_id], + entities=entity_types if entity_types else None, + edges=edge_definitions if edge_definitions else None, + ) + + def add_text_batches( + self, + graph_id: str, + chunks: List[str], + batch_size: int = 3, + progress_callback: Optional[Callable] = None + ) -> List[str]: + """分批添加文本到图谱,返回所有 episode 的 uuid 列表""" + episode_uuids = [] + total_chunks = len(chunks) + + for i in range(0, total_chunks, batch_size): + batch_chunks = chunks[i:i + batch_size] + batch_num = i // batch_size + 1 + total_batches = (total_chunks + batch_size - 1) // batch_size + + if progress_callback: + progress = (i + len(batch_chunks)) / total_chunks + progress_callback( + t('progress.sendingBatch', current=batch_num, total=total_batches, chunks=len(batch_chunks)), + progress + ) + + # 构建episode数据 + episodes = [ + EpisodeData(data=chunk, type="text") + for chunk in batch_chunks + ] + + # 发送到Zep + try: + batch_result = self.client.graph.add_batch( + graph_id=graph_id, + episodes=episodes + ) + + # 收集返回的 episode uuid + if batch_result and isinstance(batch_result, list): + for ep in batch_result: + ep_uuid = getattr(ep, 'uuid_', None) or getattr(ep, 'uuid', None) + if ep_uuid: + episode_uuids.append(ep_uuid) + + # 避免请求过快 + time.sleep(1) + + except Exception as e: + if progress_callback: + progress_callback(t('progress.batchFailed', batch=batch_num, error=str(e)), 0) + raise + + return episode_uuids + + def _wait_for_episodes( + self, + episode_uuids: List[str], + progress_callback: Optional[Callable] = None, + timeout: int = 600 + ): + """等待所有 episode 处理完成(通过查询每个 episode 的 processed 状态)""" + if not episode_uuids: + if progress_callback: + progress_callback(t('progress.noEpisodesWait'), 1.0) + return + + start_time = time.time() + pending_episodes = set(episode_uuids) + completed_count = 0 + total_episodes = len(episode_uuids) + + if progress_callback: + progress_callback(t('progress.waitingEpisodes', count=total_episodes), 0) + + while pending_episodes: + if time.time() - start_time > timeout: + if progress_callback: + progress_callback( + t('progress.episodesTimeout', completed=completed_count, total=total_episodes), + completed_count / total_episodes + ) + break + + # 检查每个 episode 的处理状态 + for ep_uuid in list(pending_episodes): + try: + episode = self.client.graph.episode.get(uuid_=ep_uuid) + is_processed = getattr(episode, 'processed', False) + + if is_processed: + pending_episodes.remove(ep_uuid) + completed_count += 1 + + except Exception as e: + # 忽略单个查询错误,继续 + pass + + elapsed = int(time.time() - start_time) + if progress_callback: + progress_callback( + t('progress.zepProcessing', completed=completed_count, total=total_episodes, pending=len(pending_episodes), elapsed=elapsed), + completed_count / total_episodes if total_episodes > 0 else 0 + ) + + if pending_episodes: + time.sleep(3) # 每3秒检查一次 + + if progress_callback: + progress_callback(t('progress.processingComplete', completed=completed_count, total=total_episodes), 1.0) + + def _get_graph_info(self, graph_id: str) -> GraphInfo: + """获取图谱信息""" + # 获取节点(分页) + nodes = fetch_all_nodes(self.client, graph_id) + + # 获取边(分页) + edges = fetch_all_edges(self.client, graph_id) + + # 统计实体类型 + entity_types = set() + for node in nodes: + if node.labels: + for label in node.labels: + if label not in ["Entity", "Node"]: + entity_types.add(label) + + return GraphInfo( + graph_id=graph_id, + node_count=len(nodes), + edge_count=len(edges), + entity_types=list(entity_types) + ) + + def get_graph_data(self, graph_id: str) -> Dict[str, Any]: + """ + 获取完整图谱数据(包含详细信息) + + Args: + graph_id: 图谱ID + + Returns: + 包含nodes和edges的字典,包括时间信息、属性等详细数据 + """ + nodes = fetch_all_nodes(self.client, graph_id) + edges = fetch_all_edges(self.client, graph_id) + + # 创建节点映射用于获取节点名称 + node_map = {} + for node in nodes: + node_map[node.uuid_] = node.name or "" + + nodes_data = [] + for node in nodes: + # 获取创建时间 + created_at = getattr(node, 'created_at', None) + if created_at: + created_at = str(created_at) + + nodes_data.append({ + "uuid": node.uuid_, + "name": node.name, + "labels": node.labels or [], + "summary": node.summary or "", + "attributes": node.attributes or {}, + "created_at": created_at, + }) + + edges_data = [] + for edge in edges: + # 获取时间信息 + created_at = getattr(edge, 'created_at', None) + valid_at = getattr(edge, 'valid_at', None) + invalid_at = getattr(edge, 'invalid_at', None) + expired_at = getattr(edge, 'expired_at', None) + + # 获取 episodes + episodes = getattr(edge, 'episodes', None) or getattr(edge, 'episode_ids', None) + if episodes and not isinstance(episodes, list): + episodes = [str(episodes)] + elif episodes: + episodes = [str(e) for e in episodes] + + # 获取 fact_type + fact_type = getattr(edge, 'fact_type', None) or edge.name or "" + + edges_data.append({ + "uuid": edge.uuid_, + "name": edge.name or "", + "fact": edge.fact or "", + "fact_type": fact_type, + "source_node_uuid": edge.source_node_uuid, + "target_node_uuid": edge.target_node_uuid, + "source_node_name": node_map.get(edge.source_node_uuid, ""), + "target_node_name": node_map.get(edge.target_node_uuid, ""), + "attributes": edge.attributes or {}, + "created_at": str(created_at) if created_at else None, + "valid_at": str(valid_at) if valid_at else None, + "invalid_at": str(invalid_at) if invalid_at else None, + "expired_at": str(expired_at) if expired_at else None, + "episodes": episodes or [], + }) + + return { + "graph_id": graph_id, + "nodes": nodes_data, + "edges": edges_data, + "node_count": len(nodes_data), + "edge_count": len(edges_data), + } + + def delete_graph(self, graph_id: str): + """删除图谱""" + self.client.graph.delete(graph_id=graph_id) + diff --git a/backend/app/services/oasis_profile_generator.py b/backend/app/services/oasis_profile_generator.py new file mode 100644 index 00000000..7704a627 --- /dev/null +++ b/backend/app/services/oasis_profile_generator.py @@ -0,0 +1,1205 @@ +""" +OASIS Agent Profile生成器 +将Zep图谱中的实体转换为OASIS模拟平台所需的Agent Profile格式 + +优化改进: +1. 调用Zep检索功能二次丰富节点信息 +2. 优化提示词生成非常详细的人设 +3. 区分个人实体和抽象群体实体 +""" + +import json +import random +import time +from typing import Dict, Any, List, Optional +from dataclasses import dataclass, field +from datetime import datetime + +from openai import OpenAI +from zep_cloud.client import Zep + +from ..config import Config +from ..utils.logger import get_logger +from ..utils.locale import get_language_instruction, get_locale, set_locale, t +from .zep_entity_reader import EntityNode, ZepEntityReader + +logger = get_logger('mirofish.oasis_profile') + + +@dataclass +class OasisAgentProfile: + """OASIS Agent Profile数据结构""" + # 通用字段 + user_id: int + user_name: str + name: str + bio: str + persona: str + + # 可选字段 - Reddit风格 + karma: int = 1000 + + # 可选字段 - Twitter风格 + friend_count: int = 100 + follower_count: int = 150 + statuses_count: int = 500 + + # 额外人设信息 + age: Optional[int] = None + gender: Optional[str] = None + mbti: Optional[str] = None + country: Optional[str] = None + profession: Optional[str] = None + interested_topics: List[str] = field(default_factory=list) + + # 来源实体信息 + source_entity_uuid: Optional[str] = None + source_entity_type: Optional[str] = None + + created_at: str = field(default_factory=lambda: datetime.now().strftime("%Y-%m-%d")) + + def to_reddit_format(self) -> Dict[str, Any]: + """转换为Reddit平台格式""" + profile = { + "user_id": self.user_id, + "username": self.user_name, # OASIS 库要求字段名为 username(无下划线) + "name": self.name, + "bio": self.bio, + "persona": self.persona, + "karma": self.karma, + "created_at": self.created_at, + } + + # 添加额外人设信息(如果有) + if self.age: + profile["age"] = self.age + if self.gender: + profile["gender"] = self.gender + if self.mbti: + profile["mbti"] = self.mbti + if self.country: + profile["country"] = self.country + if self.profession: + profile["profession"] = self.profession + if self.interested_topics: + profile["interested_topics"] = self.interested_topics + + return profile + + def to_twitter_format(self) -> Dict[str, Any]: + """转换为Twitter平台格式""" + profile = { + "user_id": self.user_id, + "username": self.user_name, # OASIS 库要求字段名为 username(无下划线) + "name": self.name, + "bio": self.bio, + "persona": self.persona, + "friend_count": self.friend_count, + "follower_count": self.follower_count, + "statuses_count": self.statuses_count, + "created_at": self.created_at, + } + + # 添加额外人设信息 + if self.age: + profile["age"] = self.age + if self.gender: + profile["gender"] = self.gender + if self.mbti: + profile["mbti"] = self.mbti + if self.country: + profile["country"] = self.country + if self.profession: + profile["profession"] = self.profession + if self.interested_topics: + profile["interested_topics"] = self.interested_topics + + return profile + + def to_dict(self) -> Dict[str, Any]: + """转换为完整字典格式""" + return { + "user_id": self.user_id, + "user_name": self.user_name, + "name": self.name, + "bio": self.bio, + "persona": self.persona, + "karma": self.karma, + "friend_count": self.friend_count, + "follower_count": self.follower_count, + "statuses_count": self.statuses_count, + "age": self.age, + "gender": self.gender, + "mbti": self.mbti, + "country": self.country, + "profession": self.profession, + "interested_topics": self.interested_topics, + "source_entity_uuid": self.source_entity_uuid, + "source_entity_type": self.source_entity_type, + "created_at": self.created_at, + } + + +class OasisProfileGenerator: + """ + OASIS Profile生成器 + + 将Zep图谱中的实体转换为OASIS模拟所需的Agent Profile + + 优化特性: + 1. 调用Zep图谱检索功能获取更丰富的上下文 + 2. 生成非常详细的人设(包括基本信息、职业经历、性格特征、社交媒体行为等) + 3. 区分个人实体和抽象群体实体 + """ + + # MBTI类型列表 + MBTI_TYPES = [ + "INTJ", "INTP", "ENTJ", "ENTP", + "INFJ", "INFP", "ENFJ", "ENFP", + "ISTJ", "ISFJ", "ESTJ", "ESFJ", + "ISTP", "ISFP", "ESTP", "ESFP" + ] + + # 常见国家列表 + COUNTRIES = [ + "China", "US", "UK", "Japan", "Germany", "France", + "Canada", "Australia", "Brazil", "India", "South Korea" + ] + + # 个人类型实体(需要生成具体人设) + INDIVIDUAL_ENTITY_TYPES = [ + "student", "alumni", "professor", "person", "publicfigure", + "expert", "faculty", "official", "journalist", "activist" + ] + + # 群体/机构类型实体(需要生成群体代表人设) + GROUP_ENTITY_TYPES = [ + "university", "governmentagency", "organization", "ngo", + "mediaoutlet", "company", "institution", "group", "community" + ] + + def __init__( + self, + api_key: Optional[str] = None, + base_url: Optional[str] = None, + model_name: Optional[str] = None, + zep_api_key: Optional[str] = None, + graph_id: Optional[str] = None + ): + self.api_key = api_key or Config.LLM_API_KEY + self.base_url = base_url or Config.LLM_BASE_URL + self.model_name = model_name or Config.LLM_MODEL_NAME + + if not self.api_key: + raise ValueError("LLM_API_KEY 未配置") + + self.client = OpenAI( + api_key=self.api_key, + base_url=self.base_url + ) + + # Zep客户端用于检索丰富上下文 + self.zep_api_key = zep_api_key or Config.ZEP_API_KEY + self.zep_client = None + self.graph_id = graph_id + + if self.zep_api_key: + try: + self.zep_client = Zep(api_key=self.zep_api_key) + except Exception as e: + logger.warning(f"Zep客户端初始化失败: {e}") + + def generate_profile_from_entity( + self, + entity: EntityNode, + user_id: int, + use_llm: bool = True + ) -> OasisAgentProfile: + """ + 从Zep实体生成OASIS Agent Profile + + Args: + entity: Zep实体节点 + user_id: 用户ID(用于OASIS) + use_llm: 是否使用LLM生成详细人设 + + Returns: + OasisAgentProfile + """ + entity_type = entity.get_entity_type() or "Entity" + + # 基础信息 + name = entity.name + user_name = self._generate_username(name) + + # 构建上下文信息 + context = self._build_entity_context(entity) + + if use_llm: + # 使用LLM生成详细人设 + profile_data = self._generate_profile_with_llm( + entity_name=name, + entity_type=entity_type, + entity_summary=entity.summary, + entity_attributes=entity.attributes, + context=context + ) + else: + # 使用规则生成基础人设 + profile_data = self._generate_profile_rule_based( + entity_name=name, + entity_type=entity_type, + entity_summary=entity.summary, + entity_attributes=entity.attributes + ) + + return OasisAgentProfile( + user_id=user_id, + user_name=user_name, + name=name, + bio=profile_data.get("bio", f"{entity_type}: {name}"), + persona=profile_data.get("persona", entity.summary or f"A {entity_type} named {name}."), + karma=profile_data.get("karma", random.randint(500, 5000)), + friend_count=profile_data.get("friend_count", random.randint(50, 500)), + follower_count=profile_data.get("follower_count", random.randint(100, 1000)), + statuses_count=profile_data.get("statuses_count", random.randint(100, 2000)), + age=profile_data.get("age"), + gender=profile_data.get("gender"), + mbti=profile_data.get("mbti"), + country=profile_data.get("country"), + profession=profile_data.get("profession"), + interested_topics=profile_data.get("interested_topics", []), + source_entity_uuid=entity.uuid, + source_entity_type=entity_type, + ) + + def _generate_username(self, name: str) -> str: + """生成用户名""" + # 移除特殊字符,转换为小写 + username = name.lower().replace(" ", "_") + username = ''.join(c for c in username if c.isalnum() or c == '_') + + # 添加随机后缀避免重复 + suffix = random.randint(100, 999) + return f"{username}_{suffix}" + + def _search_zep_for_entity(self, entity: EntityNode) -> Dict[str, Any]: + """ + 使用Zep图谱混合搜索功能获取实体相关的丰富信息 + + Zep没有内置混合搜索接口,需要分别搜索edges和nodes然后合并结果。 + 使用并行请求同时搜索,提高效率。 + + Args: + entity: 实体节点对象 + + Returns: + 包含facts, node_summaries, context的字典 + """ + import concurrent.futures + + if not self.zep_client: + return {"facts": [], "node_summaries": [], "context": ""} + + entity_name = entity.name + + results = { + "facts": [], + "node_summaries": [], + "context": "" + } + + # 必须有graph_id才能进行搜索 + if not self.graph_id: + logger.debug(f"跳过Zep检索:未设置graph_id") + return results + + comprehensive_query = t('progress.zepSearchQuery', name=entity_name) + + def search_edges(): + """搜索边(事实/关系)- 带重试机制""" + max_retries = 3 + last_exception = None + delay = 2.0 + + for attempt in range(max_retries): + try: + return self.zep_client.graph.search( + query=comprehensive_query, + graph_id=self.graph_id, + limit=30, + scope="edges", + reranker="rrf" + ) + except Exception as e: + last_exception = e + if attempt < max_retries - 1: + logger.debug(f"Zep边搜索第 {attempt + 1} 次失败: {str(e)[:80]}, 重试中...") + time.sleep(delay) + delay *= 2 + else: + logger.debug(f"Zep边搜索在 {max_retries} 次尝试后仍失败: {e}") + return None + + def search_nodes(): + """搜索节点(实体摘要)- 带重试机制""" + max_retries = 3 + last_exception = None + delay = 2.0 + + for attempt in range(max_retries): + try: + return self.zep_client.graph.search( + query=comprehensive_query, + graph_id=self.graph_id, + limit=20, + scope="nodes", + reranker="rrf" + ) + except Exception as e: + last_exception = e + if attempt < max_retries - 1: + logger.debug(f"Zep节点搜索第 {attempt + 1} 次失败: {str(e)[:80]}, 重试中...") + time.sleep(delay) + delay *= 2 + else: + logger.debug(f"Zep节点搜索在 {max_retries} 次尝试后仍失败: {e}") + return None + + try: + # 并行执行edges和nodes搜索 + with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: + edge_future = executor.submit(search_edges) + node_future = executor.submit(search_nodes) + + # 获取结果 + edge_result = edge_future.result(timeout=30) + node_result = node_future.result(timeout=30) + + # 处理边搜索结果 + all_facts = set() + if edge_result and hasattr(edge_result, 'edges') and edge_result.edges: + for edge in edge_result.edges: + if hasattr(edge, 'fact') and edge.fact: + all_facts.add(edge.fact) + results["facts"] = list(all_facts) + + # 处理节点搜索结果 + all_summaries = set() + if node_result and hasattr(node_result, 'nodes') and node_result.nodes: + for node in node_result.nodes: + if hasattr(node, 'summary') and node.summary: + all_summaries.add(node.summary) + if hasattr(node, 'name') and node.name and node.name != entity_name: + all_summaries.add(f"相关实体: {node.name}") + results["node_summaries"] = list(all_summaries) + + # 构建综合上下文 + context_parts = [] + if results["facts"]: + context_parts.append("事实信息:\n" + "\n".join(f"- {f}" for f in results["facts"][:20])) + if results["node_summaries"]: + context_parts.append("相关实体:\n" + "\n".join(f"- {s}" for s in results["node_summaries"][:10])) + results["context"] = "\n\n".join(context_parts) + + logger.info(f"Zep混合检索完成: {entity_name}, 获取 {len(results['facts'])} 条事实, {len(results['node_summaries'])} 个相关节点") + + except concurrent.futures.TimeoutError: + logger.warning(f"Zep检索超时 ({entity_name})") + except Exception as e: + logger.warning(f"Zep检索失败 ({entity_name}): {e}") + + return results + + def _build_entity_context(self, entity: EntityNode) -> str: + """ + 构建实体的完整上下文信息 + + 包括: + 1. 实体本身的边信息(事实) + 2. 关联节点的详细信息 + 3. Zep混合检索到的丰富信息 + """ + context_parts = [] + + # 1. 添加实体属性信息 + if entity.attributes: + attrs = [] + for key, value in entity.attributes.items(): + if value and str(value).strip(): + attrs.append(f"- {key}: {value}") + if attrs: + context_parts.append("### 实体属性\n" + "\n".join(attrs)) + + # 2. 添加相关边信息(事实/关系) + existing_facts = set() + if entity.related_edges: + relationships = [] + for edge in entity.related_edges: # 不限制数量 + fact = edge.get("fact", "") + edge_name = edge.get("edge_name", "") + direction = edge.get("direction", "") + + if fact: + relationships.append(f"- {fact}") + existing_facts.add(fact) + elif edge_name: + if direction == "outgoing": + relationships.append(f"- {entity.name} --[{edge_name}]--> (相关实体)") + else: + relationships.append(f"- (相关实体) --[{edge_name}]--> {entity.name}") + + if relationships: + context_parts.append("### 相关事实和关系\n" + "\n".join(relationships)) + + # 3. 添加关联节点的详细信息 + if entity.related_nodes: + related_info = [] + for node in entity.related_nodes: # 不限制数量 + node_name = node.get("name", "") + node_labels = node.get("labels", []) + node_summary = node.get("summary", "") + + # 过滤掉默认标签 + custom_labels = [l for l in node_labels if l not in ["Entity", "Node"]] + label_str = f" ({', '.join(custom_labels)})" if custom_labels else "" + + if node_summary: + related_info.append(f"- **{node_name}**{label_str}: {node_summary}") + else: + related_info.append(f"- **{node_name}**{label_str}") + + if related_info: + context_parts.append("### 关联实体信息\n" + "\n".join(related_info)) + + # 4. 使用Zep混合检索获取更丰富的信息 + zep_results = self._search_zep_for_entity(entity) + + if zep_results.get("facts"): + # 去重:排除已存在的事实 + new_facts = [f for f in zep_results["facts"] if f not in existing_facts] + if new_facts: + context_parts.append("### Zep检索到的事实信息\n" + "\n".join(f"- {f}" for f in new_facts[:15])) + + if zep_results.get("node_summaries"): + context_parts.append("### Zep检索到的相关节点\n" + "\n".join(f"- {s}" for s in zep_results["node_summaries"][:10])) + + return "\n\n".join(context_parts) + + def _is_individual_entity(self, entity_type: str) -> bool: + """判断是否是个人类型实体""" + return entity_type.lower() in self.INDIVIDUAL_ENTITY_TYPES + + def _is_group_entity(self, entity_type: str) -> bool: + """判断是否是群体/机构类型实体""" + return entity_type.lower() in self.GROUP_ENTITY_TYPES + + def _generate_profile_with_llm( + self, + entity_name: str, + entity_type: str, + entity_summary: str, + entity_attributes: Dict[str, Any], + context: str + ) -> Dict[str, Any]: + """ + 使用LLM生成非常详细的人设 + + 根据实体类型区分: + - 个人实体:生成具体的人物设定 + - 群体/机构实体:生成代表性账号设定 + """ + + is_individual = self._is_individual_entity(entity_type) + + if is_individual: + prompt = self._build_individual_persona_prompt( + entity_name, entity_type, entity_summary, entity_attributes, context + ) + else: + prompt = self._build_group_persona_prompt( + entity_name, entity_type, entity_summary, entity_attributes, context + ) + + # 尝试多次生成,直到成功或达到最大重试次数 + max_attempts = 3 + last_error = None + + for attempt in range(max_attempts): + try: + response = self.client.chat.completions.create( + model=self.model_name, + messages=[ + {"role": "system", "content": self._get_system_prompt(is_individual)}, + {"role": "user", "content": prompt} + ], + response_format={"type": "json_object"}, + temperature=0.7 - (attempt * 0.1) # 每次重试降低温度 + # 不设置max_tokens,让LLM自由发挥 + ) + + content = response.choices[0].message.content + + # 检查是否被截断(finish_reason不是'stop') + finish_reason = response.choices[0].finish_reason + if finish_reason == 'length': + logger.warning(f"LLM输出被截断 (attempt {attempt+1}), 尝试修复...") + content = self._fix_truncated_json(content) + + # 尝试解析JSON + try: + result = json.loads(content) + + # 验证必需字段 + if "bio" not in result or not result["bio"]: + result["bio"] = entity_summary[:200] if entity_summary else f"{entity_type}: {entity_name}" + if "persona" not in result or not result["persona"]: + result["persona"] = entity_summary or f"{entity_name}是一个{entity_type}。" + + return result + + except json.JSONDecodeError as je: + logger.warning(f"JSON解析失败 (attempt {attempt+1}): {str(je)[:80]}") + + # 尝试修复JSON + result = self._try_fix_json(content, entity_name, entity_type, entity_summary) + if result.get("_fixed"): + del result["_fixed"] + return result + + last_error = je + + except Exception as e: + logger.warning(f"LLM调用失败 (attempt {attempt+1}): {str(e)[:80]}") + last_error = e + import time + time.sleep(1 * (attempt + 1)) # 指数退避 + + logger.warning(f"LLM生成人设失败({max_attempts}次尝试): {last_error}, 使用规则生成") + return self._generate_profile_rule_based( + entity_name, entity_type, entity_summary, entity_attributes + ) + + def _fix_truncated_json(self, content: str) -> str: + """修复被截断的JSON(输出被max_tokens限制截断)""" + import re + + # 如果JSON被截断,尝试闭合它 + content = content.strip() + + # 计算未闭合的括号 + open_braces = content.count('{') - content.count('}') + open_brackets = content.count('[') - content.count(']') + + # 检查是否有未闭合的字符串 + # 简单检查:如果最后一个引号后没有逗号或闭合括号,可能是字符串被截断 + if content and content[-1] not in '",}]': + # 尝试闭合字符串 + content += '"' + + # 闭合括号 + content += ']' * open_brackets + content += '}' * open_braces + + return content + + def _try_fix_json(self, content: str, entity_name: str, entity_type: str, entity_summary: str = "") -> Dict[str, Any]: + """尝试修复损坏的JSON""" + import re + + # 1. 首先尝试修复被截断的情况 + content = self._fix_truncated_json(content) + + # 2. 尝试提取JSON部分 + json_match = re.search(r'\{[\s\S]*\}', content) + if json_match: + json_str = json_match.group() + + # 3. 处理字符串中的换行符问题 + # 找到所有字符串值并替换其中的换行符 + def fix_string_newlines(match): + s = match.group(0) + # 替换字符串内的实际换行符为空格 + s = s.replace('\n', ' ').replace('\r', ' ') + # 替换多余空格 + s = re.sub(r'\s+', ' ', s) + return s + + # 匹配JSON字符串值 + json_str = re.sub(r'"[^"\\]*(?:\\.[^"\\]*)*"', fix_string_newlines, json_str) + + # 4. 尝试解析 + try: + result = json.loads(json_str) + result["_fixed"] = True + return result + except json.JSONDecodeError as e: + # 5. 如果还是失败,尝试更激进的修复 + try: + # 移除所有控制字符 + json_str = re.sub(r'[\x00-\x1f\x7f-\x9f]', ' ', json_str) + # 替换所有连续空白 + json_str = re.sub(r'\s+', ' ', json_str) + result = json.loads(json_str) + result["_fixed"] = True + return result + except: + pass + + # 6. 尝试从内容中提取部分信息 + bio_match = re.search(r'"bio"\s*:\s*"([^"]*)"', content) + persona_match = re.search(r'"persona"\s*:\s*"([^"]*)', content) # 可能被截断 + + bio = bio_match.group(1) if bio_match else (entity_summary[:200] if entity_summary else f"{entity_type}: {entity_name}") + persona = persona_match.group(1) if persona_match else (entity_summary or f"{entity_name}是一个{entity_type}。") + + # 如果提取到了有意义的内容,标记为已修复 + if bio_match or persona_match: + logger.info(f"从损坏的JSON中提取了部分信息") + return { + "bio": bio, + "persona": persona, + "_fixed": True + } + + # 7. 完全失败,返回基础结构 + logger.warning(f"JSON修复失败,返回基础结构") + return { + "bio": entity_summary[:200] if entity_summary else f"{entity_type}: {entity_name}", + "persona": entity_summary or f"{entity_name}是一个{entity_type}。" + } + + def _get_system_prompt(self, is_individual: bool) -> str: + """获取系统提示词""" + base_prompt = "你是社交媒体用户画像生成专家。生成详细、真实的人设用于舆论模拟,最大程度还原已有现实情况。必须返回有效的JSON格式,所有字符串值不能包含未转义的换行符。" + return f"{base_prompt}\n\n{get_language_instruction()}" + + def _build_individual_persona_prompt( + self, + entity_name: str, + entity_type: str, + entity_summary: str, + entity_attributes: Dict[str, Any], + context: str + ) -> str: + """构建个人实体的详细人设提示词""" + + attrs_str = json.dumps(entity_attributes, ensure_ascii=False) if entity_attributes else "无" + context_str = context[:3000] if context else "无额外上下文" + + return f"""为实体生成详细的社交媒体用户人设,最大程度还原已有现实情况。 + +实体名称: {entity_name} +实体类型: {entity_type} +实体摘要: {entity_summary} +实体属性: {attrs_str} + +上下文信息: +{context_str} + +请生成JSON,包含以下字段: + +1. bio: 社交媒体简介,200字 +2. persona: 详细人设描述(2000字的纯文本),需包含: + - 基本信息(年龄、职业、教育背景、所在地) + - 人物背景(重要经历、与事件的关联、社会关系) + - 性格特征(MBTI类型、核心性格、情绪表达方式) + - 社交媒体行为(发帖频率、内容偏好、互动风格、语言特点) + - 立场观点(对话题的态度、可能被激怒/感动的内容) + - 独特特征(口头禅、特殊经历、个人爱好) + - 个人记忆(人设的重要部分,要介绍这个个体与事件的关联,以及这个个体在事件中的已有动作与反应) +3. age: 年龄数字(必须是整数) +4. gender: 性别,必须是英文: "male" 或 "female" +5. mbti: MBTI类型(如INTJ、ENFP等) +6. country: 国家(使用中文,如"中国") +7. profession: 职业 +8. interested_topics: 感兴趣话题数组 + +重要: +- 所有字段值必须是字符串或数字,不要使用换行符 +- persona必须是一段连贯的文字描述 +- {get_language_instruction()} (gender字段必须用英文male/female) +- 内容要与实体信息保持一致 +- age必须是有效的整数,gender必须是"male"或"female" +""" + + def _build_group_persona_prompt( + self, + entity_name: str, + entity_type: str, + entity_summary: str, + entity_attributes: Dict[str, Any], + context: str + ) -> str: + """构建群体/机构实体的详细人设提示词""" + + attrs_str = json.dumps(entity_attributes, ensure_ascii=False) if entity_attributes else "无" + context_str = context[:3000] if context else "无额外上下文" + + return f"""为机构/群体实体生成详细的社交媒体账号设定,最大程度还原已有现实情况。 + +实体名称: {entity_name} +实体类型: {entity_type} +实体摘要: {entity_summary} +实体属性: {attrs_str} + +上下文信息: +{context_str} + +请生成JSON,包含以下字段: + +1. bio: 官方账号简介,200字,专业得体 +2. persona: 详细账号设定描述(2000字的纯文本),需包含: + - 机构基本信息(正式名称、机构性质、成立背景、主要职能) + - 账号定位(账号类型、目标受众、核心功能) + - 发言风格(语言特点、常用表达、禁忌话题) + - 发布内容特点(内容类型、发布频率、活跃时间段) + - 立场态度(对核心话题的官方立场、面对争议的处理方式) + - 特殊说明(代表的群体画像、运营习惯) + - 机构记忆(机构人设的重要部分,要介绍这个机构与事件的关联,以及这个机构在事件中的已有动作与反应) +3. age: 固定填30(机构账号的虚拟年龄) +4. gender: 固定填"other"(机构账号使用other表示非个人) +5. mbti: MBTI类型,用于描述账号风格,如ISTJ代表严谨保守 +6. country: 国家(使用中文,如"中国") +7. profession: 机构职能描述 +8. interested_topics: 关注领域数组 + +重要: +- 所有字段值必须是字符串或数字,不允许null值 +- persona必须是一段连贯的文字描述,不要使用换行符 +- {get_language_instruction()} (gender字段必须用英文"other") +- age必须是整数30,gender必须是字符串"other" +- 机构账号发言要符合其身份定位""" + + def _generate_profile_rule_based( + self, + entity_name: str, + entity_type: str, + entity_summary: str, + entity_attributes: Dict[str, Any] + ) -> Dict[str, Any]: + """使用规则生成基础人设""" + + # 根据实体类型生成不同的人设 + entity_type_lower = entity_type.lower() + + if entity_type_lower in ["student", "alumni"]: + return { + "bio": f"{entity_type} with interests in academics and social issues.", + "persona": f"{entity_name} is a {entity_type.lower()} who is actively engaged in academic and social discussions. They enjoy sharing perspectives and connecting with peers.", + "age": random.randint(18, 30), + "gender": random.choice(["male", "female"]), + "mbti": random.choice(self.MBTI_TYPES), + "country": random.choice(self.COUNTRIES), + "profession": "Student", + "interested_topics": ["Education", "Social Issues", "Technology"], + } + + elif entity_type_lower in ["publicfigure", "expert", "faculty"]: + return { + "bio": f"Expert and thought leader in their field.", + "persona": f"{entity_name} is a recognized {entity_type.lower()} who shares insights and opinions on important matters. They are known for their expertise and influence in public discourse.", + "age": random.randint(35, 60), + "gender": random.choice(["male", "female"]), + "mbti": random.choice(["ENTJ", "INTJ", "ENTP", "INTP"]), + "country": random.choice(self.COUNTRIES), + "profession": entity_attributes.get("occupation", "Expert"), + "interested_topics": ["Politics", "Economics", "Culture & Society"], + } + + elif entity_type_lower in ["mediaoutlet", "socialmediaplatform"]: + return { + "bio": f"Official account for {entity_name}. News and updates.", + "persona": f"{entity_name} is a media entity that reports news and facilitates public discourse. The account shares timely updates and engages with the audience on current events.", + "age": 30, # 机构虚拟年龄 + "gender": "other", # 机构使用other + "mbti": "ISTJ", # 机构风格:严谨保守 + "country": "中国", + "profession": "Media", + "interested_topics": ["General News", "Current Events", "Public Affairs"], + } + + elif entity_type_lower in ["university", "governmentagency", "ngo", "organization"]: + return { + "bio": f"Official account of {entity_name}.", + "persona": f"{entity_name} is an institutional entity that communicates official positions, announcements, and engages with stakeholders on relevant matters.", + "age": 30, # 机构虚拟年龄 + "gender": "other", # 机构使用other + "mbti": "ISTJ", # 机构风格:严谨保守 + "country": "中国", + "profession": entity_type, + "interested_topics": ["Public Policy", "Community", "Official Announcements"], + } + + else: + # 默认人设 + return { + "bio": entity_summary[:150] if entity_summary else f"{entity_type}: {entity_name}", + "persona": entity_summary or f"{entity_name} is a {entity_type.lower()} participating in social discussions.", + "age": random.randint(25, 50), + "gender": random.choice(["male", "female"]), + "mbti": random.choice(self.MBTI_TYPES), + "country": random.choice(self.COUNTRIES), + "profession": entity_type, + "interested_topics": ["General", "Social Issues"], + } + + def set_graph_id(self, graph_id: str): + """设置图谱ID用于Zep检索""" + self.graph_id = graph_id + + def generate_profiles_from_entities( + self, + entities: List[EntityNode], + use_llm: bool = True, + progress_callback: Optional[callable] = None, + graph_id: Optional[str] = None, + parallel_count: int = 5, + realtime_output_path: Optional[str] = None, + output_platform: str = "reddit" + ) -> List[OasisAgentProfile]: + """ + 批量从实体生成Agent Profile(支持并行生成) + + Args: + entities: 实体列表 + use_llm: 是否使用LLM生成详细人设 + progress_callback: 进度回调函数 (current, total, message) + graph_id: 图谱ID,用于Zep检索获取更丰富上下文 + parallel_count: 并行生成数量,默认5 + realtime_output_path: 实时写入的文件路径(如果提供,每生成一个就写入一次) + output_platform: 输出平台格式 ("reddit" 或 "twitter") + + Returns: + Agent Profile列表 + """ + import concurrent.futures + from threading import Lock + + # 设置graph_id用于Zep检索 + if graph_id: + self.graph_id = graph_id + + total = len(entities) + profiles = [None] * total # 预分配列表保持顺序 + completed_count = [0] # 使用列表以便在闭包中修改 + lock = Lock() + + # 实时写入文件的辅助函数 + def save_profiles_realtime(): + """实时保存已生成的 profiles 到文件""" + if not realtime_output_path: + return + + with lock: + # 过滤出已生成的 profiles + existing_profiles = [p for p in profiles if p is not None] + if not existing_profiles: + return + + try: + if output_platform == "reddit": + # Reddit JSON 格式 + profiles_data = [p.to_reddit_format() for p in existing_profiles] + with open(realtime_output_path, 'w', encoding='utf-8') as f: + json.dump(profiles_data, f, ensure_ascii=False, indent=2) + else: + # Twitter CSV 格式 + import csv + profiles_data = [p.to_twitter_format() for p in existing_profiles] + if profiles_data: + fieldnames = list(profiles_data[0].keys()) + with open(realtime_output_path, 'w', encoding='utf-8', newline='') as f: + writer = csv.DictWriter(f, fieldnames=fieldnames) + writer.writeheader() + writer.writerows(profiles_data) + except Exception as e: + logger.warning(f"实时保存 profiles 失败: {e}") + + # Capture locale before spawning thread pool workers + current_locale = get_locale() + + def generate_single_profile(idx: int, entity: EntityNode) -> tuple: + """生成单个profile的工作函数""" + set_locale(current_locale) + entity_type = entity.get_entity_type() or "Entity" + + try: + profile = self.generate_profile_from_entity( + entity=entity, + user_id=idx, + use_llm=use_llm + ) + + # 实时输出生成的人设到控制台和日志 + self._print_generated_profile(entity.name, entity_type, profile) + + return idx, profile, None + + except Exception as e: + logger.error(f"生成实体 {entity.name} 的人设失败: {str(e)}") + # 创建一个基础profile + fallback_profile = OasisAgentProfile( + user_id=idx, + user_name=self._generate_username(entity.name), + name=entity.name, + bio=f"{entity_type}: {entity.name}", + persona=entity.summary or f"A participant in social discussions.", + source_entity_uuid=entity.uuid, + source_entity_type=entity_type, + ) + return idx, fallback_profile, str(e) + + logger.info(f"开始并行生成 {total} 个Agent人设(并行数: {parallel_count})...") + print(f"\n{'='*60}") + print(f"开始生成Agent人设 - 共 {total} 个实体,并行数: {parallel_count}") + print(f"{'='*60}\n") + + # 使用线程池并行执行 + with concurrent.futures.ThreadPoolExecutor(max_workers=parallel_count) as executor: + # 提交所有任务 + future_to_entity = { + executor.submit(generate_single_profile, idx, entity): (idx, entity) + for idx, entity in enumerate(entities) + } + + # 收集结果 + for future in concurrent.futures.as_completed(future_to_entity): + idx, entity = future_to_entity[future] + entity_type = entity.get_entity_type() or "Entity" + + try: + result_idx, profile, error = future.result() + profiles[result_idx] = profile + + with lock: + completed_count[0] += 1 + current = completed_count[0] + + # 实时写入文件 + save_profiles_realtime() + + if progress_callback: + progress_callback( + current, + total, + f"已完成 {current}/{total}: {entity.name}({entity_type})" + ) + + if error: + logger.warning(f"[{current}/{total}] {entity.name} 使用备用人设: {error}") + else: + logger.info(f"[{current}/{total}] 成功生成人设: {entity.name} ({entity_type})") + + except Exception as e: + logger.error(f"处理实体 {entity.name} 时发生异常: {str(e)}") + with lock: + completed_count[0] += 1 + profiles[idx] = OasisAgentProfile( + user_id=idx, + user_name=self._generate_username(entity.name), + name=entity.name, + bio=f"{entity_type}: {entity.name}", + persona=entity.summary or "A participant in social discussions.", + source_entity_uuid=entity.uuid, + source_entity_type=entity_type, + ) + # 实时写入文件(即使是备用人设) + save_profiles_realtime() + + print(f"\n{'='*60}") + print(f"人设生成完成!共生成 {len([p for p in profiles if p])} 个Agent") + print(f"{'='*60}\n") + + return profiles + + def _print_generated_profile(self, entity_name: str, entity_type: str, profile: OasisAgentProfile): + """实时输出生成的人设到控制台(完整内容,不截断)""" + separator = "-" * 70 + + # 构建完整输出内容(不截断) + topics_str = ', '.join(profile.interested_topics) if profile.interested_topics else '无' + + output_lines = [ + f"\n{separator}", + t('progress.profileGenerated', name=entity_name, type=entity_type), + f"{separator}", + f"用户名: {profile.user_name}", + f"", + f"【简介】", + f"{profile.bio}", + f"", + f"【详细人设】", + f"{profile.persona}", + f"", + f"【基本属性】", + f"年龄: {profile.age} | 性别: {profile.gender} | MBTI: {profile.mbti}", + f"职业: {profile.profession} | 国家: {profile.country}", + f"兴趣话题: {topics_str}", + separator + ] + + output = "\n".join(output_lines) + + # 只输出到控制台(避免重复,logger不再输出完整内容) + print(output) + + def save_profiles( + self, + profiles: List[OasisAgentProfile], + file_path: str, + platform: str = "reddit" + ): + """ + 保存Profile到文件(根据平台选择正确格式) + + OASIS平台格式要求: + - Twitter: CSV格式 + - Reddit: JSON格式 + + Args: + profiles: Profile列表 + file_path: 文件路径 + platform: 平台类型 ("reddit" 或 "twitter") + """ + if platform == "twitter": + self._save_twitter_csv(profiles, file_path) + else: + self._save_reddit_json(profiles, file_path) + + def _save_twitter_csv(self, profiles: List[OasisAgentProfile], file_path: str): + """ + 保存Twitter Profile为CSV格式(符合OASIS官方要求) + + OASIS Twitter要求的CSV字段: + - user_id: 用户ID(根据CSV顺序从0开始) + - name: 用户真实姓名 + - username: 系统中的用户名 + - user_char: 详细人设描述(注入到LLM系统提示中,指导Agent行为) + - description: 简短的公开简介(显示在用户资料页面) + + user_char vs description 区别: + - user_char: 内部使用,LLM系统提示,决定Agent如何思考和行动 + - description: 外部显示,其他用户可见的简介 + """ + import csv + + # 确保文件扩展名是.csv + if not file_path.endswith('.csv'): + file_path = file_path.replace('.json', '.csv') + + with open(file_path, 'w', newline='', encoding='utf-8') as f: + writer = csv.writer(f) + + # 写入OASIS要求的表头 + headers = ['user_id', 'name', 'username', 'user_char', 'description'] + writer.writerow(headers) + + # 写入数据行 + for idx, profile in enumerate(profiles): + # user_char: 完整人设(bio + persona),用于LLM系统提示 + user_char = profile.bio + if profile.persona and profile.persona != profile.bio: + user_char = f"{profile.bio} {profile.persona}" + # 处理换行符(CSV中用空格替代) + user_char = user_char.replace('\n', ' ').replace('\r', ' ') + + # description: 简短简介,用于外部显示 + description = profile.bio.replace('\n', ' ').replace('\r', ' ') + + row = [ + idx, # user_id: 从0开始的顺序ID + profile.name, # name: 真实姓名 + profile.user_name, # username: 用户名 + user_char, # user_char: 完整人设(内部LLM使用) + description # description: 简短简介(外部显示) + ] + writer.writerow(row) + + logger.info(f"已保存 {len(profiles)} 个Twitter Profile到 {file_path} (OASIS CSV格式)") + + def _normalize_gender(self, gender: Optional[str]) -> str: + """ + 标准化gender字段为OASIS要求的英文格式 + + OASIS要求: male, female, other + """ + if not gender: + return "other" + + gender_lower = gender.lower().strip() + + # 中文映射 + gender_map = { + "男": "male", + "女": "female", + "机构": "other", + "其他": "other", + # 英文已有 + "male": "male", + "female": "female", + "other": "other", + } + + return gender_map.get(gender_lower, "other") + + def _save_reddit_json(self, profiles: List[OasisAgentProfile], file_path: str): + """ + 保存Reddit Profile为JSON格式 + + 使用与 to_reddit_format() 一致的格式,确保 OASIS 能正确读取。 + 必须包含 user_id 字段,这是 OASIS agent_graph.get_agent() 匹配的关键! + + 必需字段: + - user_id: 用户ID(整数,用于匹配 initial_posts 中的 poster_agent_id) + - username: 用户名 + - name: 显示名称 + - bio: 简介 + - persona: 详细人设 + - age: 年龄(整数) + - gender: "male", "female", 或 "other" + - mbti: MBTI类型 + - country: 国家 + """ + data = [] + for idx, profile in enumerate(profiles): + # 使用与 to_reddit_format() 一致的格式 + item = { + "user_id": profile.user_id if profile.user_id is not None else idx, # 关键:必须包含 user_id + "username": profile.user_name, + "name": profile.name, + "bio": profile.bio[:150] if profile.bio else f"{profile.name}", + "persona": profile.persona or f"{profile.name} is a participant in social discussions.", + "karma": profile.karma if profile.karma else 1000, + "created_at": profile.created_at, + # OASIS必需字段 - 确保都有默认值 + "age": profile.age if profile.age else 30, + "gender": self._normalize_gender(profile.gender), + "mbti": profile.mbti if profile.mbti else "ISTJ", + "country": profile.country if profile.country else "中国", + } + + # 可选字段 + if profile.profession: + item["profession"] = profile.profession + if profile.interested_topics: + item["interested_topics"] = profile.interested_topics + + data.append(item) + + with open(file_path, 'w', encoding='utf-8') as f: + json.dump(data, f, ensure_ascii=False, indent=2) + + logger.info(f"已保存 {len(profiles)} 个Reddit Profile到 {file_path} (JSON格式,包含user_id字段)") + + # 保留旧方法名作为别名,保持向后兼容 + def save_profiles_to_json( + self, + profiles: List[OasisAgentProfile], + file_path: str, + platform: str = "reddit" + ): + """[已废弃] 请使用 save_profiles() 方法""" + logger.warning("save_profiles_to_json已废弃,请使用save_profiles方法") + self.save_profiles(profiles, file_path, platform) + diff --git a/backend/app/services/ontology_generator.py b/backend/app/services/ontology_generator.py new file mode 100644 index 00000000..01a3d799 --- /dev/null +++ b/backend/app/services/ontology_generator.py @@ -0,0 +1,506 @@ +""" +本体生成服务 +接口1:分析文本内容,生成适合社会模拟的实体和关系类型定义 +""" + +import json +import logging +import re +from typing import Dict, Any, List, Optional +from ..utils.llm_client import LLMClient +from ..utils.locale import get_language_instruction + +logger = logging.getLogger(__name__) + + +def _to_pascal_case(name: str) -> str: + """将任意格式的名称转换为 PascalCase(如 'works_for' -> 'WorksFor', 'person' -> 'Person')""" + # 按非字母数字字符分割 + parts = re.split(r'[^a-zA-Z0-9]+', name) + # 再按 camelCase 边界分割(如 'camelCase' -> ['camel', 'Case']) + words = [] + for part in parts: + words.extend(re.sub(r'([a-z])([A-Z])', r'\1_\2', part).split('_')) + # 每个词首字母大写,过滤空串 + result = ''.join(word.capitalize() for word in words if word) + return result if result else 'Unknown' + + +# 本体生成的系统提示词 +ONTOLOGY_SYSTEM_PROMPT = """你是一个专业的知识图谱本体设计专家。你的任务是分析给定的文本内容和模拟需求,设计适合**社交媒体舆论模拟**的实体类型和关系类型。 + +**重要:你必须输出有效的JSON格式数据,不要输出任何其他内容。** + +## 核心任务背景 + +我们正在构建一个**社交媒体舆论模拟系统**。在这个系统中: +- 每个实体都是一个可以在社交媒体上发声、互动、传播信息的"账号"或"主体" +- 实体之间会相互影响、转发、评论、回应 +- 我们需要模拟舆论事件中各方的反应和信息传播路径 + +因此,**实体必须是现实中真实存在的、可以在社媒上发声和互动的主体**: + +**可以是**: +- 具体的个人(公众人物、当事人、意见领袖、专家学者、普通人) +- 公司、企业(包括其官方账号) +- 组织机构(大学、协会、NGO、工会等) +- 政府部门、监管机构 +- 媒体机构(报纸、电视台、自媒体、网站) +- 社交媒体平台本身 +- 特定群体代表(如校友会、粉丝团、维权群体等) + +**不可以是**: +- 抽象概念(如"舆论"、"情绪"、"趋势") +- 主题/话题(如"学术诚信"、"教育改革") +- 观点/态度(如"支持方"、"反对方") + +## 输出格式 + +请输出JSON格式,包含以下结构: + +```json +{ + "entity_types": [ + { + "name": "实体类型名称(英文,PascalCase)", + "description": "简短描述(英文,不超过100字符)", + "attributes": [ + { + "name": "属性名(英文,snake_case)", + "type": "text", + "description": "属性描述" + } + ], + "examples": ["示例实体1", "示例实体2"] + } + ], + "edge_types": [ + { + "name": "关系类型名称(英文,UPPER_SNAKE_CASE)", + "description": "简短描述(英文,不超过100字符)", + "source_targets": [ + {"source": "源实体类型", "target": "目标实体类型"} + ], + "attributes": [] + } + ], + "analysis_summary": "对文本内容的简要分析说明" +} +``` + +## 设计指南(极其重要!) + +### 1. 实体类型设计 - 必须严格遵守 + +**数量要求:必须正好10个实体类型** + +**层次结构要求(必须同时包含具体类型和兜底类型)**: + +你的10个实体类型必须包含以下层次: + +A. **兜底类型(必须包含,放在列表最后2个)**: + - `Person`: 任何自然人个体的兜底类型。当一个人不属于其他更具体的人物类型时,归入此类。 + - `Organization`: 任何组织机构的兜底类型。当一个组织不属于其他更具体的组织类型时,归入此类。 + +B. **具体类型(8个,根据文本内容设计)**: + - 针对文本中出现的主要角色,设计更具体的类型 + - 例如:如果文本涉及学术事件,可以有 `Student`, `Professor`, `University` + - 例如:如果文本涉及商业事件,可以有 `Company`, `CEO`, `Employee` + +**为什么需要兜底类型**: +- 文本中会出现各种人物,如"中小学教师"、"路人甲"、"某位网友" +- 如果没有专门的类型匹配,他们应该被归入 `Person` +- 同理,小型组织、临时团体等应该归入 `Organization` + +**具体类型的设计原则**: +- 从文本中识别出高频出现或关键的角色类型 +- 每个具体类型应该有明确的边界,避免重叠 +- description 必须清晰说明这个类型和兜底类型的区别 + +### 2. 关系类型设计 + +- 数量:6-10个 +- 关系应该反映社媒互动中的真实联系 +- 确保关系的 source_targets 涵盖你定义的实体类型 + +### 3. 属性设计 + +- 每个实体类型1-3个关键属性 +- **注意**:属性名不能使用 `name`、`uuid`、`group_id`、`created_at`、`summary`(这些是系统保留字) +- 推荐使用:`full_name`, `title`, `role`, `position`, `location`, `description` 等 + +## 实体类型参考 + +**个人类(具体)**: +- Student: 学生 +- Professor: 教授/学者 +- Journalist: 记者 +- Celebrity: 明星/网红 +- Executive: 高管 +- Official: 政府官员 +- Lawyer: 律师 +- Doctor: 医生 + +**个人类(兜底)**: +- Person: 任何自然人(不属于上述具体类型时使用) + +**组织类(具体)**: +- University: 高校 +- Company: 公司企业 +- GovernmentAgency: 政府机构 +- MediaOutlet: 媒体机构 +- Hospital: 医院 +- School: 中小学 +- NGO: 非政府组织 + +**组织类(兜底)**: +- Organization: 任何组织机构(不属于上述具体类型时使用) + +## 关系类型参考 + +- WORKS_FOR: 工作于 +- STUDIES_AT: 就读于 +- AFFILIATED_WITH: 隶属于 +- REPRESENTS: 代表 +- REGULATES: 监管 +- REPORTS_ON: 报道 +- COMMENTS_ON: 评论 +- RESPONDS_TO: 回应 +- SUPPORTS: 支持 +- OPPOSES: 反对 +- COLLABORATES_WITH: 合作 +- COMPETES_WITH: 竞争 +""" + + +class OntologyGenerator: + """ + 本体生成器 + 分析文本内容,生成实体和关系类型定义 + """ + + def __init__(self, llm_client: Optional[LLMClient] = None): + self.llm_client = llm_client or LLMClient() + + def generate( + self, + document_texts: List[str], + simulation_requirement: str, + additional_context: Optional[str] = None + ) -> Dict[str, Any]: + """ + 生成本体定义 + + Args: + document_texts: 文档文本列表 + simulation_requirement: 模拟需求描述 + additional_context: 额外上下文 + + Returns: + 本体定义(entity_types, edge_types等) + """ + # 构建用户消息 + user_message = self._build_user_message( + document_texts, + simulation_requirement, + additional_context + ) + + lang_instruction = get_language_instruction() + system_prompt = f"{ONTOLOGY_SYSTEM_PROMPT}\n\n{lang_instruction}\nIMPORTANT: Entity type names MUST be in English PascalCase (e.g., 'PersonEntity', 'MediaOrganization'). Relationship type names MUST be in English UPPER_SNAKE_CASE (e.g., 'WORKS_FOR'). Attribute names MUST be in English snake_case. Only description fields and analysis_summary should use the specified language above." + messages = [ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_message} + ] + + # 调用LLM + result = self.llm_client.chat_json( + messages=messages, + temperature=0.3, + max_tokens=4096 + ) + + # 验证和后处理 + result = self._validate_and_process(result) + + return result + + # 传给 LLM 的文本最大长度(5万字) + MAX_TEXT_LENGTH_FOR_LLM = 50000 + + def _build_user_message( + self, + document_texts: List[str], + simulation_requirement: str, + additional_context: Optional[str] + ) -> str: + """构建用户消息""" + + # 合并文本 + combined_text = "\n\n---\n\n".join(document_texts) + original_length = len(combined_text) + + # 如果文本超过5万字,截断(仅影响传给LLM的内容,不影响图谱构建) + if len(combined_text) > self.MAX_TEXT_LENGTH_FOR_LLM: + combined_text = combined_text[:self.MAX_TEXT_LENGTH_FOR_LLM] + combined_text += f"\n\n...(原文共{original_length}字,已截取前{self.MAX_TEXT_LENGTH_FOR_LLM}字用于本体分析)..." + + message = f"""## 模拟需求 + +{simulation_requirement} + +## 文档内容 + +{combined_text} +""" + + if additional_context: + message += f""" +## 额外说明 + +{additional_context} +""" + + message += """ +请根据以上内容,设计适合社会舆论模拟的实体类型和关系类型。 + +**必须遵守的规则**: +1. 必须正好输出10个实体类型 +2. 最后2个必须是兜底类型:Person(个人兜底)和 Organization(组织兜底) +3. 前8个是根据文本内容设计的具体类型 +4. 所有实体类型必须是现实中可以发声的主体,不能是抽象概念 +5. 属性名不能使用 name、uuid、group_id 等保留字,用 full_name、org_name 等替代 +""" + + return message + + def _validate_and_process(self, result: Dict[str, Any]) -> Dict[str, Any]: + """验证和后处理结果""" + + # 确保必要字段存在 + if "entity_types" not in result: + result["entity_types"] = [] + if "edge_types" not in result: + result["edge_types"] = [] + if "analysis_summary" not in result: + result["analysis_summary"] = "" + + # 验证实体类型 + # 记录原始名称到 PascalCase 的映射,用于后续修正 edge 的 source_targets 引用 + entity_name_map = {} + for entity in result["entity_types"]: + # 强制将 entity name 转为 PascalCase(Zep API 要求) + if "name" in entity: + original_name = entity["name"] + entity["name"] = _to_pascal_case(original_name) + if entity["name"] != original_name: + logger.warning(f"Entity type name '{original_name}' auto-converted to '{entity['name']}'") + entity_name_map[original_name] = entity["name"] + if "attributes" not in entity: + entity["attributes"] = [] + if "examples" not in entity: + entity["examples"] = [] + # 确保description不超过100字符 + if len(entity.get("description", "")) > 100: + entity["description"] = entity["description"][:97] + "..." + + # 验证关系类型 + for edge in result["edge_types"]: + # 强制将 edge name 转为 SCREAMING_SNAKE_CASE(Zep API 要求) + if "name" in edge: + original_name = edge["name"] + edge["name"] = original_name.upper() + if edge["name"] != original_name: + logger.warning(f"Edge type name '{original_name}' auto-converted to '{edge['name']}'") + # 修正 source_targets 中的实体名称引用,与转换后的 PascalCase 保持一致 + for st in edge.get("source_targets", []): + if st.get("source") in entity_name_map: + st["source"] = entity_name_map[st["source"]] + if st.get("target") in entity_name_map: + st["target"] = entity_name_map[st["target"]] + if "source_targets" not in edge: + edge["source_targets"] = [] + if "attributes" not in edge: + edge["attributes"] = [] + if len(edge.get("description", "")) > 100: + edge["description"] = edge["description"][:97] + "..." + + # Zep API 限制:最多 10 个自定义实体类型,最多 10 个自定义边类型 + MAX_ENTITY_TYPES = 10 + MAX_EDGE_TYPES = 10 + + # 去重:按 name 去重,保留首次出现的 + seen_names = set() + deduped = [] + for entity in result["entity_types"]: + name = entity.get("name", "") + if name and name not in seen_names: + seen_names.add(name) + deduped.append(entity) + elif name in seen_names: + logger.warning(f"Duplicate entity type '{name}' removed during validation") + result["entity_types"] = deduped + + # 兜底类型定义 + person_fallback = { + "name": "Person", + "description": "Any individual person not fitting other specific person types.", + "attributes": [ + {"name": "full_name", "type": "text", "description": "Full name of the person"}, + {"name": "role", "type": "text", "description": "Role or occupation"} + ], + "examples": ["ordinary citizen", "anonymous netizen"] + } + + organization_fallback = { + "name": "Organization", + "description": "Any organization not fitting other specific organization types.", + "attributes": [ + {"name": "org_name", "type": "text", "description": "Name of the organization"}, + {"name": "org_type", "type": "text", "description": "Type of organization"} + ], + "examples": ["small business", "community group"] + } + + # 检查是否已有兜底类型 + entity_names = {e["name"] for e in result["entity_types"]} + has_person = "Person" in entity_names + has_organization = "Organization" in entity_names + + # 需要添加的兜底类型 + fallbacks_to_add = [] + if not has_person: + fallbacks_to_add.append(person_fallback) + if not has_organization: + fallbacks_to_add.append(organization_fallback) + + if fallbacks_to_add: + current_count = len(result["entity_types"]) + needed_slots = len(fallbacks_to_add) + + # 如果添加后会超过 10 个,需要移除一些现有类型 + if current_count + needed_slots > MAX_ENTITY_TYPES: + # 计算需要移除多少个 + to_remove = current_count + needed_slots - MAX_ENTITY_TYPES + # 从末尾移除(保留前面更重要的具体类型) + result["entity_types"] = result["entity_types"][:-to_remove] + + # 添加兜底类型 + result["entity_types"].extend(fallbacks_to_add) + + # 最终确保不超过限制(防御性编程) + if len(result["entity_types"]) > MAX_ENTITY_TYPES: + result["entity_types"] = result["entity_types"][:MAX_ENTITY_TYPES] + + if len(result["edge_types"]) > MAX_EDGE_TYPES: + result["edge_types"] = result["edge_types"][:MAX_EDGE_TYPES] + + return result + + def generate_python_code(self, ontology: Dict[str, Any]) -> str: + """ + 将本体定义转换为Python代码(类似ontology.py) + + Args: + ontology: 本体定义 + + Returns: + Python代码字符串 + """ + code_lines = [ + '"""', + '自定义实体类型定义', + '由MiroFish自动生成,用于社会舆论模拟', + '"""', + '', + 'from pydantic import Field', + 'from zep_cloud.external_clients.ontology import EntityModel, EntityText, EdgeModel', + '', + '', + '# ============== 实体类型定义 ==============', + '', + ] + + # 生成实体类型 + for entity in ontology.get("entity_types", []): + name = entity["name"] + desc = entity.get("description", f"A {name} entity.") + + code_lines.append(f'class {name}(EntityModel):') + code_lines.append(f' """{desc}"""') + + attrs = entity.get("attributes", []) + if attrs: + for attr in attrs: + attr_name = attr["name"] + attr_desc = attr.get("description", attr_name) + code_lines.append(f' {attr_name}: EntityText = Field(') + code_lines.append(f' description="{attr_desc}",') + code_lines.append(f' default=None') + code_lines.append(f' )') + else: + code_lines.append(' pass') + + code_lines.append('') + code_lines.append('') + + code_lines.append('# ============== 关系类型定义 ==============') + code_lines.append('') + + # 生成关系类型 + for edge in ontology.get("edge_types", []): + name = edge["name"] + # 转换为PascalCase类名 + class_name = ''.join(word.capitalize() for word in name.split('_')) + desc = edge.get("description", f"A {name} relationship.") + + code_lines.append(f'class {class_name}(EdgeModel):') + code_lines.append(f' """{desc}"""') + + attrs = edge.get("attributes", []) + if attrs: + for attr in attrs: + attr_name = attr["name"] + attr_desc = attr.get("description", attr_name) + code_lines.append(f' {attr_name}: EntityText = Field(') + code_lines.append(f' description="{attr_desc}",') + code_lines.append(f' default=None') + code_lines.append(f' )') + else: + code_lines.append(' pass') + + code_lines.append('') + code_lines.append('') + + # 生成类型字典 + code_lines.append('# ============== 类型配置 ==============') + code_lines.append('') + code_lines.append('ENTITY_TYPES = {') + for entity in ontology.get("entity_types", []): + name = entity["name"] + code_lines.append(f' "{name}": {name},') + code_lines.append('}') + code_lines.append('') + code_lines.append('EDGE_TYPES = {') + for edge in ontology.get("edge_types", []): + name = edge["name"] + class_name = ''.join(word.capitalize() for word in name.split('_')) + code_lines.append(f' "{name}": {class_name},') + code_lines.append('}') + code_lines.append('') + + # 生成边的source_targets映射 + code_lines.append('EDGE_SOURCE_TARGETS = {') + for edge in ontology.get("edge_types", []): + name = edge["name"] + source_targets = edge.get("source_targets", []) + if source_targets: + st_list = ', '.join([ + f'{{"source": "{st.get("source", "Entity")}", "target": "{st.get("target", "Entity")}"}}' + for st in source_targets + ]) + code_lines.append(f' "{name}": [{st_list}],') + code_lines.append('}') + + return '\n'.join(code_lines) + diff --git a/backend/app/services/report_agent.py b/backend/app/services/report_agent.py new file mode 100644 index 00000000..cecd70b4 --- /dev/null +++ b/backend/app/services/report_agent.py @@ -0,0 +1,2572 @@ +""" +Report Agent服务 +使用LangChain + Zep实现ReACT模式的模拟报告生成 + +功能: +1. 根据模拟需求和Zep图谱信息生成报告 +2. 先规划目录结构,然后分段生成 +3. 每段采用ReACT多轮思考与反思模式 +4. 支持与用户对话,在对话中自主调用检索工具 +""" + +import os +import json +import time +import re +from typing import Dict, Any, List, Optional, Callable +from dataclasses import dataclass, field +from datetime import datetime +from enum import Enum + +from ..config import Config +from ..utils.llm_client import LLMClient +from ..utils.logger import get_logger +from ..utils.locale import get_language_instruction, t +from .zep_tools import ( + ZepToolsService, + SearchResult, + InsightForgeResult, + PanoramaResult, + InterviewResult +) + +logger = get_logger('mirofish.report_agent') + + +class ReportLogger: + """ + Report Agent 详细日志记录器 + + 在报告文件夹中生成 agent_log.jsonl 文件,记录每一步详细动作。 + 每行是一个完整的 JSON 对象,包含时间戳、动作类型、详细内容等。 + """ + + def __init__(self, report_id: str): + """ + 初始化日志记录器 + + Args: + report_id: 报告ID,用于确定日志文件路径 + """ + self.report_id = report_id + self.log_file_path = os.path.join( + Config.UPLOAD_FOLDER, 'reports', report_id, 'agent_log.jsonl' + ) + self.start_time = datetime.now() + self._ensure_log_file() + + def _ensure_log_file(self): + """确保日志文件所在目录存在""" + log_dir = os.path.dirname(self.log_file_path) + os.makedirs(log_dir, exist_ok=True) + + def _get_elapsed_time(self) -> float: + """获取从开始到现在的耗时(秒)""" + return (datetime.now() - self.start_time).total_seconds() + + def log( + self, + action: str, + stage: str, + details: Dict[str, Any], + section_title: str = None, + section_index: int = None + ): + """ + 记录一条日志 + + Args: + action: 动作类型,如 'start', 'tool_call', 'llm_response', 'section_complete' 等 + stage: 当前阶段,如 'planning', 'generating', 'completed' + details: 详细内容字典,不截断 + section_title: 当前章节标题(可选) + section_index: 当前章节索引(可选) + """ + log_entry = { + "timestamp": datetime.now().isoformat(), + "elapsed_seconds": round(self._get_elapsed_time(), 2), + "report_id": self.report_id, + "action": action, + "stage": stage, + "section_title": section_title, + "section_index": section_index, + "details": details + } + + # 追加写入 JSONL 文件 + with open(self.log_file_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(log_entry, ensure_ascii=False) + '\n') + + def log_start(self, simulation_id: str, graph_id: str, simulation_requirement: str): + """记录报告生成开始""" + self.log( + action="report_start", + stage="pending", + details={ + "simulation_id": simulation_id, + "graph_id": graph_id, + "simulation_requirement": simulation_requirement, + "message": t('report.taskStarted') + } + ) + + def log_planning_start(self): + """记录大纲规划开始""" + self.log( + action="planning_start", + stage="planning", + details={"message": t('report.planningStart')} + ) + + def log_planning_context(self, context: Dict[str, Any]): + """记录规划时获取的上下文信息""" + self.log( + action="planning_context", + stage="planning", + details={ + "message": t('report.fetchSimContext'), + "context": context + } + ) + + def log_planning_complete(self, outline_dict: Dict[str, Any]): + """记录大纲规划完成""" + self.log( + action="planning_complete", + stage="planning", + details={ + "message": t('report.planningComplete'), + "outline": outline_dict + } + ) + + def log_section_start(self, section_title: str, section_index: int): + """记录章节生成开始""" + self.log( + action="section_start", + stage="generating", + section_title=section_title, + section_index=section_index, + details={"message": t('report.sectionStart', title=section_title)} + ) + + def log_react_thought(self, section_title: str, section_index: int, iteration: int, thought: str): + """记录 ReACT 思考过程""" + self.log( + action="react_thought", + stage="generating", + section_title=section_title, + section_index=section_index, + details={ + "iteration": iteration, + "thought": thought, + "message": t('report.reactThought', iteration=iteration) + } + ) + + def log_tool_call( + self, + section_title: str, + section_index: int, + tool_name: str, + parameters: Dict[str, Any], + iteration: int + ): + """记录工具调用""" + self.log( + action="tool_call", + stage="generating", + section_title=section_title, + section_index=section_index, + details={ + "iteration": iteration, + "tool_name": tool_name, + "parameters": parameters, + "message": t('report.toolCall', toolName=tool_name) + } + ) + + def log_tool_result( + self, + section_title: str, + section_index: int, + tool_name: str, + result: str, + iteration: int + ): + """记录工具调用结果(完整内容,不截断)""" + self.log( + action="tool_result", + stage="generating", + section_title=section_title, + section_index=section_index, + details={ + "iteration": iteration, + "tool_name": tool_name, + "result": result, # 完整结果,不截断 + "result_length": len(result), + "message": t('report.toolResult', toolName=tool_name) + } + ) + + def log_llm_response( + self, + section_title: str, + section_index: int, + response: str, + iteration: int, + has_tool_calls: bool, + has_final_answer: bool + ): + """记录 LLM 响应(完整内容,不截断)""" + self.log( + action="llm_response", + stage="generating", + section_title=section_title, + section_index=section_index, + details={ + "iteration": iteration, + "response": response, # 完整响应,不截断 + "response_length": len(response), + "has_tool_calls": has_tool_calls, + "has_final_answer": has_final_answer, + "message": t('report.llmResponse', hasToolCalls=has_tool_calls, hasFinalAnswer=has_final_answer) + } + ) + + def log_section_content( + self, + section_title: str, + section_index: int, + content: str, + tool_calls_count: int + ): + """记录章节内容生成完成(仅记录内容,不代表整个章节完成)""" + self.log( + action="section_content", + stage="generating", + section_title=section_title, + section_index=section_index, + details={ + "content": content, # 完整内容,不截断 + "content_length": len(content), + "tool_calls_count": tool_calls_count, + "message": t('report.sectionContentDone', title=section_title) + } + ) + + def log_section_full_complete( + self, + section_title: str, + section_index: int, + full_content: str + ): + """ + 记录章节生成完成 + + 前端应监听此日志来判断一个章节是否真正完成,并获取完整内容 + """ + self.log( + action="section_complete", + stage="generating", + section_title=section_title, + section_index=section_index, + details={ + "content": full_content, + "content_length": len(full_content), + "message": t('report.sectionComplete', title=section_title) + } + ) + + def log_report_complete(self, total_sections: int, total_time_seconds: float): + """记录报告生成完成""" + self.log( + action="report_complete", + stage="completed", + details={ + "total_sections": total_sections, + "total_time_seconds": round(total_time_seconds, 2), + "message": t('report.reportComplete') + } + ) + + def log_error(self, error_message: str, stage: str, section_title: str = None): + """记录错误""" + self.log( + action="error", + stage=stage, + section_title=section_title, + section_index=None, + details={ + "error": error_message, + "message": t('report.errorOccurred', error=error_message) + } + ) + + +class ReportConsoleLogger: + """ + Report Agent 控制台日志记录器 + + 将控制台风格的日志(INFO、WARNING等)写入报告文件夹中的 console_log.txt 文件。 + 这些日志与 agent_log.jsonl 不同,是纯文本格式的控制台输出。 + """ + + def __init__(self, report_id: str): + """ + 初始化控制台日志记录器 + + Args: + report_id: 报告ID,用于确定日志文件路径 + """ + self.report_id = report_id + self.log_file_path = os.path.join( + Config.UPLOAD_FOLDER, 'reports', report_id, 'console_log.txt' + ) + self._ensure_log_file() + self._file_handler = None + self._setup_file_handler() + + def _ensure_log_file(self): + """确保日志文件所在目录存在""" + log_dir = os.path.dirname(self.log_file_path) + os.makedirs(log_dir, exist_ok=True) + + def _setup_file_handler(self): + """设置文件处理器,将日志同时写入文件""" + import logging + + # 创建文件处理器 + self._file_handler = logging.FileHandler( + self.log_file_path, + mode='a', + encoding='utf-8' + ) + self._file_handler.setLevel(logging.INFO) + + # 使用与控制台相同的简洁格式 + formatter = logging.Formatter( + '[%(asctime)s] %(levelname)s: %(message)s', + datefmt='%H:%M:%S' + ) + self._file_handler.setFormatter(formatter) + + # 添加到 report_agent 相关的 logger + loggers_to_attach = [ + 'mirofish.report_agent', + 'mirofish.zep_tools', + ] + + for logger_name in loggers_to_attach: + target_logger = logging.getLogger(logger_name) + # 避免重复添加 + if self._file_handler not in target_logger.handlers: + target_logger.addHandler(self._file_handler) + + def close(self): + """关闭文件处理器并从 logger 中移除""" + import logging + + if self._file_handler: + loggers_to_detach = [ + 'mirofish.report_agent', + 'mirofish.zep_tools', + ] + + for logger_name in loggers_to_detach: + target_logger = logging.getLogger(logger_name) + if self._file_handler in target_logger.handlers: + target_logger.removeHandler(self._file_handler) + + self._file_handler.close() + self._file_handler = None + + def __del__(self): + """析构时确保关闭文件处理器""" + self.close() + + +class ReportStatus(str, Enum): + """报告状态""" + PENDING = "pending" + PLANNING = "planning" + GENERATING = "generating" + COMPLETED = "completed" + FAILED = "failed" + + +@dataclass +class ReportSection: + """报告章节""" + title: str + content: str = "" + + def to_dict(self) -> Dict[str, Any]: + return { + "title": self.title, + "content": self.content + } + + def to_markdown(self, level: int = 2) -> str: + """转换为Markdown格式""" + md = f"{'#' * level} {self.title}\n\n" + if self.content: + md += f"{self.content}\n\n" + return md + + +@dataclass +class ReportOutline: + """报告大纲""" + title: str + summary: str + sections: List[ReportSection] + + def to_dict(self) -> Dict[str, Any]: + return { + "title": self.title, + "summary": self.summary, + "sections": [s.to_dict() for s in self.sections] + } + + def to_markdown(self) -> str: + """转换为Markdown格式""" + md = f"# {self.title}\n\n" + md += f"> {self.summary}\n\n" + for section in self.sections: + md += section.to_markdown() + return md + + +@dataclass +class Report: + """完整报告""" + report_id: str + simulation_id: str + graph_id: str + simulation_requirement: str + status: ReportStatus + outline: Optional[ReportOutline] = None + markdown_content: str = "" + created_at: str = "" + completed_at: str = "" + error: Optional[str] = None + + def to_dict(self) -> Dict[str, Any]: + return { + "report_id": self.report_id, + "simulation_id": self.simulation_id, + "graph_id": self.graph_id, + "simulation_requirement": self.simulation_requirement, + "status": self.status.value, + "outline": self.outline.to_dict() if self.outline else None, + "markdown_content": self.markdown_content, + "created_at": self.created_at, + "completed_at": self.completed_at, + "error": self.error + } + + +# ═══════════════════════════════════════════════════════════════ +# Prompt 模板常量 +# ═══════════════════════════════════════════════════════════════ + +# ── 工具描述 ── + +TOOL_DESC_INSIGHT_FORGE = """\ +【深度洞察检索 - 强大的检索工具】 +这是我们强大的检索函数,专为深度分析设计。它会: +1. 自动将你的问题分解为多个子问题 +2. 从多个维度检索模拟图谱中的信息 +3. 整合语义搜索、实体分析、关系链追踪的结果 +4. 返回最全面、最深度的检索内容 + +【使用场景】 +- 需要深入分析某个话题 +- 需要了解事件的多个方面 +- 需要获取支撑报告章节的丰富素材 + +【返回内容】 +- 相关事实原文(可直接引用) +- 核心实体洞察 +- 关系链分析""" + +TOOL_DESC_PANORAMA_SEARCH = """\ +【广度搜索 - 获取全貌视图】 +这个工具用于获取模拟结果的完整全貌,特别适合了解事件演变过程。它会: +1. 获取所有相关节点和关系 +2. 区分当前有效的事实和历史/过期的事实 +3. 帮助你了解舆情是如何演变的 + +【使用场景】 +- 需要了解事件的完整发展脉络 +- 需要对比不同阶段的舆情变化 +- 需要获取全面的实体和关系信息 + +【返回内容】 +- 当前有效事实(模拟最新结果) +- 历史/过期事实(演变记录) +- 所有涉及的实体""" + +TOOL_DESC_QUICK_SEARCH = """\ +【简单搜索 - 快速检索】 +轻量级的快速检索工具,适合简单、直接的信息查询。 + +【使用场景】 +- 需要快速查找某个具体信息 +- 需要验证某个事实 +- 简单的信息检索 + +【返回内容】 +- 与查询最相关的事实列表""" + +TOOL_DESC_INTERVIEW_AGENTS = """\ +【深度采访 - 真实Agent采访(双平台)】 +调用OASIS模拟环境的采访API,对正在运行的模拟Agent进行真实采访! +这不是LLM模拟,而是调用真实的采访接口获取模拟Agent的原始回答。 +默认在Twitter和Reddit两个平台同时采访,获取更全面的观点。 + +功能流程: +1. 自动读取人设文件,了解所有模拟Agent +2. 智能选择与采访主题最相关的Agent(如学生、媒体、官方等) +3. 自动生成采访问题 +4. 调用 /api/simulation/interview/batch 接口在双平台进行真实采访 +5. 整合所有采访结果,提供多视角分析 + +【使用场景】 +- 需要从不同角色视角了解事件看法(学生怎么看?媒体怎么看?官方怎么说?) +- 需要收集多方意见和立场 +- 需要获取模拟Agent的真实回答(来自OASIS模拟环境) +- 想让报告更生动,包含"采访实录" + +【返回内容】 +- 被采访Agent的身份信息 +- 各Agent在Twitter和Reddit两个平台的采访回答 +- 关键引言(可直接引用) +- 采访摘要和观点对比 + +【重要】需要OASIS模拟环境正在运行才能使用此功能!""" + +# ── 大纲规划 prompt ── + +PLAN_SYSTEM_PROMPT = """\ +你是一个「未来预测报告」的撰写专家,拥有对模拟世界的「上帝视角」——你可以洞察模拟中每一位Agent的行为、言论和互动。 + +【核心理念】 +我们构建了一个模拟世界,并向其中注入了特定的「模拟需求」作为变量。模拟世界的演化结果,就是对未来可能发生情况的预测。你正在观察的不是"实验数据",而是"未来的预演"。 + +【你的任务】 +撰写一份「未来预测报告」,回答: +1. 在我们设定的条件下,未来发生了什么? +2. 各类Agent(人群)是如何反应和行动? +3. 这个模拟揭示了哪些值得关注的未来趋势和风险? + +【报告定位】 +- ✅ 这是一份基于模拟的未来预测报告,揭示"如果这样,未来会怎样" +- ✅ 聚焦于预测结果:事件走向、群体反应、涌现现象、潜在风险 +- ✅ 模拟世界中的Agent言行就是对未来人群行为的预测 +- ❌ 不是对现实世界现状的分析 +- ❌ 不是泛泛而谈的舆情综述 + +【章节数量限制】 +- 最少2个章节,最多5个章节 +- 不需要子章节,每个章节直接撰写完整内容 +- 内容要精炼,聚焦于核心预测发现 +- 章节结构由你根据预测结果自主设计 + +请输出JSON格式的报告大纲,格式如下: +{ + "title": "报告标题", + "summary": "报告摘要(一句话概括核心预测发现)", + "sections": [ + { + "title": "章节标题", + "description": "章节内容描述" + } + ] +} + +注意:sections数组最少2个,最多5个元素!""" + +PLAN_USER_PROMPT_TEMPLATE = """\ +【预测场景设定】 +我们向模拟世界注入的变量(模拟需求):{simulation_requirement} + +【模拟世界规模】 +- 参与模拟的实体数量: {total_nodes} +- 实体间产生的关系数量: {total_edges} +- 实体类型分布: {entity_types} +- 活跃Agent数量: {total_entities} + +【模拟预测到的部分未来事实样本】 +{related_facts_json} + +请以「上帝视角」审视这个未来预演: +1. 在我们设定的条件下,未来呈现出了什么样的状态? +2. 各类人群(Agent)是如何反应和行动的? +3. 这个模拟揭示了哪些值得关注的未来趋势? + +根据预测结果,设计最合适的报告章节结构。 + +【再次提醒】报告章节数量:最少2个,最多5个,内容要精炼聚焦于核心预测发现。""" + +# ── 章节生成 prompt ── + +SECTION_SYSTEM_PROMPT_TEMPLATE = """\ +你是一个「未来预测报告」的撰写专家,正在撰写报告的一个章节。 + +报告标题: {report_title} +报告摘要: {report_summary} +预测场景(模拟需求): {simulation_requirement} + +当前要撰写的章节: {section_title} + +═══════════════════════════════════════════════════════════════ +【核心理念】 +═══════════════════════════════════════════════════════════════ + +模拟世界是对未来的预演。我们向模拟世界注入了特定条件(模拟需求), +模拟中Agent的行为和互动,就是对未来人群行为的预测。 + +你的任务是: +- 揭示在设定条件下,未来发生了什么 +- 预测各类人群(Agent)是如何反应和行动的 +- 发现值得关注的未来趋势、风险和机会 + +❌ 不要写成对现实世界现状的分析 +✅ 要聚焦于"未来会怎样"——模拟结果就是预测的未来 + +═══════════════════════════════════════════════════════════════ +【最重要的规则 - 必须遵守】 +═══════════════════════════════════════════════════════════════ + +1. 【必须调用工具观察模拟世界】 + - 你正在以「上帝视角」观察未来的预演 + - 所有内容必须来自模拟世界中发生的事件和Agent言行 + - 禁止使用你自己的知识来编写报告内容 + - 每个章节至少调用3次工具(最多5次)来观察模拟的世界,它代表了未来 + +2. 【必须引用Agent的原始言行】 + - Agent的发言和行为是对未来人群行为的预测 + - 在报告中使用引用格式展示这些预测,例如: + > "某类人群会表示:原文内容..." + - 这些引用是模拟预测的核心证据 + +3. 【语言一致性 - 引用内容必须翻译为报告语言】 + - 工具返回的内容可能包含与报告语言不同的表述 + - 报告必须全部使用与用户指定语言一致的语言撰写 + - 当你引用工具返回的其他语言内容时,必须将其翻译为报告语言后再写入 + - 翻译时保持原意不变,确保表述自然通顺 + - 这一规则同时适用于正文和引用块(> 格式)中的内容 + +4. 【忠实呈现预测结果】 + - 报告内容必须反映模拟世界中的代表未来的模拟结果 + - 不要添加模拟中不存在的信息 + - 如果某方面信息不足,如实说明 + +═══════════════════════════════════════════════════════════════ +【⚠️ 格式规范 - 极其重要!】 +═══════════════════════════════════════════════════════════════ + +【一个章节 = 最小内容单位】 +- 每个章节是报告的最小分块单位 +- ❌ 禁止在章节内使用任何 Markdown 标题(#、##、###、#### 等) +- ❌ 禁止在内容开头添加章节主标题 +- ✅ 章节标题由系统自动添加,你只需撰写纯正文内容 +- ✅ 使用**粗体**、段落分隔、引用、列表来组织内容,但不要用标题 + +【正确示例】 +``` +本章节分析了事件的舆论传播态势。通过对模拟数据的深入分析,我们发现... + +**首发引爆阶段** + +微博作为舆情的第一现场,承担了信息首发的核心功能: + +> "微博贡献了68%的首发声量..." + +**情绪放大阶段** + +抖音平台进一步放大了事件影响力: + +- 视觉冲击力强 +- 情绪共鸣度高 +``` + +【错误示例】 +``` +## 执行摘要 ← 错误!不要添加任何标题 +### 一、首发阶段 ← 错误!不要用###分小节 +#### 1.1 详细分析 ← 错误!不要用####细分 + +本章节分析了... +``` + +═══════════════════════════════════════════════════════════════ +【可用检索工具】(每章节调用3-5次) +═══════════════════════════════════════════════════════════════ + +{tools_description} + +【工具使用建议 - 请混合使用不同工具,不要只用一种】 +- insight_forge: 深度洞察分析,自动分解问题并多维度检索事实和关系 +- panorama_search: 广角全景搜索,了解事件全貌、时间线和演变过程 +- quick_search: 快速验证某个具体信息点 +- interview_agents: 采访模拟Agent,获取不同角色的第一人称观点和真实反应 + +═══════════════════════════════════════════════════════════════ +【工作流程】 +═══════════════════════════════════════════════════════════════ + +每次回复你只能做以下两件事之一(不可同时做): + +选项A - 调用工具: +输出你的思考,然后用以下格式调用一个工具: + +{{"name": "工具名称", "parameters": {{"参数名": "参数值"}}}} + +系统会执行工具并把结果返回给你。你不需要也不能自己编写工具返回结果。 + +选项B - 输出最终内容: +当你已通过工具获取了足够信息,以 "Final Answer:" 开头输出章节内容。 + +⚠️ 严格禁止: +- 禁止在一次回复中同时包含工具调用和 Final Answer +- 禁止自己编造工具返回结果(Observation),所有工具结果由系统注入 +- 每次回复最多调用一个工具 + +═══════════════════════════════════════════════════════════════ +【章节内容要求】 +═══════════════════════════════════════════════════════════════ + +1. 内容必须基于工具检索到的模拟数据 +2. 大量引用原文来展示模拟效果 +3. 使用Markdown格式(但禁止使用标题): + - 使用 **粗体文字** 标记重点(代替子标题) + - 使用列表(-或1.2.3.)组织要点 + - 使用空行分隔不同段落 + - ❌ 禁止使用 #、##、###、#### 等任何标题语法 +4. 【引用格式规范 - 必须单独成段】 + 引用必须独立成段,前后各有一个空行,不能混在段落中: + + ✅ 正确格式: + ``` + 校方的回应被认为缺乏实质内容。 + + > "校方的应对模式在瞬息万变的社交媒体环境中显得僵化和迟缓。" + + 这一评价反映了公众的普遍不满。 + ``` + + ❌ 错误格式: + ``` + 校方的回应被认为缺乏实质内容。> "校方的应对模式..." 这一评价反映了... + ``` +5. 保持与其他章节的逻辑连贯性 +6. 【避免重复】仔细阅读下方已完成的章节内容,不要重复描述相同的信息 +7. 【再次强调】不要添加任何标题!用**粗体**代替小节标题""" + +SECTION_USER_PROMPT_TEMPLATE = """\ +已完成的章节内容(请仔细阅读,避免重复): +{previous_content} + +═══════════════════════════════════════════════════════════════ +【当前任务】撰写章节: {section_title} +═══════════════════════════════════════════════════════════════ + +【重要提醒】 +1. 仔细阅读上方已完成的章节,避免重复相同的内容! +2. 开始前必须先调用工具获取模拟数据 +3. 请混合使用不同工具,不要只用一种 +4. 报告内容必须来自检索结果,不要使用自己的知识 + +【⚠️ 格式警告 - 必须遵守】 +- ❌ 不要写任何标题(#、##、###、####都不行) +- ❌ 不要写"{section_title}"作为开头 +- ✅ 章节标题由系统自动添加 +- ✅ 直接写正文,用**粗体**代替小节标题 + +请开始: +1. 首先思考(Thought)这个章节需要什么信息 +2. 然后调用工具(Action)获取模拟数据 +3. 收集足够信息后输出 Final Answer(纯正文,无任何标题)""" + +# ── ReACT 循环内消息模板 ── + +REACT_OBSERVATION_TEMPLATE = """\ +Observation(检索结果): + +═══ 工具 {tool_name} 返回 ═══ +{result} + +═══════════════════════════════════════════════════════════════ +已调用工具 {tool_calls_count}/{max_tool_calls} 次(已用: {used_tools_str}){unused_hint} +- 如果信息充分:以 "Final Answer:" 开头输出章节内容(必须引用上述原文) +- 如果需要更多信息:调用一个工具继续检索 +═══════════════════════════════════════════════════════════════""" + +REACT_INSUFFICIENT_TOOLS_MSG = ( + "【注意】你只调用了{tool_calls_count}次工具,至少需要{min_tool_calls}次。" + "请再调用工具获取更多模拟数据,然后再输出 Final Answer。{unused_hint}" +) + +REACT_INSUFFICIENT_TOOLS_MSG_ALT = ( + "当前只调用了 {tool_calls_count} 次工具,至少需要 {min_tool_calls} 次。" + "请调用工具获取模拟数据。{unused_hint}" +) + +REACT_TOOL_LIMIT_MSG = ( + "工具调用次数已达上限({tool_calls_count}/{max_tool_calls}),不能再调用工具。" + '请立即基于已获取的信息,以 "Final Answer:" 开头输出章节内容。' +) + +REACT_UNUSED_TOOLS_HINT = "\n💡 你还没有使用过: {unused_list},建议尝试不同工具获取多角度信息" + +REACT_FORCE_FINAL_MSG = "已达到工具调用限制,请直接输出 Final Answer: 并生成章节内容。" + +# ── Chat prompt ── + +CHAT_SYSTEM_PROMPT_TEMPLATE = """\ +你是一个简洁高效的模拟预测助手。 + +【背景】 +预测条件: {simulation_requirement} + +【已生成的分析报告】 +{report_content} + +【规则】 +1. 优先基于上述报告内容回答问题 +2. 直接回答问题,避免冗长的思考论述 +3. 仅在报告内容不足以回答时,才调用工具检索更多数据 +4. 回答要简洁、清晰、有条理 + +【可用工具】(仅在需要时使用,最多调用1-2次) +{tools_description} + +【工具调用格式】 + +{{"name": "工具名称", "parameters": {{"参数名": "参数值"}}}} + + +【回答风格】 +- 简洁直接,不要长篇大论 +- 使用 > 格式引用关键内容 +- 优先给出结论,再解释原因""" + +CHAT_OBSERVATION_SUFFIX = "\n\n请简洁回答问题。" + + +# ═══════════════════════════════════════════════════════════════ +# ReportAgent 主类 +# ═══════════════════════════════════════════════════════════════ + + +class ReportAgent: + """ + Report Agent - 模拟报告生成Agent + + 采用ReACT(Reasoning + Acting)模式: + 1. 规划阶段:分析模拟需求,规划报告目录结构 + 2. 生成阶段:逐章节生成内容,每章节可多次调用工具获取信息 + 3. 反思阶段:检查内容完整性和准确性 + """ + + # 最大工具调用次数(每个章节) + MAX_TOOL_CALLS_PER_SECTION = 5 + + # 最大反思轮数 + MAX_REFLECTION_ROUNDS = 3 + + # 对话中的最大工具调用次数 + MAX_TOOL_CALLS_PER_CHAT = 2 + + def __init__( + self, + graph_id: str, + simulation_id: str, + simulation_requirement: str, + llm_client: Optional[LLMClient] = None, + zep_tools: Optional[ZepToolsService] = None + ): + """ + 初始化Report Agent + + Args: + graph_id: 图谱ID + simulation_id: 模拟ID + simulation_requirement: 模拟需求描述 + llm_client: LLM客户端(可选) + zep_tools: Zep工具服务(可选) + """ + self.graph_id = graph_id + self.simulation_id = simulation_id + self.simulation_requirement = simulation_requirement + + self.llm = llm_client or LLMClient() + self.zep_tools = zep_tools or ZepToolsService() + + # 工具定义 + self.tools = self._define_tools() + + # 日志记录器(在 generate_report 中初始化) + self.report_logger: Optional[ReportLogger] = None + # 控制台日志记录器(在 generate_report 中初始化) + self.console_logger: Optional[ReportConsoleLogger] = None + + logger.info(t('report.agentInitDone', graphId=graph_id, simulationId=simulation_id)) + + def _define_tools(self) -> Dict[str, Dict[str, Any]]: + """定义可用工具""" + return { + "insight_forge": { + "name": "insight_forge", + "description": TOOL_DESC_INSIGHT_FORGE, + "parameters": { + "query": "你想深入分析的问题或话题", + "report_context": "当前报告章节的上下文(可选,有助于生成更精准的子问题)" + } + }, + "panorama_search": { + "name": "panorama_search", + "description": TOOL_DESC_PANORAMA_SEARCH, + "parameters": { + "query": "搜索查询,用于相关性排序", + "include_expired": "是否包含过期/历史内容(默认True)" + } + }, + "quick_search": { + "name": "quick_search", + "description": TOOL_DESC_QUICK_SEARCH, + "parameters": { + "query": "搜索查询字符串", + "limit": "返回结果数量(可选,默认10)" + } + }, + "interview_agents": { + "name": "interview_agents", + "description": TOOL_DESC_INTERVIEW_AGENTS, + "parameters": { + "interview_topic": "采访主题或需求描述(如:'了解学生对宿舍甲醛事件的看法')", + "max_agents": "最多采访的Agent数量(可选,默认5,最大10)" + } + } + } + + def _execute_tool(self, tool_name: str, parameters: Dict[str, Any], report_context: str = "") -> str: + """ + 执行工具调用 + + Args: + tool_name: 工具名称 + parameters: 工具参数 + report_context: 报告上下文(用于InsightForge) + + Returns: + 工具执行结果(文本格式) + """ + logger.info(t('report.executingTool', toolName=tool_name, params=parameters)) + + try: + if tool_name == "insight_forge": + query = parameters.get("query", "") + ctx = parameters.get("report_context", "") or report_context + result = self.zep_tools.insight_forge( + graph_id=self.graph_id, + query=query, + simulation_requirement=self.simulation_requirement, + report_context=ctx + ) + return result.to_text() + + elif tool_name == "panorama_search": + # 广度搜索 - 获取全貌 + query = parameters.get("query", "") + include_expired = parameters.get("include_expired", True) + if isinstance(include_expired, str): + include_expired = include_expired.lower() in ['true', '1', 'yes'] + result = self.zep_tools.panorama_search( + graph_id=self.graph_id, + query=query, + include_expired=include_expired + ) + return result.to_text() + + elif tool_name == "quick_search": + # 简单搜索 - 快速检索 + query = parameters.get("query", "") + limit = parameters.get("limit", 10) + if isinstance(limit, str): + limit = int(limit) + result = self.zep_tools.quick_search( + graph_id=self.graph_id, + query=query, + limit=limit + ) + return result.to_text() + + elif tool_name == "interview_agents": + # 深度采访 - 调用真实的OASIS采访API获取模拟Agent的回答(双平台) + interview_topic = parameters.get("interview_topic", parameters.get("query", "")) + max_agents = parameters.get("max_agents", 5) + if isinstance(max_agents, str): + max_agents = int(max_agents) + max_agents = min(max_agents, 10) + result = self.zep_tools.interview_agents( + simulation_id=self.simulation_id, + interview_requirement=interview_topic, + simulation_requirement=self.simulation_requirement, + max_agents=max_agents + ) + return result.to_text() + + # ========== 向后兼容的旧工具(内部重定向到新工具) ========== + + elif tool_name == "search_graph": + # 重定向到 quick_search + logger.info(t('report.redirectToQuickSearch')) + return self._execute_tool("quick_search", parameters, report_context) + + elif tool_name == "get_graph_statistics": + result = self.zep_tools.get_graph_statistics(self.graph_id) + return json.dumps(result, ensure_ascii=False, indent=2) + + elif tool_name == "get_entity_summary": + entity_name = parameters.get("entity_name", "") + result = self.zep_tools.get_entity_summary( + graph_id=self.graph_id, + entity_name=entity_name + ) + return json.dumps(result, ensure_ascii=False, indent=2) + + elif tool_name == "get_simulation_context": + # 重定向到 insight_forge,因为它更强大 + logger.info(t('report.redirectToInsightForge')) + query = parameters.get("query", self.simulation_requirement) + return self._execute_tool("insight_forge", {"query": query}, report_context) + + elif tool_name == "get_entities_by_type": + entity_type = parameters.get("entity_type", "") + nodes = self.zep_tools.get_entities_by_type( + graph_id=self.graph_id, + entity_type=entity_type + ) + result = [n.to_dict() for n in nodes] + return json.dumps(result, ensure_ascii=False, indent=2) + + else: + return f"未知工具: {tool_name}。请使用以下工具之一: insight_forge, panorama_search, quick_search" + + except Exception as e: + logger.error(t('report.toolExecFailed', toolName=tool_name, error=str(e))) + return f"工具执行失败: {str(e)}" + + # 合法的工具名称集合,用于裸 JSON 兜底解析时校验 + VALID_TOOL_NAMES = {"insight_forge", "panorama_search", "quick_search", "interview_agents"} + + def _parse_tool_calls(self, response: str) -> List[Dict[str, Any]]: + """ + 从LLM响应中解析工具调用 + + 支持的格式(按优先级): + 1. {"name": "tool_name", "parameters": {...}} + 2. 裸 JSON(响应整体或单行就是一个工具调用 JSON) + """ + tool_calls = [] + + # 格式1: XML风格(标准格式) + xml_pattern = r'\s*(\{.*?\})\s*' + for match in re.finditer(xml_pattern, response, re.DOTALL): + try: + call_data = json.loads(match.group(1)) + tool_calls.append(call_data) + except json.JSONDecodeError: + pass + + if tool_calls: + return tool_calls + + # 格式2: 兜底 - LLM 直接输出裸 JSON(没包 标签) + # 只在格式1未匹配时尝试,避免误匹配正文中的 JSON + stripped = response.strip() + if stripped.startswith('{') and stripped.endswith('}'): + try: + call_data = json.loads(stripped) + if self._is_valid_tool_call(call_data): + tool_calls.append(call_data) + return tool_calls + except json.JSONDecodeError: + pass + + # 响应可能包含思考文字 + 裸 JSON,尝试提取最后一个 JSON 对象 + json_pattern = r'(\{"(?:name|tool)"\s*:.*?\})\s*$' + match = re.search(json_pattern, stripped, re.DOTALL) + if match: + try: + call_data = json.loads(match.group(1)) + if self._is_valid_tool_call(call_data): + tool_calls.append(call_data) + except json.JSONDecodeError: + pass + + return tool_calls + + def _is_valid_tool_call(self, data: dict) -> bool: + """校验解析出的 JSON 是否是合法的工具调用""" + # 支持 {"name": ..., "parameters": ...} 和 {"tool": ..., "params": ...} 两种键名 + tool_name = data.get("name") or data.get("tool") + if tool_name and tool_name in self.VALID_TOOL_NAMES: + # 统一键名为 name / parameters + if "tool" in data: + data["name"] = data.pop("tool") + if "params" in data and "parameters" not in data: + data["parameters"] = data.pop("params") + return True + return False + + def _get_tools_description(self) -> str: + """生成工具描述文本""" + desc_parts = ["可用工具:"] + for name, tool in self.tools.items(): + params_desc = ", ".join([f"{k}: {v}" for k, v in tool["parameters"].items()]) + desc_parts.append(f"- {name}: {tool['description']}") + if params_desc: + desc_parts.append(f" 参数: {params_desc}") + return "\n".join(desc_parts) + + def plan_outline( + self, + progress_callback: Optional[Callable] = None + ) -> ReportOutline: + """ + 规划报告大纲 + + 使用LLM分析模拟需求,规划报告的目录结构 + + Args: + progress_callback: 进度回调函数 + + Returns: + ReportOutline: 报告大纲 + """ + logger.info(t('report.startPlanningOutline')) + + if progress_callback: + progress_callback("planning", 0, t('progress.analyzingRequirements')) + + # 首先获取模拟上下文 + context = self.zep_tools.get_simulation_context( + graph_id=self.graph_id, + simulation_requirement=self.simulation_requirement + ) + + if progress_callback: + progress_callback("planning", 30, t('progress.generatingOutline')) + + system_prompt = f"{PLAN_SYSTEM_PROMPT}\n\n{get_language_instruction()}" + user_prompt = PLAN_USER_PROMPT_TEMPLATE.format( + simulation_requirement=self.simulation_requirement, + total_nodes=context.get('graph_statistics', {}).get('total_nodes', 0), + total_edges=context.get('graph_statistics', {}).get('total_edges', 0), + entity_types=list(context.get('graph_statistics', {}).get('entity_types', {}).keys()), + total_entities=context.get('total_entities', 0), + related_facts_json=json.dumps(context.get('related_facts', [])[:10], ensure_ascii=False, indent=2), + ) + + try: + response = self.llm.chat_json( + messages=[ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ], + temperature=0.3 + ) + + if progress_callback: + progress_callback("planning", 80, t('progress.parsingOutline')) + + # 解析大纲 + sections = [] + for section_data in response.get("sections", []): + sections.append(ReportSection( + title=section_data.get("title", ""), + content="" + )) + + outline = ReportOutline( + title=response.get("title", "模拟分析报告"), + summary=response.get("summary", ""), + sections=sections + ) + + if progress_callback: + progress_callback("planning", 100, t('progress.outlinePlanComplete')) + + logger.info(t('report.outlinePlanDone', count=len(sections))) + return outline + + except Exception as e: + logger.error(t('report.outlinePlanFailed', error=str(e))) + # 返回默认大纲(3个章节,作为fallback) + return ReportOutline( + title="未来预测报告", + summary="基于模拟预测的未来趋势与风险分析", + sections=[ + ReportSection(title="预测场景与核心发现"), + ReportSection(title="人群行为预测分析"), + ReportSection(title="趋势展望与风险提示") + ] + ) + + def _generate_section_react( + self, + section: ReportSection, + outline: ReportOutline, + previous_sections: List[str], + progress_callback: Optional[Callable] = None, + section_index: int = 0 + ) -> str: + """ + 使用ReACT模式生成单个章节内容 + + ReACT循环: + 1. Thought(思考)- 分析需要什么信息 + 2. Action(行动)- 调用工具获取信息 + 3. Observation(观察)- 分析工具返回结果 + 4. 重复直到信息足够或达到最大次数 + 5. Final Answer(最终回答)- 生成章节内容 + + Args: + section: 要生成的章节 + outline: 完整大纲 + previous_sections: 之前章节的内容(用于保持连贯性) + progress_callback: 进度回调 + section_index: 章节索引(用于日志记录) + + Returns: + 章节内容(Markdown格式) + """ + logger.info(t('report.reactGenerateSection', title=section.title)) + + # 记录章节开始日志 + if self.report_logger: + self.report_logger.log_section_start(section.title, section_index) + + system_prompt = SECTION_SYSTEM_PROMPT_TEMPLATE.format( + report_title=outline.title, + report_summary=outline.summary, + simulation_requirement=self.simulation_requirement, + section_title=section.title, + tools_description=self._get_tools_description(), + ) + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}" + + # 构建用户prompt - 每个已完成章节各传入最大4000字 + if previous_sections: + previous_parts = [] + for sec in previous_sections: + # 每个章节最多4000字 + truncated = sec[:4000] + "..." if len(sec) > 4000 else sec + previous_parts.append(truncated) + previous_content = "\n\n---\n\n".join(previous_parts) + else: + previous_content = "(这是第一个章节)" + + user_prompt = SECTION_USER_PROMPT_TEMPLATE.format( + previous_content=previous_content, + section_title=section.title, + ) + + messages = [ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ] + + # ReACT循环 + tool_calls_count = 0 + max_iterations = 5 # 最大迭代轮数 + min_tool_calls = 3 # 最少工具调用次数 + conflict_retries = 0 # 工具调用与Final Answer同时出现的连续冲突次数 + used_tools = set() # 记录已调用过的工具名 + all_tools = {"insight_forge", "panorama_search", "quick_search", "interview_agents"} + + # 报告上下文,用于InsightForge的子问题生成 + report_context = f"章节标题: {section.title}\n模拟需求: {self.simulation_requirement}" + + for iteration in range(max_iterations): + if progress_callback: + progress_callback( + "generating", + int((iteration / max_iterations) * 100), + t('progress.deepSearchAndWrite', current=tool_calls_count, max=self.MAX_TOOL_CALLS_PER_SECTION) + ) + + # 调用LLM + response = self.llm.chat( + messages=messages, + temperature=0.5, + max_tokens=4096 + ) + + # 检查 LLM 返回是否为 None(API 异常或内容为空) + if response is None: + logger.warning(t('report.sectionIterNone', title=section.title, iteration=iteration + 1)) + # 如果还有迭代次数,添加消息并重试 + if iteration < max_iterations - 1: + messages.append({"role": "assistant", "content": "(响应为空)"}) + messages.append({"role": "user", "content": "请继续生成内容。"}) + continue + # 最后一次迭代也返回 None,跳出循环进入强制收尾 + break + + logger.debug(f"LLM响应: {response[:200]}...") + + # 解析一次,复用结果 + tool_calls = self._parse_tool_calls(response) + has_tool_calls = bool(tool_calls) + has_final_answer = "Final Answer:" in response + + # ── 冲突处理:LLM 同时输出了工具调用和 Final Answer ── + if has_tool_calls and has_final_answer: + conflict_retries += 1 + logger.warning( + t('report.sectionConflict', title=section.title, iteration=iteration+1, conflictCount=conflict_retries) + ) + + if conflict_retries <= 2: + # 前两次:丢弃本次响应,要求 LLM 重新回复 + messages.append({"role": "assistant", "content": response}) + messages.append({ + "role": "user", + "content": ( + "【格式错误】你在一次回复中同时包含了工具调用和 Final Answer,这是不允许的。\n" + "每次回复只能做以下两件事之一:\n" + "- 调用一个工具(输出一个 块,不要写 Final Answer)\n" + "- 输出最终内容(以 'Final Answer:' 开头,不要包含 )\n" + "请重新回复,只做其中一件事。" + ), + }) + continue + else: + # 第三次:降级处理,截断到第一个工具调用,强制执行 + logger.warning( + t('report.sectionConflictDowngrade', title=section.title, conflictCount=conflict_retries) + ) + first_tool_end = response.find('') + if first_tool_end != -1: + response = response[:first_tool_end + len('')] + tool_calls = self._parse_tool_calls(response) + has_tool_calls = bool(tool_calls) + has_final_answer = False + conflict_retries = 0 + + # 记录 LLM 响应日志 + if self.report_logger: + self.report_logger.log_llm_response( + section_title=section.title, + section_index=section_index, + response=response, + iteration=iteration + 1, + has_tool_calls=has_tool_calls, + has_final_answer=has_final_answer + ) + + # ── 情况1:LLM 输出了 Final Answer ── + if has_final_answer: + # 工具调用次数不足,拒绝并要求继续调工具 + if tool_calls_count < min_tool_calls: + messages.append({"role": "assistant", "content": response}) + unused_tools = all_tools - used_tools + unused_hint = f"(这些工具还未使用,推荐用一下他们: {', '.join(unused_tools)})" if unused_tools else "" + messages.append({ + "role": "user", + "content": REACT_INSUFFICIENT_TOOLS_MSG.format( + tool_calls_count=tool_calls_count, + min_tool_calls=min_tool_calls, + unused_hint=unused_hint, + ), + }) + continue + + # 正常结束 + final_answer = response.split("Final Answer:")[-1].strip() + logger.info(t('report.sectionGenDone', title=section.title, count=tool_calls_count)) + + if self.report_logger: + self.report_logger.log_section_content( + section_title=section.title, + section_index=section_index, + content=final_answer, + tool_calls_count=tool_calls_count + ) + return final_answer + + # ── 情况2:LLM 尝试调用工具 ── + if has_tool_calls: + # 工具额度已耗尽 → 明确告知,要求输出 Final Answer + if tool_calls_count >= self.MAX_TOOL_CALLS_PER_SECTION: + messages.append({"role": "assistant", "content": response}) + messages.append({ + "role": "user", + "content": REACT_TOOL_LIMIT_MSG.format( + tool_calls_count=tool_calls_count, + max_tool_calls=self.MAX_TOOL_CALLS_PER_SECTION, + ), + }) + continue + + # 只执行第一个工具调用 + call = tool_calls[0] + if len(tool_calls) > 1: + logger.info(t('report.multiToolOnlyFirst', total=len(tool_calls), toolName=call['name'])) + + if self.report_logger: + self.report_logger.log_tool_call( + section_title=section.title, + section_index=section_index, + tool_name=call["name"], + parameters=call.get("parameters", {}), + iteration=iteration + 1 + ) + + result = self._execute_tool( + call["name"], + call.get("parameters", {}), + report_context=report_context + ) + + if self.report_logger: + self.report_logger.log_tool_result( + section_title=section.title, + section_index=section_index, + tool_name=call["name"], + result=result, + iteration=iteration + 1 + ) + + tool_calls_count += 1 + used_tools.add(call['name']) + + # 构建未使用工具提示 + unused_tools = all_tools - used_tools + unused_hint = "" + if unused_tools and tool_calls_count < self.MAX_TOOL_CALLS_PER_SECTION: + unused_hint = REACT_UNUSED_TOOLS_HINT.format(unused_list="、".join(unused_tools)) + + messages.append({"role": "assistant", "content": response}) + messages.append({ + "role": "user", + "content": REACT_OBSERVATION_TEMPLATE.format( + tool_name=call["name"], + result=result, + tool_calls_count=tool_calls_count, + max_tool_calls=self.MAX_TOOL_CALLS_PER_SECTION, + used_tools_str=", ".join(used_tools), + unused_hint=unused_hint, + ), + }) + continue + + # ── 情况3:既没有工具调用,也没有 Final Answer ── + messages.append({"role": "assistant", "content": response}) + + if tool_calls_count < min_tool_calls: + # 工具调用次数不足,推荐未用过的工具 + unused_tools = all_tools - used_tools + unused_hint = f"(这些工具还未使用,推荐用一下他们: {', '.join(unused_tools)})" if unused_tools else "" + + messages.append({ + "role": "user", + "content": REACT_INSUFFICIENT_TOOLS_MSG_ALT.format( + tool_calls_count=tool_calls_count, + min_tool_calls=min_tool_calls, + unused_hint=unused_hint, + ), + }) + continue + + # 工具调用已足够,LLM 输出了内容但没带 "Final Answer:" 前缀 + # 直接将这段内容作为最终答案,不再空转 + logger.info(t('report.sectionNoPrefix', title=section.title, count=tool_calls_count)) + final_answer = response.strip() + + if self.report_logger: + self.report_logger.log_section_content( + section_title=section.title, + section_index=section_index, + content=final_answer, + tool_calls_count=tool_calls_count + ) + return final_answer + + # 达到最大迭代次数,强制生成内容 + logger.warning(t('report.sectionMaxIter', title=section.title)) + messages.append({"role": "user", "content": REACT_FORCE_FINAL_MSG}) + + response = self.llm.chat( + messages=messages, + temperature=0.5, + max_tokens=4096 + ) + + # 检查强制收尾时 LLM 返回是否为 None + if response is None: + logger.error(t('report.sectionForceFailed', title=section.title)) + final_answer = t('report.sectionGenFailedContent') + elif "Final Answer:" in response: + final_answer = response.split("Final Answer:")[-1].strip() + else: + final_answer = response + + # 记录章节内容生成完成日志 + if self.report_logger: + self.report_logger.log_section_content( + section_title=section.title, + section_index=section_index, + content=final_answer, + tool_calls_count=tool_calls_count + ) + + return final_answer + + def generate_report( + self, + progress_callback: Optional[Callable[[str, int, str], None]] = None, + report_id: Optional[str] = None + ) -> Report: + """ + 生成完整报告(分章节实时输出) + + 每个章节生成完成后立即保存到文件夹,不需要等待整个报告完成。 + 文件结构: + reports/{report_id}/ + meta.json - 报告元信息 + outline.json - 报告大纲 + progress.json - 生成进度 + section_01.md - 第1章节 + section_02.md - 第2章节 + ... + full_report.md - 完整报告 + + Args: + progress_callback: 进度回调函数 (stage, progress, message) + report_id: 报告ID(可选,如果不传则自动生成) + + Returns: + Report: 完整报告 + """ + import uuid + + # 如果没有传入 report_id,则自动生成 + if not report_id: + report_id = f"report_{uuid.uuid4().hex[:12]}" + start_time = datetime.now() + + report = Report( + report_id=report_id, + simulation_id=self.simulation_id, + graph_id=self.graph_id, + simulation_requirement=self.simulation_requirement, + status=ReportStatus.PENDING, + created_at=datetime.now().isoformat() + ) + + # 已完成的章节标题列表(用于进度追踪) + completed_section_titles = [] + + try: + # 初始化:创建报告文件夹并保存初始状态 + ReportManager._ensure_report_folder(report_id) + + # 初始化日志记录器(结构化日志 agent_log.jsonl) + self.report_logger = ReportLogger(report_id) + self.report_logger.log_start( + simulation_id=self.simulation_id, + graph_id=self.graph_id, + simulation_requirement=self.simulation_requirement + ) + + # 初始化控制台日志记录器(console_log.txt) + self.console_logger = ReportConsoleLogger(report_id) + + ReportManager.update_progress( + report_id, "pending", 0, t('progress.initReport'), + completed_sections=[] + ) + ReportManager.save_report(report) + + # 阶段1: 规划大纲 + report.status = ReportStatus.PLANNING + ReportManager.update_progress( + report_id, "planning", 5, t('progress.startPlanningOutline'), + completed_sections=[] + ) + + # 记录规划开始日志 + self.report_logger.log_planning_start() + + if progress_callback: + progress_callback("planning", 0, t('progress.startPlanningOutline')) + + outline = self.plan_outline( + progress_callback=lambda stage, prog, msg: + progress_callback(stage, prog // 5, msg) if progress_callback else None + ) + report.outline = outline + + # 记录规划完成日志 + self.report_logger.log_planning_complete(outline.to_dict()) + + # 保存大纲到文件 + ReportManager.save_outline(report_id, outline) + ReportManager.update_progress( + report_id, "planning", 15, t('progress.outlineDone', count=len(outline.sections)), + completed_sections=[] + ) + ReportManager.save_report(report) + + logger.info(t('report.outlineSavedToFile', reportId=report_id)) + + # 阶段2: 逐章节生成(分章节保存) + report.status = ReportStatus.GENERATING + + total_sections = len(outline.sections) + generated_sections = [] # 保存内容用于上下文 + + for i, section in enumerate(outline.sections): + section_num = i + 1 + base_progress = 20 + int((i / total_sections) * 70) + + # 更新进度 + ReportManager.update_progress( + report_id, "generating", base_progress, + t('progress.generatingSection', title=section.title, current=section_num, total=total_sections), + current_section=section.title, + completed_sections=completed_section_titles + ) + + if progress_callback: + progress_callback( + "generating", + base_progress, + t('progress.generatingSection', title=section.title, current=section_num, total=total_sections) + ) + + # 生成主章节内容 + section_content = self._generate_section_react( + section=section, + outline=outline, + previous_sections=generated_sections, + progress_callback=lambda stage, prog, msg: + progress_callback( + stage, + base_progress + int(prog * 0.7 / total_sections), + msg + ) if progress_callback else None, + section_index=section_num + ) + + section.content = section_content + generated_sections.append(f"## {section.title}\n\n{section_content}") + + # 保存章节 + ReportManager.save_section(report_id, section_num, section) + completed_section_titles.append(section.title) + + # 记录章节完成日志 + full_section_content = f"## {section.title}\n\n{section_content}" + + if self.report_logger: + self.report_logger.log_section_full_complete( + section_title=section.title, + section_index=section_num, + full_content=full_section_content.strip() + ) + + logger.info(t('report.sectionSaved', reportId=report_id, sectionNum=f"{section_num:02d}")) + + # 更新进度 + ReportManager.update_progress( + report_id, "generating", + base_progress + int(70 / total_sections), + t('progress.sectionDone', title=section.title), + current_section=None, + completed_sections=completed_section_titles + ) + + # 阶段3: 组装完整报告 + if progress_callback: + progress_callback("generating", 95, t('progress.assemblingReport')) + + ReportManager.update_progress( + report_id, "generating", 95, t('progress.assemblingReport'), + completed_sections=completed_section_titles + ) + + # 使用ReportManager组装完整报告 + report.markdown_content = ReportManager.assemble_full_report(report_id, outline) + report.status = ReportStatus.COMPLETED + report.completed_at = datetime.now().isoformat() + + # 计算总耗时 + total_time_seconds = (datetime.now() - start_time).total_seconds() + + # 记录报告完成日志 + if self.report_logger: + self.report_logger.log_report_complete( + total_sections=total_sections, + total_time_seconds=total_time_seconds + ) + + # 保存最终报告 + ReportManager.save_report(report) + ReportManager.update_progress( + report_id, "completed", 100, t('progress.reportComplete'), + completed_sections=completed_section_titles + ) + + if progress_callback: + progress_callback("completed", 100, t('progress.reportComplete')) + + logger.info(t('report.reportGenDone', reportId=report_id)) + + # 关闭控制台日志记录器 + if self.console_logger: + self.console_logger.close() + self.console_logger = None + + return report + + except Exception as e: + logger.error(t('report.reportGenFailed', error=str(e))) + report.status = ReportStatus.FAILED + report.error = str(e) + + # 记录错误日志 + if self.report_logger: + self.report_logger.log_error(str(e), "failed") + + # 保存失败状态 + try: + ReportManager.save_report(report) + ReportManager.update_progress( + report_id, "failed", -1, t('progress.reportFailed', error=str(e)), + completed_sections=completed_section_titles + ) + except Exception: + pass # 忽略保存失败的错误 + + # 关闭控制台日志记录器 + if self.console_logger: + self.console_logger.close() + self.console_logger = None + + return report + + def chat( + self, + message: str, + chat_history: List[Dict[str, str]] = None + ) -> Dict[str, Any]: + """ + 与Report Agent对话 + + 在对话中Agent可以自主调用检索工具来回答问题 + + Args: + message: 用户消息 + chat_history: 对话历史 + + Returns: + { + "response": "Agent回复", + "tool_calls": [调用的工具列表], + "sources": [信息来源] + } + """ + logger.info(t('report.agentChat', message=message[:50])) + + chat_history = chat_history or [] + + # 获取已生成的报告内容 + report_content = "" + try: + report = ReportManager.get_report_by_simulation(self.simulation_id) + if report and report.markdown_content: + # 限制报告长度,避免上下文过长 + report_content = report.markdown_content[:15000] + if len(report.markdown_content) > 15000: + report_content += "\n\n... [报告内容已截断] ..." + except Exception as e: + logger.warning(t('report.fetchReportFailed', error=e)) + + system_prompt = CHAT_SYSTEM_PROMPT_TEMPLATE.format( + simulation_requirement=self.simulation_requirement, + report_content=report_content if report_content else "(暂无报告)", + tools_description=self._get_tools_description(), + ) + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}" + + # 构建消息 + messages = [{"role": "system", "content": system_prompt}] + + # 添加历史对话 + for h in chat_history[-10:]: # 限制历史长度 + messages.append(h) + + # 添加用户消息 + messages.append({ + "role": "user", + "content": message + }) + + # ReACT循环(简化版) + tool_calls_made = [] + max_iterations = 2 # 减少迭代轮数 + + for iteration in range(max_iterations): + response = self.llm.chat( + messages=messages, + temperature=0.5 + ) + + # 解析工具调用 + tool_calls = self._parse_tool_calls(response) + + if not tool_calls: + # 没有工具调用,直接返回响应 + clean_response = re.sub(r'.*?', '', response, flags=re.DOTALL) + clean_response = re.sub(r'\[TOOL_CALL\].*?\)', '', clean_response) + + return { + "response": clean_response.strip(), + "tool_calls": tool_calls_made, + "sources": [tc.get("parameters", {}).get("query", "") for tc in tool_calls_made] + } + + # 执行工具调用(限制数量) + tool_results = [] + for call in tool_calls[:1]: # 每轮最多执行1次工具调用 + if len(tool_calls_made) >= self.MAX_TOOL_CALLS_PER_CHAT: + break + result = self._execute_tool(call["name"], call.get("parameters", {})) + tool_results.append({ + "tool": call["name"], + "result": result[:1500] # 限制结果长度 + }) + tool_calls_made.append(call) + + # 将结果添加到消息 + messages.append({"role": "assistant", "content": response}) + observation = "\n".join([f"[{r['tool']}结果]\n{r['result']}" for r in tool_results]) + messages.append({ + "role": "user", + "content": observation + CHAT_OBSERVATION_SUFFIX + }) + + # 达到最大迭代,获取最终响应 + final_response = self.llm.chat( + messages=messages, + temperature=0.5 + ) + + # 清理响应 + clean_response = re.sub(r'.*?', '', final_response, flags=re.DOTALL) + clean_response = re.sub(r'\[TOOL_CALL\].*?\)', '', clean_response) + + return { + "response": clean_response.strip(), + "tool_calls": tool_calls_made, + "sources": [tc.get("parameters", {}).get("query", "") for tc in tool_calls_made] + } + + +class ReportManager: + """ + 报告管理器 + + 负责报告的持久化存储和检索 + + 文件结构(分章节输出): + reports/ + {report_id}/ + meta.json - 报告元信息和状态 + outline.json - 报告大纲 + progress.json - 生成进度 + section_01.md - 第1章节 + section_02.md - 第2章节 + ... + full_report.md - 完整报告 + """ + + # 报告存储目录 + REPORTS_DIR = os.path.join(Config.UPLOAD_FOLDER, 'reports') + + @classmethod + def _ensure_reports_dir(cls): + """确保报告根目录存在""" + os.makedirs(cls.REPORTS_DIR, exist_ok=True) + + @classmethod + def _get_report_folder(cls, report_id: str) -> str: + """获取报告文件夹路径""" + return os.path.join(cls.REPORTS_DIR, report_id) + + @classmethod + def _ensure_report_folder(cls, report_id: str) -> str: + """确保报告文件夹存在并返回路径""" + folder = cls._get_report_folder(report_id) + os.makedirs(folder, exist_ok=True) + return folder + + @classmethod + def _get_report_path(cls, report_id: str) -> str: + """获取报告元信息文件路径""" + return os.path.join(cls._get_report_folder(report_id), "meta.json") + + @classmethod + def _get_report_markdown_path(cls, report_id: str) -> str: + """获取完整报告Markdown文件路径""" + return os.path.join(cls._get_report_folder(report_id), "full_report.md") + + @classmethod + def _get_outline_path(cls, report_id: str) -> str: + """获取大纲文件路径""" + return os.path.join(cls._get_report_folder(report_id), "outline.json") + + @classmethod + def _get_progress_path(cls, report_id: str) -> str: + """获取进度文件路径""" + return os.path.join(cls._get_report_folder(report_id), "progress.json") + + @classmethod + def _get_section_path(cls, report_id: str, section_index: int) -> str: + """获取章节Markdown文件路径""" + return os.path.join(cls._get_report_folder(report_id), f"section_{section_index:02d}.md") + + @classmethod + def _get_agent_log_path(cls, report_id: str) -> str: + """获取 Agent 日志文件路径""" + return os.path.join(cls._get_report_folder(report_id), "agent_log.jsonl") + + @classmethod + def _get_console_log_path(cls, report_id: str) -> str: + """获取控制台日志文件路径""" + return os.path.join(cls._get_report_folder(report_id), "console_log.txt") + + @classmethod + def get_console_log(cls, report_id: str, from_line: int = 0) -> Dict[str, Any]: + """ + 获取控制台日志内容 + + 这是报告生成过程中的控制台输出日志(INFO、WARNING等), + 与 agent_log.jsonl 的结构化日志不同。 + + Args: + report_id: 报告ID + from_line: 从第几行开始读取(用于增量获取,0 表示从头开始) + + Returns: + { + "logs": [日志行列表], + "total_lines": 总行数, + "from_line": 起始行号, + "has_more": 是否还有更多日志 + } + """ + log_path = cls._get_console_log_path(report_id) + + if not os.path.exists(log_path): + return { + "logs": [], + "total_lines": 0, + "from_line": 0, + "has_more": False + } + + logs = [] + total_lines = 0 + + with open(log_path, 'r', encoding='utf-8') as f: + for i, line in enumerate(f): + total_lines = i + 1 + if i >= from_line: + # 保留原始日志行,去掉末尾换行符 + logs.append(line.rstrip('\n\r')) + + return { + "logs": logs, + "total_lines": total_lines, + "from_line": from_line, + "has_more": False # 已读取到末尾 + } + + @classmethod + def get_console_log_stream(cls, report_id: str) -> List[str]: + """ + 获取完整的控制台日志(一次性获取全部) + + Args: + report_id: 报告ID + + Returns: + 日志行列表 + """ + result = cls.get_console_log(report_id, from_line=0) + return result["logs"] + + @classmethod + def get_agent_log(cls, report_id: str, from_line: int = 0) -> Dict[str, Any]: + """ + 获取 Agent 日志内容 + + Args: + report_id: 报告ID + from_line: 从第几行开始读取(用于增量获取,0 表示从头开始) + + Returns: + { + "logs": [日志条目列表], + "total_lines": 总行数, + "from_line": 起始行号, + "has_more": 是否还有更多日志 + } + """ + log_path = cls._get_agent_log_path(report_id) + + if not os.path.exists(log_path): + return { + "logs": [], + "total_lines": 0, + "from_line": 0, + "has_more": False + } + + logs = [] + total_lines = 0 + + with open(log_path, 'r', encoding='utf-8') as f: + for i, line in enumerate(f): + total_lines = i + 1 + if i >= from_line: + try: + log_entry = json.loads(line.strip()) + logs.append(log_entry) + except json.JSONDecodeError: + # 跳过解析失败的行 + continue + + return { + "logs": logs, + "total_lines": total_lines, + "from_line": from_line, + "has_more": False # 已读取到末尾 + } + + @classmethod + def get_agent_log_stream(cls, report_id: str) -> List[Dict[str, Any]]: + """ + 获取完整的 Agent 日志(用于一次性获取全部) + + Args: + report_id: 报告ID + + Returns: + 日志条目列表 + """ + result = cls.get_agent_log(report_id, from_line=0) + return result["logs"] + + @classmethod + def save_outline(cls, report_id: str, outline: ReportOutline) -> None: + """ + 保存报告大纲 + + 在规划阶段完成后立即调用 + """ + cls._ensure_report_folder(report_id) + + with open(cls._get_outline_path(report_id), 'w', encoding='utf-8') as f: + json.dump(outline.to_dict(), f, ensure_ascii=False, indent=2) + + logger.info(t('report.outlineSaved', reportId=report_id)) + + @classmethod + def save_section( + cls, + report_id: str, + section_index: int, + section: ReportSection + ) -> str: + """ + 保存单个章节 + + 在每个章节生成完成后立即调用,实现分章节输出 + + Args: + report_id: 报告ID + section_index: 章节索引(从1开始) + section: 章节对象 + + Returns: + 保存的文件路径 + """ + cls._ensure_report_folder(report_id) + + # 构建章节Markdown内容 - 清理可能存在的重复标题 + cleaned_content = cls._clean_section_content(section.content, section.title) + md_content = f"## {section.title}\n\n" + if cleaned_content: + md_content += f"{cleaned_content}\n\n" + + # 保存文件 + file_suffix = f"section_{section_index:02d}.md" + file_path = os.path.join(cls._get_report_folder(report_id), file_suffix) + with open(file_path, 'w', encoding='utf-8') as f: + f.write(md_content) + + logger.info(t('report.sectionFileSaved', reportId=report_id, fileSuffix=file_suffix)) + return file_path + + @classmethod + def _clean_section_content(cls, content: str, section_title: str) -> str: + """ + 清理章节内容 + + 1. 移除内容开头与章节标题重复的Markdown标题行 + 2. 将所有 ### 及以下级别的标题转换为粗体文本 + + Args: + content: 原始内容 + section_title: 章节标题 + + Returns: + 清理后的内容 + """ + import re + + if not content: + return content + + content = content.strip() + lines = content.split('\n') + cleaned_lines = [] + skip_next_empty = False + + for i, line in enumerate(lines): + stripped = line.strip() + + # 检查是否是Markdown标题行 + heading_match = re.match(r'^(#{1,6})\s+(.+)$', stripped) + + if heading_match: + level = len(heading_match.group(1)) + title_text = heading_match.group(2).strip() + + # 检查是否是与章节标题重复的标题(跳过前5行内的重复) + if i < 5: + if title_text == section_title or title_text.replace(' ', '') == section_title.replace(' ', ''): + skip_next_empty = True + continue + + # 将所有级别的标题(#, ##, ###, ####等)转换为粗体 + # 因为章节标题由系统添加,内容中不应有任何标题 + cleaned_lines.append(f"**{title_text}**") + cleaned_lines.append("") # 添加空行 + continue + + # 如果上一行是被跳过的标题,且当前行为空,也跳过 + if skip_next_empty and stripped == '': + skip_next_empty = False + continue + + skip_next_empty = False + cleaned_lines.append(line) + + # 移除开头的空行 + while cleaned_lines and cleaned_lines[0].strip() == '': + cleaned_lines.pop(0) + + # 移除开头的分隔线 + while cleaned_lines and cleaned_lines[0].strip() in ['---', '***', '___']: + cleaned_lines.pop(0) + # 同时移除分隔线后的空行 + while cleaned_lines and cleaned_lines[0].strip() == '': + cleaned_lines.pop(0) + + return '\n'.join(cleaned_lines) + + @classmethod + def update_progress( + cls, + report_id: str, + status: str, + progress: int, + message: str, + current_section: str = None, + completed_sections: List[str] = None + ) -> None: + """ + 更新报告生成进度 + + 前端可以通过读取progress.json获取实时进度 + """ + cls._ensure_report_folder(report_id) + + progress_data = { + "status": status, + "progress": progress, + "message": message, + "current_section": current_section, + "completed_sections": completed_sections or [], + "updated_at": datetime.now().isoformat() + } + + with open(cls._get_progress_path(report_id), 'w', encoding='utf-8') as f: + json.dump(progress_data, f, ensure_ascii=False, indent=2) + + @classmethod + def get_progress(cls, report_id: str) -> Optional[Dict[str, Any]]: + """获取报告生成进度""" + path = cls._get_progress_path(report_id) + + if not os.path.exists(path): + return None + + with open(path, 'r', encoding='utf-8') as f: + return json.load(f) + + @classmethod + def get_generated_sections(cls, report_id: str) -> List[Dict[str, Any]]: + """ + 获取已生成的章节列表 + + 返回所有已保存的章节文件信息 + """ + folder = cls._get_report_folder(report_id) + + if not os.path.exists(folder): + return [] + + sections = [] + for filename in sorted(os.listdir(folder)): + if filename.startswith('section_') and filename.endswith('.md'): + file_path = os.path.join(folder, filename) + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + # 从文件名解析章节索引 + parts = filename.replace('.md', '').split('_') + section_index = int(parts[1]) + + sections.append({ + "filename": filename, + "section_index": section_index, + "content": content + }) + + return sections + + @classmethod + def assemble_full_report(cls, report_id: str, outline: ReportOutline) -> str: + """ + 组装完整报告 + + 从已保存的章节文件组装完整报告,并进行标题清理 + """ + folder = cls._get_report_folder(report_id) + + # 构建报告头部 + md_content = f"# {outline.title}\n\n" + md_content += f"> {outline.summary}\n\n" + md_content += f"---\n\n" + + # 按顺序读取所有章节文件 + sections = cls.get_generated_sections(report_id) + for section_info in sections: + md_content += section_info["content"] + + # 后处理:清理整个报告的标题问题 + md_content = cls._post_process_report(md_content, outline) + + # 保存完整报告 + full_path = cls._get_report_markdown_path(report_id) + with open(full_path, 'w', encoding='utf-8') as f: + f.write(md_content) + + logger.info(t('report.fullReportAssembled', reportId=report_id)) + return md_content + + @classmethod + def _post_process_report(cls, content: str, outline: ReportOutline) -> str: + """ + 后处理报告内容 + + 1. 移除重复的标题 + 2. 保留报告主标题(#)和章节标题(##),移除其他级别的标题(###, ####等) + 3. 清理多余的空行和分隔线 + + Args: + content: 原始报告内容 + outline: 报告大纲 + + Returns: + 处理后的内容 + """ + import re + + lines = content.split('\n') + processed_lines = [] + prev_was_heading = False + + # 收集大纲中的所有章节标题 + section_titles = set() + for section in outline.sections: + section_titles.add(section.title) + + i = 0 + while i < len(lines): + line = lines[i] + stripped = line.strip() + + # 检查是否是标题行 + heading_match = re.match(r'^(#{1,6})\s+(.+)$', stripped) + + if heading_match: + level = len(heading_match.group(1)) + title = heading_match.group(2).strip() + + # 检查是否是重复标题(在连续5行内出现相同内容的标题) + is_duplicate = False + for j in range(max(0, len(processed_lines) - 5), len(processed_lines)): + prev_line = processed_lines[j].strip() + prev_match = re.match(r'^(#{1,6})\s+(.+)$', prev_line) + if prev_match: + prev_title = prev_match.group(2).strip() + if prev_title == title: + is_duplicate = True + break + + if is_duplicate: + # 跳过重复标题及其后的空行 + i += 1 + while i < len(lines) and lines[i].strip() == '': + i += 1 + continue + + # 标题层级处理: + # - # (level=1) 只保留报告主标题 + # - ## (level=2) 保留章节标题 + # - ### 及以下 (level>=3) 转换为粗体文本 + + if level == 1: + if title == outline.title: + # 保留报告主标题 + processed_lines.append(line) + prev_was_heading = True + elif title in section_titles: + # 章节标题错误使用了#,修正为## + processed_lines.append(f"## {title}") + prev_was_heading = True + else: + # 其他一级标题转为粗体 + processed_lines.append(f"**{title}**") + processed_lines.append("") + prev_was_heading = False + elif level == 2: + if title in section_titles or title == outline.title: + # 保留章节标题 + processed_lines.append(line) + prev_was_heading = True + else: + # 非章节的二级标题转为粗体 + processed_lines.append(f"**{title}**") + processed_lines.append("") + prev_was_heading = False + else: + # ### 及以下级别的标题转换为粗体文本 + processed_lines.append(f"**{title}**") + processed_lines.append("") + prev_was_heading = False + + i += 1 + continue + + elif stripped == '---' and prev_was_heading: + # 跳过标题后紧跟的分隔线 + i += 1 + continue + + elif stripped == '' and prev_was_heading: + # 标题后只保留一个空行 + if processed_lines and processed_lines[-1].strip() != '': + processed_lines.append(line) + prev_was_heading = False + + else: + processed_lines.append(line) + prev_was_heading = False + + i += 1 + + # 清理连续的多个空行(保留最多2个) + result_lines = [] + empty_count = 0 + for line in processed_lines: + if line.strip() == '': + empty_count += 1 + if empty_count <= 2: + result_lines.append(line) + else: + empty_count = 0 + result_lines.append(line) + + return '\n'.join(result_lines) + + @classmethod + def save_report(cls, report: Report) -> None: + """保存报告元信息和完整报告""" + cls._ensure_report_folder(report.report_id) + + # 保存元信息JSON + with open(cls._get_report_path(report.report_id), 'w', encoding='utf-8') as f: + json.dump(report.to_dict(), f, ensure_ascii=False, indent=2) + + # 保存大纲 + if report.outline: + cls.save_outline(report.report_id, report.outline) + + # 保存完整Markdown报告 + if report.markdown_content: + with open(cls._get_report_markdown_path(report.report_id), 'w', encoding='utf-8') as f: + f.write(report.markdown_content) + + logger.info(t('report.reportSaved', reportId=report.report_id)) + + @classmethod + def get_report(cls, report_id: str) -> Optional[Report]: + """获取报告""" + path = cls._get_report_path(report_id) + + if not os.path.exists(path): + # 兼容旧格式:检查直接存储在reports目录下的文件 + old_path = os.path.join(cls.REPORTS_DIR, f"{report_id}.json") + if os.path.exists(old_path): + path = old_path + else: + return None + + with open(path, 'r', encoding='utf-8') as f: + data = json.load(f) + + # 重建Report对象 + outline = None + if data.get('outline'): + outline_data = data['outline'] + sections = [] + for s in outline_data.get('sections', []): + sections.append(ReportSection( + title=s['title'], + content=s.get('content', '') + )) + outline = ReportOutline( + title=outline_data['title'], + summary=outline_data['summary'], + sections=sections + ) + + # 如果markdown_content为空,尝试从full_report.md读取 + markdown_content = data.get('markdown_content', '') + if not markdown_content: + full_report_path = cls._get_report_markdown_path(report_id) + if os.path.exists(full_report_path): + with open(full_report_path, 'r', encoding='utf-8') as f: + markdown_content = f.read() + + return Report( + report_id=data['report_id'], + simulation_id=data['simulation_id'], + graph_id=data['graph_id'], + simulation_requirement=data['simulation_requirement'], + status=ReportStatus(data['status']), + outline=outline, + markdown_content=markdown_content, + created_at=data.get('created_at', ''), + completed_at=data.get('completed_at', ''), + error=data.get('error') + ) + + @classmethod + def get_report_by_simulation(cls, simulation_id: str) -> Optional[Report]: + """根据模拟ID获取报告""" + cls._ensure_reports_dir() + + for item in os.listdir(cls.REPORTS_DIR): + item_path = os.path.join(cls.REPORTS_DIR, item) + # 新格式:文件夹 + if os.path.isdir(item_path): + report = cls.get_report(item) + if report and report.simulation_id == simulation_id: + return report + # 兼容旧格式:JSON文件 + elif item.endswith('.json'): + report_id = item[:-5] + report = cls.get_report(report_id) + if report and report.simulation_id == simulation_id: + return report + + return None + + @classmethod + def list_reports(cls, simulation_id: Optional[str] = None, limit: int = 50) -> List[Report]: + """列出报告""" + cls._ensure_reports_dir() + + reports = [] + for item in os.listdir(cls.REPORTS_DIR): + item_path = os.path.join(cls.REPORTS_DIR, item) + # 新格式:文件夹 + if os.path.isdir(item_path): + report = cls.get_report(item) + if report: + if simulation_id is None or report.simulation_id == simulation_id: + reports.append(report) + # 兼容旧格式:JSON文件 + elif item.endswith('.json'): + report_id = item[:-5] + report = cls.get_report(report_id) + if report: + if simulation_id is None or report.simulation_id == simulation_id: + reports.append(report) + + # 按创建时间倒序 + reports.sort(key=lambda r: r.created_at, reverse=True) + + return reports[:limit] + + @classmethod + def delete_report(cls, report_id: str) -> bool: + """删除报告(整个文件夹)""" + import shutil + + folder_path = cls._get_report_folder(report_id) + + # 新格式:删除整个文件夹 + if os.path.exists(folder_path) and os.path.isdir(folder_path): + shutil.rmtree(folder_path) + logger.info(t('report.reportFolderDeleted', reportId=report_id)) + return True + + # 兼容旧格式:删除单独的文件 + deleted = False + old_json_path = os.path.join(cls.REPORTS_DIR, f"{report_id}.json") + old_md_path = os.path.join(cls.REPORTS_DIR, f"{report_id}.md") + + if os.path.exists(old_json_path): + os.remove(old_json_path) + deleted = True + if os.path.exists(old_md_path): + os.remove(old_md_path) + deleted = True + + return deleted diff --git a/backend/app/services/simulation_config_generator.py b/backend/app/services/simulation_config_generator.py new file mode 100644 index 00000000..cb77f6b6 --- /dev/null +++ b/backend/app/services/simulation_config_generator.py @@ -0,0 +1,991 @@ +""" +模拟配置智能生成器 +使用LLM根据模拟需求、文档内容、图谱信息自动生成细致的模拟参数 +实现全程自动化,无需人工设置参数 + +采用分步生成策略,避免一次性生成过长内容导致失败: +1. 生成时间配置 +2. 生成事件配置 +3. 分批生成Agent配置 +4. 生成平台配置 +""" + +import json +import math +from typing import Dict, Any, List, Optional, Callable +from dataclasses import dataclass, field, asdict +from datetime import datetime + +from openai import OpenAI + +from ..config import Config +from ..utils.logger import get_logger +from ..utils.locale import get_language_instruction, t +from .zep_entity_reader import EntityNode, ZepEntityReader + +logger = get_logger('mirofish.simulation_config') + +# 中国作息时间配置(北京时间) +CHINA_TIMEZONE_CONFIG = { + # 深夜时段(几乎无人活动) + "dead_hours": [0, 1, 2, 3, 4, 5], + # 早间时段(逐渐醒来) + "morning_hours": [6, 7, 8], + # 工作时段 + "work_hours": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], + # 晚间高峰(最活跃) + "peak_hours": [19, 20, 21, 22], + # 夜间时段(活跃度下降) + "night_hours": [23], + # 活跃度系数 + "activity_multipliers": { + "dead": 0.05, # 凌晨几乎无人 + "morning": 0.4, # 早间逐渐活跃 + "work": 0.7, # 工作时段中等 + "peak": 1.5, # 晚间高峰 + "night": 0.5 # 深夜下降 + } +} + + +@dataclass +class AgentActivityConfig: + """单个Agent的活动配置""" + agent_id: int + entity_uuid: str + entity_name: str + entity_type: str + + # 活跃度配置 (0.0-1.0) + activity_level: float = 0.5 # 整体活跃度 + + # 发言频率(每小时预期发言次数) + posts_per_hour: float = 1.0 + comments_per_hour: float = 2.0 + + # 活跃时间段(24小时制,0-23) + active_hours: List[int] = field(default_factory=lambda: list(range(8, 23))) + + # 响应速度(对热点事件的反应延迟,单位:模拟分钟) + response_delay_min: int = 5 + response_delay_max: int = 60 + + # 情感倾向 (-1.0到1.0,负面到正面) + sentiment_bias: float = 0.0 + + # 立场(对特定话题的态度) + stance: str = "neutral" # supportive, opposing, neutral, observer + + # 影响力权重(决定其发言被其他Agent看到的概率) + influence_weight: float = 1.0 + + +@dataclass +class TimeSimulationConfig: + """时间模拟配置(基于中国人作息习惯)""" + # 模拟总时长(模拟小时数) + total_simulation_hours: int = 72 # 默认模拟72小时(3天) + + # 每轮代表的时间(模拟分钟)- 默认60分钟(1小时),加快时间流速 + minutes_per_round: int = 60 + + # 每小时激活的Agent数量范围 + agents_per_hour_min: int = 5 + agents_per_hour_max: int = 20 + + # 高峰时段(晚间19-22点,中国人最活跃的时间) + peak_hours: List[int] = field(default_factory=lambda: [19, 20, 21, 22]) + peak_activity_multiplier: float = 1.5 + + # 低谷时段(凌晨0-5点,几乎无人活动) + off_peak_hours: List[int] = field(default_factory=lambda: [0, 1, 2, 3, 4, 5]) + off_peak_activity_multiplier: float = 0.05 # 凌晨活跃度极低 + + # 早间时段 + morning_hours: List[int] = field(default_factory=lambda: [6, 7, 8]) + morning_activity_multiplier: float = 0.4 + + # 工作时段 + work_hours: List[int] = field(default_factory=lambda: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) + work_activity_multiplier: float = 0.7 + + +@dataclass +class EventConfig: + """事件配置""" + # 初始事件(模拟开始时的触发事件) + initial_posts: List[Dict[str, Any]] = field(default_factory=list) + + # 定时事件(在特定时间触发的事件) + scheduled_events: List[Dict[str, Any]] = field(default_factory=list) + + # 热点话题关键词 + hot_topics: List[str] = field(default_factory=list) + + # 舆论引导方向 + narrative_direction: str = "" + + +@dataclass +class PlatformConfig: + """平台特定配置""" + platform: str # twitter or reddit + + # 推荐算法权重 + recency_weight: float = 0.4 # 时间新鲜度 + popularity_weight: float = 0.3 # 热度 + relevance_weight: float = 0.3 # 相关性 + + # 病毒传播阈值(达到多少互动后触发扩散) + viral_threshold: int = 10 + + # 回声室效应强度(相似观点聚集程度) + echo_chamber_strength: float = 0.5 + + +@dataclass +class SimulationParameters: + """完整的模拟参数配置""" + # 基础信息 + simulation_id: str + project_id: str + graph_id: str + simulation_requirement: str + + # 时间配置 + time_config: TimeSimulationConfig = field(default_factory=TimeSimulationConfig) + + # Agent配置列表 + agent_configs: List[AgentActivityConfig] = field(default_factory=list) + + # 事件配置 + event_config: EventConfig = field(default_factory=EventConfig) + + # 平台配置 + twitter_config: Optional[PlatformConfig] = None + reddit_config: Optional[PlatformConfig] = None + + # LLM配置 + llm_model: str = "" + llm_base_url: str = "" + + # 生成元数据 + generated_at: str = field(default_factory=lambda: datetime.now().isoformat()) + generation_reasoning: str = "" # LLM的推理说明 + + def to_dict(self) -> Dict[str, Any]: + """转换为字典""" + time_dict = asdict(self.time_config) + return { + "simulation_id": self.simulation_id, + "project_id": self.project_id, + "graph_id": self.graph_id, + "simulation_requirement": self.simulation_requirement, + "time_config": time_dict, + "agent_configs": [asdict(a) for a in self.agent_configs], + "event_config": asdict(self.event_config), + "twitter_config": asdict(self.twitter_config) if self.twitter_config else None, + "reddit_config": asdict(self.reddit_config) if self.reddit_config else None, + "llm_model": self.llm_model, + "llm_base_url": self.llm_base_url, + "generated_at": self.generated_at, + "generation_reasoning": self.generation_reasoning, + } + + def to_json(self, indent: int = 2) -> str: + """转换为JSON字符串""" + return json.dumps(self.to_dict(), ensure_ascii=False, indent=indent) + + +class SimulationConfigGenerator: + """ + 模拟配置智能生成器 + + 使用LLM分析模拟需求、文档内容、图谱实体信息, + 自动生成最佳的模拟参数配置 + + 采用分步生成策略: + 1. 生成时间配置和事件配置(轻量级) + 2. 分批生成Agent配置(每批10-20个) + 3. 生成平台配置 + """ + + # 上下文最大字符数 + MAX_CONTEXT_LENGTH = 50000 + # 每批生成的Agent数量 + AGENTS_PER_BATCH = 15 + + # 各步骤的上下文截断长度(字符数) + TIME_CONFIG_CONTEXT_LENGTH = 10000 # 时间配置 + EVENT_CONFIG_CONTEXT_LENGTH = 8000 # 事件配置 + ENTITY_SUMMARY_LENGTH = 300 # 实体摘要 + AGENT_SUMMARY_LENGTH = 300 # Agent配置中的实体摘要 + ENTITIES_PER_TYPE_DISPLAY = 20 # 每类实体显示数量 + + def __init__( + self, + api_key: Optional[str] = None, + base_url: Optional[str] = None, + model_name: Optional[str] = None + ): + self.api_key = api_key or Config.LLM_API_KEY + self.base_url = base_url or Config.LLM_BASE_URL + self.model_name = model_name or Config.LLM_MODEL_NAME + + if not self.api_key: + raise ValueError("LLM_API_KEY 未配置") + + self.client = OpenAI( + api_key=self.api_key, + base_url=self.base_url + ) + + def generate_config( + self, + simulation_id: str, + project_id: str, + graph_id: str, + simulation_requirement: str, + document_text: str, + entities: List[EntityNode], + enable_twitter: bool = True, + enable_reddit: bool = True, + progress_callback: Optional[Callable[[int, int, str], None]] = None, + ) -> SimulationParameters: + """ + 智能生成完整的模拟配置(分步生成) + + Args: + simulation_id: 模拟ID + project_id: 项目ID + graph_id: 图谱ID + simulation_requirement: 模拟需求描述 + document_text: 原始文档内容 + entities: 过滤后的实体列表 + enable_twitter: 是否启用Twitter + enable_reddit: 是否启用Reddit + progress_callback: 进度回调函数(current_step, total_steps, message) + + Returns: + SimulationParameters: 完整的模拟参数 + """ + logger.info(f"开始智能生成模拟配置: simulation_id={simulation_id}, 实体数={len(entities)}") + + # 计算总步骤数 + num_batches = math.ceil(len(entities) / self.AGENTS_PER_BATCH) + total_steps = 3 + num_batches # 时间配置 + 事件配置 + N批Agent + 平台配置 + current_step = 0 + + def report_progress(step: int, message: str): + nonlocal current_step + current_step = step + if progress_callback: + progress_callback(step, total_steps, message) + logger.info(f"[{step}/{total_steps}] {message}") + + # 1. 构建基础上下文信息 + context = self._build_context( + simulation_requirement=simulation_requirement, + document_text=document_text, + entities=entities + ) + + reasoning_parts = [] + + # ========== 步骤1: 生成时间配置 ========== + report_progress(1, t('progress.generatingTimeConfig')) + num_entities = len(entities) + time_config_result = self._generate_time_config(context, num_entities) + time_config = self._parse_time_config(time_config_result, num_entities) + reasoning_parts.append(f"{t('progress.timeConfigLabel')}: {time_config_result.get('reasoning', t('common.success'))}") + + # ========== 步骤2: 生成事件配置 ========== + report_progress(2, t('progress.generatingEventConfig')) + event_config_result = self._generate_event_config(context, simulation_requirement, entities) + event_config = self._parse_event_config(event_config_result) + reasoning_parts.append(f"{t('progress.eventConfigLabel')}: {event_config_result.get('reasoning', t('common.success'))}") + + # ========== 步骤3-N: 分批生成Agent配置 ========== + all_agent_configs = [] + for batch_idx in range(num_batches): + start_idx = batch_idx * self.AGENTS_PER_BATCH + end_idx = min(start_idx + self.AGENTS_PER_BATCH, len(entities)) + batch_entities = entities[start_idx:end_idx] + + report_progress( + 3 + batch_idx, + t('progress.generatingAgentConfig', start=start_idx + 1, end=end_idx, total=len(entities)) + ) + + batch_configs = self._generate_agent_configs_batch( + context=context, + entities=batch_entities, + start_idx=start_idx, + simulation_requirement=simulation_requirement + ) + all_agent_configs.extend(batch_configs) + + reasoning_parts.append(t('progress.agentConfigResult', count=len(all_agent_configs))) + + # ========== 为初始帖子分配发布者 Agent ========== + logger.info("为初始帖子分配合适的发布者 Agent...") + event_config = self._assign_initial_post_agents(event_config, all_agent_configs) + assigned_count = len([p for p in event_config.initial_posts if p.get("poster_agent_id") is not None]) + reasoning_parts.append(t('progress.postAssignResult', count=assigned_count)) + + # ========== 最后一步: 生成平台配置 ========== + report_progress(total_steps, t('progress.generatingPlatformConfig')) + twitter_config = None + reddit_config = None + + if enable_twitter: + twitter_config = PlatformConfig( + platform="twitter", + recency_weight=0.4, + popularity_weight=0.3, + relevance_weight=0.3, + viral_threshold=10, + echo_chamber_strength=0.5 + ) + + if enable_reddit: + reddit_config = PlatformConfig( + platform="reddit", + recency_weight=0.3, + popularity_weight=0.4, + relevance_weight=0.3, + viral_threshold=15, + echo_chamber_strength=0.6 + ) + + # 构建最终参数 + params = SimulationParameters( + simulation_id=simulation_id, + project_id=project_id, + graph_id=graph_id, + simulation_requirement=simulation_requirement, + time_config=time_config, + agent_configs=all_agent_configs, + event_config=event_config, + twitter_config=twitter_config, + reddit_config=reddit_config, + llm_model=self.model_name, + llm_base_url=self.base_url, + generation_reasoning=" | ".join(reasoning_parts) + ) + + logger.info(f"模拟配置生成完成: {len(params.agent_configs)} 个Agent配置") + + return params + + def _build_context( + self, + simulation_requirement: str, + document_text: str, + entities: List[EntityNode] + ) -> str: + """构建LLM上下文,截断到最大长度""" + + # 实体摘要 + entity_summary = self._summarize_entities(entities) + + # 构建上下文 + context_parts = [ + f"## 模拟需求\n{simulation_requirement}", + f"\n## 实体信息 ({len(entities)}个)\n{entity_summary}", + ] + + current_length = sum(len(p) for p in context_parts) + remaining_length = self.MAX_CONTEXT_LENGTH - current_length - 500 # 留500字符余量 + + if remaining_length > 0 and document_text: + doc_text = document_text[:remaining_length] + if len(document_text) > remaining_length: + doc_text += "\n...(文档已截断)" + context_parts.append(f"\n## 原始文档内容\n{doc_text}") + + return "\n".join(context_parts) + + def _summarize_entities(self, entities: List[EntityNode]) -> str: + """生成实体摘要""" + lines = [] + + # 按类型分组 + by_type: Dict[str, List[EntityNode]] = {} + for e in entities: + t = e.get_entity_type() or "Unknown" + if t not in by_type: + by_type[t] = [] + by_type[t].append(e) + + for entity_type, type_entities in by_type.items(): + lines.append(f"\n### {entity_type} ({len(type_entities)}个)") + # 使用配置的显示数量和摘要长度 + display_count = self.ENTITIES_PER_TYPE_DISPLAY + summary_len = self.ENTITY_SUMMARY_LENGTH + for e in type_entities[:display_count]: + summary_preview = (e.summary[:summary_len] + "...") if len(e.summary) > summary_len else e.summary + lines.append(f"- {e.name}: {summary_preview}") + if len(type_entities) > display_count: + lines.append(f" ... 还有 {len(type_entities) - display_count} 个") + + return "\n".join(lines) + + def _call_llm_with_retry(self, prompt: str, system_prompt: str) -> Dict[str, Any]: + """带重试的LLM调用,包含JSON修复逻辑""" + import re + + max_attempts = 3 + last_error = None + + for attempt in range(max_attempts): + try: + response = self.client.chat.completions.create( + model=self.model_name, + messages=[ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": prompt} + ], + response_format={"type": "json_object"}, + temperature=0.7 - (attempt * 0.1) # 每次重试降低温度 + # 不设置max_tokens,让LLM自由发挥 + ) + + content = response.choices[0].message.content + finish_reason = response.choices[0].finish_reason + + # 检查是否被截断 + if finish_reason == 'length': + logger.warning(f"LLM输出被截断 (attempt {attempt+1})") + content = self._fix_truncated_json(content) + + # 尝试解析JSON + try: + return json.loads(content) + except json.JSONDecodeError as e: + logger.warning(f"JSON解析失败 (attempt {attempt+1}): {str(e)[:80]}") + + # 尝试修复JSON + fixed = self._try_fix_config_json(content) + if fixed: + return fixed + + last_error = e + + except Exception as e: + logger.warning(f"LLM调用失败 (attempt {attempt+1}): {str(e)[:80]}") + last_error = e + import time + time.sleep(2 * (attempt + 1)) + + raise last_error or Exception("LLM调用失败") + + def _fix_truncated_json(self, content: str) -> str: + """修复被截断的JSON""" + content = content.strip() + + # 计算未闭合的括号 + open_braces = content.count('{') - content.count('}') + open_brackets = content.count('[') - content.count(']') + + # 检查是否有未闭合的字符串 + if content and content[-1] not in '",}]': + content += '"' + + # 闭合括号 + content += ']' * open_brackets + content += '}' * open_braces + + return content + + def _try_fix_config_json(self, content: str) -> Optional[Dict[str, Any]]: + """尝试修复配置JSON""" + import re + + # 修复被截断的情况 + content = self._fix_truncated_json(content) + + # 提取JSON部分 + json_match = re.search(r'\{[\s\S]*\}', content) + if json_match: + json_str = json_match.group() + + # 移除字符串中的换行符 + def fix_string(match): + s = match.group(0) + s = s.replace('\n', ' ').replace('\r', ' ') + s = re.sub(r'\s+', ' ', s) + return s + + json_str = re.sub(r'"[^"\\]*(?:\\.[^"\\]*)*"', fix_string, json_str) + + try: + return json.loads(json_str) + except: + # 尝试移除所有控制字符 + json_str = re.sub(r'[\x00-\x1f\x7f-\x9f]', ' ', json_str) + json_str = re.sub(r'\s+', ' ', json_str) + try: + return json.loads(json_str) + except: + pass + + return None + + def _generate_time_config(self, context: str, num_entities: int) -> Dict[str, Any]: + """生成时间配置""" + # 使用配置的上下文截断长度 + context_truncated = context[:self.TIME_CONFIG_CONTEXT_LENGTH] + + # 计算最大允许值(80%的agent数) + max_agents_allowed = max(1, int(num_entities * 0.9)) + + prompt = f"""基于以下模拟需求,生成时间模拟配置。 + +{context_truncated} + +## 任务 +请生成时间配置JSON。 + +### 基本原则(仅供参考,需根据具体事件和参与群体灵活调整): +- 请根据模拟场景推断目标用户群体所在时区和作息习惯,以下为东八区(UTC+8)的参考示例 +- 凌晨0-5点几乎无人活动(活跃度系数0.05) +- 早上6-8点逐渐活跃(活跃度系数0.4) +- 工作时间9-18点中等活跃(活跃度系数0.7) +- 晚间19-22点是高峰期(活跃度系数1.5) +- 23点后活跃度下降(活跃度系数0.5) +- 一般规律:凌晨低活跃、早间渐增、工作时段中等、晚间高峰 +- **重要**:以下示例值仅供参考,你需要根据事件性质、参与群体特点来调整具体时段 + - 例如:学生群体高峰可能是21-23点;媒体全天活跃;官方机构只在工作时间 + - 例如:突发热点可能导致深夜也有讨论,off_peak_hours 可适当缩短 + +### 返回JSON格式(不要markdown) + +示例: +{{ + "total_simulation_hours": 72, + "minutes_per_round": 60, + "agents_per_hour_min": 5, + "agents_per_hour_max": 50, + "peak_hours": [19, 20, 21, 22], + "off_peak_hours": [0, 1, 2, 3, 4, 5], + "morning_hours": [6, 7, 8], + "work_hours": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], + "reasoning": "针对该事件的时间配置说明" +}} + +字段说明: +- total_simulation_hours (int): 模拟总时长,24-168小时,突发事件短、持续话题长 +- minutes_per_round (int): 每轮时长,30-120分钟,建议60分钟 +- agents_per_hour_min (int): 每小时最少激活Agent数(取值范围: 1-{max_agents_allowed}) +- agents_per_hour_max (int): 每小时最多激活Agent数(取值范围: 1-{max_agents_allowed}) +- peak_hours (int数组): 高峰时段,根据事件参与群体调整 +- off_peak_hours (int数组): 低谷时段,通常深夜凌晨 +- morning_hours (int数组): 早间时段 +- work_hours (int数组): 工作时段 +- reasoning (string): 简要说明为什么这样配置""" + + system_prompt = "你是社交媒体模拟专家。返回纯JSON格式,时间配置需符合模拟场景中目标用户群体的作息习惯。" + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}" + + try: + return self._call_llm_with_retry(prompt, system_prompt) + except Exception as e: + logger.warning(f"时间配置LLM生成失败: {e}, 使用默认配置") + return self._get_default_time_config(num_entities) + + def _get_default_time_config(self, num_entities: int) -> Dict[str, Any]: + """获取默认时间配置(中国人作息)""" + return { + "total_simulation_hours": 72, + "minutes_per_round": 60, # 每轮1小时,加快时间流速 + "agents_per_hour_min": max(1, num_entities // 15), + "agents_per_hour_max": max(5, num_entities // 5), + "peak_hours": [19, 20, 21, 22], + "off_peak_hours": [0, 1, 2, 3, 4, 5], + "morning_hours": [6, 7, 8], + "work_hours": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], + "reasoning": "使用默认中国人作息配置(每轮1小时)" + } + + def _parse_time_config(self, result: Dict[str, Any], num_entities: int) -> TimeSimulationConfig: + """解析时间配置结果,并验证agents_per_hour值不超过总agent数""" + # 获取原始值 + agents_per_hour_min = result.get("agents_per_hour_min", max(1, num_entities // 15)) + agents_per_hour_max = result.get("agents_per_hour_max", max(5, num_entities // 5)) + + # 验证并修正:确保不超过总agent数 + if agents_per_hour_min > num_entities: + logger.warning(f"agents_per_hour_min ({agents_per_hour_min}) 超过总Agent数 ({num_entities}),已修正") + agents_per_hour_min = max(1, num_entities // 10) + + if agents_per_hour_max > num_entities: + logger.warning(f"agents_per_hour_max ({agents_per_hour_max}) 超过总Agent数 ({num_entities}),已修正") + agents_per_hour_max = max(agents_per_hour_min + 1, num_entities // 2) + + # 确保 min < max + if agents_per_hour_min >= agents_per_hour_max: + agents_per_hour_min = max(1, agents_per_hour_max // 2) + logger.warning(f"agents_per_hour_min >= max,已修正为 {agents_per_hour_min}") + + return TimeSimulationConfig( + total_simulation_hours=result.get("total_simulation_hours", 72), + minutes_per_round=result.get("minutes_per_round", 60), # 默认每轮1小时 + agents_per_hour_min=agents_per_hour_min, + agents_per_hour_max=agents_per_hour_max, + peak_hours=result.get("peak_hours", [19, 20, 21, 22]), + off_peak_hours=result.get("off_peak_hours", [0, 1, 2, 3, 4, 5]), + off_peak_activity_multiplier=0.05, # 凌晨几乎无人 + morning_hours=result.get("morning_hours", [6, 7, 8]), + morning_activity_multiplier=0.4, + work_hours=result.get("work_hours", list(range(9, 19))), + work_activity_multiplier=0.7, + peak_activity_multiplier=1.5 + ) + + def _generate_event_config( + self, + context: str, + simulation_requirement: str, + entities: List[EntityNode] + ) -> Dict[str, Any]: + """生成事件配置""" + + # 获取可用的实体类型列表,供 LLM 参考 + entity_types_available = list(set( + e.get_entity_type() or "Unknown" for e in entities + )) + + # 为每种类型列出代表性实体名称 + type_examples = {} + for e in entities: + etype = e.get_entity_type() or "Unknown" + if etype not in type_examples: + type_examples[etype] = [] + if len(type_examples[etype]) < 3: + type_examples[etype].append(e.name) + + type_info = "\n".join([ + f"- {t}: {', '.join(examples)}" + for t, examples in type_examples.items() + ]) + + # 使用配置的上下文截断长度 + context_truncated = context[:self.EVENT_CONFIG_CONTEXT_LENGTH] + + prompt = f"""基于以下模拟需求,生成事件配置。 + +模拟需求: {simulation_requirement} + +{context_truncated} + +## 可用实体类型及示例 +{type_info} + +## 任务 +请生成事件配置JSON: +- 提取热点话题关键词 +- 描述舆论发展方向 +- 设计初始帖子内容,**每个帖子必须指定 poster_type(发布者类型)** + +**重要**: poster_type 必须从上面的"可用实体类型"中选择,这样初始帖子才能分配给合适的 Agent 发布。 +例如:官方声明应由 Official/University 类型发布,新闻由 MediaOutlet 发布,学生观点由 Student 发布。 + +返回JSON格式(不要markdown): +{{ + "hot_topics": ["关键词1", "关键词2", ...], + "narrative_direction": "<舆论发展方向描述>", + "initial_posts": [ + {{"content": "帖子内容", "poster_type": "实体类型(必须从可用类型中选择)"}}, + ... + ], + "reasoning": "<简要说明>" +}}""" + + system_prompt = "你是舆论分析专家。返回纯JSON格式。注意 poster_type 必须精确匹配可用实体类型。" + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}\nIMPORTANT: The 'poster_type' field value MUST be in English PascalCase exactly matching the available entity types. Only 'content', 'narrative_direction', 'hot_topics' and 'reasoning' fields should use the specified language." + + try: + return self._call_llm_with_retry(prompt, system_prompt) + except Exception as e: + logger.warning(f"事件配置LLM生成失败: {e}, 使用默认配置") + return { + "hot_topics": [], + "narrative_direction": "", + "initial_posts": [], + "reasoning": "使用默认配置" + } + + def _parse_event_config(self, result: Dict[str, Any]) -> EventConfig: + """解析事件配置结果""" + return EventConfig( + initial_posts=result.get("initial_posts", []), + scheduled_events=[], + hot_topics=result.get("hot_topics", []), + narrative_direction=result.get("narrative_direction", "") + ) + + def _assign_initial_post_agents( + self, + event_config: EventConfig, + agent_configs: List[AgentActivityConfig] + ) -> EventConfig: + """ + 为初始帖子分配合适的发布者 Agent + + 根据每个帖子的 poster_type 匹配最合适的 agent_id + """ + if not event_config.initial_posts: + return event_config + + # 按实体类型建立 agent 索引 + agents_by_type: Dict[str, List[AgentActivityConfig]] = {} + for agent in agent_configs: + etype = agent.entity_type.lower() + if etype not in agents_by_type: + agents_by_type[etype] = [] + agents_by_type[etype].append(agent) + + # 类型映射表(处理 LLM 可能输出的不同格式) + type_aliases = { + "official": ["official", "university", "governmentagency", "government"], + "university": ["university", "official"], + "mediaoutlet": ["mediaoutlet", "media"], + "student": ["student", "person"], + "professor": ["professor", "expert", "teacher"], + "alumni": ["alumni", "person"], + "organization": ["organization", "ngo", "company", "group"], + "person": ["person", "student", "alumni"], + } + + # 记录每种类型已使用的 agent 索引,避免重复使用同一个 agent + used_indices: Dict[str, int] = {} + + updated_posts = [] + for post in event_config.initial_posts: + poster_type = post.get("poster_type", "").lower() + content = post.get("content", "") + + # 尝试找到匹配的 agent + matched_agent_id = None + + # 1. 直接匹配 + if poster_type in agents_by_type: + agents = agents_by_type[poster_type] + idx = used_indices.get(poster_type, 0) % len(agents) + matched_agent_id = agents[idx].agent_id + used_indices[poster_type] = idx + 1 + else: + # 2. 使用别名匹配 + for alias_key, aliases in type_aliases.items(): + if poster_type in aliases or alias_key == poster_type: + for alias in aliases: + if alias in agents_by_type: + agents = agents_by_type[alias] + idx = used_indices.get(alias, 0) % len(agents) + matched_agent_id = agents[idx].agent_id + used_indices[alias] = idx + 1 + break + if matched_agent_id is not None: + break + + # 3. 如果仍未找到,使用影响力最高的 agent + if matched_agent_id is None: + logger.warning(f"未找到类型 '{poster_type}' 的匹配 Agent,使用影响力最高的 Agent") + if agent_configs: + # 按影响力排序,选择影响力最高的 + sorted_agents = sorted(agent_configs, key=lambda a: a.influence_weight, reverse=True) + matched_agent_id = sorted_agents[0].agent_id + else: + matched_agent_id = 0 + + updated_posts.append({ + "content": content, + "poster_type": post.get("poster_type", "Unknown"), + "poster_agent_id": matched_agent_id + }) + + logger.info(f"初始帖子分配: poster_type='{poster_type}' -> agent_id={matched_agent_id}") + + event_config.initial_posts = updated_posts + return event_config + + def _generate_agent_configs_batch( + self, + context: str, + entities: List[EntityNode], + start_idx: int, + simulation_requirement: str + ) -> List[AgentActivityConfig]: + """分批生成Agent配置""" + + # 构建实体信息(使用配置的摘要长度) + entity_list = [] + summary_len = self.AGENT_SUMMARY_LENGTH + for i, e in enumerate(entities): + entity_list.append({ + "agent_id": start_idx + i, + "entity_name": e.name, + "entity_type": e.get_entity_type() or "Unknown", + "summary": e.summary[:summary_len] if e.summary else "" + }) + + prompt = f"""基于以下信息,为每个实体生成社交媒体活动配置。 + +模拟需求: {simulation_requirement} + +## 实体列表 +```json +{json.dumps(entity_list, ensure_ascii=False, indent=2)} +``` + +## 任务 +为每个实体生成活动配置,注意: +- **时间符合目标用户群体作息**:以下为参考(东八区),请根据模拟场景调整 +- **官方机构**(University/GovernmentAgency):活跃度低(0.1-0.3),工作时间(9-17)活动,响应慢(60-240分钟),影响力高(2.5-3.0) +- **媒体**(MediaOutlet):活跃度中(0.4-0.6),全天活动(8-23),响应快(5-30分钟),影响力高(2.0-2.5) +- **个人**(Student/Person/Alumni):活跃度高(0.6-0.9),主要晚间活动(18-23),响应快(1-15分钟),影响力低(0.8-1.2) +- **公众人物/专家**:活跃度中(0.4-0.6),影响力中高(1.5-2.0) + +返回JSON格式(不要markdown): +{{ + "agent_configs": [ + {{ + "agent_id": <必须与输入一致>, + "activity_level": <0.0-1.0>, + "posts_per_hour": <发帖频率>, + "comments_per_hour": <评论频率>, + "active_hours": [<活跃小时列表,考虑中国人作息>], + "response_delay_min": <最小响应延迟分钟>, + "response_delay_max": <最大响应延迟分钟>, + "sentiment_bias": <-1.0到1.0>, + "stance": "", + "influence_weight": <影响力权重> + }}, + ... + ] +}}""" + + system_prompt = "你是社交媒体行为分析专家。返回纯JSON,配置需符合模拟场景中目标用户群体的作息习惯。" + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}\nIMPORTANT: The 'stance' field value MUST be one of the English strings: 'supportive', 'opposing', 'neutral', 'observer'. All JSON field names and numeric values must remain unchanged. Only natural language text fields should use the specified language." + + try: + result = self._call_llm_with_retry(prompt, system_prompt) + llm_configs = {cfg["agent_id"]: cfg for cfg in result.get("agent_configs", [])} + except Exception as e: + logger.warning(f"Agent配置批次LLM生成失败: {e}, 使用规则生成") + llm_configs = {} + + # 构建AgentActivityConfig对象 + configs = [] + for i, entity in enumerate(entities): + agent_id = start_idx + i + cfg = llm_configs.get(agent_id, {}) + + # 如果LLM没有生成,使用规则生成 + if not cfg: + cfg = self._generate_agent_config_by_rule(entity) + + config = AgentActivityConfig( + agent_id=agent_id, + entity_uuid=entity.uuid, + entity_name=entity.name, + entity_type=entity.get_entity_type() or "Unknown", + activity_level=cfg.get("activity_level", 0.5), + posts_per_hour=cfg.get("posts_per_hour", 0.5), + comments_per_hour=cfg.get("comments_per_hour", 1.0), + active_hours=cfg.get("active_hours", list(range(9, 23))), + response_delay_min=cfg.get("response_delay_min", 5), + response_delay_max=cfg.get("response_delay_max", 60), + sentiment_bias=cfg.get("sentiment_bias", 0.0), + stance=cfg.get("stance", "neutral"), + influence_weight=cfg.get("influence_weight", 1.0) + ) + configs.append(config) + + return configs + + def _generate_agent_config_by_rule(self, entity: EntityNode) -> Dict[str, Any]: + """基于规则生成单个Agent配置(中国人作息)""" + entity_type = (entity.get_entity_type() or "Unknown").lower() + + if entity_type in ["university", "governmentagency", "ngo"]: + # 官方机构:工作时间活动,低频率,高影响力 + return { + "activity_level": 0.2, + "posts_per_hour": 0.1, + "comments_per_hour": 0.05, + "active_hours": list(range(9, 18)), # 9:00-17:59 + "response_delay_min": 60, + "response_delay_max": 240, + "sentiment_bias": 0.0, + "stance": "neutral", + "influence_weight": 3.0 + } + elif entity_type in ["mediaoutlet"]: + # 媒体:全天活动,中等频率,高影响力 + return { + "activity_level": 0.5, + "posts_per_hour": 0.8, + "comments_per_hour": 0.3, + "active_hours": list(range(7, 24)), # 7:00-23:59 + "response_delay_min": 5, + "response_delay_max": 30, + "sentiment_bias": 0.0, + "stance": "observer", + "influence_weight": 2.5 + } + elif entity_type in ["professor", "expert", "official"]: + # 专家/教授:工作+晚间活动,中等频率 + return { + "activity_level": 0.4, + "posts_per_hour": 0.3, + "comments_per_hour": 0.5, + "active_hours": list(range(8, 22)), # 8:00-21:59 + "response_delay_min": 15, + "response_delay_max": 90, + "sentiment_bias": 0.0, + "stance": "neutral", + "influence_weight": 2.0 + } + elif entity_type in ["student"]: + # 学生:晚间为主,高频率 + return { + "activity_level": 0.8, + "posts_per_hour": 0.6, + "comments_per_hour": 1.5, + "active_hours": [8, 9, 10, 11, 12, 13, 18, 19, 20, 21, 22, 23], # 上午+晚间 + "response_delay_min": 1, + "response_delay_max": 15, + "sentiment_bias": 0.0, + "stance": "neutral", + "influence_weight": 0.8 + } + elif entity_type in ["alumni"]: + # 校友:晚间为主 + return { + "activity_level": 0.6, + "posts_per_hour": 0.4, + "comments_per_hour": 0.8, + "active_hours": [12, 13, 19, 20, 21, 22, 23], # 午休+晚间 + "response_delay_min": 5, + "response_delay_max": 30, + "sentiment_bias": 0.0, + "stance": "neutral", + "influence_weight": 1.0 + } + else: + # 普通人:晚间高峰 + return { + "activity_level": 0.7, + "posts_per_hour": 0.5, + "comments_per_hour": 1.2, + "active_hours": [9, 10, 11, 12, 13, 18, 19, 20, 21, 22, 23], # 白天+晚间 + "response_delay_min": 2, + "response_delay_max": 20, + "sentiment_bias": 0.0, + "stance": "neutral", + "influence_weight": 1.0 + } + + diff --git a/backend/app/services/simulation_ipc.py b/backend/app/services/simulation_ipc.py new file mode 100644 index 00000000..9d70d0be --- /dev/null +++ b/backend/app/services/simulation_ipc.py @@ -0,0 +1,394 @@ +""" +模拟IPC通信模块 +用于Flask后端和模拟脚本之间的进程间通信 + +通过文件系统实现简单的命令/响应模式: +1. Flask写入命令到 commands/ 目录 +2. 模拟脚本轮询命令目录,执行命令并写入响应到 responses/ 目录 +3. Flask轮询响应目录获取结果 +""" + +import os +import json +import time +import uuid +from typing import Dict, Any, Optional, List +from dataclasses import dataclass, field +from datetime import datetime +from enum import Enum + +from ..utils.logger import get_logger + +logger = get_logger('mirofish.simulation_ipc') + + +class CommandType(str, Enum): + """命令类型""" + INTERVIEW = "interview" # 单个Agent采访 + BATCH_INTERVIEW = "batch_interview" # 批量采访 + CLOSE_ENV = "close_env" # 关闭环境 + + +class CommandStatus(str, Enum): + """命令状态""" + PENDING = "pending" + PROCESSING = "processing" + COMPLETED = "completed" + FAILED = "failed" + + +@dataclass +class IPCCommand: + """IPC命令""" + command_id: str + command_type: CommandType + args: Dict[str, Any] + timestamp: str = field(default_factory=lambda: datetime.now().isoformat()) + + def to_dict(self) -> Dict[str, Any]: + return { + "command_id": self.command_id, + "command_type": self.command_type.value, + "args": self.args, + "timestamp": self.timestamp + } + + @classmethod + def from_dict(cls, data: Dict[str, Any]) -> 'IPCCommand': + return cls( + command_id=data["command_id"], + command_type=CommandType(data["command_type"]), + args=data.get("args", {}), + timestamp=data.get("timestamp", datetime.now().isoformat()) + ) + + +@dataclass +class IPCResponse: + """IPC响应""" + command_id: str + status: CommandStatus + result: Optional[Dict[str, Any]] = None + error: Optional[str] = None + timestamp: str = field(default_factory=lambda: datetime.now().isoformat()) + + def to_dict(self) -> Dict[str, Any]: + return { + "command_id": self.command_id, + "status": self.status.value, + "result": self.result, + "error": self.error, + "timestamp": self.timestamp + } + + @classmethod + def from_dict(cls, data: Dict[str, Any]) -> 'IPCResponse': + return cls( + command_id=data["command_id"], + status=CommandStatus(data["status"]), + result=data.get("result"), + error=data.get("error"), + timestamp=data.get("timestamp", datetime.now().isoformat()) + ) + + +class SimulationIPCClient: + """ + 模拟IPC客户端(Flask端使用) + + 用于向模拟进程发送命令并等待响应 + """ + + def __init__(self, simulation_dir: str): + """ + 初始化IPC客户端 + + Args: + simulation_dir: 模拟数据目录 + """ + self.simulation_dir = simulation_dir + self.commands_dir = os.path.join(simulation_dir, "ipc_commands") + self.responses_dir = os.path.join(simulation_dir, "ipc_responses") + + # 确保目录存在 + os.makedirs(self.commands_dir, exist_ok=True) + os.makedirs(self.responses_dir, exist_ok=True) + + def send_command( + self, + command_type: CommandType, + args: Dict[str, Any], + timeout: float = 60.0, + poll_interval: float = 0.5 + ) -> IPCResponse: + """ + 发送命令并等待响应 + + Args: + command_type: 命令类型 + args: 命令参数 + timeout: 超时时间(秒) + poll_interval: 轮询间隔(秒) + + Returns: + IPCResponse + + Raises: + TimeoutError: 等待响应超时 + """ + command_id = str(uuid.uuid4()) + command = IPCCommand( + command_id=command_id, + command_type=command_type, + args=args + ) + + # 写入命令文件 + command_file = os.path.join(self.commands_dir, f"{command_id}.json") + with open(command_file, 'w', encoding='utf-8') as f: + json.dump(command.to_dict(), f, ensure_ascii=False, indent=2) + + logger.info(f"发送IPC命令: {command_type.value}, command_id={command_id}") + + # 等待响应 + response_file = os.path.join(self.responses_dir, f"{command_id}.json") + start_time = time.time() + + while time.time() - start_time < timeout: + if os.path.exists(response_file): + try: + with open(response_file, 'r', encoding='utf-8') as f: + response_data = json.load(f) + response = IPCResponse.from_dict(response_data) + + # 清理命令和响应文件 + try: + os.remove(command_file) + os.remove(response_file) + except OSError: + pass + + logger.info(f"收到IPC响应: command_id={command_id}, status={response.status.value}") + return response + except (json.JSONDecodeError, KeyError) as e: + logger.warning(f"解析响应失败: {e}") + + time.sleep(poll_interval) + + # 超时 + logger.error(f"等待IPC响应超时: command_id={command_id}") + + # 清理命令文件 + try: + os.remove(command_file) + except OSError: + pass + + raise TimeoutError(f"等待命令响应超时 ({timeout}秒)") + + def send_interview( + self, + agent_id: int, + prompt: str, + platform: str = None, + timeout: float = 60.0 + ) -> IPCResponse: + """ + 发送单个Agent采访命令 + + Args: + agent_id: Agent ID + prompt: 采访问题 + platform: 指定平台(可选) + - "twitter": 只采访Twitter平台 + - "reddit": 只采访Reddit平台 + - None: 双平台模拟时同时采访两个平台,单平台模拟时采访该平台 + timeout: 超时时间 + + Returns: + IPCResponse,result字段包含采访结果 + """ + args = { + "agent_id": agent_id, + "prompt": prompt + } + if platform: + args["platform"] = platform + + return self.send_command( + command_type=CommandType.INTERVIEW, + args=args, + timeout=timeout + ) + + def send_batch_interview( + self, + interviews: List[Dict[str, Any]], + platform: str = None, + timeout: float = 120.0 + ) -> IPCResponse: + """ + 发送批量采访命令 + + Args: + interviews: 采访列表,每个元素包含 {"agent_id": int, "prompt": str, "platform": str(可选)} + platform: 默认平台(可选,会被每个采访项的platform覆盖) + - "twitter": 默认只采访Twitter平台 + - "reddit": 默认只采访Reddit平台 + - None: 双平台模拟时每个Agent同时采访两个平台 + timeout: 超时时间 + + Returns: + IPCResponse,result字段包含所有采访结果 + """ + args = {"interviews": interviews} + if platform: + args["platform"] = platform + + return self.send_command( + command_type=CommandType.BATCH_INTERVIEW, + args=args, + timeout=timeout + ) + + def send_close_env(self, timeout: float = 30.0) -> IPCResponse: + """ + 发送关闭环境命令 + + Args: + timeout: 超时时间 + + Returns: + IPCResponse + """ + return self.send_command( + command_type=CommandType.CLOSE_ENV, + args={}, + timeout=timeout + ) + + def check_env_alive(self) -> bool: + """ + 检查模拟环境是否存活 + + 通过检查 env_status.json 文件来判断 + """ + status_file = os.path.join(self.simulation_dir, "env_status.json") + if not os.path.exists(status_file): + return False + + try: + with open(status_file, 'r', encoding='utf-8') as f: + status = json.load(f) + return status.get("status") == "alive" + except (json.JSONDecodeError, OSError): + return False + + +class SimulationIPCServer: + """ + 模拟IPC服务器(模拟脚本端使用) + + 轮询命令目录,执行命令并返回响应 + """ + + def __init__(self, simulation_dir: str): + """ + 初始化IPC服务器 + + Args: + simulation_dir: 模拟数据目录 + """ + self.simulation_dir = simulation_dir + self.commands_dir = os.path.join(simulation_dir, "ipc_commands") + self.responses_dir = os.path.join(simulation_dir, "ipc_responses") + + # 确保目录存在 + os.makedirs(self.commands_dir, exist_ok=True) + os.makedirs(self.responses_dir, exist_ok=True) + + # 环境状态 + self._running = False + + def start(self): + """标记服务器为运行状态""" + self._running = True + self._update_env_status("alive") + + def stop(self): + """标记服务器为停止状态""" + self._running = False + self._update_env_status("stopped") + + def _update_env_status(self, status: str): + """更新环境状态文件""" + status_file = os.path.join(self.simulation_dir, "env_status.json") + with open(status_file, 'w', encoding='utf-8') as f: + json.dump({ + "status": status, + "timestamp": datetime.now().isoformat() + }, f, ensure_ascii=False, indent=2) + + def poll_commands(self) -> Optional[IPCCommand]: + """ + 轮询命令目录,返回第一个待处理的命令 + + Returns: + IPCCommand 或 None + """ + if not os.path.exists(self.commands_dir): + return None + + # 按时间排序获取命令文件 + command_files = [] + for filename in os.listdir(self.commands_dir): + if filename.endswith('.json'): + filepath = os.path.join(self.commands_dir, filename) + command_files.append((filepath, os.path.getmtime(filepath))) + + command_files.sort(key=lambda x: x[1]) + + for filepath, _ in command_files: + try: + with open(filepath, 'r', encoding='utf-8') as f: + data = json.load(f) + return IPCCommand.from_dict(data) + except (json.JSONDecodeError, KeyError, OSError) as e: + logger.warning(f"读取命令文件失败: {filepath}, {e}") + continue + + return None + + def send_response(self, response: IPCResponse): + """ + 发送响应 + + Args: + response: IPC响应 + """ + response_file = os.path.join(self.responses_dir, f"{response.command_id}.json") + with open(response_file, 'w', encoding='utf-8') as f: + json.dump(response.to_dict(), f, ensure_ascii=False, indent=2) + + # 删除命令文件 + command_file = os.path.join(self.commands_dir, f"{response.command_id}.json") + try: + os.remove(command_file) + except OSError: + pass + + def send_success(self, command_id: str, result: Dict[str, Any]): + """发送成功响应""" + self.send_response(IPCResponse( + command_id=command_id, + status=CommandStatus.COMPLETED, + result=result + )) + + def send_error(self, command_id: str, error: str): + """发送错误响应""" + self.send_response(IPCResponse( + command_id=command_id, + status=CommandStatus.FAILED, + error=error + )) diff --git a/backend/app/services/simulation_manager.py b/backend/app/services/simulation_manager.py new file mode 100644 index 00000000..0d161a90 --- /dev/null +++ b/backend/app/services/simulation_manager.py @@ -0,0 +1,529 @@ +""" +OASIS模拟管理器 +管理Twitter和Reddit双平台并行模拟 +使用预设脚本 + LLM智能生成配置参数 +""" + +import os +import json +import shutil +from typing import Dict, Any, List, Optional +from dataclasses import dataclass, field +from datetime import datetime +from enum import Enum + +from ..config import Config +from ..utils.logger import get_logger +from .zep_entity_reader import ZepEntityReader, FilteredEntities +from .oasis_profile_generator import OasisProfileGenerator, OasisAgentProfile +from .simulation_config_generator import SimulationConfigGenerator, SimulationParameters +from ..utils.locale import t + +logger = get_logger('mirofish.simulation') + + +class SimulationStatus(str, Enum): + """模拟状态""" + CREATED = "created" + PREPARING = "preparing" + READY = "ready" + RUNNING = "running" + PAUSED = "paused" + STOPPED = "stopped" # 模拟被手动停止 + COMPLETED = "completed" # 模拟自然完成 + FAILED = "failed" + + +class PlatformType(str, Enum): + """平台类型""" + TWITTER = "twitter" + REDDIT = "reddit" + + +@dataclass +class SimulationState: + """模拟状态""" + simulation_id: str + project_id: str + graph_id: str + + # 平台启用状态 + enable_twitter: bool = True + enable_reddit: bool = True + + # 状态 + status: SimulationStatus = SimulationStatus.CREATED + + # 准备阶段数据 + entities_count: int = 0 + profiles_count: int = 0 + entity_types: List[str] = field(default_factory=list) + + # 配置生成信息 + config_generated: bool = False + config_reasoning: str = "" + + # 运行时数据 + current_round: int = 0 + twitter_status: str = "not_started" + reddit_status: str = "not_started" + + # 时间戳 + created_at: str = field(default_factory=lambda: datetime.now().isoformat()) + updated_at: str = field(default_factory=lambda: datetime.now().isoformat()) + + # 错误信息 + error: Optional[str] = None + + def to_dict(self) -> Dict[str, Any]: + """完整状态字典(内部使用)""" + return { + "simulation_id": self.simulation_id, + "project_id": self.project_id, + "graph_id": self.graph_id, + "enable_twitter": self.enable_twitter, + "enable_reddit": self.enable_reddit, + "status": self.status.value, + "entities_count": self.entities_count, + "profiles_count": self.profiles_count, + "entity_types": self.entity_types, + "config_generated": self.config_generated, + "config_reasoning": self.config_reasoning, + "current_round": self.current_round, + "twitter_status": self.twitter_status, + "reddit_status": self.reddit_status, + "created_at": self.created_at, + "updated_at": self.updated_at, + "error": self.error, + } + + def to_simple_dict(self) -> Dict[str, Any]: + """简化状态字典(API返回使用)""" + return { + "simulation_id": self.simulation_id, + "project_id": self.project_id, + "graph_id": self.graph_id, + "status": self.status.value, + "entities_count": self.entities_count, + "profiles_count": self.profiles_count, + "entity_types": self.entity_types, + "config_generated": self.config_generated, + "error": self.error, + } + + +class SimulationManager: + """ + 模拟管理器 + + 核心功能: + 1. 从Zep图谱读取实体并过滤 + 2. 生成OASIS Agent Profile + 3. 使用LLM智能生成模拟配置参数 + 4. 准备预设脚本所需的所有文件 + """ + + # 模拟数据存储目录 + SIMULATION_DATA_DIR = os.path.join( + os.path.dirname(__file__), + '../../uploads/simulations' + ) + + def __init__(self): + # 确保目录存在 + os.makedirs(self.SIMULATION_DATA_DIR, exist_ok=True) + + # 内存中的模拟状态缓存 + self._simulations: Dict[str, SimulationState] = {} + + def _get_simulation_dir(self, simulation_id: str) -> str: + """获取模拟数据目录""" + sim_dir = os.path.join(self.SIMULATION_DATA_DIR, simulation_id) + os.makedirs(sim_dir, exist_ok=True) + return sim_dir + + def _save_simulation_state(self, state: SimulationState): + """保存模拟状态到文件""" + sim_dir = self._get_simulation_dir(state.simulation_id) + state_file = os.path.join(sim_dir, "state.json") + + state.updated_at = datetime.now().isoformat() + + with open(state_file, 'w', encoding='utf-8') as f: + json.dump(state.to_dict(), f, ensure_ascii=False, indent=2) + + self._simulations[state.simulation_id] = state + + def _load_simulation_state(self, simulation_id: str) -> Optional[SimulationState]: + """从文件加载模拟状态""" + if simulation_id in self._simulations: + return self._simulations[simulation_id] + + sim_dir = self._get_simulation_dir(simulation_id) + state_file = os.path.join(sim_dir, "state.json") + + if not os.path.exists(state_file): + return None + + with open(state_file, 'r', encoding='utf-8') as f: + data = json.load(f) + + state = SimulationState( + simulation_id=simulation_id, + project_id=data.get("project_id", ""), + graph_id=data.get("graph_id", ""), + enable_twitter=data.get("enable_twitter", True), + enable_reddit=data.get("enable_reddit", True), + status=SimulationStatus(data.get("status", "created")), + entities_count=data.get("entities_count", 0), + profiles_count=data.get("profiles_count", 0), + entity_types=data.get("entity_types", []), + config_generated=data.get("config_generated", False), + config_reasoning=data.get("config_reasoning", ""), + current_round=data.get("current_round", 0), + twitter_status=data.get("twitter_status", "not_started"), + reddit_status=data.get("reddit_status", "not_started"), + created_at=data.get("created_at", datetime.now().isoformat()), + updated_at=data.get("updated_at", datetime.now().isoformat()), + error=data.get("error"), + ) + + self._simulations[simulation_id] = state + return state + + def create_simulation( + self, + project_id: str, + graph_id: str, + enable_twitter: bool = True, + enable_reddit: bool = True, + ) -> SimulationState: + """ + 创建新的模拟 + + Args: + project_id: 项目ID + graph_id: Zep图谱ID + enable_twitter: 是否启用Twitter模拟 + enable_reddit: 是否启用Reddit模拟 + + Returns: + SimulationState + """ + import uuid + simulation_id = f"sim_{uuid.uuid4().hex[:12]}" + + state = SimulationState( + simulation_id=simulation_id, + project_id=project_id, + graph_id=graph_id, + enable_twitter=enable_twitter, + enable_reddit=enable_reddit, + status=SimulationStatus.CREATED, + ) + + self._save_simulation_state(state) + logger.info(f"创建模拟: {simulation_id}, project={project_id}, graph={graph_id}") + + return state + + def prepare_simulation( + self, + simulation_id: str, + simulation_requirement: str, + document_text: str, + defined_entity_types: Optional[List[str]] = None, + use_llm_for_profiles: bool = True, + progress_callback: Optional[callable] = None, + parallel_profile_count: int = 3 + ) -> SimulationState: + """ + 准备模拟环境(全程自动化) + + 步骤: + 1. 从Zep图谱读取并过滤实体 + 2. 为每个实体生成OASIS Agent Profile(可选LLM增强,支持并行) + 3. 使用LLM智能生成模拟配置参数(时间、活跃度、发言频率等) + 4. 保存配置文件和Profile文件 + 5. 复制预设脚本到模拟目录 + + Args: + simulation_id: 模拟ID + simulation_requirement: 模拟需求描述(用于LLM生成配置) + document_text: 原始文档内容(用于LLM理解背景) + defined_entity_types: 预定义的实体类型(可选) + use_llm_for_profiles: 是否使用LLM生成详细人设 + progress_callback: 进度回调函数 (stage, progress, message) + parallel_profile_count: 并行生成人设的数量,默认3 + + Returns: + SimulationState + """ + state = self._load_simulation_state(simulation_id) + if not state: + raise ValueError(f"模拟不存在: {simulation_id}") + + try: + state.status = SimulationStatus.PREPARING + self._save_simulation_state(state) + + sim_dir = self._get_simulation_dir(simulation_id) + + # ========== 阶段1: 读取并过滤实体 ========== + if progress_callback: + progress_callback("reading", 0, t('progress.connectingZepGraph')) + + reader = ZepEntityReader() + + if progress_callback: + progress_callback("reading", 30, t('progress.readingNodeData')) + + filtered = reader.filter_defined_entities( + graph_id=state.graph_id, + defined_entity_types=defined_entity_types, + enrich_with_edges=True + ) + + state.entities_count = filtered.filtered_count + state.entity_types = list(filtered.entity_types) + + if progress_callback: + progress_callback( + "reading", 100, + t('progress.readingComplete', count=filtered.filtered_count), + current=filtered.filtered_count, + total=filtered.filtered_count + ) + + if filtered.filtered_count == 0: + state.status = SimulationStatus.FAILED + state.error = "没有找到符合条件的实体,请检查图谱是否正确构建" + self._save_simulation_state(state) + return state + + # ========== 阶段2: 生成Agent Profile ========== + total_entities = len(filtered.entities) + + if progress_callback: + progress_callback( + "generating_profiles", 0, + t('progress.startGenerating'), + current=0, + total=total_entities + ) + + # 传入graph_id以启用Zep检索功能,获取更丰富的上下文 + generator = OasisProfileGenerator(graph_id=state.graph_id) + + def profile_progress(current, total, msg): + if progress_callback: + progress_callback( + "generating_profiles", + int(current / total * 100), + msg, + current=current, + total=total, + item_name=msg + ) + + # 设置实时保存的文件路径(优先使用 Reddit JSON 格式) + realtime_output_path = None + realtime_platform = "reddit" + if state.enable_reddit: + realtime_output_path = os.path.join(sim_dir, "reddit_profiles.json") + realtime_platform = "reddit" + elif state.enable_twitter: + realtime_output_path = os.path.join(sim_dir, "twitter_profiles.csv") + realtime_platform = "twitter" + + profiles = generator.generate_profiles_from_entities( + entities=filtered.entities, + use_llm=use_llm_for_profiles, + progress_callback=profile_progress, + graph_id=state.graph_id, # 传入graph_id用于Zep检索 + parallel_count=parallel_profile_count, # 并行生成数量 + realtime_output_path=realtime_output_path, # 实时保存路径 + output_platform=realtime_platform # 输出格式 + ) + + state.profiles_count = len(profiles) + + # 保存Profile文件(注意:Twitter使用CSV格式,Reddit使用JSON格式) + # Reddit 已经在生成过程中实时保存了,这里再保存一次确保完整性 + if progress_callback: + progress_callback( + "generating_profiles", 95, + t('progress.savingProfiles'), + current=total_entities, + total=total_entities + ) + + if state.enable_reddit: + generator.save_profiles( + profiles=profiles, + file_path=os.path.join(sim_dir, "reddit_profiles.json"), + platform="reddit" + ) + + if state.enable_twitter: + # Twitter使用CSV格式!这是OASIS的要求 + generator.save_profiles( + profiles=profiles, + file_path=os.path.join(sim_dir, "twitter_profiles.csv"), + platform="twitter" + ) + + if progress_callback: + progress_callback( + "generating_profiles", 100, + t('progress.profilesComplete', count=len(profiles)), + current=len(profiles), + total=len(profiles) + ) + + # ========== 阶段3: LLM智能生成模拟配置 ========== + if progress_callback: + progress_callback( + "generating_config", 0, + t('progress.analyzingRequirements'), + current=0, + total=3 + ) + + config_generator = SimulationConfigGenerator() + + if progress_callback: + progress_callback( + "generating_config", 30, + t('progress.callingLLMConfig'), + current=1, + total=3 + ) + + sim_params = config_generator.generate_config( + simulation_id=simulation_id, + project_id=state.project_id, + graph_id=state.graph_id, + simulation_requirement=simulation_requirement, + document_text=document_text, + entities=filtered.entities, + enable_twitter=state.enable_twitter, + enable_reddit=state.enable_reddit + ) + + if progress_callback: + progress_callback( + "generating_config", 70, + t('progress.savingConfigFiles'), + current=2, + total=3 + ) + + # 保存配置文件 + config_path = os.path.join(sim_dir, "simulation_config.json") + with open(config_path, 'w', encoding='utf-8') as f: + f.write(sim_params.to_json()) + + state.config_generated = True + state.config_reasoning = sim_params.generation_reasoning + + if progress_callback: + progress_callback( + "generating_config", 100, + t('progress.configComplete'), + current=3, + total=3 + ) + + # 注意:运行脚本保留在 backend/scripts/ 目录,不再复制到模拟目录 + # 启动模拟时,simulation_runner 会从 scripts/ 目录运行脚本 + + # 更新状态 + state.status = SimulationStatus.READY + self._save_simulation_state(state) + + logger.info(f"模拟准备完成: {simulation_id}, " + f"entities={state.entities_count}, profiles={state.profiles_count}") + + return state + + except Exception as e: + logger.error(f"模拟准备失败: {simulation_id}, error={str(e)}") + import traceback + logger.error(traceback.format_exc()) + state.status = SimulationStatus.FAILED + state.error = str(e) + self._save_simulation_state(state) + raise + + def get_simulation(self, simulation_id: str) -> Optional[SimulationState]: + """获取模拟状态""" + return self._load_simulation_state(simulation_id) + + def list_simulations(self, project_id: Optional[str] = None) -> List[SimulationState]: + """列出所有模拟""" + simulations = [] + + if os.path.exists(self.SIMULATION_DATA_DIR): + for sim_id in os.listdir(self.SIMULATION_DATA_DIR): + # 跳过隐藏文件(如 .DS_Store)和非目录文件 + sim_path = os.path.join(self.SIMULATION_DATA_DIR, sim_id) + if sim_id.startswith('.') or not os.path.isdir(sim_path): + continue + + state = self._load_simulation_state(sim_id) + if state: + if project_id is None or state.project_id == project_id: + simulations.append(state) + + return simulations + + def get_profiles(self, simulation_id: str, platform: str = "reddit") -> List[Dict[str, Any]]: + """获取模拟的Agent Profile""" + state = self._load_simulation_state(simulation_id) + if not state: + raise ValueError(f"模拟不存在: {simulation_id}") + + sim_dir = self._get_simulation_dir(simulation_id) + profile_path = os.path.join(sim_dir, f"{platform}_profiles.json") + + if not os.path.exists(profile_path): + return [] + + with open(profile_path, 'r', encoding='utf-8') as f: + return json.load(f) + + def get_simulation_config(self, simulation_id: str) -> Optional[Dict[str, Any]]: + """获取模拟配置""" + sim_dir = self._get_simulation_dir(simulation_id) + config_path = os.path.join(sim_dir, "simulation_config.json") + + if not os.path.exists(config_path): + return None + + with open(config_path, 'r', encoding='utf-8') as f: + return json.load(f) + + def get_run_instructions(self, simulation_id: str) -> Dict[str, str]: + """获取运行说明""" + sim_dir = self._get_simulation_dir(simulation_id) + config_path = os.path.join(sim_dir, "simulation_config.json") + scripts_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../scripts')) + + return { + "simulation_dir": sim_dir, + "scripts_dir": scripts_dir, + "config_file": config_path, + "commands": { + "twitter": f"python {scripts_dir}/run_twitter_simulation.py --config {config_path}", + "reddit": f"python {scripts_dir}/run_reddit_simulation.py --config {config_path}", + "parallel": f"python {scripts_dir}/run_parallel_simulation.py --config {config_path}", + }, + "instructions": ( + f"1. 激活conda环境: conda activate MiroFish\n" + f"2. 运行模拟 (脚本位于 {scripts_dir}):\n" + f" - 单独运行Twitter: python {scripts_dir}/run_twitter_simulation.py --config {config_path}\n" + f" - 单独运行Reddit: python {scripts_dir}/run_reddit_simulation.py --config {config_path}\n" + f" - 并行运行双平台: python {scripts_dir}/run_parallel_simulation.py --config {config_path}" + ) + } diff --git a/backend/app/services/simulation_runner.py b/backend/app/services/simulation_runner.py new file mode 100644 index 00000000..e86021f8 --- /dev/null +++ b/backend/app/services/simulation_runner.py @@ -0,0 +1,1768 @@ +""" +OASIS模拟运行器 +在后台运行模拟并记录每个Agent的动作,支持实时状态监控 +""" + +import os +import sys +import json +import time +import asyncio +import threading +import subprocess +import signal +import atexit +from typing import Dict, Any, List, Optional, Union +from dataclasses import dataclass, field +from datetime import datetime +from enum import Enum +from queue import Queue + +from ..config import Config +from ..utils.logger import get_logger +from ..utils.locale import get_locale, set_locale +from .zep_graph_memory_updater import ZepGraphMemoryManager +from .simulation_ipc import SimulationIPCClient, CommandType, IPCResponse + +logger = get_logger('mirofish.simulation_runner') + +# 标记是否已注册清理函数 +_cleanup_registered = False + +# 平台检测 +IS_WINDOWS = sys.platform == 'win32' + + +class RunnerStatus(str, Enum): + """运行器状态""" + IDLE = "idle" + STARTING = "starting" + RUNNING = "running" + PAUSED = "paused" + STOPPING = "stopping" + STOPPED = "stopped" + COMPLETED = "completed" + FAILED = "failed" + + +@dataclass +class AgentAction: + """Agent动作记录""" + round_num: int + timestamp: str + platform: str # twitter / reddit + agent_id: int + agent_name: str + action_type: str # CREATE_POST, LIKE_POST, etc. + action_args: Dict[str, Any] = field(default_factory=dict) + result: Optional[str] = None + success: bool = True + + def to_dict(self) -> Dict[str, Any]: + return { + "round_num": self.round_num, + "timestamp": self.timestamp, + "platform": self.platform, + "agent_id": self.agent_id, + "agent_name": self.agent_name, + "action_type": self.action_type, + "action_args": self.action_args, + "result": self.result, + "success": self.success, + } + + +@dataclass +class RoundSummary: + """每轮摘要""" + round_num: int + start_time: str + end_time: Optional[str] = None + simulated_hour: int = 0 + twitter_actions: int = 0 + reddit_actions: int = 0 + active_agents: List[int] = field(default_factory=list) + actions: List[AgentAction] = field(default_factory=list) + + def to_dict(self) -> Dict[str, Any]: + return { + "round_num": self.round_num, + "start_time": self.start_time, + "end_time": self.end_time, + "simulated_hour": self.simulated_hour, + "twitter_actions": self.twitter_actions, + "reddit_actions": self.reddit_actions, + "active_agents": self.active_agents, + "actions_count": len(self.actions), + "actions": [a.to_dict() for a in self.actions], + } + + +@dataclass +class SimulationRunState: + """模拟运行状态(实时)""" + simulation_id: str + runner_status: RunnerStatus = RunnerStatus.IDLE + + # 进度信息 + current_round: int = 0 + total_rounds: int = 0 + simulated_hours: int = 0 + total_simulation_hours: int = 0 + + # 各平台独立轮次和模拟时间(用于双平台并行显示) + twitter_current_round: int = 0 + reddit_current_round: int = 0 + twitter_simulated_hours: int = 0 + reddit_simulated_hours: int = 0 + + # 平台状态 + twitter_running: bool = False + reddit_running: bool = False + twitter_actions_count: int = 0 + reddit_actions_count: int = 0 + + # 平台完成状态(通过检测 actions.jsonl 中的 simulation_end 事件) + twitter_completed: bool = False + reddit_completed: bool = False + + # 每轮摘要 + rounds: List[RoundSummary] = field(default_factory=list) + + # 最近动作(用于前端实时展示) + recent_actions: List[AgentAction] = field(default_factory=list) + max_recent_actions: int = 50 + + # 时间戳 + started_at: Optional[str] = None + updated_at: str = field(default_factory=lambda: datetime.now().isoformat()) + completed_at: Optional[str] = None + + # 错误信息 + error: Optional[str] = None + + # 进程ID(用于停止) + process_pid: Optional[int] = None + + def add_action(self, action: AgentAction): + """添加动作到最近动作列表""" + self.recent_actions.insert(0, action) + if len(self.recent_actions) > self.max_recent_actions: + self.recent_actions = self.recent_actions[:self.max_recent_actions] + + if action.platform == "twitter": + self.twitter_actions_count += 1 + else: + self.reddit_actions_count += 1 + + self.updated_at = datetime.now().isoformat() + + def to_dict(self) -> Dict[str, Any]: + return { + "simulation_id": self.simulation_id, + "runner_status": self.runner_status.value, + "current_round": self.current_round, + "total_rounds": self.total_rounds, + "simulated_hours": self.simulated_hours, + "total_simulation_hours": self.total_simulation_hours, + "progress_percent": round(self.current_round / max(self.total_rounds, 1) * 100, 1), + # 各平台独立轮次和时间 + "twitter_current_round": self.twitter_current_round, + "reddit_current_round": self.reddit_current_round, + "twitter_simulated_hours": self.twitter_simulated_hours, + "reddit_simulated_hours": self.reddit_simulated_hours, + "twitter_running": self.twitter_running, + "reddit_running": self.reddit_running, + "twitter_completed": self.twitter_completed, + "reddit_completed": self.reddit_completed, + "twitter_actions_count": self.twitter_actions_count, + "reddit_actions_count": self.reddit_actions_count, + "total_actions_count": self.twitter_actions_count + self.reddit_actions_count, + "started_at": self.started_at, + "updated_at": self.updated_at, + "completed_at": self.completed_at, + "error": self.error, + "process_pid": self.process_pid, + } + + def to_detail_dict(self) -> Dict[str, Any]: + """包含最近动作的详细信息""" + result = self.to_dict() + result["recent_actions"] = [a.to_dict() for a in self.recent_actions] + result["rounds_count"] = len(self.rounds) + return result + + +class SimulationRunner: + """ + 模拟运行器 + + 负责: + 1. 在后台进程中运行OASIS模拟 + 2. 解析运行日志,记录每个Agent的动作 + 3. 提供实时状态查询接口 + 4. 支持暂停/停止/恢复操作 + """ + + # 运行状态存储目录 + RUN_STATE_DIR = os.path.join( + os.path.dirname(__file__), + '../../uploads/simulations' + ) + + # 脚本目录 + SCRIPTS_DIR = os.path.join( + os.path.dirname(__file__), + '../../scripts' + ) + + # 内存中的运行状态 + _run_states: Dict[str, SimulationRunState] = {} + _processes: Dict[str, subprocess.Popen] = {} + _action_queues: Dict[str, Queue] = {} + _monitor_threads: Dict[str, threading.Thread] = {} + _stdout_files: Dict[str, Any] = {} # 存储 stdout 文件句柄 + _stderr_files: Dict[str, Any] = {} # 存储 stderr 文件句柄 + + # 图谱记忆更新配置 + _graph_memory_enabled: Dict[str, bool] = {} # simulation_id -> enabled + + @classmethod + def get_run_state(cls, simulation_id: str) -> Optional[SimulationRunState]: + """获取运行状态""" + if simulation_id in cls._run_states: + return cls._run_states[simulation_id] + + # 尝试从文件加载 + state = cls._load_run_state(simulation_id) + if state: + cls._run_states[simulation_id] = state + return state + + @classmethod + def _load_run_state(cls, simulation_id: str) -> Optional[SimulationRunState]: + """从文件加载运行状态""" + state_file = os.path.join(cls.RUN_STATE_DIR, simulation_id, "run_state.json") + if not os.path.exists(state_file): + return None + + try: + with open(state_file, 'r', encoding='utf-8') as f: + data = json.load(f) + + state = SimulationRunState( + simulation_id=simulation_id, + runner_status=RunnerStatus(data.get("runner_status", "idle")), + current_round=data.get("current_round", 0), + total_rounds=data.get("total_rounds", 0), + simulated_hours=data.get("simulated_hours", 0), + total_simulation_hours=data.get("total_simulation_hours", 0), + # 各平台独立轮次和时间 + twitter_current_round=data.get("twitter_current_round", 0), + reddit_current_round=data.get("reddit_current_round", 0), + twitter_simulated_hours=data.get("twitter_simulated_hours", 0), + reddit_simulated_hours=data.get("reddit_simulated_hours", 0), + twitter_running=data.get("twitter_running", False), + reddit_running=data.get("reddit_running", False), + twitter_completed=data.get("twitter_completed", False), + reddit_completed=data.get("reddit_completed", False), + twitter_actions_count=data.get("twitter_actions_count", 0), + reddit_actions_count=data.get("reddit_actions_count", 0), + started_at=data.get("started_at"), + updated_at=data.get("updated_at", datetime.now().isoformat()), + completed_at=data.get("completed_at"), + error=data.get("error"), + process_pid=data.get("process_pid"), + ) + + # 加载最近动作 + actions_data = data.get("recent_actions", []) + for a in actions_data: + state.recent_actions.append(AgentAction( + round_num=a.get("round_num", 0), + timestamp=a.get("timestamp", ""), + platform=a.get("platform", ""), + agent_id=a.get("agent_id", 0), + agent_name=a.get("agent_name", ""), + action_type=a.get("action_type", ""), + action_args=a.get("action_args", {}), + result=a.get("result"), + success=a.get("success", True), + )) + + return state + except Exception as e: + logger.error(f"加载运行状态失败: {str(e)}") + return None + + @classmethod + def _save_run_state(cls, state: SimulationRunState): + """保存运行状态到文件""" + sim_dir = os.path.join(cls.RUN_STATE_DIR, state.simulation_id) + os.makedirs(sim_dir, exist_ok=True) + state_file = os.path.join(sim_dir, "run_state.json") + + data = state.to_detail_dict() + + with open(state_file, 'w', encoding='utf-8') as f: + json.dump(data, f, ensure_ascii=False, indent=2) + + cls._run_states[state.simulation_id] = state + + @classmethod + def start_simulation( + cls, + simulation_id: str, + platform: str = "parallel", # twitter / reddit / parallel + max_rounds: int = None, # 最大模拟轮数(可选,用于截断过长的模拟) + enable_graph_memory_update: bool = False, # 是否将活动更新到Zep图谱 + graph_id: str = None # Zep图谱ID(启用图谱更新时必需) + ) -> SimulationRunState: + """ + 启动模拟 + + Args: + simulation_id: 模拟ID + platform: 运行平台 (twitter/reddit/parallel) + max_rounds: 最大模拟轮数(可选,用于截断过长的模拟) + enable_graph_memory_update: 是否将Agent活动动态更新到Zep图谱 + graph_id: Zep图谱ID(启用图谱更新时必需) + + Returns: + SimulationRunState + """ + # 检查是否已在运行 + existing = cls.get_run_state(simulation_id) + if existing and existing.runner_status in [RunnerStatus.RUNNING, RunnerStatus.STARTING]: + raise ValueError(f"模拟已在运行中: {simulation_id}") + + # 加载模拟配置 + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + config_path = os.path.join(sim_dir, "simulation_config.json") + + if not os.path.exists(config_path): + raise ValueError(f"模拟配置不存在,请先调用 /prepare 接口") + + with open(config_path, 'r', encoding='utf-8') as f: + config = json.load(f) + + # 初始化运行状态 + time_config = config.get("time_config", {}) + total_hours = time_config.get("total_simulation_hours", 72) + minutes_per_round = time_config.get("minutes_per_round", 30) + total_rounds = int(total_hours * 60 / minutes_per_round) + + # 如果指定了最大轮数,则截断 + if max_rounds is not None and max_rounds > 0: + original_rounds = total_rounds + total_rounds = min(total_rounds, max_rounds) + if total_rounds < original_rounds: + logger.info(f"轮数已截断: {original_rounds} -> {total_rounds} (max_rounds={max_rounds})") + + state = SimulationRunState( + simulation_id=simulation_id, + runner_status=RunnerStatus.STARTING, + total_rounds=total_rounds, + total_simulation_hours=total_hours, + started_at=datetime.now().isoformat(), + ) + + cls._save_run_state(state) + + # 如果启用图谱记忆更新,创建更新器 + if enable_graph_memory_update: + if not graph_id: + raise ValueError("启用图谱记忆更新时必须提供 graph_id") + + try: + ZepGraphMemoryManager.create_updater(simulation_id, graph_id) + cls._graph_memory_enabled[simulation_id] = True + logger.info(f"已启用图谱记忆更新: simulation_id={simulation_id}, graph_id={graph_id}") + except Exception as e: + logger.error(f"创建图谱记忆更新器失败: {e}") + cls._graph_memory_enabled[simulation_id] = False + else: + cls._graph_memory_enabled[simulation_id] = False + + # 确定运行哪个脚本(脚本位于 backend/scripts/ 目录) + if platform == "twitter": + script_name = "run_twitter_simulation.py" + state.twitter_running = True + elif platform == "reddit": + script_name = "run_reddit_simulation.py" + state.reddit_running = True + else: + script_name = "run_parallel_simulation.py" + state.twitter_running = True + state.reddit_running = True + + script_path = os.path.join(cls.SCRIPTS_DIR, script_name) + + if not os.path.exists(script_path): + raise ValueError(f"脚本不存在: {script_path}") + + # 创建动作队列 + action_queue = Queue() + cls._action_queues[simulation_id] = action_queue + + # 启动模拟进程 + try: + # 构建运行命令,使用完整路径 + # 新的日志结构: + # twitter/actions.jsonl - Twitter 动作日志 + # reddit/actions.jsonl - Reddit 动作日志 + # simulation.log - 主进程日志 + + cmd = [ + sys.executable, # Python解释器 + script_path, + "--config", config_path, # 使用完整配置文件路径 + ] + + # 如果指定了最大轮数,添加到命令行参数 + if max_rounds is not None and max_rounds > 0: + cmd.extend(["--max-rounds", str(max_rounds)]) + + # 创建主日志文件,避免 stdout/stderr 管道缓冲区满导致进程阻塞 + main_log_path = os.path.join(sim_dir, "simulation.log") + main_log_file = open(main_log_path, 'w', encoding='utf-8') + + # 设置子进程环境变量,确保 Windows 上使用 UTF-8 编码 + # 这可以修复第三方库(如 OASIS)读取文件时未指定编码的问题 + env = os.environ.copy() + env['PYTHONUTF8'] = '1' # Python 3.7+ 支持,让所有 open() 默认使用 UTF-8 + env['PYTHONIOENCODING'] = 'utf-8' # 确保 stdout/stderr 使用 UTF-8 + + # 设置工作目录为模拟目录(数据库等文件会生成在此) + # 使用 start_new_session=True 创建新的进程组,确保可以通过 os.killpg 终止所有子进程 + process = subprocess.Popen( + cmd, + cwd=sim_dir, + stdout=main_log_file, + stderr=subprocess.STDOUT, # stderr 也写入同一个文件 + text=True, + encoding='utf-8', # 显式指定编码 + bufsize=1, + env=env, # 传递带有 UTF-8 设置的环境变量 + start_new_session=True, # 创建新进程组,确保服务器关闭时能终止所有相关进程 + ) + + # 保存文件句柄以便后续关闭 + cls._stdout_files[simulation_id] = main_log_file + cls._stderr_files[simulation_id] = None # 不再需要单独的 stderr + + state.process_pid = process.pid + state.runner_status = RunnerStatus.RUNNING + cls._processes[simulation_id] = process + cls._save_run_state(state) + + # Capture locale before spawning monitor thread + current_locale = get_locale() + + # 启动监控线程 + monitor_thread = threading.Thread( + target=cls._monitor_simulation, + args=(simulation_id, current_locale), + daemon=True + ) + monitor_thread.start() + cls._monitor_threads[simulation_id] = monitor_thread + + logger.info(f"模拟启动成功: {simulation_id}, pid={process.pid}, platform={platform}") + + except Exception as e: + state.runner_status = RunnerStatus.FAILED + state.error = str(e) + cls._save_run_state(state) + raise + + return state + + @classmethod + def _monitor_simulation(cls, simulation_id: str, locale: str = 'zh'): + """监控模拟进程,解析动作日志""" + set_locale(locale) + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + + # 新的日志结构:分平台的动作日志 + twitter_actions_log = os.path.join(sim_dir, "twitter", "actions.jsonl") + reddit_actions_log = os.path.join(sim_dir, "reddit", "actions.jsonl") + + process = cls._processes.get(simulation_id) + state = cls.get_run_state(simulation_id) + + if not process or not state: + return + + twitter_position = 0 + reddit_position = 0 + + try: + while process.poll() is None: # 进程仍在运行 + # 读取 Twitter 动作日志 + if os.path.exists(twitter_actions_log): + twitter_position = cls._read_action_log( + twitter_actions_log, twitter_position, state, "twitter" + ) + + # 读取 Reddit 动作日志 + if os.path.exists(reddit_actions_log): + reddit_position = cls._read_action_log( + reddit_actions_log, reddit_position, state, "reddit" + ) + + # 更新状态 + cls._save_run_state(state) + time.sleep(2) + + # 进程结束后,最后读取一次日志 + if os.path.exists(twitter_actions_log): + cls._read_action_log(twitter_actions_log, twitter_position, state, "twitter") + if os.path.exists(reddit_actions_log): + cls._read_action_log(reddit_actions_log, reddit_position, state, "reddit") + + # 进程结束 + exit_code = process.returncode + + if exit_code == 0: + state.runner_status = RunnerStatus.COMPLETED + state.completed_at = datetime.now().isoformat() + logger.info(f"模拟完成: {simulation_id}") + else: + state.runner_status = RunnerStatus.FAILED + # 从主日志文件读取错误信息 + main_log_path = os.path.join(sim_dir, "simulation.log") + error_info = "" + try: + if os.path.exists(main_log_path): + with open(main_log_path, 'r', encoding='utf-8') as f: + error_info = f.read()[-2000:] # 取最后2000字符 + except Exception: + pass + state.error = f"进程退出码: {exit_code}, 错误: {error_info}" + logger.error(f"模拟失败: {simulation_id}, error={state.error}") + + state.twitter_running = False + state.reddit_running = False + cls._save_run_state(state) + + except Exception as e: + logger.error(f"监控线程异常: {simulation_id}, error={str(e)}") + state.runner_status = RunnerStatus.FAILED + state.error = str(e) + cls._save_run_state(state) + + finally: + # 停止图谱记忆更新器 + if cls._graph_memory_enabled.get(simulation_id, False): + try: + ZepGraphMemoryManager.stop_updater(simulation_id) + logger.info(f"已停止图谱记忆更新: simulation_id={simulation_id}") + except Exception as e: + logger.error(f"停止图谱记忆更新器失败: {e}") + cls._graph_memory_enabled.pop(simulation_id, None) + + # 清理进程资源 + cls._processes.pop(simulation_id, None) + cls._action_queues.pop(simulation_id, None) + + # 关闭日志文件句柄 + if simulation_id in cls._stdout_files: + try: + cls._stdout_files[simulation_id].close() + except Exception: + pass + cls._stdout_files.pop(simulation_id, None) + if simulation_id in cls._stderr_files and cls._stderr_files[simulation_id]: + try: + cls._stderr_files[simulation_id].close() + except Exception: + pass + cls._stderr_files.pop(simulation_id, None) + + @classmethod + def _read_action_log( + cls, + log_path: str, + position: int, + state: SimulationRunState, + platform: str + ) -> int: + """ + 读取动作日志文件 + + Args: + log_path: 日志文件路径 + position: 上次读取位置 + state: 运行状态对象 + platform: 平台名称 (twitter/reddit) + + Returns: + 新的读取位置 + """ + # 检查是否启用了图谱记忆更新 + graph_memory_enabled = cls._graph_memory_enabled.get(state.simulation_id, False) + graph_updater = None + if graph_memory_enabled: + graph_updater = ZepGraphMemoryManager.get_updater(state.simulation_id) + + try: + with open(log_path, 'r', encoding='utf-8') as f: + f.seek(position) + for line in f: + line = line.strip() + if line: + try: + action_data = json.loads(line) + + # 处理事件类型的条目 + if "event_type" in action_data: + event_type = action_data.get("event_type") + + # 检测 simulation_end 事件,标记平台已完成 + if event_type == "simulation_end": + if platform == "twitter": + state.twitter_completed = True + state.twitter_running = False + logger.info(f"Twitter 模拟已完成: {state.simulation_id}, total_rounds={action_data.get('total_rounds')}, total_actions={action_data.get('total_actions')}") + elif platform == "reddit": + state.reddit_completed = True + state.reddit_running = False + logger.info(f"Reddit 模拟已完成: {state.simulation_id}, total_rounds={action_data.get('total_rounds')}, total_actions={action_data.get('total_actions')}") + + # 检查是否所有启用的平台都已完成 + # 如果只运行了一个平台,只检查那个平台 + # 如果运行了两个平台,需要两个都完成 + all_completed = cls._check_all_platforms_completed(state) + if all_completed: + state.runner_status = RunnerStatus.COMPLETED + state.completed_at = datetime.now().isoformat() + logger.info(f"所有平台模拟已完成: {state.simulation_id}") + + # 更新轮次信息(从 round_end 事件) + elif event_type == "round_end": + round_num = action_data.get("round", 0) + simulated_hours = action_data.get("simulated_hours", 0) + + # 更新各平台独立的轮次和时间 + if platform == "twitter": + if round_num > state.twitter_current_round: + state.twitter_current_round = round_num + state.twitter_simulated_hours = simulated_hours + elif platform == "reddit": + if round_num > state.reddit_current_round: + state.reddit_current_round = round_num + state.reddit_simulated_hours = simulated_hours + + # 总体轮次取两个平台的最大值 + if round_num > state.current_round: + state.current_round = round_num + # 总体时间取两个平台的最大值 + state.simulated_hours = max(state.twitter_simulated_hours, state.reddit_simulated_hours) + + continue + + action = AgentAction( + round_num=action_data.get("round", 0), + timestamp=action_data.get("timestamp", datetime.now().isoformat()), + platform=platform, + agent_id=action_data.get("agent_id", 0), + agent_name=action_data.get("agent_name", ""), + action_type=action_data.get("action_type", ""), + action_args=action_data.get("action_args", {}), + result=action_data.get("result"), + success=action_data.get("success", True), + ) + state.add_action(action) + + # 更新轮次 + if action.round_num and action.round_num > state.current_round: + state.current_round = action.round_num + + # 如果启用了图谱记忆更新,将活动发送到Zep + if graph_updater: + graph_updater.add_activity_from_dict(action_data, platform) + + except json.JSONDecodeError: + pass + return f.tell() + except Exception as e: + logger.warning(f"读取动作日志失败: {log_path}, error={e}") + return position + + @classmethod + def _check_all_platforms_completed(cls, state: SimulationRunState) -> bool: + """ + 检查所有启用的平台是否都已完成模拟 + + 通过检查对应的 actions.jsonl 文件是否存在来判断平台是否被启用 + + Returns: + True 如果所有启用的平台都已完成 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, state.simulation_id) + twitter_log = os.path.join(sim_dir, "twitter", "actions.jsonl") + reddit_log = os.path.join(sim_dir, "reddit", "actions.jsonl") + + # 检查哪些平台被启用(通过文件是否存在判断) + twitter_enabled = os.path.exists(twitter_log) + reddit_enabled = os.path.exists(reddit_log) + + # 如果平台被启用但未完成,则返回 False + if twitter_enabled and not state.twitter_completed: + return False + if reddit_enabled and not state.reddit_completed: + return False + + # 至少有一个平台被启用且已完成 + return twitter_enabled or reddit_enabled + + @classmethod + def _terminate_process(cls, process: subprocess.Popen, simulation_id: str, timeout: int = 10): + """ + 跨平台终止进程及其子进程 + + Args: + process: 要终止的进程 + simulation_id: 模拟ID(用于日志) + timeout: 等待进程退出的超时时间(秒) + """ + if IS_WINDOWS: + # Windows: 使用 taskkill 命令终止进程树 + # /F = 强制终止, /T = 终止进程树(包括子进程) + logger.info(f"终止进程树 (Windows): simulation={simulation_id}, pid={process.pid}") + try: + # 先尝试优雅终止 + subprocess.run( + ['taskkill', '/PID', str(process.pid), '/T'], + capture_output=True, + timeout=5 + ) + try: + process.wait(timeout=timeout) + except subprocess.TimeoutExpired: + # 强制终止 + logger.warning(f"进程未响应,强制终止: {simulation_id}") + subprocess.run( + ['taskkill', '/F', '/PID', str(process.pid), '/T'], + capture_output=True, + timeout=5 + ) + process.wait(timeout=5) + except Exception as e: + logger.warning(f"taskkill 失败,尝试 terminate: {e}") + process.terminate() + try: + process.wait(timeout=5) + except subprocess.TimeoutExpired: + process.kill() + else: + # Unix: 使用进程组终止 + # 由于使用了 start_new_session=True,进程组 ID 等于主进程 PID + pgid = os.getpgid(process.pid) + logger.info(f"终止进程组 (Unix): simulation={simulation_id}, pgid={pgid}") + + # 先发送 SIGTERM 给整个进程组 + os.killpg(pgid, signal.SIGTERM) + + try: + process.wait(timeout=timeout) + except subprocess.TimeoutExpired: + # 如果超时后还没结束,强制发送 SIGKILL + logger.warning(f"进程组未响应 SIGTERM,强制终止: {simulation_id}") + os.killpg(pgid, signal.SIGKILL) + process.wait(timeout=5) + + @classmethod + def stop_simulation(cls, simulation_id: str) -> SimulationRunState: + """停止模拟""" + state = cls.get_run_state(simulation_id) + if not state: + raise ValueError(f"模拟不存在: {simulation_id}") + + if state.runner_status not in [RunnerStatus.RUNNING, RunnerStatus.PAUSED]: + raise ValueError(f"模拟未在运行: {simulation_id}, status={state.runner_status}") + + state.runner_status = RunnerStatus.STOPPING + cls._save_run_state(state) + + # 终止进程 + process = cls._processes.get(simulation_id) + if process and process.poll() is None: + try: + cls._terminate_process(process, simulation_id) + except ProcessLookupError: + # 进程已经不存在 + pass + except Exception as e: + logger.error(f"终止进程组失败: {simulation_id}, error={e}") + # 回退到直接终止进程 + try: + process.terminate() + process.wait(timeout=5) + except Exception: + process.kill() + + state.runner_status = RunnerStatus.STOPPED + state.twitter_running = False + state.reddit_running = False + state.completed_at = datetime.now().isoformat() + cls._save_run_state(state) + + # 停止图谱记忆更新器 + if cls._graph_memory_enabled.get(simulation_id, False): + try: + ZepGraphMemoryManager.stop_updater(simulation_id) + logger.info(f"已停止图谱记忆更新: simulation_id={simulation_id}") + except Exception as e: + logger.error(f"停止图谱记忆更新器失败: {e}") + cls._graph_memory_enabled.pop(simulation_id, None) + + logger.info(f"模拟已停止: {simulation_id}") + return state + + @classmethod + def _read_actions_from_file( + cls, + file_path: str, + default_platform: Optional[str] = None, + platform_filter: Optional[str] = None, + agent_id: Optional[int] = None, + round_num: Optional[int] = None + ) -> List[AgentAction]: + """ + 从单个动作文件中读取动作 + + Args: + file_path: 动作日志文件路径 + default_platform: 默认平台(当动作记录中没有 platform 字段时使用) + platform_filter: 过滤平台 + agent_id: 过滤 Agent ID + round_num: 过滤轮次 + """ + if not os.path.exists(file_path): + return [] + + actions = [] + + with open(file_path, 'r', encoding='utf-8') as f: + for line in f: + line = line.strip() + if not line: + continue + + try: + data = json.loads(line) + + # 跳过非动作记录(如 simulation_start, round_start, round_end 等事件) + if "event_type" in data: + continue + + # 跳过没有 agent_id 的记录(非 Agent 动作) + if "agent_id" not in data: + continue + + # 获取平台:优先使用记录中的 platform,否则使用默认平台 + record_platform = data.get("platform") or default_platform or "" + + # 过滤 + if platform_filter and record_platform != platform_filter: + continue + if agent_id is not None and data.get("agent_id") != agent_id: + continue + if round_num is not None and data.get("round") != round_num: + continue + + actions.append(AgentAction( + round_num=data.get("round", 0), + timestamp=data.get("timestamp", ""), + platform=record_platform, + agent_id=data.get("agent_id", 0), + agent_name=data.get("agent_name", ""), + action_type=data.get("action_type", ""), + action_args=data.get("action_args", {}), + result=data.get("result"), + success=data.get("success", True), + )) + + except json.JSONDecodeError: + continue + + return actions + + @classmethod + def get_all_actions( + cls, + simulation_id: str, + platform: Optional[str] = None, + agent_id: Optional[int] = None, + round_num: Optional[int] = None + ) -> List[AgentAction]: + """ + 获取所有平台的完整动作历史(无分页限制) + + Args: + simulation_id: 模拟ID + platform: 过滤平台(twitter/reddit) + agent_id: 过滤Agent + round_num: 过滤轮次 + + Returns: + 完整的动作列表(按时间戳排序,新的在前) + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + actions = [] + + # 读取 Twitter 动作文件(根据文件路径自动设置 platform 为 twitter) + twitter_actions_log = os.path.join(sim_dir, "twitter", "actions.jsonl") + if not platform or platform == "twitter": + actions.extend(cls._read_actions_from_file( + twitter_actions_log, + default_platform="twitter", # 自动填充 platform 字段 + platform_filter=platform, + agent_id=agent_id, + round_num=round_num + )) + + # 读取 Reddit 动作文件(根据文件路径自动设置 platform 为 reddit) + reddit_actions_log = os.path.join(sim_dir, "reddit", "actions.jsonl") + if not platform or platform == "reddit": + actions.extend(cls._read_actions_from_file( + reddit_actions_log, + default_platform="reddit", # 自动填充 platform 字段 + platform_filter=platform, + agent_id=agent_id, + round_num=round_num + )) + + # 如果分平台文件不存在,尝试读取旧的单一文件格式 + if not actions: + actions_log = os.path.join(sim_dir, "actions.jsonl") + actions = cls._read_actions_from_file( + actions_log, + default_platform=None, # 旧格式文件中应该有 platform 字段 + platform_filter=platform, + agent_id=agent_id, + round_num=round_num + ) + + # 按时间戳排序(新的在前) + actions.sort(key=lambda x: x.timestamp, reverse=True) + + return actions + + @classmethod + def get_actions( + cls, + simulation_id: str, + limit: int = 100, + offset: int = 0, + platform: Optional[str] = None, + agent_id: Optional[int] = None, + round_num: Optional[int] = None + ) -> List[AgentAction]: + """ + 获取动作历史(带分页) + + Args: + simulation_id: 模拟ID + limit: 返回数量限制 + offset: 偏移量 + platform: 过滤平台 + agent_id: 过滤Agent + round_num: 过滤轮次 + + Returns: + 动作列表 + """ + actions = cls.get_all_actions( + simulation_id=simulation_id, + platform=platform, + agent_id=agent_id, + round_num=round_num + ) + + # 分页 + return actions[offset:offset + limit] + + @classmethod + def get_timeline( + cls, + simulation_id: str, + start_round: int = 0, + end_round: Optional[int] = None + ) -> List[Dict[str, Any]]: + """ + 获取模拟时间线(按轮次汇总) + + Args: + simulation_id: 模拟ID + start_round: 起始轮次 + end_round: 结束轮次 + + Returns: + 每轮的汇总信息 + """ + actions = cls.get_actions(simulation_id, limit=10000) + + # 按轮次分组 + rounds: Dict[int, Dict[str, Any]] = {} + + for action in actions: + round_num = action.round_num + + if round_num < start_round: + continue + if end_round is not None and round_num > end_round: + continue + + if round_num not in rounds: + rounds[round_num] = { + "round_num": round_num, + "twitter_actions": 0, + "reddit_actions": 0, + "active_agents": set(), + "action_types": {}, + "first_action_time": action.timestamp, + "last_action_time": action.timestamp, + } + + r = rounds[round_num] + + if action.platform == "twitter": + r["twitter_actions"] += 1 + else: + r["reddit_actions"] += 1 + + r["active_agents"].add(action.agent_id) + r["action_types"][action.action_type] = r["action_types"].get(action.action_type, 0) + 1 + r["last_action_time"] = action.timestamp + + # 转换为列表 + result = [] + for round_num in sorted(rounds.keys()): + r = rounds[round_num] + result.append({ + "round_num": round_num, + "twitter_actions": r["twitter_actions"], + "reddit_actions": r["reddit_actions"], + "total_actions": r["twitter_actions"] + r["reddit_actions"], + "active_agents_count": len(r["active_agents"]), + "active_agents": list(r["active_agents"]), + "action_types": r["action_types"], + "first_action_time": r["first_action_time"], + "last_action_time": r["last_action_time"], + }) + + return result + + @classmethod + def get_agent_stats(cls, simulation_id: str) -> List[Dict[str, Any]]: + """ + 获取每个Agent的统计信息 + + Returns: + Agent统计列表 + """ + actions = cls.get_actions(simulation_id, limit=10000) + + agent_stats: Dict[int, Dict[str, Any]] = {} + + for action in actions: + agent_id = action.agent_id + + if agent_id not in agent_stats: + agent_stats[agent_id] = { + "agent_id": agent_id, + "agent_name": action.agent_name, + "total_actions": 0, + "twitter_actions": 0, + "reddit_actions": 0, + "action_types": {}, + "first_action_time": action.timestamp, + "last_action_time": action.timestamp, + } + + stats = agent_stats[agent_id] + stats["total_actions"] += 1 + + if action.platform == "twitter": + stats["twitter_actions"] += 1 + else: + stats["reddit_actions"] += 1 + + stats["action_types"][action.action_type] = stats["action_types"].get(action.action_type, 0) + 1 + stats["last_action_time"] = action.timestamp + + # 按总动作数排序 + result = sorted(agent_stats.values(), key=lambda x: x["total_actions"], reverse=True) + + return result + + @classmethod + def cleanup_simulation_logs(cls, simulation_id: str) -> Dict[str, Any]: + """ + 清理模拟的运行日志(用于强制重新开始模拟) + + 会删除以下文件: + - run_state.json + - twitter/actions.jsonl + - reddit/actions.jsonl + - simulation.log + - stdout.log / stderr.log + - twitter_simulation.db(模拟数据库) + - reddit_simulation.db(模拟数据库) + - env_status.json(环境状态) + + 注意:不会删除配置文件(simulation_config.json)和 profile 文件 + + Args: + simulation_id: 模拟ID + + Returns: + 清理结果信息 + """ + import shutil + + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + + if not os.path.exists(sim_dir): + return {"success": True, "message": "模拟目录不存在,无需清理"} + + cleaned_files = [] + errors = [] + + # 要删除的文件列表(包括数据库文件) + files_to_delete = [ + "run_state.json", + "simulation.log", + "stdout.log", + "stderr.log", + "twitter_simulation.db", # Twitter 平台数据库 + "reddit_simulation.db", # Reddit 平台数据库 + "env_status.json", # 环境状态文件 + ] + + # 要删除的目录列表(包含动作日志) + dirs_to_clean = ["twitter", "reddit"] + + # 删除文件 + for filename in files_to_delete: + file_path = os.path.join(sim_dir, filename) + if os.path.exists(file_path): + try: + os.remove(file_path) + cleaned_files.append(filename) + except Exception as e: + errors.append(f"删除 {filename} 失败: {str(e)}") + + # 清理平台目录中的动作日志 + for dir_name in dirs_to_clean: + dir_path = os.path.join(sim_dir, dir_name) + if os.path.exists(dir_path): + actions_file = os.path.join(dir_path, "actions.jsonl") + if os.path.exists(actions_file): + try: + os.remove(actions_file) + cleaned_files.append(f"{dir_name}/actions.jsonl") + except Exception as e: + errors.append(f"删除 {dir_name}/actions.jsonl 失败: {str(e)}") + + # 清理内存中的运行状态 + if simulation_id in cls._run_states: + del cls._run_states[simulation_id] + + logger.info(f"清理模拟日志完成: {simulation_id}, 删除文件: {cleaned_files}") + + return { + "success": len(errors) == 0, + "cleaned_files": cleaned_files, + "errors": errors if errors else None + } + + # 防止重复清理的标志 + _cleanup_done = False + + @classmethod + def cleanup_all_simulations(cls): + """ + 清理所有运行中的模拟进程 + + 在服务器关闭时调用,确保所有子进程被终止 + """ + # 防止重复清理 + if cls._cleanup_done: + return + cls._cleanup_done = True + + # 检查是否有内容需要清理(避免空进程的进程打印无用日志) + has_processes = bool(cls._processes) + has_updaters = bool(cls._graph_memory_enabled) + + if not has_processes and not has_updaters: + return # 没有需要清理的内容,静默返回 + + logger.info("正在清理所有模拟进程...") + + # 首先停止所有图谱记忆更新器(stop_all 内部会打印日志) + try: + ZepGraphMemoryManager.stop_all() + except Exception as e: + logger.error(f"停止图谱记忆更新器失败: {e}") + cls._graph_memory_enabled.clear() + + # 复制字典以避免在迭代时修改 + processes = list(cls._processes.items()) + + for simulation_id, process in processes: + try: + if process.poll() is None: # 进程仍在运行 + logger.info(f"终止模拟进程: {simulation_id}, pid={process.pid}") + + try: + # 使用跨平台的进程终止方法 + cls._terminate_process(process, simulation_id, timeout=5) + except (ProcessLookupError, OSError): + # 进程可能已经不存在,尝试直接终止 + try: + process.terminate() + process.wait(timeout=3) + except Exception: + process.kill() + + # 更新 run_state.json + state = cls.get_run_state(simulation_id) + if state: + state.runner_status = RunnerStatus.STOPPED + state.twitter_running = False + state.reddit_running = False + state.completed_at = datetime.now().isoformat() + state.error = "服务器关闭,模拟被终止" + cls._save_run_state(state) + + # 同时更新 state.json,将状态设为 stopped + try: + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + state_file = os.path.join(sim_dir, "state.json") + logger.info(f"尝试更新 state.json: {state_file}") + if os.path.exists(state_file): + with open(state_file, 'r', encoding='utf-8') as f: + state_data = json.load(f) + state_data['status'] = 'stopped' + state_data['updated_at'] = datetime.now().isoformat() + with open(state_file, 'w', encoding='utf-8') as f: + json.dump(state_data, f, indent=2, ensure_ascii=False) + logger.info(f"已更新 state.json 状态为 stopped: {simulation_id}") + else: + logger.warning(f"state.json 不存在: {state_file}") + except Exception as state_err: + logger.warning(f"更新 state.json 失败: {simulation_id}, error={state_err}") + + except Exception as e: + logger.error(f"清理进程失败: {simulation_id}, error={e}") + + # 清理文件句柄 + for simulation_id, file_handle in list(cls._stdout_files.items()): + try: + if file_handle: + file_handle.close() + except Exception: + pass + cls._stdout_files.clear() + + for simulation_id, file_handle in list(cls._stderr_files.items()): + try: + if file_handle: + file_handle.close() + except Exception: + pass + cls._stderr_files.clear() + + # 清理内存中的状态 + cls._processes.clear() + cls._action_queues.clear() + + logger.info("模拟进程清理完成") + + @classmethod + def register_cleanup(cls): + """ + 注册清理函数 + + 在 Flask 应用启动时调用,确保服务器关闭时清理所有模拟进程 + """ + global _cleanup_registered + + if _cleanup_registered: + return + + # Flask debug 模式下,只在 reloader 子进程中注册清理(实际运行应用的进程) + # WERKZEUG_RUN_MAIN=true 表示是 reloader 子进程 + # 如果不是 debug 模式,则没有这个环境变量,也需要注册 + is_reloader_process = os.environ.get('WERKZEUG_RUN_MAIN') == 'true' + is_debug_mode = os.environ.get('FLASK_DEBUG') == '1' or os.environ.get('WERKZEUG_RUN_MAIN') is not None + + # 在 debug 模式下,只在 reloader 子进程中注册;非 debug 模式下始终注册 + if is_debug_mode and not is_reloader_process: + _cleanup_registered = True # 标记已注册,防止子进程再次尝试 + return + + # 保存原有的信号处理器 + original_sigint = signal.getsignal(signal.SIGINT) + original_sigterm = signal.getsignal(signal.SIGTERM) + # SIGHUP 只在 Unix 系统存在(macOS/Linux),Windows 没有 + original_sighup = None + has_sighup = hasattr(signal, 'SIGHUP') + if has_sighup: + original_sighup = signal.getsignal(signal.SIGHUP) + + def cleanup_handler(signum=None, frame=None): + """信号处理器:先清理模拟进程,再调用原处理器""" + # 只有在有进程需要清理时才打印日志 + if cls._processes or cls._graph_memory_enabled: + logger.info(f"收到信号 {signum},开始清理...") + cls.cleanup_all_simulations() + + # 调用原有的信号处理器,让 Flask 正常退出 + if signum == signal.SIGINT and callable(original_sigint): + original_sigint(signum, frame) + elif signum == signal.SIGTERM and callable(original_sigterm): + original_sigterm(signum, frame) + elif has_sighup and signum == signal.SIGHUP: + # SIGHUP: 终端关闭时发送 + if callable(original_sighup): + original_sighup(signum, frame) + else: + # 默认行为:正常退出 + sys.exit(0) + else: + # 如果原处理器不可调用(如 SIG_DFL),则使用默认行为 + raise KeyboardInterrupt + + # 注册 atexit 处理器(作为备用) + atexit.register(cls.cleanup_all_simulations) + + # 注册信号处理器(仅在主线程中) + try: + # SIGTERM: kill 命令默认信号 + signal.signal(signal.SIGTERM, cleanup_handler) + # SIGINT: Ctrl+C + signal.signal(signal.SIGINT, cleanup_handler) + # SIGHUP: 终端关闭(仅 Unix 系统) + if has_sighup: + signal.signal(signal.SIGHUP, cleanup_handler) + except ValueError: + # 不在主线程中,只能使用 atexit + logger.warning("无法注册信号处理器(不在主线程),仅使用 atexit") + + _cleanup_registered = True + + @classmethod + def get_running_simulations(cls) -> List[str]: + """ + 获取所有正在运行的模拟ID列表 + """ + running = [] + for sim_id, process in cls._processes.items(): + if process.poll() is None: + running.append(sim_id) + return running + + # ============== Interview 功能 ============== + + @classmethod + def check_env_alive(cls, simulation_id: str) -> bool: + """ + 检查模拟环境是否存活(可以接收Interview命令) + + Args: + simulation_id: 模拟ID + + Returns: + True 表示环境存活,False 表示环境已关闭 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + if not os.path.exists(sim_dir): + return False + + ipc_client = SimulationIPCClient(sim_dir) + return ipc_client.check_env_alive() + + @classmethod + def get_env_status_detail(cls, simulation_id: str) -> Dict[str, Any]: + """ + 获取模拟环境的详细状态信息 + + Args: + simulation_id: 模拟ID + + Returns: + 状态详情字典,包含 status, twitter_available, reddit_available, timestamp + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + status_file = os.path.join(sim_dir, "env_status.json") + + default_status = { + "status": "stopped", + "twitter_available": False, + "reddit_available": False, + "timestamp": None + } + + if not os.path.exists(status_file): + return default_status + + try: + with open(status_file, 'r', encoding='utf-8') as f: + status = json.load(f) + return { + "status": status.get("status", "stopped"), + "twitter_available": status.get("twitter_available", False), + "reddit_available": status.get("reddit_available", False), + "timestamp": status.get("timestamp") + } + except (json.JSONDecodeError, OSError): + return default_status + + @classmethod + def interview_agent( + cls, + simulation_id: str, + agent_id: int, + prompt: str, + platform: str = None, + timeout: float = 60.0 + ) -> Dict[str, Any]: + """ + 采访单个Agent + + Args: + simulation_id: 模拟ID + agent_id: Agent ID + prompt: 采访问题 + platform: 指定平台(可选) + - "twitter": 只采访Twitter平台 + - "reddit": 只采访Reddit平台 + - None: 双平台模拟时同时采访两个平台,返回整合结果 + timeout: 超时时间(秒) + + Returns: + 采访结果字典 + + Raises: + ValueError: 模拟不存在或环境未运行 + TimeoutError: 等待响应超时 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + if not os.path.exists(sim_dir): + raise ValueError(f"模拟不存在: {simulation_id}") + + ipc_client = SimulationIPCClient(sim_dir) + + if not ipc_client.check_env_alive(): + raise ValueError(f"模拟环境未运行或已关闭,无法执行Interview: {simulation_id}") + + logger.info(f"发送Interview命令: simulation_id={simulation_id}, agent_id={agent_id}, platform={platform}") + + response = ipc_client.send_interview( + agent_id=agent_id, + prompt=prompt, + platform=platform, + timeout=timeout + ) + + if response.status.value == "completed": + return { + "success": True, + "agent_id": agent_id, + "prompt": prompt, + "result": response.result, + "timestamp": response.timestamp + } + else: + return { + "success": False, + "agent_id": agent_id, + "prompt": prompt, + "error": response.error, + "timestamp": response.timestamp + } + + @classmethod + def interview_agents_batch( + cls, + simulation_id: str, + interviews: List[Dict[str, Any]], + platform: str = None, + timeout: float = 120.0 + ) -> Dict[str, Any]: + """ + 批量采访多个Agent + + Args: + simulation_id: 模拟ID + interviews: 采访列表,每个元素包含 {"agent_id": int, "prompt": str, "platform": str(可选)} + platform: 默认平台(可选,会被每个采访项的platform覆盖) + - "twitter": 默认只采访Twitter平台 + - "reddit": 默认只采访Reddit平台 + - None: 双平台模拟时每个Agent同时采访两个平台 + timeout: 超时时间(秒) + + Returns: + 批量采访结果字典 + + Raises: + ValueError: 模拟不存在或环境未运行 + TimeoutError: 等待响应超时 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + if not os.path.exists(sim_dir): + raise ValueError(f"模拟不存在: {simulation_id}") + + ipc_client = SimulationIPCClient(sim_dir) + + if not ipc_client.check_env_alive(): + raise ValueError(f"模拟环境未运行或已关闭,无法执行Interview: {simulation_id}") + + logger.info(f"发送批量Interview命令: simulation_id={simulation_id}, count={len(interviews)}, platform={platform}") + + response = ipc_client.send_batch_interview( + interviews=interviews, + platform=platform, + timeout=timeout + ) + + if response.status.value == "completed": + return { + "success": True, + "interviews_count": len(interviews), + "result": response.result, + "timestamp": response.timestamp + } + else: + return { + "success": False, + "interviews_count": len(interviews), + "error": response.error, + "timestamp": response.timestamp + } + + @classmethod + def interview_all_agents( + cls, + simulation_id: str, + prompt: str, + platform: str = None, + timeout: float = 180.0 + ) -> Dict[str, Any]: + """ + 采访所有Agent(全局采访) + + 使用相同的问题采访模拟中的所有Agent + + Args: + simulation_id: 模拟ID + prompt: 采访问题(所有Agent使用相同问题) + platform: 指定平台(可选) + - "twitter": 只采访Twitter平台 + - "reddit": 只采访Reddit平台 + - None: 双平台模拟时每个Agent同时采访两个平台 + timeout: 超时时间(秒) + + Returns: + 全局采访结果字典 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + if not os.path.exists(sim_dir): + raise ValueError(f"模拟不存在: {simulation_id}") + + # 从配置文件获取所有Agent信息 + config_path = os.path.join(sim_dir, "simulation_config.json") + if not os.path.exists(config_path): + raise ValueError(f"模拟配置不存在: {simulation_id}") + + with open(config_path, 'r', encoding='utf-8') as f: + config = json.load(f) + + agent_configs = config.get("agent_configs", []) + if not agent_configs: + raise ValueError(f"模拟配置中没有Agent: {simulation_id}") + + # 构建批量采访列表 + interviews = [] + for agent_config in agent_configs: + agent_id = agent_config.get("agent_id") + if agent_id is not None: + interviews.append({ + "agent_id": agent_id, + "prompt": prompt + }) + + logger.info(f"发送全局Interview命令: simulation_id={simulation_id}, agent_count={len(interviews)}, platform={platform}") + + return cls.interview_agents_batch( + simulation_id=simulation_id, + interviews=interviews, + platform=platform, + timeout=timeout + ) + + @classmethod + def close_simulation_env( + cls, + simulation_id: str, + timeout: float = 30.0 + ) -> Dict[str, Any]: + """ + 关闭模拟环境(而不是停止模拟进程) + + 向模拟发送关闭环境命令,使其优雅退出等待命令模式 + + Args: + simulation_id: 模拟ID + timeout: 超时时间(秒) + + Returns: + 操作结果字典 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + if not os.path.exists(sim_dir): + raise ValueError(f"模拟不存在: {simulation_id}") + + ipc_client = SimulationIPCClient(sim_dir) + + if not ipc_client.check_env_alive(): + return { + "success": True, + "message": "环境已经关闭" + } + + logger.info(f"发送关闭环境命令: simulation_id={simulation_id}") + + try: + response = ipc_client.send_close_env(timeout=timeout) + + return { + "success": response.status.value == "completed", + "message": "环境关闭命令已发送", + "result": response.result, + "timestamp": response.timestamp + } + except TimeoutError: + # 超时可能是因为环境正在关闭 + return { + "success": True, + "message": "环境关闭命令已发送(等待响应超时,环境可能正在关闭)" + } + + @classmethod + def _get_interview_history_from_db( + cls, + db_path: str, + platform_name: str, + agent_id: Optional[int] = None, + limit: int = 100 + ) -> List[Dict[str, Any]]: + """从单个数据库获取Interview历史""" + import sqlite3 + + if not os.path.exists(db_path): + return [] + + results = [] + + try: + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + if agent_id is not None: + cursor.execute(""" + SELECT user_id, info, created_at + FROM trace + WHERE action = 'interview' AND user_id = ? + ORDER BY created_at DESC + LIMIT ? + """, (agent_id, limit)) + else: + cursor.execute(""" + SELECT user_id, info, created_at + FROM trace + WHERE action = 'interview' + ORDER BY created_at DESC + LIMIT ? + """, (limit,)) + + for user_id, info_json, created_at in cursor.fetchall(): + try: + info = json.loads(info_json) if info_json else {} + except json.JSONDecodeError: + info = {"raw": info_json} + + results.append({ + "agent_id": user_id, + "response": info.get("response", info), + "prompt": info.get("prompt", ""), + "timestamp": created_at, + "platform": platform_name + }) + + conn.close() + + except Exception as e: + logger.error(f"读取Interview历史失败 ({platform_name}): {e}") + + return results + + @classmethod + def get_interview_history( + cls, + simulation_id: str, + platform: str = None, + agent_id: Optional[int] = None, + limit: int = 100 + ) -> List[Dict[str, Any]]: + """ + 获取Interview历史记录(从数据库读取) + + Args: + simulation_id: 模拟ID + platform: 平台类型(reddit/twitter/None) + - "reddit": 只获取Reddit平台的历史 + - "twitter": 只获取Twitter平台的历史 + - None: 获取两个平台的所有历史 + agent_id: 指定Agent ID(可选,只获取该Agent的历史) + limit: 每个平台返回数量限制 + + Returns: + Interview历史记录列表 + """ + sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id) + + results = [] + + # 确定要查询的平台 + if platform in ("reddit", "twitter"): + platforms = [platform] + else: + # 不指定platform时,查询两个平台 + platforms = ["twitter", "reddit"] + + for p in platforms: + db_path = os.path.join(sim_dir, f"{p}_simulation.db") + platform_results = cls._get_interview_history_from_db( + db_path=db_path, + platform_name=p, + agent_id=agent_id, + limit=limit + ) + results.extend(platform_results) + + # 按时间降序排序 + results.sort(key=lambda x: x.get("timestamp", ""), reverse=True) + + # 如果查询了多个平台,限制总数 + if len(platforms) > 1 and len(results) > limit: + results = results[:limit] + + return results + diff --git a/backend/app/services/text_processor.py b/backend/app/services/text_processor.py new file mode 100644 index 00000000..91e32acc --- /dev/null +++ b/backend/app/services/text_processor.py @@ -0,0 +1,71 @@ +""" +文本处理服务 +""" + +from typing import List, Optional +from ..utils.file_parser import FileParser, split_text_into_chunks + + +class TextProcessor: + """文本处理器""" + + @staticmethod + def extract_from_files(file_paths: List[str]) -> str: + """从多个文件提取文本""" + return FileParser.extract_from_multiple(file_paths) + + @staticmethod + def split_text( + text: str, + chunk_size: int = 500, + overlap: int = 50 + ) -> List[str]: + """ + 分割文本 + + Args: + text: 原始文本 + chunk_size: 块大小 + overlap: 重叠大小 + + Returns: + 文本块列表 + """ + return split_text_into_chunks(text, chunk_size, overlap) + + @staticmethod + def preprocess_text(text: str) -> str: + """ + 预处理文本 + - 移除多余空白 + - 标准化换行 + + Args: + text: 原始文本 + + Returns: + 处理后的文本 + """ + import re + + # 标准化换行 + text = text.replace('\r\n', '\n').replace('\r', '\n') + + # 移除连续空行(保留最多两个换行) + text = re.sub(r'\n{3,}', '\n\n', text) + + # 移除行首行尾空白 + lines = [line.strip() for line in text.split('\n')] + text = '\n'.join(lines) + + return text.strip() + + @staticmethod + def get_text_stats(text: str) -> dict: + """获取文本统计信息""" + return { + "total_chars": len(text), + "total_lines": text.count('\n') + 1, + "total_words": len(text.split()), + } + diff --git a/backend/app/services/zep_entity_reader.py b/backend/app/services/zep_entity_reader.py new file mode 100644 index 00000000..71661be4 --- /dev/null +++ b/backend/app/services/zep_entity_reader.py @@ -0,0 +1,437 @@ +""" +Zep实体读取与过滤服务 +从Zep图谱中读取节点,筛选出符合预定义实体类型的节点 +""" + +import time +from typing import Dict, Any, List, Optional, Set, Callable, TypeVar +from dataclasses import dataclass, field + +from zep_cloud.client import Zep + +from ..config import Config +from ..utils.logger import get_logger +from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges + +logger = get_logger('mirofish.zep_entity_reader') + +# 用于泛型返回类型 +T = TypeVar('T') + + +@dataclass +class EntityNode: + """实体节点数据结构""" + uuid: str + name: str + labels: List[str] + summary: str + attributes: Dict[str, Any] + # 相关的边信息 + related_edges: List[Dict[str, Any]] = field(default_factory=list) + # 相关的其他节点信息 + related_nodes: List[Dict[str, Any]] = field(default_factory=list) + + def to_dict(self) -> Dict[str, Any]: + return { + "uuid": self.uuid, + "name": self.name, + "labels": self.labels, + "summary": self.summary, + "attributes": self.attributes, + "related_edges": self.related_edges, + "related_nodes": self.related_nodes, + } + + def get_entity_type(self) -> Optional[str]: + """获取实体类型(排除默认的Entity标签)""" + for label in self.labels: + if label not in ["Entity", "Node"]: + return label + return None + + +@dataclass +class FilteredEntities: + """过滤后的实体集合""" + entities: List[EntityNode] + entity_types: Set[str] + total_count: int + filtered_count: int + + def to_dict(self) -> Dict[str, Any]: + return { + "entities": [e.to_dict() for e in self.entities], + "entity_types": list(self.entity_types), + "total_count": self.total_count, + "filtered_count": self.filtered_count, + } + + +class ZepEntityReader: + """ + Zep实体读取与过滤服务 + + 主要功能: + 1. 从Zep图谱读取所有节点 + 2. 筛选出符合预定义实体类型的节点(Labels不只是Entity的节点) + 3. 获取每个实体的相关边和关联节点信息 + """ + + def __init__(self, api_key: Optional[str] = None): + self.api_key = api_key or Config.ZEP_API_KEY + if not self.api_key: + raise ValueError("ZEP_API_KEY 未配置") + + self.client = Zep(api_key=self.api_key) + + def _call_with_retry( + self, + func: Callable[[], T], + operation_name: str, + max_retries: int = 3, + initial_delay: float = 2.0 + ) -> T: + """ + 带重试机制的Zep API调用 + + Args: + func: 要执行的函数(无参数的lambda或callable) + operation_name: 操作名称,用于日志 + max_retries: 最大重试次数(默认3次,即最多尝试3次) + initial_delay: 初始延迟秒数 + + Returns: + API调用结果 + """ + last_exception = None + delay = initial_delay + + for attempt in range(max_retries): + try: + return func() + except Exception as e: + last_exception = e + if attempt < max_retries - 1: + logger.warning( + f"Zep {operation_name} 第 {attempt + 1} 次尝试失败: {str(e)[:100]}, " + f"{delay:.1f}秒后重试..." + ) + time.sleep(delay) + delay *= 2 # 指数退避 + else: + logger.error(f"Zep {operation_name} 在 {max_retries} 次尝试后仍失败: {str(e)}") + + raise last_exception + + def get_all_nodes(self, graph_id: str) -> List[Dict[str, Any]]: + """ + 获取图谱的所有节点(分页获取) + + Args: + graph_id: 图谱ID + + Returns: + 节点列表 + """ + logger.info(f"获取图谱 {graph_id} 的所有节点...") + + nodes = fetch_all_nodes(self.client, graph_id) + + nodes_data = [] + for node in nodes: + nodes_data.append({ + "uuid": getattr(node, 'uuid_', None) or getattr(node, 'uuid', ''), + "name": node.name or "", + "labels": node.labels or [], + "summary": node.summary or "", + "attributes": node.attributes or {}, + }) + + logger.info(f"共获取 {len(nodes_data)} 个节点") + return nodes_data + + def get_all_edges(self, graph_id: str) -> List[Dict[str, Any]]: + """ + 获取图谱的所有边(分页获取) + + Args: + graph_id: 图谱ID + + Returns: + 边列表 + """ + logger.info(f"获取图谱 {graph_id} 的所有边...") + + edges = fetch_all_edges(self.client, graph_id) + + edges_data = [] + for edge in edges: + edges_data.append({ + "uuid": getattr(edge, 'uuid_', None) or getattr(edge, 'uuid', ''), + "name": edge.name or "", + "fact": edge.fact or "", + "source_node_uuid": edge.source_node_uuid, + "target_node_uuid": edge.target_node_uuid, + "attributes": edge.attributes or {}, + }) + + logger.info(f"共获取 {len(edges_data)} 条边") + return edges_data + + def get_node_edges(self, node_uuid: str) -> List[Dict[str, Any]]: + """ + 获取指定节点的所有相关边(带重试机制) + + Args: + node_uuid: 节点UUID + + Returns: + 边列表 + """ + try: + # 使用重试机制调用Zep API + edges = self._call_with_retry( + func=lambda: self.client.graph.node.get_entity_edges(node_uuid=node_uuid), + operation_name=f"获取节点边(node={node_uuid[:8]}...)" + ) + + edges_data = [] + for edge in edges: + edges_data.append({ + "uuid": getattr(edge, 'uuid_', None) or getattr(edge, 'uuid', ''), + "name": edge.name or "", + "fact": edge.fact or "", + "source_node_uuid": edge.source_node_uuid, + "target_node_uuid": edge.target_node_uuid, + "attributes": edge.attributes or {}, + }) + + return edges_data + except Exception as e: + logger.warning(f"获取节点 {node_uuid} 的边失败: {str(e)}") + return [] + + def filter_defined_entities( + self, + graph_id: str, + defined_entity_types: Optional[List[str]] = None, + enrich_with_edges: bool = True + ) -> FilteredEntities: + """ + 筛选出符合预定义实体类型的节点 + + 筛选逻辑: + - 如果节点的Labels只有一个"Entity",说明这个实体不符合我们预定义的类型,跳过 + - 如果节点的Labels包含除"Entity"和"Node"之外的标签,说明符合预定义类型,保留 + + Args: + graph_id: 图谱ID + defined_entity_types: 预定义的实体类型列表(可选,如果提供则只保留这些类型) + enrich_with_edges: 是否获取每个实体的相关边信息 + + Returns: + FilteredEntities: 过滤后的实体集合 + """ + logger.info(f"开始筛选图谱 {graph_id} 的实体...") + + # 获取所有节点 + all_nodes = self.get_all_nodes(graph_id) + total_count = len(all_nodes) + + # 获取所有边(用于后续关联查找) + all_edges = self.get_all_edges(graph_id) if enrich_with_edges else [] + + # 构建节点UUID到节点数据的映射 + node_map = {n["uuid"]: n for n in all_nodes} + + # 筛选符合条件的实体 + filtered_entities = [] + entity_types_found = set() + + for node in all_nodes: + labels = node.get("labels", []) + + # 筛选逻辑:Labels必须包含除"Entity"和"Node"之外的标签 + custom_labels = [l for l in labels if l not in ["Entity", "Node"]] + + if not custom_labels: + # 只有默认标签,跳过 + continue + + # 如果指定了预定义类型,检查是否匹配 + if defined_entity_types: + matching_labels = [l for l in custom_labels if l in defined_entity_types] + if not matching_labels: + continue + entity_type = matching_labels[0] + else: + entity_type = custom_labels[0] + + entity_types_found.add(entity_type) + + # 创建实体节点对象 + entity = EntityNode( + uuid=node["uuid"], + name=node["name"], + labels=labels, + summary=node["summary"], + attributes=node["attributes"], + ) + + # 获取相关边和节点 + if enrich_with_edges: + related_edges = [] + related_node_uuids = set() + + for edge in all_edges: + if edge["source_node_uuid"] == node["uuid"]: + related_edges.append({ + "direction": "outgoing", + "edge_name": edge["name"], + "fact": edge["fact"], + "target_node_uuid": edge["target_node_uuid"], + }) + related_node_uuids.add(edge["target_node_uuid"]) + elif edge["target_node_uuid"] == node["uuid"]: + related_edges.append({ + "direction": "incoming", + "edge_name": edge["name"], + "fact": edge["fact"], + "source_node_uuid": edge["source_node_uuid"], + }) + related_node_uuids.add(edge["source_node_uuid"]) + + entity.related_edges = related_edges + + # 获取关联节点的基本信息 + related_nodes = [] + for related_uuid in related_node_uuids: + if related_uuid in node_map: + related_node = node_map[related_uuid] + related_nodes.append({ + "uuid": related_node["uuid"], + "name": related_node["name"], + "labels": related_node["labels"], + "summary": related_node.get("summary", ""), + }) + + entity.related_nodes = related_nodes + + filtered_entities.append(entity) + + logger.info(f"筛选完成: 总节点 {total_count}, 符合条件 {len(filtered_entities)}, " + f"实体类型: {entity_types_found}") + + return FilteredEntities( + entities=filtered_entities, + entity_types=entity_types_found, + total_count=total_count, + filtered_count=len(filtered_entities), + ) + + def get_entity_with_context( + self, + graph_id: str, + entity_uuid: str + ) -> Optional[EntityNode]: + """ + 获取单个实体及其完整上下文(边和关联节点,带重试机制) + + Args: + graph_id: 图谱ID + entity_uuid: 实体UUID + + Returns: + EntityNode或None + """ + try: + # 使用重试机制获取节点 + node = self._call_with_retry( + func=lambda: self.client.graph.node.get(uuid_=entity_uuid), + operation_name=f"获取节点详情(uuid={entity_uuid[:8]}...)" + ) + + if not node: + return None + + # 获取节点的边 + edges = self.get_node_edges(entity_uuid) + + # 获取所有节点用于关联查找 + all_nodes = self.get_all_nodes(graph_id) + node_map = {n["uuid"]: n for n in all_nodes} + + # 处理相关边和节点 + related_edges = [] + related_node_uuids = set() + + for edge in edges: + if edge["source_node_uuid"] == entity_uuid: + related_edges.append({ + "direction": "outgoing", + "edge_name": edge["name"], + "fact": edge["fact"], + "target_node_uuid": edge["target_node_uuid"], + }) + related_node_uuids.add(edge["target_node_uuid"]) + else: + related_edges.append({ + "direction": "incoming", + "edge_name": edge["name"], + "fact": edge["fact"], + "source_node_uuid": edge["source_node_uuid"], + }) + related_node_uuids.add(edge["source_node_uuid"]) + + # 获取关联节点信息 + related_nodes = [] + for related_uuid in related_node_uuids: + if related_uuid in node_map: + related_node = node_map[related_uuid] + related_nodes.append({ + "uuid": related_node["uuid"], + "name": related_node["name"], + "labels": related_node["labels"], + "summary": related_node.get("summary", ""), + }) + + return EntityNode( + uuid=getattr(node, 'uuid_', None) or getattr(node, 'uuid', ''), + name=node.name or "", + labels=node.labels or [], + summary=node.summary or "", + attributes=node.attributes or {}, + related_edges=related_edges, + related_nodes=related_nodes, + ) + + except Exception as e: + logger.error(f"获取实体 {entity_uuid} 失败: {str(e)}") + return None + + def get_entities_by_type( + self, + graph_id: str, + entity_type: str, + enrich_with_edges: bool = True + ) -> List[EntityNode]: + """ + 获取指定类型的所有实体 + + Args: + graph_id: 图谱ID + entity_type: 实体类型(如 "Student", "PublicFigure" 等) + enrich_with_edges: 是否获取相关边信息 + + Returns: + 实体列表 + """ + result = self.filter_defined_entities( + graph_id=graph_id, + defined_entity_types=[entity_type], + enrich_with_edges=enrich_with_edges + ) + return result.entities + + diff --git a/backend/app/services/zep_graph_memory_updater.py b/backend/app/services/zep_graph_memory_updater.py new file mode 100644 index 00000000..e034fee2 --- /dev/null +++ b/backend/app/services/zep_graph_memory_updater.py @@ -0,0 +1,554 @@ +""" +Zep图谱记忆更新服务 +将模拟中的Agent活动动态更新到Zep图谱中 +""" + +import os +import time +import threading +import json +from typing import Dict, Any, List, Optional, Callable +from dataclasses import dataclass +from datetime import datetime +from queue import Queue, Empty + +from zep_cloud.client import Zep + +from ..config import Config +from ..utils.logger import get_logger +from ..utils.locale import get_locale, set_locale + +logger = get_logger('mirofish.zep_graph_memory_updater') + + +@dataclass +class AgentActivity: + """Agent活动记录""" + platform: str # twitter / reddit + agent_id: int + agent_name: str + action_type: str # CREATE_POST, LIKE_POST, etc. + action_args: Dict[str, Any] + round_num: int + timestamp: str + + def to_episode_text(self) -> str: + """ + 将活动转换为可以发送给Zep的文本描述 + + 采用自然语言描述格式,让Zep能够从中提取实体和关系 + 不添加模拟相关的前缀,避免误导图谱更新 + """ + # 根据不同的动作类型生成不同的描述 + action_descriptions = { + "CREATE_POST": self._describe_create_post, + "LIKE_POST": self._describe_like_post, + "DISLIKE_POST": self._describe_dislike_post, + "REPOST": self._describe_repost, + "QUOTE_POST": self._describe_quote_post, + "FOLLOW": self._describe_follow, + "CREATE_COMMENT": self._describe_create_comment, + "LIKE_COMMENT": self._describe_like_comment, + "DISLIKE_COMMENT": self._describe_dislike_comment, + "SEARCH_POSTS": self._describe_search, + "SEARCH_USER": self._describe_search_user, + "MUTE": self._describe_mute, + } + + describe_func = action_descriptions.get(self.action_type, self._describe_generic) + description = describe_func() + + # 直接返回 "agent名称: 活动描述" 格式,不添加模拟前缀 + return f"{self.agent_name}: {description}" + + def _describe_create_post(self) -> str: + content = self.action_args.get("content", "") + if content: + return f"发布了一条帖子:「{content}」" + return "发布了一条帖子" + + def _describe_like_post(self) -> str: + """点赞帖子 - 包含帖子原文和作者信息""" + post_content = self.action_args.get("post_content", "") + post_author = self.action_args.get("post_author_name", "") + + if post_content and post_author: + return f"点赞了{post_author}的帖子:「{post_content}」" + elif post_content: + return f"点赞了一条帖子:「{post_content}」" + elif post_author: + return f"点赞了{post_author}的一条帖子" + return "点赞了一条帖子" + + def _describe_dislike_post(self) -> str: + """踩帖子 - 包含帖子原文和作者信息""" + post_content = self.action_args.get("post_content", "") + post_author = self.action_args.get("post_author_name", "") + + if post_content and post_author: + return f"踩了{post_author}的帖子:「{post_content}」" + elif post_content: + return f"踩了一条帖子:「{post_content}」" + elif post_author: + return f"踩了{post_author}的一条帖子" + return "踩了一条帖子" + + def _describe_repost(self) -> str: + """转发帖子 - 包含原帖内容和作者信息""" + original_content = self.action_args.get("original_content", "") + original_author = self.action_args.get("original_author_name", "") + + if original_content and original_author: + return f"转发了{original_author}的帖子:「{original_content}」" + elif original_content: + return f"转发了一条帖子:「{original_content}」" + elif original_author: + return f"转发了{original_author}的一条帖子" + return "转发了一条帖子" + + def _describe_quote_post(self) -> str: + """引用帖子 - 包含原帖内容、作者信息和引用评论""" + original_content = self.action_args.get("original_content", "") + original_author = self.action_args.get("original_author_name", "") + quote_content = self.action_args.get("quote_content", "") or self.action_args.get("content", "") + + base = "" + if original_content and original_author: + base = f"引用了{original_author}的帖子「{original_content}」" + elif original_content: + base = f"引用了一条帖子「{original_content}」" + elif original_author: + base = f"引用了{original_author}的一条帖子" + else: + base = "引用了一条帖子" + + if quote_content: + base += f",并评论道:「{quote_content}」" + return base + + def _describe_follow(self) -> str: + """关注用户 - 包含被关注用户的名称""" + target_user_name = self.action_args.get("target_user_name", "") + + if target_user_name: + return f"关注了用户「{target_user_name}」" + return "关注了一个用户" + + def _describe_create_comment(self) -> str: + """发表评论 - 包含评论内容和所评论的帖子信息""" + content = self.action_args.get("content", "") + post_content = self.action_args.get("post_content", "") + post_author = self.action_args.get("post_author_name", "") + + if content: + if post_content and post_author: + return f"在{post_author}的帖子「{post_content}」下评论道:「{content}」" + elif post_content: + return f"在帖子「{post_content}」下评论道:「{content}」" + elif post_author: + return f"在{post_author}的帖子下评论道:「{content}」" + return f"评论道:「{content}」" + return "发表了评论" + + def _describe_like_comment(self) -> str: + """点赞评论 - 包含评论内容和作者信息""" + comment_content = self.action_args.get("comment_content", "") + comment_author = self.action_args.get("comment_author_name", "") + + if comment_content and comment_author: + return f"点赞了{comment_author}的评论:「{comment_content}」" + elif comment_content: + return f"点赞了一条评论:「{comment_content}」" + elif comment_author: + return f"点赞了{comment_author}的一条评论" + return "点赞了一条评论" + + def _describe_dislike_comment(self) -> str: + """踩评论 - 包含评论内容和作者信息""" + comment_content = self.action_args.get("comment_content", "") + comment_author = self.action_args.get("comment_author_name", "") + + if comment_content and comment_author: + return f"踩了{comment_author}的评论:「{comment_content}」" + elif comment_content: + return f"踩了一条评论:「{comment_content}」" + elif comment_author: + return f"踩了{comment_author}的一条评论" + return "踩了一条评论" + + def _describe_search(self) -> str: + """搜索帖子 - 包含搜索关键词""" + query = self.action_args.get("query", "") or self.action_args.get("keyword", "") + return f"搜索了「{query}」" if query else "进行了搜索" + + def _describe_search_user(self) -> str: + """搜索用户 - 包含搜索关键词""" + query = self.action_args.get("query", "") or self.action_args.get("username", "") + return f"搜索了用户「{query}」" if query else "搜索了用户" + + def _describe_mute(self) -> str: + """屏蔽用户 - 包含被屏蔽用户的名称""" + target_user_name = self.action_args.get("target_user_name", "") + + if target_user_name: + return f"屏蔽了用户「{target_user_name}」" + return "屏蔽了一个用户" + + def _describe_generic(self) -> str: + # 对于未知的动作类型,生成通用描述 + return f"执行了{self.action_type}操作" + + +class ZepGraphMemoryUpdater: + """ + Zep图谱记忆更新器 + + 监控模拟的actions日志文件,将新的agent活动实时更新到Zep图谱中。 + 按平台分组,每累积BATCH_SIZE条活动后批量发送到Zep。 + + 所有有意义的行为都会被更新到Zep,action_args中会包含完整的上下文信息: + - 点赞/踩的帖子原文 + - 转发/引用的帖子原文 + - 关注/屏蔽的用户名 + - 点赞/踩的评论原文 + """ + + # 批量发送大小(每个平台累积多少条后发送) + BATCH_SIZE = 5 + + # 平台名称映射(用于控制台显示) + PLATFORM_DISPLAY_NAMES = { + 'twitter': '世界1', + 'reddit': '世界2', + } + + # 发送间隔(秒),避免请求过快 + SEND_INTERVAL = 0.5 + + # 重试配置 + MAX_RETRIES = 3 + RETRY_DELAY = 2 # 秒 + + def __init__(self, graph_id: str, api_key: Optional[str] = None): + """ + 初始化更新器 + + Args: + graph_id: Zep图谱ID + api_key: Zep API Key(可选,默认从配置读取) + """ + self.graph_id = graph_id + self.api_key = api_key or Config.ZEP_API_KEY + + if not self.api_key: + raise ValueError("ZEP_API_KEY未配置") + + self.client = Zep(api_key=self.api_key) + + # 活动队列 + self._activity_queue: Queue = Queue() + + # 按平台分组的活动缓冲区(每个平台各自累积到BATCH_SIZE后批量发送) + self._platform_buffers: Dict[str, List[AgentActivity]] = { + 'twitter': [], + 'reddit': [], + } + self._buffer_lock = threading.Lock() + + # 控制标志 + self._running = False + self._worker_thread: Optional[threading.Thread] = None + + # 统计 + self._total_activities = 0 # 实际添加到队列的活动数 + self._total_sent = 0 # 成功发送到Zep的批次数 + self._total_items_sent = 0 # 成功发送到Zep的活动条数 + self._failed_count = 0 # 发送失败的批次数 + self._skipped_count = 0 # 被过滤跳过的活动数(DO_NOTHING) + + logger.info(f"ZepGraphMemoryUpdater 初始化完成: graph_id={graph_id}, batch_size={self.BATCH_SIZE}") + + def _get_platform_display_name(self, platform: str) -> str: + """获取平台的显示名称""" + return self.PLATFORM_DISPLAY_NAMES.get(platform.lower(), platform) + + def start(self): + """启动后台工作线程""" + if self._running: + return + + # Capture locale before spawning background thread + current_locale = get_locale() + + self._running = True + self._worker_thread = threading.Thread( + target=self._worker_loop, + args=(current_locale,), + daemon=True, + name=f"ZepMemoryUpdater-{self.graph_id[:8]}" + ) + self._worker_thread.start() + logger.info(f"ZepGraphMemoryUpdater 已启动: graph_id={self.graph_id}") + + def stop(self): + """停止后台工作线程""" + self._running = False + + # 发送剩余的活动 + self._flush_remaining() + + if self._worker_thread and self._worker_thread.is_alive(): + self._worker_thread.join(timeout=10) + + logger.info(f"ZepGraphMemoryUpdater 已停止: graph_id={self.graph_id}, " + f"total_activities={self._total_activities}, " + f"batches_sent={self._total_sent}, " + f"items_sent={self._total_items_sent}, " + f"failed={self._failed_count}, " + f"skipped={self._skipped_count}") + + def add_activity(self, activity: AgentActivity): + """ + 添加一个agent活动到队列 + + 所有有意义的行为都会被添加到队列,包括: + - CREATE_POST(发帖) + - CREATE_COMMENT(评论) + - QUOTE_POST(引用帖子) + - SEARCH_POSTS(搜索帖子) + - SEARCH_USER(搜索用户) + - LIKE_POST/DISLIKE_POST(点赞/踩帖子) + - REPOST(转发) + - FOLLOW(关注) + - MUTE(屏蔽) + - LIKE_COMMENT/DISLIKE_COMMENT(点赞/踩评论) + + action_args中会包含完整的上下文信息(如帖子原文、用户名等)。 + + Args: + activity: Agent活动记录 + """ + # 跳过DO_NOTHING类型的活动 + if activity.action_type == "DO_NOTHING": + self._skipped_count += 1 + return + + self._activity_queue.put(activity) + self._total_activities += 1 + logger.debug(f"添加活动到Zep队列: {activity.agent_name} - {activity.action_type}") + + def add_activity_from_dict(self, data: Dict[str, Any], platform: str): + """ + 从字典数据添加活动 + + Args: + data: 从actions.jsonl解析的字典数据 + platform: 平台名称 (twitter/reddit) + """ + # 跳过事件类型的条目 + if "event_type" in data: + return + + activity = AgentActivity( + platform=platform, + agent_id=data.get("agent_id", 0), + agent_name=data.get("agent_name", ""), + action_type=data.get("action_type", ""), + action_args=data.get("action_args", {}), + round_num=data.get("round", 0), + timestamp=data.get("timestamp", datetime.now().isoformat()), + ) + + self.add_activity(activity) + + def _worker_loop(self, locale: str = 'zh'): + """后台工作循环 - 按平台批量发送活动到Zep""" + set_locale(locale) + while self._running or not self._activity_queue.empty(): + try: + # 尝试从队列获取活动(超时1秒) + try: + activity = self._activity_queue.get(timeout=1) + + # 将活动添加到对应平台的缓冲区 + platform = activity.platform.lower() + with self._buffer_lock: + if platform not in self._platform_buffers: + self._platform_buffers[platform] = [] + self._platform_buffers[platform].append(activity) + + # 检查该平台是否达到批量大小 + if len(self._platform_buffers[platform]) >= self.BATCH_SIZE: + batch = self._platform_buffers[platform][:self.BATCH_SIZE] + self._platform_buffers[platform] = self._platform_buffers[platform][self.BATCH_SIZE:] + # 释放锁后再发送 + self._send_batch_activities(batch, platform) + # 发送间隔,避免请求过快 + time.sleep(self.SEND_INTERVAL) + + except Empty: + pass + + except Exception as e: + logger.error(f"工作循环异常: {e}") + time.sleep(1) + + def _send_batch_activities(self, activities: List[AgentActivity], platform: str): + """ + 批量发送活动到Zep图谱(合并为一条文本) + + Args: + activities: Agent活动列表 + platform: 平台名称 + """ + if not activities: + return + + # 将多条活动合并为一条文本,用换行分隔 + episode_texts = [activity.to_episode_text() for activity in activities] + combined_text = "\n".join(episode_texts) + + # 带重试的发送 + for attempt in range(self.MAX_RETRIES): + try: + self.client.graph.add( + graph_id=self.graph_id, + type="text", + data=combined_text + ) + + self._total_sent += 1 + self._total_items_sent += len(activities) + display_name = self._get_platform_display_name(platform) + logger.info(f"成功批量发送 {len(activities)} 条{display_name}活动到图谱 {self.graph_id}") + logger.debug(f"批量内容预览: {combined_text[:200]}...") + return + + except Exception as e: + if attempt < self.MAX_RETRIES - 1: + logger.warning(f"批量发送到Zep失败 (尝试 {attempt + 1}/{self.MAX_RETRIES}): {e}") + time.sleep(self.RETRY_DELAY * (attempt + 1)) + else: + logger.error(f"批量发送到Zep失败,已重试{self.MAX_RETRIES}次: {e}") + self._failed_count += 1 + + def _flush_remaining(self): + """发送队列和缓冲区中剩余的活动""" + # 首先处理队列中剩余的活动,添加到缓冲区 + while not self._activity_queue.empty(): + try: + activity = self._activity_queue.get_nowait() + platform = activity.platform.lower() + with self._buffer_lock: + if platform not in self._platform_buffers: + self._platform_buffers[platform] = [] + self._platform_buffers[platform].append(activity) + except Empty: + break + + # 然后发送各平台缓冲区中剩余的活动(即使不足BATCH_SIZE条) + with self._buffer_lock: + for platform, buffer in self._platform_buffers.items(): + if buffer: + display_name = self._get_platform_display_name(platform) + logger.info(f"发送{display_name}平台剩余的 {len(buffer)} 条活动") + self._send_batch_activities(buffer, platform) + # 清空所有缓冲区 + for platform in self._platform_buffers: + self._platform_buffers[platform] = [] + + def get_stats(self) -> Dict[str, Any]: + """获取统计信息""" + with self._buffer_lock: + buffer_sizes = {p: len(b) for p, b in self._platform_buffers.items()} + + return { + "graph_id": self.graph_id, + "batch_size": self.BATCH_SIZE, + "total_activities": self._total_activities, # 添加到队列的活动总数 + "batches_sent": self._total_sent, # 成功发送的批次数 + "items_sent": self._total_items_sent, # 成功发送的活动条数 + "failed_count": self._failed_count, # 发送失败的批次数 + "skipped_count": self._skipped_count, # 被过滤跳过的活动数(DO_NOTHING) + "queue_size": self._activity_queue.qsize(), + "buffer_sizes": buffer_sizes, # 各平台缓冲区大小 + "running": self._running, + } + + +class ZepGraphMemoryManager: + """ + 管理多个模拟的Zep图谱记忆更新器 + + 每个模拟可以有自己的更新器实例 + """ + + _updaters: Dict[str, ZepGraphMemoryUpdater] = {} + _lock = threading.Lock() + + @classmethod + def create_updater(cls, simulation_id: str, graph_id: str) -> ZepGraphMemoryUpdater: + """ + 为模拟创建图谱记忆更新器 + + Args: + simulation_id: 模拟ID + graph_id: Zep图谱ID + + Returns: + ZepGraphMemoryUpdater实例 + """ + with cls._lock: + # 如果已存在,先停止旧的 + if simulation_id in cls._updaters: + cls._updaters[simulation_id].stop() + + updater = ZepGraphMemoryUpdater(graph_id) + updater.start() + cls._updaters[simulation_id] = updater + + logger.info(f"创建图谱记忆更新器: simulation_id={simulation_id}, graph_id={graph_id}") + return updater + + @classmethod + def get_updater(cls, simulation_id: str) -> Optional[ZepGraphMemoryUpdater]: + """获取模拟的更新器""" + return cls._updaters.get(simulation_id) + + @classmethod + def stop_updater(cls, simulation_id: str): + """停止并移除模拟的更新器""" + with cls._lock: + if simulation_id in cls._updaters: + cls._updaters[simulation_id].stop() + del cls._updaters[simulation_id] + logger.info(f"已停止图谱记忆更新器: simulation_id={simulation_id}") + + # 防止 stop_all 重复调用的标志 + _stop_all_done = False + + @classmethod + def stop_all(cls): + """停止所有更新器""" + # 防止重复调用 + if cls._stop_all_done: + return + cls._stop_all_done = True + + with cls._lock: + if cls._updaters: + for simulation_id, updater in list(cls._updaters.items()): + try: + updater.stop() + except Exception as e: + logger.error(f"停止更新器失败: simulation_id={simulation_id}, error={e}") + cls._updaters.clear() + logger.info("已停止所有图谱记忆更新器") + + @classmethod + def get_all_stats(cls) -> Dict[str, Dict[str, Any]]: + """获取所有更新器的统计信息""" + return { + sim_id: updater.get_stats() + for sim_id, updater in cls._updaters.items() + } diff --git a/backend/app/services/zep_tools.py b/backend/app/services/zep_tools.py new file mode 100644 index 00000000..3bc8a57a --- /dev/null +++ b/backend/app/services/zep_tools.py @@ -0,0 +1,1736 @@ +""" +Zep检索工具服务 +封装图谱搜索、节点读取、边查询等工具,供Report Agent使用 + +核心检索工具(优化后): +1. InsightForge(深度洞察检索)- 最强大的混合检索,自动生成子问题并多维度检索 +2. PanoramaSearch(广度搜索)- 获取全貌,包括过期内容 +3. QuickSearch(简单搜索)- 快速检索 +""" + +import time +import json +from typing import Dict, Any, List, Optional +from dataclasses import dataclass, field + +from zep_cloud.client import Zep + +from ..config import Config +from ..utils.logger import get_logger +from ..utils.llm_client import LLMClient +from ..utils.locale import get_locale, t +from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges + +logger = get_logger('mirofish.zep_tools') + + +@dataclass +class SearchResult: + """搜索结果""" + facts: List[str] + edges: List[Dict[str, Any]] + nodes: List[Dict[str, Any]] + query: str + total_count: int + + def to_dict(self) -> Dict[str, Any]: + return { + "facts": self.facts, + "edges": self.edges, + "nodes": self.nodes, + "query": self.query, + "total_count": self.total_count + } + + def to_text(self) -> str: + """转换为文本格式,供LLM理解""" + text_parts = [f"搜索查询: {self.query}", f"找到 {self.total_count} 条相关信息"] + + if self.facts: + text_parts.append("\n### 相关事实:") + for i, fact in enumerate(self.facts, 1): + text_parts.append(f"{i}. {fact}") + + return "\n".join(text_parts) + + +@dataclass +class NodeInfo: + """节点信息""" + uuid: str + name: str + labels: List[str] + summary: str + attributes: Dict[str, Any] + + def to_dict(self) -> Dict[str, Any]: + return { + "uuid": self.uuid, + "name": self.name, + "labels": self.labels, + "summary": self.summary, + "attributes": self.attributes + } + + def to_text(self) -> str: + """转换为文本格式""" + entity_type = next((l for l in self.labels if l not in ["Entity", "Node"]), "未知类型") + return f"实体: {self.name} (类型: {entity_type})\n摘要: {self.summary}" + + +@dataclass +class EdgeInfo: + """边信息""" + uuid: str + name: str + fact: str + source_node_uuid: str + target_node_uuid: str + source_node_name: Optional[str] = None + target_node_name: Optional[str] = None + # 时间信息 + created_at: Optional[str] = None + valid_at: Optional[str] = None + invalid_at: Optional[str] = None + expired_at: Optional[str] = None + + def to_dict(self) -> Dict[str, Any]: + return { + "uuid": self.uuid, + "name": self.name, + "fact": self.fact, + "source_node_uuid": self.source_node_uuid, + "target_node_uuid": self.target_node_uuid, + "source_node_name": self.source_node_name, + "target_node_name": self.target_node_name, + "created_at": self.created_at, + "valid_at": self.valid_at, + "invalid_at": self.invalid_at, + "expired_at": self.expired_at + } + + def to_text(self, include_temporal: bool = False) -> str: + """转换为文本格式""" + source = self.source_node_name or self.source_node_uuid[:8] + target = self.target_node_name or self.target_node_uuid[:8] + base_text = f"关系: {source} --[{self.name}]--> {target}\n事实: {self.fact}" + + if include_temporal: + valid_at = self.valid_at or "未知" + invalid_at = self.invalid_at or "至今" + base_text += f"\n时效: {valid_at} - {invalid_at}" + if self.expired_at: + base_text += f" (已过期: {self.expired_at})" + + return base_text + + @property + def is_expired(self) -> bool: + """是否已过期""" + return self.expired_at is not None + + @property + def is_invalid(self) -> bool: + """是否已失效""" + return self.invalid_at is not None + + +@dataclass +class InsightForgeResult: + """ + 深度洞察检索结果 (InsightForge) + 包含多个子问题的检索结果,以及综合分析 + """ + query: str + simulation_requirement: str + sub_queries: List[str] + + # 各维度检索结果 + semantic_facts: List[str] = field(default_factory=list) # 语义搜索结果 + entity_insights: List[Dict[str, Any]] = field(default_factory=list) # 实体洞察 + relationship_chains: List[str] = field(default_factory=list) # 关系链 + + # 统计信息 + total_facts: int = 0 + total_entities: int = 0 + total_relationships: int = 0 + + def to_dict(self) -> Dict[str, Any]: + return { + "query": self.query, + "simulation_requirement": self.simulation_requirement, + "sub_queries": self.sub_queries, + "semantic_facts": self.semantic_facts, + "entity_insights": self.entity_insights, + "relationship_chains": self.relationship_chains, + "total_facts": self.total_facts, + "total_entities": self.total_entities, + "total_relationships": self.total_relationships + } + + def to_text(self) -> str: + """转换为详细的文本格式,供LLM理解""" + text_parts = [ + f"## 未来预测深度分析", + f"分析问题: {self.query}", + f"预测场景: {self.simulation_requirement}", + f"\n### 预测数据统计", + f"- 相关预测事实: {self.total_facts}条", + f"- 涉及实体: {self.total_entities}个", + f"- 关系链: {self.total_relationships}条" + ] + + # 子问题 + if self.sub_queries: + text_parts.append(f"\n### 分析的子问题") + for i, sq in enumerate(self.sub_queries, 1): + text_parts.append(f"{i}. {sq}") + + # 语义搜索结果 + if self.semantic_facts: + text_parts.append(f"\n### 【关键事实】(请在报告中引用这些原文)") + for i, fact in enumerate(self.semantic_facts, 1): + text_parts.append(f"{i}. \"{fact}\"") + + # 实体洞察 + if self.entity_insights: + text_parts.append(f"\n### 【核心实体】") + for entity in self.entity_insights: + text_parts.append(f"- **{entity.get('name', '未知')}** ({entity.get('type', '实体')})") + if entity.get('summary'): + text_parts.append(f" 摘要: \"{entity.get('summary')}\"") + if entity.get('related_facts'): + text_parts.append(f" 相关事实: {len(entity.get('related_facts', []))}条") + + # 关系链 + if self.relationship_chains: + text_parts.append(f"\n### 【关系链】") + for chain in self.relationship_chains: + text_parts.append(f"- {chain}") + + return "\n".join(text_parts) + + +@dataclass +class PanoramaResult: + """ + 广度搜索结果 (Panorama) + 包含所有相关信息,包括过期内容 + """ + query: str + + # 全部节点 + all_nodes: List[NodeInfo] = field(default_factory=list) + # 全部边(包括过期的) + all_edges: List[EdgeInfo] = field(default_factory=list) + # 当前有效的事实 + active_facts: List[str] = field(default_factory=list) + # 已过期/失效的事实(历史记录) + historical_facts: List[str] = field(default_factory=list) + + # 统计 + total_nodes: int = 0 + total_edges: int = 0 + active_count: int = 0 + historical_count: int = 0 + + def to_dict(self) -> Dict[str, Any]: + return { + "query": self.query, + "all_nodes": [n.to_dict() for n in self.all_nodes], + "all_edges": [e.to_dict() for e in self.all_edges], + "active_facts": self.active_facts, + "historical_facts": self.historical_facts, + "total_nodes": self.total_nodes, + "total_edges": self.total_edges, + "active_count": self.active_count, + "historical_count": self.historical_count + } + + def to_text(self) -> str: + """转换为文本格式(完整版本,不截断)""" + text_parts = [ + f"## 广度搜索结果(未来全景视图)", + f"查询: {self.query}", + f"\n### 统计信息", + f"- 总节点数: {self.total_nodes}", + f"- 总边数: {self.total_edges}", + f"- 当前有效事实: {self.active_count}条", + f"- 历史/过期事实: {self.historical_count}条" + ] + + # 当前有效的事实(完整输出,不截断) + if self.active_facts: + text_parts.append(f"\n### 【当前有效事实】(模拟结果原文)") + for i, fact in enumerate(self.active_facts, 1): + text_parts.append(f"{i}. \"{fact}\"") + + # 历史/过期事实(完整输出,不截断) + if self.historical_facts: + text_parts.append(f"\n### 【历史/过期事实】(演变过程记录)") + for i, fact in enumerate(self.historical_facts, 1): + text_parts.append(f"{i}. \"{fact}\"") + + # 关键实体(完整输出,不截断) + if self.all_nodes: + text_parts.append(f"\n### 【涉及实体】") + for node in self.all_nodes: + entity_type = next((l for l in node.labels if l not in ["Entity", "Node"]), "实体") + text_parts.append(f"- **{node.name}** ({entity_type})") + + return "\n".join(text_parts) + + +@dataclass +class AgentInterview: + """单个Agent的采访结果""" + agent_name: str + agent_role: str # 角色类型(如:学生、教师、媒体等) + agent_bio: str # 简介 + question: str # 采访问题 + response: str # 采访回答 + key_quotes: List[str] = field(default_factory=list) # 关键引言 + + def to_dict(self) -> Dict[str, Any]: + return { + "agent_name": self.agent_name, + "agent_role": self.agent_role, + "agent_bio": self.agent_bio, + "question": self.question, + "response": self.response, + "key_quotes": self.key_quotes + } + + def to_text(self) -> str: + text = f"**{self.agent_name}** ({self.agent_role})\n" + # 显示完整的agent_bio,不截断 + text += f"_简介: {self.agent_bio}_\n\n" + text += f"**Q:** {self.question}\n\n" + text += f"**A:** {self.response}\n" + if self.key_quotes: + text += "\n**关键引言:**\n" + for quote in self.key_quotes: + # 清理各种引号 + clean_quote = quote.replace('\u201c', '').replace('\u201d', '').replace('"', '') + clean_quote = clean_quote.replace('\u300c', '').replace('\u300d', '') + clean_quote = clean_quote.strip() + # 去掉开头的标点 + while clean_quote and clean_quote[0] in ',,;;::、。!?\n\r\t ': + clean_quote = clean_quote[1:] + # 过滤包含问题编号的垃圾内容(问题1-9) + skip = False + for d in '123456789': + if f'\u95ee\u9898{d}' in clean_quote: + skip = True + break + if skip: + continue + # 截断过长内容(按句号截断,而非硬截断) + if len(clean_quote) > 150: + dot_pos = clean_quote.find('\u3002', 80) + if dot_pos > 0: + clean_quote = clean_quote[:dot_pos + 1] + else: + clean_quote = clean_quote[:147] + "..." + if clean_quote and len(clean_quote) >= 10: + text += f'> "{clean_quote}"\n' + return text + + +@dataclass +class InterviewResult: + """ + 采访结果 (Interview) + 包含多个模拟Agent的采访回答 + """ + interview_topic: str # 采访主题 + interview_questions: List[str] # 采访问题列表 + + # 采访选择的Agent + selected_agents: List[Dict[str, Any]] = field(default_factory=list) + # 各Agent的采访回答 + interviews: List[AgentInterview] = field(default_factory=list) + + # 选择Agent的理由 + selection_reasoning: str = "" + # 整合后的采访摘要 + summary: str = "" + + # 统计 + total_agents: int = 0 + interviewed_count: int = 0 + + def to_dict(self) -> Dict[str, Any]: + return { + "interview_topic": self.interview_topic, + "interview_questions": self.interview_questions, + "selected_agents": self.selected_agents, + "interviews": [i.to_dict() for i in self.interviews], + "selection_reasoning": self.selection_reasoning, + "summary": self.summary, + "total_agents": self.total_agents, + "interviewed_count": self.interviewed_count + } + + def to_text(self) -> str: + """转换为详细的文本格式,供LLM理解和报告引用""" + text_parts = [ + "## 深度采访报告", + f"**采访主题:** {self.interview_topic}", + f"**采访人数:** {self.interviewed_count} / {self.total_agents} 位模拟Agent", + "\n### 采访对象选择理由", + self.selection_reasoning or "(自动选择)", + "\n---", + "\n### 采访实录", + ] + + if self.interviews: + for i, interview in enumerate(self.interviews, 1): + text_parts.append(f"\n#### 采访 #{i}: {interview.agent_name}") + text_parts.append(interview.to_text()) + text_parts.append("\n---") + else: + text_parts.append("(无采访记录)\n\n---") + + text_parts.append("\n### 采访摘要与核心观点") + text_parts.append(self.summary or "(无摘要)") + + return "\n".join(text_parts) + + +class ZepToolsService: + """ + Zep检索工具服务 + + 【核心检索工具 - 优化后】 + 1. insight_forge - 深度洞察检索(最强大,自动生成子问题,多维度检索) + 2. panorama_search - 广度搜索(获取全貌,包括过期内容) + 3. quick_search - 简单搜索(快速检索) + 4. interview_agents - 深度采访(采访模拟Agent,获取多视角观点) + + 【基础工具】 + - search_graph - 图谱语义搜索 + - get_all_nodes - 获取图谱所有节点 + - get_all_edges - 获取图谱所有边(含时间信息) + - get_node_detail - 获取节点详细信息 + - get_node_edges - 获取节点相关的边 + - get_entities_by_type - 按类型获取实体 + - get_entity_summary - 获取实体的关系摘要 + """ + + # 重试配置 + MAX_RETRIES = 3 + RETRY_DELAY = 2.0 + + def __init__(self, api_key: Optional[str] = None, llm_client: Optional[LLMClient] = None): + self.api_key = api_key or Config.ZEP_API_KEY + if not self.api_key: + raise ValueError("ZEP_API_KEY 未配置") + + self.client = Zep(api_key=self.api_key) + # LLM客户端用于InsightForge生成子问题 + self._llm_client = llm_client + logger.info(t("console.zepToolsInitialized")) + + @property + def llm(self) -> LLMClient: + """延迟初始化LLM客户端""" + if self._llm_client is None: + self._llm_client = LLMClient() + return self._llm_client + + def _call_with_retry(self, func, operation_name: str, max_retries: int = None): + """带重试机制的API调用""" + max_retries = max_retries or self.MAX_RETRIES + last_exception = None + delay = self.RETRY_DELAY + + for attempt in range(max_retries): + try: + return func() + except Exception as e: + last_exception = e + if attempt < max_retries - 1: + logger.warning( + t("console.zepRetryAttempt", operation=operation_name, attempt=attempt + 1, error=str(e)[:100], delay=f"{delay:.1f}") + ) + time.sleep(delay) + delay *= 2 + else: + logger.error(t("console.zepAllRetriesFailed", operation=operation_name, retries=max_retries, error=str(e))) + + raise last_exception + + def search_graph( + self, + graph_id: str, + query: str, + limit: int = 10, + scope: str = "edges" + ) -> SearchResult: + """ + 图谱语义搜索 + + 使用混合搜索(语义+BM25)在图谱中搜索相关信息。 + 如果Zep Cloud的search API不可用,则降级为本地关键词匹配。 + + Args: + graph_id: 图谱ID (Standalone Graph) + query: 搜索查询 + limit: 返回结果数量 + scope: 搜索范围,"edges" 或 "nodes" + + Returns: + SearchResult: 搜索结果 + """ + logger.info(t("console.graphSearch", graphId=graph_id, query=query[:50])) + + # 尝试使用Zep Cloud Search API + try: + search_results = self._call_with_retry( + func=lambda: self.client.graph.search( + graph_id=graph_id, + query=query, + limit=limit, + scope=scope, + reranker="cross_encoder" + ), + operation_name=t("console.graphSearchOp", graphId=graph_id) + ) + + facts = [] + edges = [] + nodes = [] + + # 解析边搜索结果 + if hasattr(search_results, 'edges') and search_results.edges: + for edge in search_results.edges: + if hasattr(edge, 'fact') and edge.fact: + facts.append(edge.fact) + edges.append({ + "uuid": getattr(edge, 'uuid_', None) or getattr(edge, 'uuid', ''), + "name": getattr(edge, 'name', ''), + "fact": getattr(edge, 'fact', ''), + "source_node_uuid": getattr(edge, 'source_node_uuid', ''), + "target_node_uuid": getattr(edge, 'target_node_uuid', ''), + }) + + # 解析节点搜索结果 + if hasattr(search_results, 'nodes') and search_results.nodes: + for node in search_results.nodes: + nodes.append({ + "uuid": getattr(node, 'uuid_', None) or getattr(node, 'uuid', ''), + "name": getattr(node, 'name', ''), + "labels": getattr(node, 'labels', []), + "summary": getattr(node, 'summary', ''), + }) + # 节点摘要也算作事实 + if hasattr(node, 'summary') and node.summary: + facts.append(f"[{node.name}]: {node.summary}") + + logger.info(t("console.searchComplete", count=len(facts))) + + return SearchResult( + facts=facts, + edges=edges, + nodes=nodes, + query=query, + total_count=len(facts) + ) + + except Exception as e: + logger.warning(t("console.zepSearchApiFallback", error=str(e))) + # 降级:使用本地关键词匹配搜索 + return self._local_search(graph_id, query, limit, scope) + + def _local_search( + self, + graph_id: str, + query: str, + limit: int = 10, + scope: str = "edges" + ) -> SearchResult: + """ + 本地关键词匹配搜索(作为Zep Search API的降级方案) + + 获取所有边/节点,然后在本地进行关键词匹配 + + Args: + graph_id: 图谱ID + query: 搜索查询 + limit: 返回结果数量 + scope: 搜索范围 + + Returns: + SearchResult: 搜索结果 + """ + logger.info(t("console.usingLocalSearch", query=query[:30])) + + facts = [] + edges_result = [] + nodes_result = [] + + # 提取查询关键词(简单分词) + query_lower = query.lower() + keywords = [w.strip() for w in query_lower.replace(',', ' ').replace(',', ' ').split() if len(w.strip()) > 1] + + def match_score(text: str) -> int: + """计算文本与查询的匹配分数""" + if not text: + return 0 + text_lower = text.lower() + # 完全匹配查询 + if query_lower in text_lower: + return 100 + # 关键词匹配 + score = 0 + for keyword in keywords: + if keyword in text_lower: + score += 10 + return score + + try: + if scope in ["edges", "both"]: + # 获取所有边并匹配 + all_edges = self.get_all_edges(graph_id) + scored_edges = [] + for edge in all_edges: + score = match_score(edge.fact) + match_score(edge.name) + if score > 0: + scored_edges.append((score, edge)) + + # 按分数排序 + scored_edges.sort(key=lambda x: x[0], reverse=True) + + for score, edge in scored_edges[:limit]: + if edge.fact: + facts.append(edge.fact) + edges_result.append({ + "uuid": edge.uuid, + "name": edge.name, + "fact": edge.fact, + "source_node_uuid": edge.source_node_uuid, + "target_node_uuid": edge.target_node_uuid, + }) + + if scope in ["nodes", "both"]: + # 获取所有节点并匹配 + all_nodes = self.get_all_nodes(graph_id) + scored_nodes = [] + for node in all_nodes: + score = match_score(node.name) + match_score(node.summary) + if score > 0: + scored_nodes.append((score, node)) + + scored_nodes.sort(key=lambda x: x[0], reverse=True) + + for score, node in scored_nodes[:limit]: + nodes_result.append({ + "uuid": node.uuid, + "name": node.name, + "labels": node.labels, + "summary": node.summary, + }) + if node.summary: + facts.append(f"[{node.name}]: {node.summary}") + + logger.info(t("console.localSearchComplete", count=len(facts))) + + except Exception as e: + logger.error(t("console.localSearchFailed", error=str(e))) + + return SearchResult( + facts=facts, + edges=edges_result, + nodes=nodes_result, + query=query, + total_count=len(facts) + ) + + def get_all_nodes(self, graph_id: str) -> List[NodeInfo]: + """ + 获取图谱的所有节点(分页获取) + + Args: + graph_id: 图谱ID + + Returns: + 节点列表 + """ + logger.info(t("console.fetchingAllNodes", graphId=graph_id)) + + nodes = fetch_all_nodes(self.client, graph_id) + + result = [] + for node in nodes: + node_uuid = getattr(node, 'uuid_', None) or getattr(node, 'uuid', None) or "" + result.append(NodeInfo( + uuid=str(node_uuid) if node_uuid else "", + name=node.name or "", + labels=node.labels or [], + summary=node.summary or "", + attributes=node.attributes or {} + )) + + logger.info(t("console.fetchedNodes", count=len(result))) + return result + + def get_all_edges(self, graph_id: str, include_temporal: bool = True) -> List[EdgeInfo]: + """ + 获取图谱的所有边(分页获取,包含时间信息) + + Args: + graph_id: 图谱ID + include_temporal: 是否包含时间信息(默认True) + + Returns: + 边列表(包含created_at, valid_at, invalid_at, expired_at) + """ + logger.info(t("console.fetchingAllEdges", graphId=graph_id)) + + edges = fetch_all_edges(self.client, graph_id) + + result = [] + for edge in edges: + edge_uuid = getattr(edge, 'uuid_', None) or getattr(edge, 'uuid', None) or "" + edge_info = EdgeInfo( + uuid=str(edge_uuid) if edge_uuid else "", + name=edge.name or "", + fact=edge.fact or "", + source_node_uuid=edge.source_node_uuid or "", + target_node_uuid=edge.target_node_uuid or "" + ) + + # 添加时间信息 + if include_temporal: + edge_info.created_at = getattr(edge, 'created_at', None) + edge_info.valid_at = getattr(edge, 'valid_at', None) + edge_info.invalid_at = getattr(edge, 'invalid_at', None) + edge_info.expired_at = getattr(edge, 'expired_at', None) + + result.append(edge_info) + + logger.info(t("console.fetchedEdges", count=len(result))) + return result + + def get_node_detail(self, node_uuid: str) -> Optional[NodeInfo]: + """ + 获取单个节点的详细信息 + + Args: + node_uuid: 节点UUID + + Returns: + 节点信息或None + """ + logger.info(t("console.fetchingNodeDetail", uuid=node_uuid[:8])) + + try: + node = self._call_with_retry( + func=lambda: self.client.graph.node.get(uuid_=node_uuid), + operation_name=t("console.fetchNodeDetailOp", uuid=node_uuid[:8]) + ) + + if not node: + return None + + return NodeInfo( + uuid=getattr(node, 'uuid_', None) or getattr(node, 'uuid', ''), + name=node.name or "", + labels=node.labels or [], + summary=node.summary or "", + attributes=node.attributes or {} + ) + except Exception as e: + logger.error(t("console.fetchNodeDetailFailed", error=str(e))) + return None + + def get_node_edges(self, graph_id: str, node_uuid: str) -> List[EdgeInfo]: + """ + 获取节点相关的所有边 + + 通过获取图谱所有边,然后过滤出与指定节点相关的边 + + Args: + graph_id: 图谱ID + node_uuid: 节点UUID + + Returns: + 边列表 + """ + logger.info(t("console.fetchingNodeEdges", uuid=node_uuid[:8])) + + try: + # 获取图谱所有边,然后过滤 + all_edges = self.get_all_edges(graph_id) + + result = [] + for edge in all_edges: + # 检查边是否与指定节点相关(作为源或目标) + if edge.source_node_uuid == node_uuid or edge.target_node_uuid == node_uuid: + result.append(edge) + + logger.info(t("console.foundNodeEdges", count=len(result))) + return result + + except Exception as e: + logger.warning(t("console.fetchNodeEdgesFailed", error=str(e))) + return [] + + def get_entities_by_type( + self, + graph_id: str, + entity_type: str + ) -> List[NodeInfo]: + """ + 按类型获取实体 + + Args: + graph_id: 图谱ID + entity_type: 实体类型(如 Student, PublicFigure 等) + + Returns: + 符合类型的实体列表 + """ + logger.info(t("console.fetchingEntitiesByType", type=entity_type)) + + all_nodes = self.get_all_nodes(graph_id) + + filtered = [] + for node in all_nodes: + # 检查labels是否包含指定类型 + if entity_type in node.labels: + filtered.append(node) + + logger.info(t("console.foundEntitiesByType", count=len(filtered), type=entity_type)) + return filtered + + def get_entity_summary( + self, + graph_id: str, + entity_name: str + ) -> Dict[str, Any]: + """ + 获取指定实体的关系摘要 + + 搜索与该实体相关的所有信息,并生成摘要 + + Args: + graph_id: 图谱ID + entity_name: 实体名称 + + Returns: + 实体摘要信息 + """ + logger.info(t("console.fetchingEntitySummary", name=entity_name)) + + # 先搜索该实体相关的信息 + search_result = self.search_graph( + graph_id=graph_id, + query=entity_name, + limit=20 + ) + + # 尝试在所有节点中找到该实体 + all_nodes = self.get_all_nodes(graph_id) + entity_node = None + for node in all_nodes: + if node.name.lower() == entity_name.lower(): + entity_node = node + break + + related_edges = [] + if entity_node: + # 传入graph_id参数 + related_edges = self.get_node_edges(graph_id, entity_node.uuid) + + return { + "entity_name": entity_name, + "entity_info": entity_node.to_dict() if entity_node else None, + "related_facts": search_result.facts, + "related_edges": [e.to_dict() for e in related_edges], + "total_relations": len(related_edges) + } + + def get_graph_statistics(self, graph_id: str) -> Dict[str, Any]: + """ + 获取图谱的统计信息 + + Args: + graph_id: 图谱ID + + Returns: + 统计信息 + """ + logger.info(t("console.fetchingGraphStats", graphId=graph_id)) + + nodes = self.get_all_nodes(graph_id) + edges = self.get_all_edges(graph_id) + + # 统计实体类型分布 + entity_types = {} + for node in nodes: + for label in node.labels: + if label not in ["Entity", "Node"]: + entity_types[label] = entity_types.get(label, 0) + 1 + + # 统计关系类型分布 + relation_types = {} + for edge in edges: + relation_types[edge.name] = relation_types.get(edge.name, 0) + 1 + + return { + "graph_id": graph_id, + "total_nodes": len(nodes), + "total_edges": len(edges), + "entity_types": entity_types, + "relation_types": relation_types + } + + def get_simulation_context( + self, + graph_id: str, + simulation_requirement: str, + limit: int = 30 + ) -> Dict[str, Any]: + """ + 获取模拟相关的上下文信息 + + 综合搜索与模拟需求相关的所有信息 + + Args: + graph_id: 图谱ID + simulation_requirement: 模拟需求描述 + limit: 每类信息的数量限制 + + Returns: + 模拟上下文信息 + """ + logger.info(t("console.fetchingSimContext", requirement=simulation_requirement[:50])) + + # 搜索与模拟需求相关的信息 + search_result = self.search_graph( + graph_id=graph_id, + query=simulation_requirement, + limit=limit + ) + + # 获取图谱统计 + stats = self.get_graph_statistics(graph_id) + + # 获取所有实体节点 + all_nodes = self.get_all_nodes(graph_id) + + # 筛选有实际类型的实体(非纯Entity节点) + entities = [] + for node in all_nodes: + custom_labels = [l for l in node.labels if l not in ["Entity", "Node"]] + if custom_labels: + entities.append({ + "name": node.name, + "type": custom_labels[0], + "summary": node.summary + }) + + return { + "simulation_requirement": simulation_requirement, + "related_facts": search_result.facts, + "graph_statistics": stats, + "entities": entities[:limit], # 限制数量 + "total_entities": len(entities) + } + + # ========== 核心检索工具(优化后) ========== + + def insight_forge( + self, + graph_id: str, + query: str, + simulation_requirement: str, + report_context: str = "", + max_sub_queries: int = 5 + ) -> InsightForgeResult: + """ + 【InsightForge - 深度洞察检索】 + + 最强大的混合检索函数,自动分解问题并多维度检索: + 1. 使用LLM将问题分解为多个子问题 + 2. 对每个子问题进行语义搜索 + 3. 提取相关实体并获取其详细信息 + 4. 追踪关系链 + 5. 整合所有结果,生成深度洞察 + + Args: + graph_id: 图谱ID + query: 用户问题 + simulation_requirement: 模拟需求描述 + report_context: 报告上下文(可选,用于更精准的子问题生成) + max_sub_queries: 最大子问题数量 + + Returns: + InsightForgeResult: 深度洞察检索结果 + """ + logger.info(t("console.insightForgeStart", query=query[:50])) + + result = InsightForgeResult( + query=query, + simulation_requirement=simulation_requirement, + sub_queries=[] + ) + + # Step 1: 使用LLM生成子问题 + sub_queries = self._generate_sub_queries( + query=query, + simulation_requirement=simulation_requirement, + report_context=report_context, + max_queries=max_sub_queries + ) + result.sub_queries = sub_queries + logger.info(t("console.generatedSubQueries", count=len(sub_queries))) + + # Step 2: 对每个子问题进行语义搜索 + all_facts = [] + all_edges = [] + seen_facts = set() + + for sub_query in sub_queries: + search_result = self.search_graph( + graph_id=graph_id, + query=sub_query, + limit=15, + scope="edges" + ) + + for fact in search_result.facts: + if fact not in seen_facts: + all_facts.append(fact) + seen_facts.add(fact) + + all_edges.extend(search_result.edges) + + # 对原始问题也进行搜索 + main_search = self.search_graph( + graph_id=graph_id, + query=query, + limit=20, + scope="edges" + ) + for fact in main_search.facts: + if fact not in seen_facts: + all_facts.append(fact) + seen_facts.add(fact) + + result.semantic_facts = all_facts + result.total_facts = len(all_facts) + + # Step 3: 从边中提取相关实体UUID,只获取这些实体的信息(不获取全部节点) + entity_uuids = set() + for edge_data in all_edges: + if isinstance(edge_data, dict): + source_uuid = edge_data.get('source_node_uuid', '') + target_uuid = edge_data.get('target_node_uuid', '') + if source_uuid: + entity_uuids.add(source_uuid) + if target_uuid: + entity_uuids.add(target_uuid) + + # 获取所有相关实体的详情(不限制数量,完整输出) + entity_insights = [] + node_map = {} # 用于后续关系链构建 + + for uuid in list(entity_uuids): # 处理所有实体,不截断 + if not uuid: + continue + try: + # 单独获取每个相关节点的信息 + node = self.get_node_detail(uuid) + if node: + node_map[uuid] = node + entity_type = next((l for l in node.labels if l not in ["Entity", "Node"]), "实体") + + # 获取该实体相关的所有事实(不截断) + related_facts = [ + f for f in all_facts + if node.name.lower() in f.lower() + ] + + entity_insights.append({ + "uuid": node.uuid, + "name": node.name, + "type": entity_type, + "summary": node.summary, + "related_facts": related_facts # 完整输出,不截断 + }) + except Exception as e: + logger.debug(f"获取节点 {uuid} 失败: {e}") + continue + + result.entity_insights = entity_insights + result.total_entities = len(entity_insights) + + # Step 4: 构建所有关系链(不限制数量) + relationship_chains = [] + for edge_data in all_edges: # 处理所有边,不截断 + if isinstance(edge_data, dict): + source_uuid = edge_data.get('source_node_uuid', '') + target_uuid = edge_data.get('target_node_uuid', '') + relation_name = edge_data.get('name', '') + + source_name = node_map.get(source_uuid, NodeInfo('', '', [], '', {})).name or source_uuid[:8] + target_name = node_map.get(target_uuid, NodeInfo('', '', [], '', {})).name or target_uuid[:8] + + chain = f"{source_name} --[{relation_name}]--> {target_name}" + if chain not in relationship_chains: + relationship_chains.append(chain) + + result.relationship_chains = relationship_chains + result.total_relationships = len(relationship_chains) + + logger.info(t("console.insightForgeComplete", facts=result.total_facts, entities=result.total_entities, relationships=result.total_relationships)) + return result + + def _generate_sub_queries( + self, + query: str, + simulation_requirement: str, + report_context: str = "", + max_queries: int = 5 + ) -> List[str]: + """ + 使用LLM生成子问题 + + 将复杂问题分解为多个可以独立检索的子问题 + """ + system_prompt = """你是一个专业的问题分析专家。你的任务是将一个复杂问题分解为多个可以在模拟世界中独立观察的子问题。 + +要求: +1. 每个子问题应该足够具体,可以在模拟世界中找到相关的Agent行为或事件 +2. 子问题应该覆盖原问题的不同维度(如:谁、什么、为什么、怎么样、何时、何地) +3. 子问题应该与模拟场景相关 +4. 返回JSON格式:{"sub_queries": ["子问题1", "子问题2", ...]}""" + + user_prompt = f"""模拟需求背景: +{simulation_requirement} + +{f"报告上下文:{report_context[:500]}" if report_context else ""} + +请将以下问题分解为{max_queries}个子问题: +{query} + +返回JSON格式的子问题列表。""" + + try: + response = self.llm.chat_json( + messages=[ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ], + temperature=0.3 + ) + + sub_queries = response.get("sub_queries", []) + # 确保是字符串列表 + return [str(sq) for sq in sub_queries[:max_queries]] + + except Exception as e: + logger.warning(t("console.generateSubQueriesFailed", error=str(e))) + # 降级:返回基于原问题的变体 + return [ + query, + f"{query} 的主要参与者", + f"{query} 的原因和影响", + f"{query} 的发展过程" + ][:max_queries] + + def panorama_search( + self, + graph_id: str, + query: str, + include_expired: bool = True, + limit: int = 50 + ) -> PanoramaResult: + """ + 【PanoramaSearch - 广度搜索】 + + 获取全貌视图,包括所有相关内容和历史/过期信息: + 1. 获取所有相关节点 + 2. 获取所有边(包括已过期/失效的) + 3. 分类整理当前有效和历史信息 + + 这个工具适用于需要了解事件全貌、追踪演变过程的场景。 + + Args: + graph_id: 图谱ID + query: 搜索查询(用于相关性排序) + include_expired: 是否包含过期内容(默认True) + limit: 返回结果数量限制 + + Returns: + PanoramaResult: 广度搜索结果 + """ + logger.info(t("console.panoramaSearchStart", query=query[:50])) + + result = PanoramaResult(query=query) + + # 获取所有节点 + all_nodes = self.get_all_nodes(graph_id) + node_map = {n.uuid: n for n in all_nodes} + result.all_nodes = all_nodes + result.total_nodes = len(all_nodes) + + # 获取所有边(包含时间信息) + all_edges = self.get_all_edges(graph_id, include_temporal=True) + result.all_edges = all_edges + result.total_edges = len(all_edges) + + # 分类事实 + active_facts = [] + historical_facts = [] + + for edge in all_edges: + if not edge.fact: + continue + + # 为事实添加实体名称 + source_name = node_map.get(edge.source_node_uuid, NodeInfo('', '', [], '', {})).name or edge.source_node_uuid[:8] + target_name = node_map.get(edge.target_node_uuid, NodeInfo('', '', [], '', {})).name or edge.target_node_uuid[:8] + + # 判断是否过期/失效 + is_historical = edge.is_expired or edge.is_invalid + + if is_historical: + # 历史/过期事实,添加时间标记 + valid_at = edge.valid_at or "未知" + invalid_at = edge.invalid_at or edge.expired_at or "未知" + fact_with_time = f"[{valid_at} - {invalid_at}] {edge.fact}" + historical_facts.append(fact_with_time) + else: + # 当前有效事实 + active_facts.append(edge.fact) + + # 基于查询进行相关性排序 + query_lower = query.lower() + keywords = [w.strip() for w in query_lower.replace(',', ' ').replace(',', ' ').split() if len(w.strip()) > 1] + + def relevance_score(fact: str) -> int: + fact_lower = fact.lower() + score = 0 + if query_lower in fact_lower: + score += 100 + for kw in keywords: + if kw in fact_lower: + score += 10 + return score + + # 排序并限制数量 + active_facts.sort(key=relevance_score, reverse=True) + historical_facts.sort(key=relevance_score, reverse=True) + + result.active_facts = active_facts[:limit] + result.historical_facts = historical_facts[:limit] if include_expired else [] + result.active_count = len(active_facts) + result.historical_count = len(historical_facts) + + logger.info(t("console.panoramaSearchComplete", active=result.active_count, historical=result.historical_count)) + return result + + def quick_search( + self, + graph_id: str, + query: str, + limit: int = 10 + ) -> SearchResult: + """ + 【QuickSearch - 简单搜索】 + + 快速、轻量级的检索工具: + 1. 直接调用Zep语义搜索 + 2. 返回最相关的结果 + 3. 适用于简单、直接的检索需求 + + Args: + graph_id: 图谱ID + query: 搜索查询 + limit: 返回结果数量 + + Returns: + SearchResult: 搜索结果 + """ + logger.info(t("console.quickSearchStart", query=query[:50])) + + # 直接调用现有的search_graph方法 + result = self.search_graph( + graph_id=graph_id, + query=query, + limit=limit, + scope="edges" + ) + + logger.info(t("console.quickSearchComplete", count=result.total_count)) + return result + + def interview_agents( + self, + simulation_id: str, + interview_requirement: str, + simulation_requirement: str = "", + max_agents: int = 5, + custom_questions: List[str] = None + ) -> InterviewResult: + """ + 【InterviewAgents - 深度采访】 + + 调用真实的OASIS采访API,采访模拟中正在运行的Agent: + 1. 自动读取人设文件,了解所有模拟Agent + 2. 使用LLM分析采访需求,智能选择最相关的Agent + 3. 使用LLM生成采访问题 + 4. 调用 /api/simulation/interview/batch 接口进行真实采访(双平台同时采访) + 5. 整合所有采访结果,生成采访报告 + + 【重要】此功能需要模拟环境处于运行状态(OASIS环境未关闭) + + 【使用场景】 + - 需要从不同角色视角了解事件看法 + - 需要收集多方意见和观点 + - 需要获取模拟Agent的真实回答(非LLM模拟) + + Args: + simulation_id: 模拟ID(用于定位人设文件和调用采访API) + interview_requirement: 采访需求描述(非结构化,如"了解学生对事件的看法") + simulation_requirement: 模拟需求背景(可选) + max_agents: 最多采访的Agent数量 + custom_questions: 自定义采访问题(可选,若不提供则自动生成) + + Returns: + InterviewResult: 采访结果 + """ + from .simulation_runner import SimulationRunner + + logger.info(t("console.interviewAgentsStart", requirement=interview_requirement[:50])) + + result = InterviewResult( + interview_topic=interview_requirement, + interview_questions=custom_questions or [] + ) + + # Step 1: 读取人设文件 + profiles = self._load_agent_profiles(simulation_id) + + if not profiles: + logger.warning(t("console.profilesNotFound", simId=simulation_id)) + result.summary = "未找到可采访的Agent人设文件" + return result + + result.total_agents = len(profiles) + logger.info(t("console.loadedProfiles", count=len(profiles))) + + # Step 2: 使用LLM选择要采访的Agent(返回agent_id列表) + selected_agents, selected_indices, selection_reasoning = self._select_agents_for_interview( + profiles=profiles, + interview_requirement=interview_requirement, + simulation_requirement=simulation_requirement, + max_agents=max_agents + ) + + result.selected_agents = selected_agents + result.selection_reasoning = selection_reasoning + logger.info(t("console.selectedAgentsForInterview", count=len(selected_agents), indices=selected_indices)) + + # Step 3: 生成采访问题(如果没有提供) + if not result.interview_questions: + result.interview_questions = self._generate_interview_questions( + interview_requirement=interview_requirement, + simulation_requirement=simulation_requirement, + selected_agents=selected_agents + ) + logger.info(t("console.generatedInterviewQuestions", count=len(result.interview_questions))) + + # 将问题合并为一个采访prompt + combined_prompt = "\n".join([f"{i+1}. {q}" for i, q in enumerate(result.interview_questions)]) + + # 添加优化前缀,约束Agent回复格式 + INTERVIEW_PROMPT_PREFIX = ( + "你正在接受一次采访。请结合你的人设、所有的过往记忆与行动," + "以纯文本方式直接回答以下问题。\n" + "回复要求:\n" + "1. 直接用自然语言回答,不要调用任何工具\n" + "2. 不要返回JSON格式或工具调用格式\n" + "3. 不要使用Markdown标题(如#、##、###)\n" + "4. 按问题编号逐一回答,每个回答以「问题X:」开头(X为问题编号)\n" + "5. 每个问题的回答之间用空行分隔\n" + "6. 回答要有实质内容,每个问题至少回答2-3句话\n\n" + ) + optimized_prompt = f"{INTERVIEW_PROMPT_PREFIX}{combined_prompt}" + + # Step 4: 调用真实的采访API(不指定platform,默认双平台同时采访) + try: + # 构建批量采访列表(不指定platform,双平台采访) + interviews_request = [] + for agent_idx in selected_indices: + interviews_request.append({ + "agent_id": agent_idx, + "prompt": optimized_prompt # 使用优化后的prompt + # 不指定platform,API会在twitter和reddit两个平台都采访 + }) + + logger.info(t("console.callingBatchInterviewApi", count=len(interviews_request))) + + # 调用 SimulationRunner 的批量采访方法(不传platform,双平台采访) + api_result = SimulationRunner.interview_agents_batch( + simulation_id=simulation_id, + interviews=interviews_request, + platform=None, # 不指定platform,双平台采访 + timeout=180.0 # 双平台需要更长超时 + ) + + logger.info(t("console.interviewApiReturned", count=api_result.get('interviews_count', 0), success=api_result.get('success'))) + + # 检查API调用是否成功 + if not api_result.get("success", False): + error_msg = api_result.get("error", "未知错误") + logger.warning(t("console.interviewApiReturnedFailure", error=error_msg)) + result.summary = f"采访API调用失败:{error_msg}。请检查OASIS模拟环境状态。" + return result + + # Step 5: 解析API返回结果,构建AgentInterview对象 + # 双平台模式返回格式: {"twitter_0": {...}, "reddit_0": {...}, "twitter_1": {...}, ...} + api_data = api_result.get("result", {}) + results_dict = api_data.get("results", {}) if isinstance(api_data, dict) else {} + + for i, agent_idx in enumerate(selected_indices): + agent = selected_agents[i] + agent_name = agent.get("realname", agent.get("username", f"Agent_{agent_idx}")) + agent_role = agent.get("profession", "未知") + agent_bio = agent.get("bio", "") + + # 获取该Agent在两个平台的采访结果 + twitter_result = results_dict.get(f"twitter_{agent_idx}", {}) + reddit_result = results_dict.get(f"reddit_{agent_idx}", {}) + + twitter_response = twitter_result.get("response", "") + reddit_response = reddit_result.get("response", "") + + # 清理可能的工具调用 JSON 包裹 + twitter_response = self._clean_tool_call_response(twitter_response) + reddit_response = self._clean_tool_call_response(reddit_response) + + # 始终输出双平台标记 + twitter_text = twitter_response if twitter_response else "(该平台未获得回复)" + reddit_text = reddit_response if reddit_response else "(该平台未获得回复)" + response_text = f"【Twitter平台回答】\n{twitter_text}\n\n【Reddit平台回答】\n{reddit_text}" + + # 提取关键引言(从两个平台的回答中) + import re + combined_responses = f"{twitter_response} {reddit_response}" + + # 清理响应文本:去掉标记、编号、Markdown 等干扰 + clean_text = re.sub(r'#{1,6}\s+', '', combined_responses) + clean_text = re.sub(r'\{[^}]*tool_name[^}]*\}', '', clean_text) + clean_text = re.sub(r'[*_`|>~\-]{2,}', '', clean_text) + clean_text = re.sub(r'问题\d+[::]\s*', '', clean_text) + clean_text = re.sub(r'【[^】]+】', '', clean_text) + + # 策略1(主): 提取完整的有实质内容的句子 + sentences = re.split(r'[。!?]', clean_text) + meaningful = [ + s.strip() for s in sentences + if 20 <= len(s.strip()) <= 150 + and not re.match(r'^[\s\W,,;;::、]+', s.strip()) + and not s.strip().startswith(('{', '问题')) + ] + meaningful.sort(key=len, reverse=True) + key_quotes = [s + "。" for s in meaningful[:3]] + + # 策略2(补充): 正确配对的中文引号「」内长文本 + if not key_quotes: + paired = re.findall(r'\u201c([^\u201c\u201d]{15,100})\u201d', clean_text) + paired += re.findall(r'\u300c([^\u300c\u300d]{15,100})\u300d', clean_text) + key_quotes = [q for q in paired if not re.match(r'^[,,;;::、]', q)][:3] + + interview = AgentInterview( + agent_name=agent_name, + agent_role=agent_role, + agent_bio=agent_bio[:1000], # 扩大bio长度限制 + question=combined_prompt, + response=response_text, + key_quotes=key_quotes[:5] + ) + result.interviews.append(interview) + + result.interviewed_count = len(result.interviews) + + except ValueError as e: + # 模拟环境未运行 + logger.warning(t("console.interviewApiCallFailed", error=e)) + result.summary = f"采访失败:{str(e)}。模拟环境可能已关闭,请确保OASIS环境正在运行。" + return result + except Exception as e: + logger.error(t("console.interviewApiCallException", error=e)) + import traceback + logger.error(traceback.format_exc()) + result.summary = f"采访过程发生错误:{str(e)}" + return result + + # Step 6: 生成采访摘要 + if result.interviews: + result.summary = self._generate_interview_summary( + interviews=result.interviews, + interview_requirement=interview_requirement + ) + + logger.info(t("console.interviewAgentsComplete", count=result.interviewed_count)) + return result + + @staticmethod + def _clean_tool_call_response(response: str) -> str: + """清理 Agent 回复中的 JSON 工具调用包裹,提取实际内容""" + if not response or not response.strip().startswith('{'): + return response + text = response.strip() + if 'tool_name' not in text[:80]: + return response + import re as _re + try: + data = json.loads(text) + if isinstance(data, dict) and 'arguments' in data: + for key in ('content', 'text', 'body', 'message', 'reply'): + if key in data['arguments']: + return str(data['arguments'][key]) + except (json.JSONDecodeError, KeyError, TypeError): + match = _re.search(r'"content"\s*:\s*"((?:[^"\\]|\\.)*)"', text) + if match: + return match.group(1).replace('\\n', '\n').replace('\\"', '"') + return response + + def _load_agent_profiles(self, simulation_id: str) -> List[Dict[str, Any]]: + """加载模拟的Agent人设文件""" + import os + import csv + + # 构建人设文件路径 + sim_dir = os.path.join( + os.path.dirname(__file__), + f'../../uploads/simulations/{simulation_id}' + ) + + profiles = [] + + # 优先尝试读取Reddit JSON格式 + reddit_profile_path = os.path.join(sim_dir, "reddit_profiles.json") + if os.path.exists(reddit_profile_path): + try: + with open(reddit_profile_path, 'r', encoding='utf-8') as f: + profiles = json.load(f) + logger.info(t("console.loadedRedditProfiles", count=len(profiles))) + return profiles + except Exception as e: + logger.warning(t("console.readRedditProfilesFailed", error=e)) + + # 尝试读取Twitter CSV格式 + twitter_profile_path = os.path.join(sim_dir, "twitter_profiles.csv") + if os.path.exists(twitter_profile_path): + try: + with open(twitter_profile_path, 'r', encoding='utf-8') as f: + reader = csv.DictReader(f) + for row in reader: + # CSV格式转换为统一格式 + profiles.append({ + "realname": row.get("name", ""), + "username": row.get("username", ""), + "bio": row.get("description", ""), + "persona": row.get("user_char", ""), + "profession": "未知" + }) + logger.info(t("console.loadedTwitterProfiles", count=len(profiles))) + return profiles + except Exception as e: + logger.warning(t("console.readTwitterProfilesFailed", error=e)) + + return profiles + + def _select_agents_for_interview( + self, + profiles: List[Dict[str, Any]], + interview_requirement: str, + simulation_requirement: str, + max_agents: int + ) -> tuple: + """ + 使用LLM选择要采访的Agent + + Returns: + tuple: (selected_agents, selected_indices, reasoning) + - selected_agents: 选中Agent的完整信息列表 + - selected_indices: 选中Agent的索引列表(用于API调用) + - reasoning: 选择理由 + """ + + # 构建Agent摘要列表 + agent_summaries = [] + for i, profile in enumerate(profiles): + summary = { + "index": i, + "name": profile.get("realname", profile.get("username", f"Agent_{i}")), + "profession": profile.get("profession", "未知"), + "bio": profile.get("bio", "")[:200], + "interested_topics": profile.get("interested_topics", []) + } + agent_summaries.append(summary) + + system_prompt = """你是一个专业的采访策划专家。你的任务是根据采访需求,从模拟Agent列表中选择最适合采访的对象。 + +选择标准: +1. Agent的身份/职业与采访主题相关 +2. Agent可能持有独特或有价值的观点 +3. 选择多样化的视角(如:支持方、反对方、中立方、专业人士等) +4. 优先选择与事件直接相关的角色 + +返回JSON格式: +{ + "selected_indices": [选中Agent的索引列表], + "reasoning": "选择理由说明" +}""" + + user_prompt = f"""采访需求: +{interview_requirement} + +模拟背景: +{simulation_requirement if simulation_requirement else "未提供"} + +可选择的Agent列表(共{len(agent_summaries)}个): +{json.dumps(agent_summaries, ensure_ascii=False, indent=2)} + +请选择最多{max_agents}个最适合采访的Agent,并说明选择理由。""" + + try: + response = self.llm.chat_json( + messages=[ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ], + temperature=0.3 + ) + + selected_indices = response.get("selected_indices", [])[:max_agents] + reasoning = response.get("reasoning", "基于相关性自动选择") + + # 获取选中的Agent完整信息 + selected_agents = [] + valid_indices = [] + for idx in selected_indices: + if 0 <= idx < len(profiles): + selected_agents.append(profiles[idx]) + valid_indices.append(idx) + + return selected_agents, valid_indices, reasoning + + except Exception as e: + logger.warning(t("console.llmSelectAgentFailed", error=e)) + # 降级:选择前N个 + selected = profiles[:max_agents] + indices = list(range(min(max_agents, len(profiles)))) + return selected, indices, "使用默认选择策略" + + def _generate_interview_questions( + self, + interview_requirement: str, + simulation_requirement: str, + selected_agents: List[Dict[str, Any]] + ) -> List[str]: + """使用LLM生成采访问题""" + + agent_roles = [a.get("profession", "未知") for a in selected_agents] + + system_prompt = """你是一个专业的记者/采访者。根据采访需求,生成3-5个深度采访问题。 + +问题要求: +1. 开放性问题,鼓励详细回答 +2. 针对不同角色可能有不同答案 +3. 涵盖事实、观点、感受等多个维度 +4. 语言自然,像真实采访一样 +5. 每个问题控制在50字以内,简洁明了 +6. 直接提问,不要包含背景说明或前缀 + +返回JSON格式:{"questions": ["问题1", "问题2", ...]}""" + + user_prompt = f"""采访需求:{interview_requirement} + +模拟背景:{simulation_requirement if simulation_requirement else "未提供"} + +采访对象角色:{', '.join(agent_roles)} + +请生成3-5个采访问题。""" + + try: + response = self.llm.chat_json( + messages=[ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ], + temperature=0.5 + ) + + return response.get("questions", [f"关于{interview_requirement},您有什么看法?"]) + + except Exception as e: + logger.warning(t("console.generateInterviewQuestionsFailed", error=e)) + return [ + f"关于{interview_requirement},您的观点是什么?", + "这件事对您或您所代表的群体有什么影响?", + "您认为应该如何解决或改进这个问题?" + ] + + def _generate_interview_summary( + self, + interviews: List[AgentInterview], + interview_requirement: str + ) -> str: + """生成采访摘要""" + + if not interviews: + return "未完成任何采访" + + # 收集所有采访内容 + interview_texts = [] + for interview in interviews: + interview_texts.append(f"【{interview.agent_name}({interview.agent_role})】\n{interview.response[:500]}") + + quote_instruction = "引用受访者原话时使用中文引号「」" if get_locale() == 'zh' else 'Use quotation marks "" when quoting interviewees' + system_prompt = f"""你是一个专业的新闻编辑。请根据多位受访者的回答,生成一份采访摘要。 + +摘要要求: +1. 提炼各方主要观点 +2. 指出观点的共识和分歧 +3. 突出有价值的引言 +4. 客观中立,不偏袒任何一方 +5. 控制在1000字内 + +格式约束(必须遵守): +- 使用纯文本段落,用空行分隔不同部分 +- 不要使用Markdown标题(如#、##、###) +- 不要使用分割线(如---、***) +- {quote_instruction} +- 可以使用**加粗**标记关键词,但不要使用其他Markdown语法""" + + user_prompt = f"""采访主题:{interview_requirement} + +采访内容: +{"".join(interview_texts)} + +请生成采访摘要。""" + + try: + summary = self.llm.chat( + messages=[ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ], + temperature=0.3, + max_tokens=800 + ) + return summary + + except Exception as e: + logger.warning(t("console.generateInterviewSummaryFailed", error=e)) + # 降级:简单拼接 + return f"共采访了{len(interviews)}位受访者,包括:" + "、".join([i.agent_name for i in interviews]) diff --git a/backend/app/utils/__init__.py b/backend/app/utils/__init__.py new file mode 100644 index 00000000..e70161ac --- /dev/null +++ b/backend/app/utils/__init__.py @@ -0,0 +1,10 @@ +""" +工具模块 +""" + +from .file_parser import FileParser +from .llm_client import LLMClient +from .locale import t, get_locale, set_locale, get_language_instruction + +__all__ = ['FileParser', 'LLMClient', 't', 'get_locale', 'set_locale', 'get_language_instruction'] + diff --git a/backend/app/utils/file_parser.py b/backend/app/utils/file_parser.py new file mode 100644 index 00000000..5e540434 --- /dev/null +++ b/backend/app/utils/file_parser.py @@ -0,0 +1,203 @@ +""" +文件解析工具 +支持PDF、Markdown、TXT文件的文本提取 +""" + +import os +from pathlib import Path +from typing import List, Optional + + +def _read_text_with_fallback(file_path: str) -> str: + """ + 读取文本文件,UTF-8失败时自动探测编码。 + + 采用多级回退策略: + 1. 首先尝试 UTF-8 解码 + 2. 使用 charset_normalizer 检测编码 + 3. 回退到 chardet 检测编码 + 4. 最终使用 UTF-8 + errors='replace' 兜底 + + Args: + file_path: 文件路径 + + Returns: + 解码后的文本内容 + """ + data = Path(file_path).read_bytes() + + # 首先尝试 UTF-8 + try: + return data.decode('utf-8') + except UnicodeDecodeError: + pass + + # 尝试使用 charset_normalizer 检测编码 + encoding = None + try: + from charset_normalizer import from_bytes + best = from_bytes(data).best() + if best and best.encoding: + encoding = best.encoding + except Exception: + pass + + # 回退到 chardet + if not encoding: + try: + import chardet + result = chardet.detect(data) + encoding = result.get('encoding') if result else None + except Exception: + pass + + # 最终兜底:使用 UTF-8 + replace + if not encoding: + encoding = 'utf-8' + + return data.decode(encoding, errors='replace') + + +class FileParser: + """文件解析器""" + + SUPPORTED_EXTENSIONS = {'.pdf', '.md', '.markdown', '.txt'} + + @classmethod + def is_supported(cls, file_path: str) -> bool: + """ + 检查文件是否为支持的格式 + + Args: + file_path: 文件路径 + + Returns: + 如果文件格式受支持则返回 True + """ + suffix = Path(file_path).suffix.lower() + return suffix in cls.SUPPORTED_EXTENSIONS + + @classmethod + def extract_text(cls, file_path: str) -> str: + """ + 从文件中提取文本 + + Args: + file_path: 文件路径 + + Returns: + 提取的文本内容 + """ + path = Path(file_path) + + if not path.exists(): + raise FileNotFoundError(f"文件不存在: {file_path}") + + suffix = path.suffix.lower() + + if suffix not in cls.SUPPORTED_EXTENSIONS: + raise ValueError(f"不支持的文件格式: {suffix}") + + if suffix == '.pdf': + return cls._extract_from_pdf(file_path) + elif suffix in {'.md', '.markdown'}: + return cls._extract_from_md(file_path) + elif suffix == '.txt': + return cls._extract_from_txt(file_path) + + raise ValueError(f"无法处理的文件格式: {suffix}") + + @staticmethod + def _extract_from_pdf(file_path: str) -> str: + """从PDF提取文本""" + try: + import fitz # PyMuPDF + except ImportError: + raise ImportError("需要安装PyMuPDF: pip install PyMuPDF") + + text_parts = [] + with fitz.open(file_path) as doc: + for page in doc: + text = page.get_text() + if text.strip(): + text_parts.append(text) + + return "\n\n".join(text_parts) + + @staticmethod + def _extract_from_md(file_path: str) -> str: + """从Markdown提取文本,支持自动编码检测""" + return _read_text_with_fallback(file_path) + + @staticmethod + def _extract_from_txt(file_path: str) -> str: + """从TXT提取文本,支持自动编码检测""" + return _read_text_with_fallback(file_path) + + @classmethod + def extract_from_multiple(cls, file_paths: List[str]) -> str: + """ + 从多个文件提取文本并合并 + + Args: + file_paths: 文件路径列表 + + Returns: + 合并后的文本 + """ + all_texts = [] + + for i, file_path in enumerate(file_paths, 1): + try: + text = cls.extract_text(file_path) + filename = Path(file_path).name + all_texts.append(f"=== 文档 {i}: {filename} ===\n{text}") + except Exception as e: + all_texts.append(f"=== 文档 {i}: {file_path} (提取失败: {str(e)}) ===") + + return "\n\n".join(all_texts) + + +def split_text_into_chunks( + text: str, + chunk_size: int = 500, + overlap: int = 50 +) -> List[str]: + """ + 将文本分割成小块 + + Args: + text: 原始文本 + chunk_size: 每块的字符数 + overlap: 重叠字符数 + + Returns: + 文本块列表 + """ + if len(text) <= chunk_size: + return [text] if text.strip() else [] + + chunks = [] + start = 0 + + while start < len(text): + end = start + chunk_size + + # 尝试在句子边界处分割 + if end < len(text): + # 查找最近的句子结束符 + for sep in ['。', '!', '?', '.\n', '!\n', '?\n', '\n\n', '. ', '! ', '? ']: + last_sep = text[start:end].rfind(sep) + if last_sep != -1 and last_sep > chunk_size * 0.3: + end = start + last_sep + len(sep) + break + + chunk = text[start:end].strip() + if chunk: + chunks.append(chunk) + + # 下一个块从重叠位置开始 + start = end - overlap if end < len(text) else len(text) + + return chunks + diff --git a/backend/app/utils/llm_client.py b/backend/app/utils/llm_client.py new file mode 100644 index 00000000..6c1a81f4 --- /dev/null +++ b/backend/app/utils/llm_client.py @@ -0,0 +1,103 @@ +""" +LLM客户端封装 +统一使用OpenAI格式调用 +""" + +import json +import re +from typing import Optional, Dict, Any, List +from openai import OpenAI + +from ..config import Config + + +class LLMClient: + """LLM客户端""" + + def __init__( + self, + api_key: Optional[str] = None, + base_url: Optional[str] = None, + model: Optional[str] = None + ): + self.api_key = api_key or Config.LLM_API_KEY + self.base_url = base_url or Config.LLM_BASE_URL + self.model = model or Config.LLM_MODEL_NAME + + if not self.api_key: + raise ValueError("LLM_API_KEY 未配置") + + self.client = OpenAI( + api_key=self.api_key, + base_url=self.base_url + ) + + def chat( + self, + messages: List[Dict[str, str]], + temperature: float = 0.7, + max_tokens: int = 4096, + response_format: Optional[Dict] = None + ) -> str: + """ + 发送聊天请求 + + Args: + messages: 消息列表 + temperature: 温度参数 + max_tokens: 最大token数 + response_format: 响应格式(如JSON模式) + + Returns: + 模型响应文本 + """ + kwargs = { + "model": self.model, + "messages": messages, + "temperature": temperature, + "max_tokens": max_tokens, + } + + if response_format: + kwargs["response_format"] = response_format + + response = self.client.chat.completions.create(**kwargs) + content = response.choices[0].message.content + # 部分模型(如MiniMax M2.5)会在content中包含思考内容,需要移除 + content = re.sub(r'[\s\S]*?', '', content).strip() + return content + + def chat_json( + self, + messages: List[Dict[str, str]], + temperature: float = 0.3, + max_tokens: int = 4096 + ) -> Dict[str, Any]: + """ + 发送聊天请求并返回JSON + + Args: + messages: 消息列表 + temperature: 温度参数 + max_tokens: 最大token数 + + Returns: + 解析后的JSON对象 + """ + response = self.chat( + messages=messages, + temperature=temperature, + max_tokens=max_tokens, + response_format={"type": "json_object"} + ) + # 清理markdown代码块标记 + cleaned_response = response.strip() + cleaned_response = re.sub(r'^```(?:json)?\s*\n?', '', cleaned_response, flags=re.IGNORECASE) + cleaned_response = re.sub(r'\n?```\s*$', '', cleaned_response) + cleaned_response = cleaned_response.strip() + + try: + return json.loads(cleaned_response) + except json.JSONDecodeError: + raise ValueError(f"LLM返回的JSON格式无效: {cleaned_response}") + diff --git a/backend/app/utils/locale.py b/backend/app/utils/locale.py new file mode 100644 index 00000000..23d04aa9 --- /dev/null +++ b/backend/app/utils/locale.py @@ -0,0 +1,69 @@ +import json +import os +import threading +from flask import request, has_request_context + +_thread_local = threading.local() + +_locales_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'locales') + +# Load language registry +with open(os.path.join(_locales_dir, 'languages.json'), 'r', encoding='utf-8') as f: + _languages = json.load(f) + +# Load translation files +_translations = {} +for filename in os.listdir(_locales_dir): + if filename.endswith('.json') and filename != 'languages.json': + locale_name = filename[:-5] + with open(os.path.join(_locales_dir, filename), 'r', encoding='utf-8') as f: + _translations[locale_name] = json.load(f) + + +def set_locale(locale: str): + """Set locale for current thread. Call at the start of background threads.""" + _thread_local.locale = locale + + +def get_locale() -> str: + if has_request_context(): + raw = request.headers.get('Accept-Language', 'zh') + return raw if raw in _translations else 'zh' + return getattr(_thread_local, 'locale', 'zh') + + +def t(key: str, **kwargs) -> str: + locale = get_locale() + messages = _translations.get(locale, _translations.get('zh', {})) + + value = messages + for part in key.split('.'): + if isinstance(value, dict): + value = value.get(part) + else: + value = None + break + + if value is None: + value = _translations.get('zh', {}) + for part in key.split('.'): + if isinstance(value, dict): + value = value.get(part) + else: + value = None + break + + if value is None: + return key + + if kwargs: + for k, v in kwargs.items(): + value = value.replace(f'{{{k}}}', str(v)) + + return value + + +def get_language_instruction() -> str: + locale = get_locale() + lang_config = _languages.get(locale, _languages.get('zh', {})) + return lang_config.get('llmInstruction', '请使用中文回答。') diff --git a/backend/app/utils/logger.py b/backend/app/utils/logger.py new file mode 100644 index 00000000..93422afa --- /dev/null +++ b/backend/app/utils/logger.py @@ -0,0 +1,126 @@ +""" +日志配置模块 +提供统一的日志管理,同时输出到控制台和文件 +""" + +import os +import sys +import logging +from datetime import datetime +from logging.handlers import RotatingFileHandler + + +def _ensure_utf8_stdout(): + """ + 确保 stdout/stderr 使用 UTF-8 编码 + 解决 Windows 控制台中文乱码问题 + """ + if sys.platform == 'win32': + # Windows 下重新配置标准输出为 UTF-8 + if hasattr(sys.stdout, 'reconfigure'): + sys.stdout.reconfigure(encoding='utf-8', errors='replace') + if hasattr(sys.stderr, 'reconfigure'): + sys.stderr.reconfigure(encoding='utf-8', errors='replace') + + +# 日志目录 +LOG_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'logs') + + +def setup_logger(name: str = 'mirofish', level: int = logging.DEBUG) -> logging.Logger: + """ + 设置日志器 + + Args: + name: 日志器名称 + level: 日志级别 + + Returns: + 配置好的日志器 + """ + # 确保日志目录存在 + os.makedirs(LOG_DIR, exist_ok=True) + + # 创建日志器 + logger = logging.getLogger(name) + logger.setLevel(level) + + # 阻止日志向上传播到根 logger,避免重复输出 + logger.propagate = False + + # 如果已经有处理器,不重复添加 + if logger.handlers: + return logger + + # 日志格式 + detailed_formatter = logging.Formatter( + '[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + ) + + simple_formatter = logging.Formatter( + '[%(asctime)s] %(levelname)s: %(message)s', + datefmt='%H:%M:%S' + ) + + # 1. 文件处理器 - 详细日志(按日期命名,带轮转) + log_filename = datetime.now().strftime('%Y-%m-%d') + '.log' + file_handler = RotatingFileHandler( + os.path.join(LOG_DIR, log_filename), + maxBytes=10 * 1024 * 1024, # 10MB + backupCount=5, + encoding='utf-8' + ) + file_handler.setLevel(logging.DEBUG) + file_handler.setFormatter(detailed_formatter) + + # 2. 控制台处理器 - 简洁日志(INFO及以上) + # 确保 Windows 下使用 UTF-8 编码,避免中文乱码 + _ensure_utf8_stdout() + console_handler = logging.StreamHandler(sys.stdout) + console_handler.setLevel(logging.INFO) + console_handler.setFormatter(simple_formatter) + + # 添加处理器 + logger.addHandler(file_handler) + logger.addHandler(console_handler) + + return logger + + +def get_logger(name: str = 'mirofish') -> logging.Logger: + """ + 获取日志器(如果不存在则创建) + + Args: + name: 日志器名称 + + Returns: + 日志器实例 + """ + logger = logging.getLogger(name) + if not logger.handlers: + return setup_logger(name) + return logger + + +# 创建默认日志器 +logger = setup_logger() + + +# 便捷方法 +def debug(msg: str, *args, **kwargs) -> None: + logger.debug(msg, *args, **kwargs) + +def info(msg: str, *args, **kwargs) -> None: + logger.info(msg, *args, **kwargs) + +def warning(msg: str, *args, **kwargs) -> None: + logger.warning(msg, *args, **kwargs) + +def error(msg: str, *args, **kwargs) -> None: + logger.error(msg, *args, **kwargs) + +def critical(msg: str, *args, **kwargs) -> None: + logger.critical(msg, *args, **kwargs) + diff --git a/backend/app/utils/retry.py b/backend/app/utils/retry.py new file mode 100644 index 00000000..819b1cfc --- /dev/null +++ b/backend/app/utils/retry.py @@ -0,0 +1,238 @@ +""" +API调用重试机制 +用于处理LLM等外部API调用的重试逻辑 +""" + +import time +import random +import functools +from typing import Callable, Any, Optional, Type, Tuple +from ..utils.logger import get_logger + +logger = get_logger('mirofish.retry') + + +def retry_with_backoff( + max_retries: int = 3, + initial_delay: float = 1.0, + max_delay: float = 30.0, + backoff_factor: float = 2.0, + jitter: bool = True, + exceptions: Tuple[Type[Exception], ...] = (Exception,), + on_retry: Optional[Callable[[Exception, int], None]] = None +): + """ + 带指数退避的重试装饰器 + + Args: + max_retries: 最大重试次数 + initial_delay: 初始延迟(秒) + max_delay: 最大延迟(秒) + backoff_factor: 退避因子 + jitter: 是否添加随机抖动 + exceptions: 需要重试的异常类型 + on_retry: 重试时的回调函数 (exception, retry_count) + + Usage: + @retry_with_backoff(max_retries=3) + def call_llm_api(): + ... + """ + def decorator(func: Callable) -> Callable: + @functools.wraps(func) + def wrapper(*args, **kwargs) -> Any: + last_exception = None + delay = initial_delay + + for attempt in range(max_retries + 1): + try: + return func(*args, **kwargs) + + except exceptions as e: + last_exception = e + + if attempt == max_retries: + logger.error(f"函数 {func.__name__} 在 {max_retries} 次重试后仍失败: {str(e)}") + raise + + # 计算延迟 + current_delay = min(delay, max_delay) + if jitter: + current_delay = current_delay * (0.5 + random.random()) + + logger.warning( + f"函数 {func.__name__} 第 {attempt + 1} 次尝试失败: {str(e)}, " + f"{current_delay:.1f}秒后重试..." + ) + + if on_retry: + on_retry(e, attempt + 1) + + time.sleep(current_delay) + delay *= backoff_factor + + raise last_exception + + return wrapper + return decorator + + +def retry_with_backoff_async( + max_retries: int = 3, + initial_delay: float = 1.0, + max_delay: float = 30.0, + backoff_factor: float = 2.0, + jitter: bool = True, + exceptions: Tuple[Type[Exception], ...] = (Exception,), + on_retry: Optional[Callable[[Exception, int], None]] = None +): + """ + 异步版本的重试装饰器 + """ + import asyncio + + def decorator(func: Callable) -> Callable: + @functools.wraps(func) + async def wrapper(*args, **kwargs) -> Any: + last_exception = None + delay = initial_delay + + for attempt in range(max_retries + 1): + try: + return await func(*args, **kwargs) + + except exceptions as e: + last_exception = e + + if attempt == max_retries: + logger.error(f"异步函数 {func.__name__} 在 {max_retries} 次重试后仍失败: {str(e)}") + raise + + current_delay = min(delay, max_delay) + if jitter: + current_delay = current_delay * (0.5 + random.random()) + + logger.warning( + f"异步函数 {func.__name__} 第 {attempt + 1} 次尝试失败: {str(e)}, " + f"{current_delay:.1f}秒后重试..." + ) + + if on_retry: + on_retry(e, attempt + 1) + + await asyncio.sleep(current_delay) + delay *= backoff_factor + + raise last_exception + + return wrapper + return decorator + + +class RetryableAPIClient: + """ + 可重试的API客户端封装 + """ + + def __init__( + self, + max_retries: int = 3, + initial_delay: float = 1.0, + max_delay: float = 30.0, + backoff_factor: float = 2.0 + ): + self.max_retries = max_retries + self.initial_delay = initial_delay + self.max_delay = max_delay + self.backoff_factor = backoff_factor + + def call_with_retry( + self, + func: Callable, + *args, + exceptions: Tuple[Type[Exception], ...] = (Exception,), + **kwargs + ) -> Any: + """ + 执行函数调用并在失败时重试 + + Args: + func: 要调用的函数 + *args: 函数参数 + exceptions: 需要重试的异常类型 + **kwargs: 函数关键字参数 + + Returns: + 函数返回值 + """ + last_exception = None + delay = self.initial_delay + + for attempt in range(self.max_retries + 1): + try: + return func(*args, **kwargs) + + except exceptions as e: + last_exception = e + + if attempt == self.max_retries: + logger.error(f"API调用在 {self.max_retries} 次重试后仍失败: {str(e)}") + raise + + current_delay = min(delay, self.max_delay) + current_delay = current_delay * (0.5 + random.random()) + + logger.warning( + f"API调用第 {attempt + 1} 次尝试失败: {str(e)}, " + f"{current_delay:.1f}秒后重试..." + ) + + time.sleep(current_delay) + delay *= self.backoff_factor + + raise last_exception + + def call_batch_with_retry( + self, + items: list, + process_func: Callable, + exceptions: Tuple[Type[Exception], ...] = (Exception,), + continue_on_failure: bool = True + ) -> Tuple[list, list]: + """ + 批量调用并对每个失败项单独重试 + + Args: + items: 要处理的项目列表 + process_func: 处理函数,接收单个item作为参数 + exceptions: 需要重试的异常类型 + continue_on_failure: 单项失败后是否继续处理其他项 + + Returns: + (成功结果列表, 失败项列表) + """ + results = [] + failures = [] + + for idx, item in enumerate(items): + try: + result = self.call_with_retry( + process_func, + item, + exceptions=exceptions + ) + results.append(result) + + except Exception as e: + logger.error(f"处理第 {idx + 1} 项失败: {str(e)}") + failures.append({ + "index": idx, + "item": item, + "error": str(e) + }) + + if not continue_on_failure: + raise + + return results, failures + diff --git a/backend/app/utils/zep_paging.py b/backend/app/utils/zep_paging.py new file mode 100644 index 00000000..943cd1ae --- /dev/null +++ b/backend/app/utils/zep_paging.py @@ -0,0 +1,143 @@ +"""Zep Graph 分页读取工具。 + +Zep 的 node/edge 列表接口使用 UUID cursor 分页, +本模块封装自动翻页逻辑(含单页重试),对调用方透明地返回完整列表。 +""" + +from __future__ import annotations + +import time +from collections.abc import Callable +from typing import Any + +from zep_cloud import InternalServerError +from zep_cloud.client import Zep + +from .logger import get_logger + +logger = get_logger('mirofish.zep_paging') + +_DEFAULT_PAGE_SIZE = 100 +_MAX_NODES = 2000 +_DEFAULT_MAX_RETRIES = 3 +_DEFAULT_RETRY_DELAY = 2.0 # seconds, doubles each retry + + +def _fetch_page_with_retry( + api_call: Callable[..., list[Any]], + *args: Any, + max_retries: int = _DEFAULT_MAX_RETRIES, + retry_delay: float = _DEFAULT_RETRY_DELAY, + page_description: str = "page", + **kwargs: Any, +) -> list[Any]: + """单页请求,失败时指数退避重试。仅重试网络/IO类瞬态错误。""" + if max_retries < 1: + raise ValueError("max_retries must be >= 1") + + last_exception: Exception | None = None + delay = retry_delay + + for attempt in range(max_retries): + try: + return api_call(*args, **kwargs) + except (ConnectionError, TimeoutError, OSError, InternalServerError) as e: + last_exception = e + if attempt < max_retries - 1: + logger.warning( + f"Zep {page_description} attempt {attempt + 1} failed: {str(e)[:100]}, retrying in {delay:.1f}s..." + ) + time.sleep(delay) + delay *= 2 + else: + logger.error(f"Zep {page_description} failed after {max_retries} attempts: {str(e)}") + + assert last_exception is not None + raise last_exception + + +def fetch_all_nodes( + client: Zep, + graph_id: str, + page_size: int = _DEFAULT_PAGE_SIZE, + max_items: int = _MAX_NODES, + max_retries: int = _DEFAULT_MAX_RETRIES, + retry_delay: float = _DEFAULT_RETRY_DELAY, +) -> list[Any]: + """分页获取图谱节点,最多返回 max_items 条(默认 2000)。每页请求自带重试。""" + all_nodes: list[Any] = [] + cursor: str | None = None + page_num = 0 + + while True: + kwargs: dict[str, Any] = {"limit": page_size} + if cursor is not None: + kwargs["uuid_cursor"] = cursor + + page_num += 1 + batch = _fetch_page_with_retry( + client.graph.node.get_by_graph_id, + graph_id, + max_retries=max_retries, + retry_delay=retry_delay, + page_description=f"fetch nodes page {page_num} (graph={graph_id})", + **kwargs, + ) + if not batch: + break + + all_nodes.extend(batch) + if len(all_nodes) >= max_items: + all_nodes = all_nodes[:max_items] + logger.warning(f"Node count reached limit ({max_items}), stopping pagination for graph {graph_id}") + break + if len(batch) < page_size: + break + + cursor = getattr(batch[-1], "uuid_", None) or getattr(batch[-1], "uuid", None) + if cursor is None: + logger.warning(f"Node missing uuid field, stopping pagination at {len(all_nodes)} nodes") + break + + return all_nodes + + +def fetch_all_edges( + client: Zep, + graph_id: str, + page_size: int = _DEFAULT_PAGE_SIZE, + max_retries: int = _DEFAULT_MAX_RETRIES, + retry_delay: float = _DEFAULT_RETRY_DELAY, +) -> list[Any]: + """分页获取图谱所有边,返回完整列表。每页请求自带重试。""" + all_edges: list[Any] = [] + cursor: str | None = None + page_num = 0 + + while True: + kwargs: dict[str, Any] = {"limit": page_size} + if cursor is not None: + kwargs["uuid_cursor"] = cursor + + page_num += 1 + batch = _fetch_page_with_retry( + client.graph.edge.get_by_graph_id, + graph_id, + max_retries=max_retries, + retry_delay=retry_delay, + page_description=f"fetch edges page {page_num} (graph={graph_id})", + **kwargs, + ) + if not batch: + break + + all_edges.extend(batch) + if len(batch) < page_size: + break + + cursor = getattr(batch[-1], "uuid_", None) or getattr(batch[-1], "uuid", None) + if cursor is None: + logger.warning(f"Edge missing uuid field, stopping pagination at {len(all_edges)} edges") + break + + return all_edges diff --git a/backend/pyproject.toml b/backend/pyproject.toml new file mode 100644 index 00000000..8c65b729 --- /dev/null +++ b/backend/pyproject.toml @@ -0,0 +1,55 @@ +[project] +name = "mirofish-backend" +version = "0.1.0" +description = "MiroFish - 简洁通用的群体智能引擎,预测万物" +requires-python = ">=3.11,<3.13" +license = { text = "AGPL-3.0" } +authors = [ + { name = "MiroFish Team" } +] + +dependencies = [ + # 核心框架 + "flask>=3.0.0", + "flask-cors>=6.0.0", + + # LLM 相关 + "openai>=1.0.0", + + # Zep Cloud + "zep-cloud==3.13.0", + + # OASIS 社交媒体模拟 + "camel-oasis==0.2.5", + "camel-ai==0.2.78", + + # 文件处理 + "PyMuPDF>=1.24.0", + # 编码检测(支持非UTF-8编码的文本文件) + "charset-normalizer>=3.0.0", + "chardet>=5.0.0", + + # 工具库 + "python-dotenv>=1.0.0", + "pydantic>=2.0.0", +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.0.0", + "pytest-asyncio>=0.23.0", + "pipreqs>=0.5.0", +] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[dependency-groups] +dev = [ + "pytest>=8.0.0", + "pytest-asyncio>=0.23.0", +] + +[tool.hatch.build.targets.wheel] +packages = ["app"] diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 00000000..4f146296 --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,35 @@ +# =========================================== +# MiroFish Backend Dependencies +# =========================================== +# Python 3.11+ required +# Install: pip install -r requirements.txt +# =========================================== + +# ============= 核心框架 ============= +flask>=3.0.0 +flask-cors>=6.0.0 + +# ============= LLM 相关 ============= +# OpenAI SDK(统一使用 OpenAI 格式调用 LLM) +openai>=1.0.0 + +# ============= Zep Cloud ============= +zep-cloud==3.13.0 + +# ============= OASIS 社交媒体模拟 ============= +# OASIS 社交模拟框架 +camel-oasis==0.2.5 +camel-ai==0.2.78 + +# ============= 文件处理 ============= +PyMuPDF>=1.24.0 +# 编码检测(支持非UTF-8编码的文本文件) +charset-normalizer>=3.0.0 +chardet>=5.0.0 + +# ============= 工具库 ============= +# 环境变量加载 +python-dotenv>=1.0.0 + +# 数据验证 +pydantic>=2.0.0 diff --git a/backend/run.py b/backend/run.py new file mode 100644 index 00000000..4e3b04fa --- /dev/null +++ b/backend/run.py @@ -0,0 +1,50 @@ +""" +MiroFish Backend 启动入口 +""" + +import os +import sys + +# 解决 Windows 控制台中文乱码问题:在所有导入之前设置 UTF-8 编码 +if sys.platform == 'win32': + # 设置环境变量确保 Python 使用 UTF-8 + os.environ.setdefault('PYTHONIOENCODING', 'utf-8') + # 重新配置标准输出流为 UTF-8 + if hasattr(sys.stdout, 'reconfigure'): + sys.stdout.reconfigure(encoding='utf-8', errors='replace') + if hasattr(sys.stderr, 'reconfigure'): + sys.stderr.reconfigure(encoding='utf-8', errors='replace') + +# 添加项目根目录到路径 +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + +from app import create_app +from app.config import Config + + +def main(): + """主函数""" + # 验证配置 + errors = Config.validate() + if errors: + print("配置错误:") + for err in errors: + print(f" - {err}") + print("\n请检查 .env 文件中的配置") + sys.exit(1) + + # 创建应用 + app = create_app() + + # 获取运行配置 + host = os.environ.get('FLASK_HOST', '0.0.0.0') + port = int(os.environ.get('FLASK_PORT', 5001)) + debug = Config.DEBUG + + # 启动服务 + app.run(host=host, port=port, debug=debug, threaded=True) + + +if __name__ == '__main__': + main() + diff --git a/backend/scripts/action_logger.py b/backend/scripts/action_logger.py new file mode 100644 index 00000000..38d025a6 --- /dev/null +++ b/backend/scripts/action_logger.py @@ -0,0 +1,305 @@ +""" +动作日志记录器 +用于记录OASIS模拟中每个Agent的动作,供后端监控使用 + +日志结构: + sim_xxx/ + ├── twitter/ + │ └── actions.jsonl # Twitter 平台动作日志 + ├── reddit/ + │ └── actions.jsonl # Reddit 平台动作日志 + ├── simulation.log # 主模拟进程日志 + └── run_state.json # 运行状态(API 查询用) +""" + +import json +import os +import logging +from datetime import datetime +from typing import Dict, Any, Optional + + +class PlatformActionLogger: + """单平台动作日志记录器""" + + def __init__(self, platform: str, base_dir: str): + """ + 初始化日志记录器 + + Args: + platform: 平台名称 (twitter/reddit) + base_dir: 模拟目录的基础路径 + """ + self.platform = platform + self.base_dir = base_dir + self.log_dir = os.path.join(base_dir, platform) + self.log_path = os.path.join(self.log_dir, "actions.jsonl") + self._ensure_dir() + + def _ensure_dir(self): + """确保目录存在""" + os.makedirs(self.log_dir, exist_ok=True) + + def log_action( + self, + round_num: int, + agent_id: int, + agent_name: str, + action_type: str, + action_args: Optional[Dict[str, Any]] = None, + result: Optional[str] = None, + success: bool = True + ): + """记录一个动作""" + entry = { + "round": round_num, + "timestamp": datetime.now().isoformat(), + "agent_id": agent_id, + "agent_name": agent_name, + "action_type": action_type, + "action_args": action_args or {}, + "result": result, + "success": success, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_round_start(self, round_num: int, simulated_hour: int): + """记录轮次开始""" + entry = { + "round": round_num, + "timestamp": datetime.now().isoformat(), + "event_type": "round_start", + "simulated_hour": simulated_hour, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_round_end(self, round_num: int, actions_count: int): + """记录轮次结束""" + entry = { + "round": round_num, + "timestamp": datetime.now().isoformat(), + "event_type": "round_end", + "actions_count": actions_count, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_simulation_start(self, config: Dict[str, Any]): + """记录模拟开始""" + entry = { + "timestamp": datetime.now().isoformat(), + "event_type": "simulation_start", + "platform": self.platform, + "total_rounds": config.get("time_config", {}).get("total_simulation_hours", 72) * 2, + "agents_count": len(config.get("agent_configs", [])), + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_simulation_end(self, total_rounds: int, total_actions: int): + """记录模拟结束""" + entry = { + "timestamp": datetime.now().isoformat(), + "event_type": "simulation_end", + "platform": self.platform, + "total_rounds": total_rounds, + "total_actions": total_actions, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + +class SimulationLogManager: + """ + 模拟日志管理器 + 统一管理所有日志文件,按平台分离 + """ + + def __init__(self, simulation_dir: str): + """ + 初始化日志管理器 + + Args: + simulation_dir: 模拟目录路径 + """ + self.simulation_dir = simulation_dir + self.twitter_logger: Optional[PlatformActionLogger] = None + self.reddit_logger: Optional[PlatformActionLogger] = None + self._main_logger: Optional[logging.Logger] = None + + # 设置主日志 + self._setup_main_logger() + + def _setup_main_logger(self): + """设置主模拟日志""" + log_path = os.path.join(self.simulation_dir, "simulation.log") + + # 创建 logger + self._main_logger = logging.getLogger(f"simulation.{os.path.basename(self.simulation_dir)}") + self._main_logger.setLevel(logging.INFO) + self._main_logger.handlers.clear() + + # 文件处理器 + file_handler = logging.FileHandler(log_path, encoding='utf-8', mode='w') + file_handler.setLevel(logging.INFO) + file_handler.setFormatter(logging.Formatter( + '%(asctime)s - %(levelname)s - %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + )) + self._main_logger.addHandler(file_handler) + + # 控制台处理器 + console_handler = logging.StreamHandler() + console_handler.setLevel(logging.INFO) + console_handler.setFormatter(logging.Formatter( + '[%(asctime)s] %(message)s', + datefmt='%H:%M:%S' + )) + self._main_logger.addHandler(console_handler) + + self._main_logger.propagate = False + + def get_twitter_logger(self) -> PlatformActionLogger: + """获取 Twitter 平台日志记录器""" + if self.twitter_logger is None: + self.twitter_logger = PlatformActionLogger("twitter", self.simulation_dir) + return self.twitter_logger + + def get_reddit_logger(self) -> PlatformActionLogger: + """获取 Reddit 平台日志记录器""" + if self.reddit_logger is None: + self.reddit_logger = PlatformActionLogger("reddit", self.simulation_dir) + return self.reddit_logger + + def log(self, message: str, level: str = "info"): + """记录主日志""" + if self._main_logger: + getattr(self._main_logger, level.lower(), self._main_logger.info)(message) + + def info(self, message: str): + self.log(message, "info") + + def warning(self, message: str): + self.log(message, "warning") + + def error(self, message: str): + self.log(message, "error") + + def debug(self, message: str): + self.log(message, "debug") + + +# ============ 兼容旧接口 ============ + +class ActionLogger: + """ + 动作日志记录器(兼容旧接口) + 建议使用 SimulationLogManager 代替 + """ + + def __init__(self, log_path: str): + self.log_path = log_path + self._ensure_dir() + + def _ensure_dir(self): + log_dir = os.path.dirname(self.log_path) + if log_dir: + os.makedirs(log_dir, exist_ok=True) + + def log_action( + self, + round_num: int, + platform: str, + agent_id: int, + agent_name: str, + action_type: str, + action_args: Optional[Dict[str, Any]] = None, + result: Optional[str] = None, + success: bool = True + ): + entry = { + "round": round_num, + "timestamp": datetime.now().isoformat(), + "platform": platform, + "agent_id": agent_id, + "agent_name": agent_name, + "action_type": action_type, + "action_args": action_args or {}, + "result": result, + "success": success, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_round_start(self, round_num: int, simulated_hour: int, platform: str): + entry = { + "round": round_num, + "timestamp": datetime.now().isoformat(), + "platform": platform, + "event_type": "round_start", + "simulated_hour": simulated_hour, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_round_end(self, round_num: int, actions_count: int, platform: str): + entry = { + "round": round_num, + "timestamp": datetime.now().isoformat(), + "platform": platform, + "event_type": "round_end", + "actions_count": actions_count, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_simulation_start(self, platform: str, config: Dict[str, Any]): + entry = { + "timestamp": datetime.now().isoformat(), + "platform": platform, + "event_type": "simulation_start", + "total_rounds": config.get("time_config", {}).get("total_simulation_hours", 72) * 2, + "agents_count": len(config.get("agent_configs", [])), + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + def log_simulation_end(self, platform: str, total_rounds: int, total_actions: int): + entry = { + "timestamp": datetime.now().isoformat(), + "platform": platform, + "event_type": "simulation_end", + "total_rounds": total_rounds, + "total_actions": total_actions, + } + + with open(self.log_path, 'a', encoding='utf-8') as f: + f.write(json.dumps(entry, ensure_ascii=False) + '\n') + + +# 全局日志实例(兼容旧接口) +_global_logger: Optional[ActionLogger] = None + + +def get_logger(log_path: Optional[str] = None) -> ActionLogger: + """获取全局日志实例(兼容旧接口)""" + global _global_logger + + if log_path: + _global_logger = ActionLogger(log_path) + + if _global_logger is None: + _global_logger = ActionLogger("actions.jsonl") + + return _global_logger diff --git a/backend/scripts/run_parallel_simulation.py b/backend/scripts/run_parallel_simulation.py new file mode 100644 index 00000000..2a627ffd --- /dev/null +++ b/backend/scripts/run_parallel_simulation.py @@ -0,0 +1,1699 @@ +""" +OASIS 双平台并行模拟预设脚本 +同时运行Twitter和Reddit模拟,读取相同的配置文件 + +功能特性: +- 双平台(Twitter + Reddit)并行模拟 +- 完成模拟后不立即关闭环境,进入等待命令模式 +- 支持通过IPC接收Interview命令 +- 支持单个Agent采访和批量采访 +- 支持远程关闭环境命令 + +使用方式: + python run_parallel_simulation.py --config simulation_config.json + python run_parallel_simulation.py --config simulation_config.json --no-wait # 完成后立即关闭 + python run_parallel_simulation.py --config simulation_config.json --twitter-only + python run_parallel_simulation.py --config simulation_config.json --reddit-only + +日志结构: + sim_xxx/ + ├── twitter/ + │ └── actions.jsonl # Twitter 平台动作日志 + ├── reddit/ + │ └── actions.jsonl # Reddit 平台动作日志 + ├── simulation.log # 主模拟进程日志 + └── run_state.json # 运行状态(API 查询用) +""" + +# ============================================================ +# 解决 Windows 编码问题:在所有 import 之前设置 UTF-8 编码 +# 这是为了修复 OASIS 第三方库读取文件时未指定编码的问题 +# ============================================================ +import sys +import os + +if sys.platform == 'win32': + # 设置 Python 默认 I/O 编码为 UTF-8 + # 这会影响所有未指定编码的 open() 调用 + os.environ.setdefault('PYTHONUTF8', '1') + os.environ.setdefault('PYTHONIOENCODING', 'utf-8') + + # 重新配置标准输出流为 UTF-8(解决控制台中文乱码) + if hasattr(sys.stdout, 'reconfigure'): + sys.stdout.reconfigure(encoding='utf-8', errors='replace') + if hasattr(sys.stderr, 'reconfigure'): + sys.stderr.reconfigure(encoding='utf-8', errors='replace') + + # 强制设置默认编码(影响 open() 函数的默认编码) + # 注意:这需要在 Python 启动时就设置,运行时设置可能不生效 + # 所以我们还需要 monkey-patch 内置的 open 函数 + import builtins + _original_open = builtins.open + + def _utf8_open(file, mode='r', buffering=-1, encoding=None, errors=None, + newline=None, closefd=True, opener=None): + """ + 包装 open() 函数,对于文本模式默认使用 UTF-8 编码 + 这可以修复第三方库(如 OASIS)读取文件时未指定编码的问题 + """ + # 只对文本模式(非二进制)且未指定编码的情况设置默认编码 + if encoding is None and 'b' not in mode: + encoding = 'utf-8' + return _original_open(file, mode, buffering, encoding, errors, + newline, closefd, opener) + + builtins.open = _utf8_open + +import argparse +import asyncio +import json +import logging +import multiprocessing +import random +import signal +import sqlite3 +import warnings +from datetime import datetime +from typing import Dict, Any, List, Optional, Tuple + + +# 全局变量:用于信号处理 +_shutdown_event = None +_cleanup_done = False + +# 添加 backend 目录到路径 +# 脚本固定位于 backend/scripts/ 目录 +_scripts_dir = os.path.dirname(os.path.abspath(__file__)) +_backend_dir = os.path.abspath(os.path.join(_scripts_dir, '..')) +_project_root = os.path.abspath(os.path.join(_backend_dir, '..')) +sys.path.insert(0, _scripts_dir) +sys.path.insert(0, _backend_dir) + +# 加载项目根目录的 .env 文件(包含 LLM_API_KEY 等配置) +from dotenv import load_dotenv +_env_file = os.path.join(_project_root, '.env') +if os.path.exists(_env_file): + load_dotenv(_env_file) + print(f"已加载环境配置: {_env_file}") +else: + # 尝试加载 backend/.env + _backend_env = os.path.join(_backend_dir, '.env') + if os.path.exists(_backend_env): + load_dotenv(_backend_env) + print(f"已加载环境配置: {_backend_env}") + + +class MaxTokensWarningFilter(logging.Filter): + """过滤掉 camel-ai 关于 max_tokens 的警告(我们故意不设置 max_tokens,让模型自行决定)""" + + def filter(self, record): + # 过滤掉包含 max_tokens 警告的日志 + if "max_tokens" in record.getMessage() and "Invalid or missing" in record.getMessage(): + return False + return True + + +# 在模块加载时立即添加过滤器,确保在 camel 代码执行前生效 +logging.getLogger().addFilter(MaxTokensWarningFilter()) + + +def disable_oasis_logging(): + """ + 禁用 OASIS 库的详细日志输出 + OASIS 的日志太冗余(记录每个 agent 的观察和动作),我们使用自己的 action_logger + """ + # 禁用 OASIS 的所有日志器 + oasis_loggers = [ + "social.agent", + "social.twitter", + "social.rec", + "oasis.env", + "table", + ] + + for logger_name in oasis_loggers: + logger = logging.getLogger(logger_name) + logger.setLevel(logging.CRITICAL) # 只记录严重错误 + logger.handlers.clear() + logger.propagate = False + + +def init_logging_for_simulation(simulation_dir: str): + """ + 初始化模拟的日志配置 + + Args: + simulation_dir: 模拟目录路径 + """ + # 禁用 OASIS 的详细日志 + disable_oasis_logging() + + # 清理旧的 log 目录(如果存在) + old_log_dir = os.path.join(simulation_dir, "log") + if os.path.exists(old_log_dir): + import shutil + shutil.rmtree(old_log_dir, ignore_errors=True) + + +from action_logger import SimulationLogManager, PlatformActionLogger + +try: + from camel.models import ModelFactory + from camel.types import ModelPlatformType + import oasis + from oasis import ( + ActionType, + LLMAction, + ManualAction, + generate_twitter_agent_graph, + generate_reddit_agent_graph + ) +except ImportError as e: + print(f"错误: 缺少依赖 {e}") + print("请先安装: pip install oasis-ai camel-ai") + sys.exit(1) + + +# Twitter可用动作(不包含INTERVIEW,INTERVIEW只能通过ManualAction手动触发) +TWITTER_ACTIONS = [ + ActionType.CREATE_POST, + ActionType.LIKE_POST, + ActionType.REPOST, + ActionType.FOLLOW, + ActionType.DO_NOTHING, + ActionType.QUOTE_POST, +] + +# Reddit可用动作(不包含INTERVIEW,INTERVIEW只能通过ManualAction手动触发) +REDDIT_ACTIONS = [ + ActionType.LIKE_POST, + ActionType.DISLIKE_POST, + ActionType.CREATE_POST, + ActionType.CREATE_COMMENT, + ActionType.LIKE_COMMENT, + ActionType.DISLIKE_COMMENT, + ActionType.SEARCH_POSTS, + ActionType.SEARCH_USER, + ActionType.TREND, + ActionType.REFRESH, + ActionType.DO_NOTHING, + ActionType.FOLLOW, + ActionType.MUTE, +] + + +# IPC相关常量 +IPC_COMMANDS_DIR = "ipc_commands" +IPC_RESPONSES_DIR = "ipc_responses" +ENV_STATUS_FILE = "env_status.json" + +class CommandType: + """命令类型常量""" + INTERVIEW = "interview" + BATCH_INTERVIEW = "batch_interview" + CLOSE_ENV = "close_env" + + +class ParallelIPCHandler: + """ + 双平台IPC命令处理器 + + 管理两个平台的环境,处理Interview命令 + """ + + def __init__( + self, + simulation_dir: str, + twitter_env=None, + twitter_agent_graph=None, + reddit_env=None, + reddit_agent_graph=None + ): + self.simulation_dir = simulation_dir + self.twitter_env = twitter_env + self.twitter_agent_graph = twitter_agent_graph + self.reddit_env = reddit_env + self.reddit_agent_graph = reddit_agent_graph + + self.commands_dir = os.path.join(simulation_dir, IPC_COMMANDS_DIR) + self.responses_dir = os.path.join(simulation_dir, IPC_RESPONSES_DIR) + self.status_file = os.path.join(simulation_dir, ENV_STATUS_FILE) + + # 确保目录存在 + os.makedirs(self.commands_dir, exist_ok=True) + os.makedirs(self.responses_dir, exist_ok=True) + + def update_status(self, status: str): + """更新环境状态""" + with open(self.status_file, 'w', encoding='utf-8') as f: + json.dump({ + "status": status, + "twitter_available": self.twitter_env is not None, + "reddit_available": self.reddit_env is not None, + "timestamp": datetime.now().isoformat() + }, f, ensure_ascii=False, indent=2) + + def poll_command(self) -> Optional[Dict[str, Any]]: + """轮询获取待处理命令""" + if not os.path.exists(self.commands_dir): + return None + + # 获取命令文件(按时间排序) + command_files = [] + for filename in os.listdir(self.commands_dir): + if filename.endswith('.json'): + filepath = os.path.join(self.commands_dir, filename) + command_files.append((filepath, os.path.getmtime(filepath))) + + command_files.sort(key=lambda x: x[1]) + + for filepath, _ in command_files: + try: + with open(filepath, 'r', encoding='utf-8') as f: + return json.load(f) + except (json.JSONDecodeError, OSError): + continue + + return None + + def send_response(self, command_id: str, status: str, result: Dict = None, error: str = None): + """发送响应""" + response = { + "command_id": command_id, + "status": status, + "result": result, + "error": error, + "timestamp": datetime.now().isoformat() + } + + response_file = os.path.join(self.responses_dir, f"{command_id}.json") + with open(response_file, 'w', encoding='utf-8') as f: + json.dump(response, f, ensure_ascii=False, indent=2) + + # 删除命令文件 + command_file = os.path.join(self.commands_dir, f"{command_id}.json") + try: + os.remove(command_file) + except OSError: + pass + + def _get_env_and_graph(self, platform: str): + """ + 获取指定平台的环境和agent_graph + + Args: + platform: 平台名称 ("twitter" 或 "reddit") + + Returns: + (env, agent_graph, platform_name) 或 (None, None, None) + """ + if platform == "twitter" and self.twitter_env: + return self.twitter_env, self.twitter_agent_graph, "twitter" + elif platform == "reddit" and self.reddit_env: + return self.reddit_env, self.reddit_agent_graph, "reddit" + else: + return None, None, None + + async def _interview_single_platform(self, agent_id: int, prompt: str, platform: str) -> Dict[str, Any]: + """ + 在单个平台上执行Interview + + Returns: + 包含结果的字典,或包含error的字典 + """ + env, agent_graph, actual_platform = self._get_env_and_graph(platform) + + if not env or not agent_graph: + return {"platform": platform, "error": f"{platform}平台不可用"} + + try: + agent = agent_graph.get_agent(agent_id) + interview_action = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + actions = {agent: interview_action} + await env.step(actions) + + result = self._get_interview_result(agent_id, actual_platform) + result["platform"] = actual_platform + return result + + except Exception as e: + return {"platform": platform, "error": str(e)} + + async def handle_interview(self, command_id: str, agent_id: int, prompt: str, platform: str = None) -> bool: + """ + 处理单个Agent采访命令 + + Args: + command_id: 命令ID + agent_id: Agent ID + prompt: 采访问题 + platform: 指定平台(可选) + - "twitter": 只采访Twitter平台 + - "reddit": 只采访Reddit平台 + - None/不指定: 同时采访两个平台,返回整合结果 + + Returns: + True 表示成功,False 表示失败 + """ + # 如果指定了平台,只采访该平台 + if platform in ("twitter", "reddit"): + result = await self._interview_single_platform(agent_id, prompt, platform) + + if "error" in result: + self.send_response(command_id, "failed", error=result["error"]) + print(f" Interview失败: agent_id={agent_id}, platform={platform}, error={result['error']}") + return False + else: + self.send_response(command_id, "completed", result=result) + print(f" Interview完成: agent_id={agent_id}, platform={platform}") + return True + + # 未指定平台:同时采访两个平台 + if not self.twitter_env and not self.reddit_env: + self.send_response(command_id, "failed", error="没有可用的模拟环境") + return False + + results = { + "agent_id": agent_id, + "prompt": prompt, + "platforms": {} + } + success_count = 0 + + # 并行采访两个平台 + tasks = [] + platforms_to_interview = [] + + if self.twitter_env: + tasks.append(self._interview_single_platform(agent_id, prompt, "twitter")) + platforms_to_interview.append("twitter") + + if self.reddit_env: + tasks.append(self._interview_single_platform(agent_id, prompt, "reddit")) + platforms_to_interview.append("reddit") + + # 并行执行 + platform_results = await asyncio.gather(*tasks) + + for platform_name, platform_result in zip(platforms_to_interview, platform_results): + results["platforms"][platform_name] = platform_result + if "error" not in platform_result: + success_count += 1 + + if success_count > 0: + self.send_response(command_id, "completed", result=results) + print(f" Interview完成: agent_id={agent_id}, 成功平台数={success_count}/{len(platforms_to_interview)}") + return True + else: + errors = [f"{p}: {r.get('error', '未知错误')}" for p, r in results["platforms"].items()] + self.send_response(command_id, "failed", error="; ".join(errors)) + print(f" Interview失败: agent_id={agent_id}, 所有平台都失败") + return False + + async def handle_batch_interview(self, command_id: str, interviews: List[Dict], platform: str = None) -> bool: + """ + 处理批量采访命令 + + Args: + command_id: 命令ID + interviews: [{"agent_id": int, "prompt": str, "platform": str(optional)}, ...] + platform: 默认平台(可被每个interview项覆盖) + - "twitter": 只采访Twitter平台 + - "reddit": 只采访Reddit平台 + - None/不指定: 每个Agent同时采访两个平台 + """ + # 按平台分组 + twitter_interviews = [] + reddit_interviews = [] + both_platforms_interviews = [] # 需要同时采访两个平台的 + + for interview in interviews: + item_platform = interview.get("platform", platform) + if item_platform == "twitter": + twitter_interviews.append(interview) + elif item_platform == "reddit": + reddit_interviews.append(interview) + else: + # 未指定平台:两个平台都采访 + both_platforms_interviews.append(interview) + + # 把 both_platforms_interviews 拆分到两个平台 + if both_platforms_interviews: + if self.twitter_env: + twitter_interviews.extend(both_platforms_interviews) + if self.reddit_env: + reddit_interviews.extend(both_platforms_interviews) + + results = {} + + # 处理Twitter平台的采访 + if twitter_interviews and self.twitter_env: + try: + twitter_actions = {} + for interview in twitter_interviews: + agent_id = interview.get("agent_id") + prompt = interview.get("prompt", "") + try: + agent = self.twitter_agent_graph.get_agent(agent_id) + twitter_actions[agent] = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + except Exception as e: + print(f" 警告: 无法获取Twitter Agent {agent_id}: {e}") + + if twitter_actions: + await self.twitter_env.step(twitter_actions) + + for interview in twitter_interviews: + agent_id = interview.get("agent_id") + result = self._get_interview_result(agent_id, "twitter") + result["platform"] = "twitter" + results[f"twitter_{agent_id}"] = result + except Exception as e: + print(f" Twitter批量Interview失败: {e}") + + # 处理Reddit平台的采访 + if reddit_interviews and self.reddit_env: + try: + reddit_actions = {} + for interview in reddit_interviews: + agent_id = interview.get("agent_id") + prompt = interview.get("prompt", "") + try: + agent = self.reddit_agent_graph.get_agent(agent_id) + reddit_actions[agent] = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + except Exception as e: + print(f" 警告: 无法获取Reddit Agent {agent_id}: {e}") + + if reddit_actions: + await self.reddit_env.step(reddit_actions) + + for interview in reddit_interviews: + agent_id = interview.get("agent_id") + result = self._get_interview_result(agent_id, "reddit") + result["platform"] = "reddit" + results[f"reddit_{agent_id}"] = result + except Exception as e: + print(f" Reddit批量Interview失败: {e}") + + if results: + self.send_response(command_id, "completed", result={ + "interviews_count": len(results), + "results": results + }) + print(f" 批量Interview完成: {len(results)} 个Agent") + return True + else: + self.send_response(command_id, "failed", error="没有成功的采访") + return False + + def _get_interview_result(self, agent_id: int, platform: str) -> Dict[str, Any]: + """从数据库获取最新的Interview结果""" + db_path = os.path.join(self.simulation_dir, f"{platform}_simulation.db") + + result = { + "agent_id": agent_id, + "response": None, + "timestamp": None + } + + if not os.path.exists(db_path): + return result + + try: + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + # 查询最新的Interview记录 + cursor.execute(""" + SELECT user_id, info, created_at + FROM trace + WHERE action = ? AND user_id = ? + ORDER BY created_at DESC + LIMIT 1 + """, (ActionType.INTERVIEW.value, agent_id)) + + row = cursor.fetchone() + if row: + user_id, info_json, created_at = row + try: + info = json.loads(info_json) if info_json else {} + result["response"] = info.get("response", info) + result["timestamp"] = created_at + except json.JSONDecodeError: + result["response"] = info_json + + conn.close() + + except Exception as e: + print(f" 读取Interview结果失败: {e}") + + return result + + async def process_commands(self) -> bool: + """ + 处理所有待处理命令 + + Returns: + True 表示继续运行,False 表示应该退出 + """ + command = self.poll_command() + if not command: + return True + + command_id = command.get("command_id") + command_type = command.get("command_type") + args = command.get("args", {}) + + print(f"\n收到IPC命令: {command_type}, id={command_id}") + + if command_type == CommandType.INTERVIEW: + await self.handle_interview( + command_id, + args.get("agent_id", 0), + args.get("prompt", ""), + args.get("platform") + ) + return True + + elif command_type == CommandType.BATCH_INTERVIEW: + await self.handle_batch_interview( + command_id, + args.get("interviews", []), + args.get("platform") + ) + return True + + elif command_type == CommandType.CLOSE_ENV: + print("收到关闭环境命令") + self.send_response(command_id, "completed", result={"message": "环境即将关闭"}) + return False + + else: + self.send_response(command_id, "failed", error=f"未知命令类型: {command_type}") + return True + + +def load_config(config_path: str) -> Dict[str, Any]: + """加载配置文件""" + with open(config_path, 'r', encoding='utf-8') as f: + return json.load(f) + + +# 需要过滤掉的非核心动作类型(这些动作对分析价值较低) +FILTERED_ACTIONS = {'refresh', 'sign_up'} + +# 动作类型映射表(数据库中的名称 -> 标准名称) +ACTION_TYPE_MAP = { + 'create_post': 'CREATE_POST', + 'like_post': 'LIKE_POST', + 'dislike_post': 'DISLIKE_POST', + 'repost': 'REPOST', + 'quote_post': 'QUOTE_POST', + 'follow': 'FOLLOW', + 'mute': 'MUTE', + 'create_comment': 'CREATE_COMMENT', + 'like_comment': 'LIKE_COMMENT', + 'dislike_comment': 'DISLIKE_COMMENT', + 'search_posts': 'SEARCH_POSTS', + 'search_user': 'SEARCH_USER', + 'trend': 'TREND', + 'do_nothing': 'DO_NOTHING', + 'interview': 'INTERVIEW', +} + + +def get_agent_names_from_config(config: Dict[str, Any]) -> Dict[int, str]: + """ + 从 simulation_config 中获取 agent_id -> entity_name 的映射 + + 这样可以在 actions.jsonl 中显示真实的实体名称,而不是 "Agent_0" 这样的代号 + + Args: + config: simulation_config.json 的内容 + + Returns: + agent_id -> entity_name 的映射字典 + """ + agent_names = {} + agent_configs = config.get("agent_configs", []) + + for agent_config in agent_configs: + agent_id = agent_config.get("agent_id") + entity_name = agent_config.get("entity_name", f"Agent_{agent_id}") + if agent_id is not None: + agent_names[agent_id] = entity_name + + return agent_names + + +def fetch_new_actions_from_db( + db_path: str, + last_rowid: int, + agent_names: Dict[int, str] +) -> Tuple[List[Dict[str, Any]], int]: + """ + 从数据库中获取新的动作记录,并补充完整的上下文信息 + + Args: + db_path: 数据库文件路径 + last_rowid: 上次读取的最大 rowid 值(使用 rowid 而不是 created_at,因为不同平台的 created_at 格式不同) + agent_names: agent_id -> agent_name 映射 + + Returns: + (actions_list, new_last_rowid) + - actions_list: 动作列表,每个元素包含 agent_id, agent_name, action_type, action_args(含上下文信息) + - new_last_rowid: 新的最大 rowid 值 + """ + actions = [] + new_last_rowid = last_rowid + + if not os.path.exists(db_path): + return actions, new_last_rowid + + try: + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + # 使用 rowid 来追踪已处理的记录(rowid 是 SQLite 的内置自增字段) + # 这样可以避免 created_at 格式差异问题(Twitter 用整数,Reddit 用日期时间字符串) + cursor.execute(""" + SELECT rowid, user_id, action, info + FROM trace + WHERE rowid > ? + ORDER BY rowid ASC + """, (last_rowid,)) + + for rowid, user_id, action, info_json in cursor.fetchall(): + # 更新最大 rowid + new_last_rowid = rowid + + # 过滤非核心动作 + if action in FILTERED_ACTIONS: + continue + + # 解析动作参数 + try: + action_args = json.loads(info_json) if info_json else {} + except json.JSONDecodeError: + action_args = {} + + # 精简 action_args,只保留关键字段(保留完整内容,不截断) + simplified_args = {} + if 'content' in action_args: + simplified_args['content'] = action_args['content'] + if 'post_id' in action_args: + simplified_args['post_id'] = action_args['post_id'] + if 'comment_id' in action_args: + simplified_args['comment_id'] = action_args['comment_id'] + if 'quoted_id' in action_args: + simplified_args['quoted_id'] = action_args['quoted_id'] + if 'new_post_id' in action_args: + simplified_args['new_post_id'] = action_args['new_post_id'] + if 'follow_id' in action_args: + simplified_args['follow_id'] = action_args['follow_id'] + if 'query' in action_args: + simplified_args['query'] = action_args['query'] + if 'like_id' in action_args: + simplified_args['like_id'] = action_args['like_id'] + if 'dislike_id' in action_args: + simplified_args['dislike_id'] = action_args['dislike_id'] + + # 转换动作类型名称 + action_type = ACTION_TYPE_MAP.get(action, action.upper()) + + # 补充上下文信息(帖子内容、用户名等) + _enrich_action_context(cursor, action_type, simplified_args, agent_names) + + actions.append({ + 'agent_id': user_id, + 'agent_name': agent_names.get(user_id, f'Agent_{user_id}'), + 'action_type': action_type, + 'action_args': simplified_args, + }) + + conn.close() + except Exception as e: + print(f"读取数据库动作失败: {e}") + + return actions, new_last_rowid + + +def _enrich_action_context( + cursor, + action_type: str, + action_args: Dict[str, Any], + agent_names: Dict[int, str] +) -> None: + """ + 为动作补充上下文信息(帖子内容、用户名等) + + Args: + cursor: 数据库游标 + action_type: 动作类型 + action_args: 动作参数(会被修改) + agent_names: agent_id -> agent_name 映射 + """ + try: + # 点赞/踩帖子:补充帖子内容和作者 + if action_type in ('LIKE_POST', 'DISLIKE_POST'): + post_id = action_args.get('post_id') + if post_id: + post_info = _get_post_info(cursor, post_id, agent_names) + if post_info: + action_args['post_content'] = post_info.get('content', '') + action_args['post_author_name'] = post_info.get('author_name', '') + + # 转发帖子:补充原帖内容和作者 + elif action_type == 'REPOST': + new_post_id = action_args.get('new_post_id') + if new_post_id: + # 转发帖子的 original_post_id 指向原帖 + cursor.execute(""" + SELECT original_post_id FROM post WHERE post_id = ? + """, (new_post_id,)) + row = cursor.fetchone() + if row and row[0]: + original_post_id = row[0] + original_info = _get_post_info(cursor, original_post_id, agent_names) + if original_info: + action_args['original_content'] = original_info.get('content', '') + action_args['original_author_name'] = original_info.get('author_name', '') + + # 引用帖子:补充原帖内容、作者和引用评论 + elif action_type == 'QUOTE_POST': + quoted_id = action_args.get('quoted_id') + new_post_id = action_args.get('new_post_id') + + if quoted_id: + original_info = _get_post_info(cursor, quoted_id, agent_names) + if original_info: + action_args['original_content'] = original_info.get('content', '') + action_args['original_author_name'] = original_info.get('author_name', '') + + # 获取引用帖子的评论内容(quote_content) + if new_post_id: + cursor.execute(""" + SELECT quote_content FROM post WHERE post_id = ? + """, (new_post_id,)) + row = cursor.fetchone() + if row and row[0]: + action_args['quote_content'] = row[0] + + # 关注用户:补充被关注用户的名称 + elif action_type == 'FOLLOW': + follow_id = action_args.get('follow_id') + if follow_id: + # 从 follow 表获取 followee_id + cursor.execute(""" + SELECT followee_id FROM follow WHERE follow_id = ? + """, (follow_id,)) + row = cursor.fetchone() + if row: + followee_id = row[0] + target_name = _get_user_name(cursor, followee_id, agent_names) + if target_name: + action_args['target_user_name'] = target_name + + # 屏蔽用户:补充被屏蔽用户的名称 + elif action_type == 'MUTE': + # 从 action_args 中获取 user_id 或 target_id + target_id = action_args.get('user_id') or action_args.get('target_id') + if target_id: + target_name = _get_user_name(cursor, target_id, agent_names) + if target_name: + action_args['target_user_name'] = target_name + + # 点赞/踩评论:补充评论内容和作者 + elif action_type in ('LIKE_COMMENT', 'DISLIKE_COMMENT'): + comment_id = action_args.get('comment_id') + if comment_id: + comment_info = _get_comment_info(cursor, comment_id, agent_names) + if comment_info: + action_args['comment_content'] = comment_info.get('content', '') + action_args['comment_author_name'] = comment_info.get('author_name', '') + + # 发表评论:补充所评论的帖子信息 + elif action_type == 'CREATE_COMMENT': + post_id = action_args.get('post_id') + if post_id: + post_info = _get_post_info(cursor, post_id, agent_names) + if post_info: + action_args['post_content'] = post_info.get('content', '') + action_args['post_author_name'] = post_info.get('author_name', '') + + except Exception as e: + # 补充上下文失败不影响主流程 + print(f"补充动作上下文失败: {e}") + + +def _get_post_info( + cursor, + post_id: int, + agent_names: Dict[int, str] +) -> Optional[Dict[str, str]]: + """ + 获取帖子信息 + + Args: + cursor: 数据库游标 + post_id: 帖子ID + agent_names: agent_id -> agent_name 映射 + + Returns: + 包含 content 和 author_name 的字典,或 None + """ + try: + cursor.execute(""" + SELECT p.content, p.user_id, u.agent_id + FROM post p + LEFT JOIN user u ON p.user_id = u.user_id + WHERE p.post_id = ? + """, (post_id,)) + row = cursor.fetchone() + if row: + content = row[0] or '' + user_id = row[1] + agent_id = row[2] + + # 优先使用 agent_names 中的名称 + author_name = '' + if agent_id is not None and agent_id in agent_names: + author_name = agent_names[agent_id] + elif user_id: + # 从 user 表获取名称 + cursor.execute("SELECT name, user_name FROM user WHERE user_id = ?", (user_id,)) + user_row = cursor.fetchone() + if user_row: + author_name = user_row[0] or user_row[1] or '' + + return {'content': content, 'author_name': author_name} + except Exception: + pass + return None + + +def _get_user_name( + cursor, + user_id: int, + agent_names: Dict[int, str] +) -> Optional[str]: + """ + 获取用户名称 + + Args: + cursor: 数据库游标 + user_id: 用户ID + agent_names: agent_id -> agent_name 映射 + + Returns: + 用户名称,或 None + """ + try: + cursor.execute(""" + SELECT agent_id, name, user_name FROM user WHERE user_id = ? + """, (user_id,)) + row = cursor.fetchone() + if row: + agent_id = row[0] + name = row[1] + user_name = row[2] + + # 优先使用 agent_names 中的名称 + if agent_id is not None and agent_id in agent_names: + return agent_names[agent_id] + return name or user_name or '' + except Exception: + pass + return None + + +def _get_comment_info( + cursor, + comment_id: int, + agent_names: Dict[int, str] +) -> Optional[Dict[str, str]]: + """ + 获取评论信息 + + Args: + cursor: 数据库游标 + comment_id: 评论ID + agent_names: agent_id -> agent_name 映射 + + Returns: + 包含 content 和 author_name 的字典,或 None + """ + try: + cursor.execute(""" + SELECT c.content, c.user_id, u.agent_id + FROM comment c + LEFT JOIN user u ON c.user_id = u.user_id + WHERE c.comment_id = ? + """, (comment_id,)) + row = cursor.fetchone() + if row: + content = row[0] or '' + user_id = row[1] + agent_id = row[2] + + # 优先使用 agent_names 中的名称 + author_name = '' + if agent_id is not None and agent_id in agent_names: + author_name = agent_names[agent_id] + elif user_id: + # 从 user 表获取名称 + cursor.execute("SELECT name, user_name FROM user WHERE user_id = ?", (user_id,)) + user_row = cursor.fetchone() + if user_row: + author_name = user_row[0] or user_row[1] or '' + + return {'content': content, 'author_name': author_name} + except Exception: + pass + return None + + +def create_model(config: Dict[str, Any], use_boost: bool = False): + """ + 创建LLM模型 + + 支持双 LLM 配置,用于并行模拟时提速: + - 通用配置:LLM_API_KEY, LLM_BASE_URL, LLM_MODEL_NAME + - 加速配置(可选):LLM_BOOST_API_KEY, LLM_BOOST_BASE_URL, LLM_BOOST_MODEL_NAME + + 如果配置了加速 LLM,并行模拟时可以让不同平台使用不同的 API 服务商,提高并发能力。 + + Args: + config: 模拟配置字典 + use_boost: 是否使用加速 LLM 配置(如果可用) + """ + # 检查是否有加速配置 + boost_api_key = os.environ.get("LLM_BOOST_API_KEY", "") + boost_base_url = os.environ.get("LLM_BOOST_BASE_URL", "") + boost_model = os.environ.get("LLM_BOOST_MODEL_NAME", "") + has_boost_config = bool(boost_api_key) + + # 根据参数和配置情况选择使用哪个 LLM + if use_boost and has_boost_config: + # 使用加速配置 + llm_api_key = boost_api_key + llm_base_url = boost_base_url + llm_model = boost_model or os.environ.get("LLM_MODEL_NAME", "") + config_label = "[加速LLM]" + else: + # 使用通用配置 + llm_api_key = os.environ.get("LLM_API_KEY", "") + llm_base_url = os.environ.get("LLM_BASE_URL", "") + llm_model = os.environ.get("LLM_MODEL_NAME", "") + config_label = "[通用LLM]" + + # 如果 .env 中没有模型名,则使用 config 作为备用 + if not llm_model: + llm_model = config.get("llm_model", "gpt-4o-mini") + + # 设置 camel-ai 所需的环境变量 + if llm_api_key: + os.environ["OPENAI_API_KEY"] = llm_api_key + + if not os.environ.get("OPENAI_API_KEY"): + raise ValueError("缺少 API Key 配置,请在项目根目录 .env 文件中设置 LLM_API_KEY") + + if llm_base_url: + os.environ["OPENAI_API_BASE_URL"] = llm_base_url + + print(f"{config_label} model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...") + + return ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=llm_model, + ) + + +def get_active_agents_for_round( + env, + config: Dict[str, Any], + current_hour: int, + round_num: int +) -> List: + """根据时间和配置决定本轮激活哪些Agent""" + time_config = config.get("time_config", {}) + agent_configs = config.get("agent_configs", []) + + base_min = time_config.get("agents_per_hour_min", 5) + base_max = time_config.get("agents_per_hour_max", 20) + + peak_hours = time_config.get("peak_hours", [9, 10, 11, 14, 15, 20, 21, 22]) + off_peak_hours = time_config.get("off_peak_hours", [0, 1, 2, 3, 4, 5]) + + if current_hour in peak_hours: + multiplier = time_config.get("peak_activity_multiplier", 1.5) + elif current_hour in off_peak_hours: + multiplier = time_config.get("off_peak_activity_multiplier", 0.3) + else: + multiplier = 1.0 + + target_count = int(random.uniform(base_min, base_max) * multiplier) + + candidates = [] + for cfg in agent_configs: + agent_id = cfg.get("agent_id", 0) + active_hours = cfg.get("active_hours", list(range(8, 23))) + activity_level = cfg.get("activity_level", 0.5) + + if current_hour not in active_hours: + continue + + if random.random() < activity_level: + candidates.append(agent_id) + + selected_ids = random.sample( + candidates, + min(target_count, len(candidates)) + ) if candidates else [] + + active_agents = [] + for agent_id in selected_ids: + try: + agent = env.agent_graph.get_agent(agent_id) + active_agents.append((agent_id, agent)) + except Exception: + pass + + return active_agents + + +class PlatformSimulation: + """平台模拟结果容器""" + def __init__(self): + self.env = None + self.agent_graph = None + self.total_actions = 0 + + +async def run_twitter_simulation( + config: Dict[str, Any], + simulation_dir: str, + action_logger: Optional[PlatformActionLogger] = None, + main_logger: Optional[SimulationLogManager] = None, + max_rounds: Optional[int] = None +) -> PlatformSimulation: + """运行Twitter模拟 + + Args: + config: 模拟配置 + simulation_dir: 模拟目录 + action_logger: 动作日志记录器 + main_logger: 主日志管理器 + max_rounds: 最大模拟轮数(可选,用于截断过长的模拟) + + Returns: + PlatformSimulation: 包含env和agent_graph的结果对象 + """ + result = PlatformSimulation() + + def log_info(msg): + if main_logger: + main_logger.info(f"[Twitter] {msg}") + print(f"[Twitter] {msg}") + + log_info("初始化...") + + # Twitter 使用通用 LLM 配置 + model = create_model(config, use_boost=False) + + # OASIS Twitter使用CSV格式 + profile_path = os.path.join(simulation_dir, "twitter_profiles.csv") + if not os.path.exists(profile_path): + log_info(f"错误: Profile文件不存在: {profile_path}") + return result + + result.agent_graph = await generate_twitter_agent_graph( + profile_path=profile_path, + model=model, + available_actions=TWITTER_ACTIONS, + ) + + # 从配置文件获取 Agent 真实名称映射(使用 entity_name 而非默认的 Agent_X) + agent_names = get_agent_names_from_config(config) + # 如果配置中没有某个 agent,则使用 OASIS 的默认名称 + for agent_id, agent in result.agent_graph.get_agents(): + if agent_id not in agent_names: + agent_names[agent_id] = getattr(agent, 'name', f'Agent_{agent_id}') + + db_path = os.path.join(simulation_dir, "twitter_simulation.db") + if os.path.exists(db_path): + os.remove(db_path) + + result.env = oasis.make( + agent_graph=result.agent_graph, + platform=oasis.DefaultPlatformType.TWITTER, + database_path=db_path, + semaphore=30, # 限制最大并发 LLM 请求数,防止 API 过载 + ) + + await result.env.reset() + log_info("环境已启动") + + if action_logger: + action_logger.log_simulation_start(config) + + total_actions = 0 + last_rowid = 0 # 跟踪数据库中最后处理的行号(使用 rowid 避免 created_at 格式差异) + + # 执行初始事件 + event_config = config.get("event_config", {}) + initial_posts = event_config.get("initial_posts", []) + + # 记录 round 0 开始(初始事件阶段) + if action_logger: + action_logger.log_round_start(0, 0) # round 0, simulated_hour 0 + + initial_action_count = 0 + if initial_posts: + initial_actions = {} + for post in initial_posts: + agent_id = post.get("poster_agent_id", 0) + content = post.get("content", "") + try: + agent = result.env.agent_graph.get_agent(agent_id) + initial_actions[agent] = ManualAction( + action_type=ActionType.CREATE_POST, + action_args={"content": content} + ) + + if action_logger: + action_logger.log_action( + round_num=0, + agent_id=agent_id, + agent_name=agent_names.get(agent_id, f"Agent_{agent_id}"), + action_type="CREATE_POST", + action_args={"content": content} + ) + total_actions += 1 + initial_action_count += 1 + except Exception: + pass + + if initial_actions: + await result.env.step(initial_actions) + log_info(f"已发布 {len(initial_actions)} 条初始帖子") + + # 记录 round 0 结束 + if action_logger: + action_logger.log_round_end(0, initial_action_count) + + # 主模拟循环 + time_config = config.get("time_config", {}) + total_hours = time_config.get("total_simulation_hours", 72) + minutes_per_round = time_config.get("minutes_per_round", 30) + total_rounds = (total_hours * 60) // minutes_per_round + + # 如果指定了最大轮数,则截断 + if max_rounds is not None and max_rounds > 0: + original_rounds = total_rounds + total_rounds = min(total_rounds, max_rounds) + if total_rounds < original_rounds: + log_info(f"轮数已截断: {original_rounds} -> {total_rounds} (max_rounds={max_rounds})") + + start_time = datetime.now() + + for round_num in range(total_rounds): + # 检查是否收到退出信号 + if _shutdown_event and _shutdown_event.is_set(): + if main_logger: + main_logger.info(f"收到退出信号,在第 {round_num + 1} 轮停止模拟") + break + + simulated_minutes = round_num * minutes_per_round + simulated_hour = (simulated_minutes // 60) % 24 + simulated_day = simulated_minutes // (60 * 24) + 1 + + active_agents = get_active_agents_for_round( + result.env, config, simulated_hour, round_num + ) + + # 无论是否有活跃agent,都记录round开始 + if action_logger: + action_logger.log_round_start(round_num + 1, simulated_hour) + + if not active_agents: + # 没有活跃agent时也记录round结束(actions_count=0) + if action_logger: + action_logger.log_round_end(round_num + 1, 0) + continue + + actions = {agent: LLMAction() for _, agent in active_agents} + await result.env.step(actions) + + # 从数据库获取实际执行的动作并记录 + actual_actions, last_rowid = fetch_new_actions_from_db( + db_path, last_rowid, agent_names + ) + + round_action_count = 0 + for action_data in actual_actions: + if action_logger: + action_logger.log_action( + round_num=round_num + 1, + agent_id=action_data['agent_id'], + agent_name=action_data['agent_name'], + action_type=action_data['action_type'], + action_args=action_data['action_args'] + ) + total_actions += 1 + round_action_count += 1 + + if action_logger: + action_logger.log_round_end(round_num + 1, round_action_count) + + if (round_num + 1) % 20 == 0: + progress = (round_num + 1) / total_rounds * 100 + log_info(f"Day {simulated_day}, {simulated_hour:02d}:00 - Round {round_num + 1}/{total_rounds} ({progress:.1f}%)") + + # 注意:不关闭环境,保留给Interview使用 + + if action_logger: + action_logger.log_simulation_end(total_rounds, total_actions) + + result.total_actions = total_actions + elapsed = (datetime.now() - start_time).total_seconds() + log_info(f"模拟循环完成! 耗时: {elapsed:.1f}秒, 总动作: {total_actions}") + + return result + + +async def run_reddit_simulation( + config: Dict[str, Any], + simulation_dir: str, + action_logger: Optional[PlatformActionLogger] = None, + main_logger: Optional[SimulationLogManager] = None, + max_rounds: Optional[int] = None +) -> PlatformSimulation: + """运行Reddit模拟 + + Args: + config: 模拟配置 + simulation_dir: 模拟目录 + action_logger: 动作日志记录器 + main_logger: 主日志管理器 + max_rounds: 最大模拟轮数(可选,用于截断过长的模拟) + + Returns: + PlatformSimulation: 包含env和agent_graph的结果对象 + """ + result = PlatformSimulation() + + def log_info(msg): + if main_logger: + main_logger.info(f"[Reddit] {msg}") + print(f"[Reddit] {msg}") + + log_info("初始化...") + + # Reddit 使用加速 LLM 配置(如果有的话,否则回退到通用配置) + model = create_model(config, use_boost=True) + + profile_path = os.path.join(simulation_dir, "reddit_profiles.json") + if not os.path.exists(profile_path): + log_info(f"错误: Profile文件不存在: {profile_path}") + return result + + result.agent_graph = await generate_reddit_agent_graph( + profile_path=profile_path, + model=model, + available_actions=REDDIT_ACTIONS, + ) + + # 从配置文件获取 Agent 真实名称映射(使用 entity_name 而非默认的 Agent_X) + agent_names = get_agent_names_from_config(config) + # 如果配置中没有某个 agent,则使用 OASIS 的默认名称 + for agent_id, agent in result.agent_graph.get_agents(): + if agent_id not in agent_names: + agent_names[agent_id] = getattr(agent, 'name', f'Agent_{agent_id}') + + db_path = os.path.join(simulation_dir, "reddit_simulation.db") + if os.path.exists(db_path): + os.remove(db_path) + + result.env = oasis.make( + agent_graph=result.agent_graph, + platform=oasis.DefaultPlatformType.REDDIT, + database_path=db_path, + semaphore=30, # 限制最大并发 LLM 请求数,防止 API 过载 + ) + + await result.env.reset() + log_info("环境已启动") + + if action_logger: + action_logger.log_simulation_start(config) + + total_actions = 0 + last_rowid = 0 # 跟踪数据库中最后处理的行号(使用 rowid 避免 created_at 格式差异) + + # 执行初始事件 + event_config = config.get("event_config", {}) + initial_posts = event_config.get("initial_posts", []) + + # 记录 round 0 开始(初始事件阶段) + if action_logger: + action_logger.log_round_start(0, 0) # round 0, simulated_hour 0 + + initial_action_count = 0 + if initial_posts: + initial_actions = {} + for post in initial_posts: + agent_id = post.get("poster_agent_id", 0) + content = post.get("content", "") + try: + agent = result.env.agent_graph.get_agent(agent_id) + if agent in initial_actions: + if not isinstance(initial_actions[agent], list): + initial_actions[agent] = [initial_actions[agent]] + initial_actions[agent].append(ManualAction( + action_type=ActionType.CREATE_POST, + action_args={"content": content} + )) + else: + initial_actions[agent] = ManualAction( + action_type=ActionType.CREATE_POST, + action_args={"content": content} + ) + + if action_logger: + action_logger.log_action( + round_num=0, + agent_id=agent_id, + agent_name=agent_names.get(agent_id, f"Agent_{agent_id}"), + action_type="CREATE_POST", + action_args={"content": content} + ) + total_actions += 1 + initial_action_count += 1 + except Exception: + pass + + if initial_actions: + await result.env.step(initial_actions) + log_info(f"已发布 {len(initial_actions)} 条初始帖子") + + # 记录 round 0 结束 + if action_logger: + action_logger.log_round_end(0, initial_action_count) + + # 主模拟循环 + time_config = config.get("time_config", {}) + total_hours = time_config.get("total_simulation_hours", 72) + minutes_per_round = time_config.get("minutes_per_round", 30) + total_rounds = (total_hours * 60) // minutes_per_round + + # 如果指定了最大轮数,则截断 + if max_rounds is not None and max_rounds > 0: + original_rounds = total_rounds + total_rounds = min(total_rounds, max_rounds) + if total_rounds < original_rounds: + log_info(f"轮数已截断: {original_rounds} -> {total_rounds} (max_rounds={max_rounds})") + + start_time = datetime.now() + + for round_num in range(total_rounds): + # 检查是否收到退出信号 + if _shutdown_event and _shutdown_event.is_set(): + if main_logger: + main_logger.info(f"收到退出信号,在第 {round_num + 1} 轮停止模拟") + break + + simulated_minutes = round_num * minutes_per_round + simulated_hour = (simulated_minutes // 60) % 24 + simulated_day = simulated_minutes // (60 * 24) + 1 + + active_agents = get_active_agents_for_round( + result.env, config, simulated_hour, round_num + ) + + # 无论是否有活跃agent,都记录round开始 + if action_logger: + action_logger.log_round_start(round_num + 1, simulated_hour) + + if not active_agents: + # 没有活跃agent时也记录round结束(actions_count=0) + if action_logger: + action_logger.log_round_end(round_num + 1, 0) + continue + + actions = {agent: LLMAction() for _, agent in active_agents} + await result.env.step(actions) + + # 从数据库获取实际执行的动作并记录 + actual_actions, last_rowid = fetch_new_actions_from_db( + db_path, last_rowid, agent_names + ) + + round_action_count = 0 + for action_data in actual_actions: + if action_logger: + action_logger.log_action( + round_num=round_num + 1, + agent_id=action_data['agent_id'], + agent_name=action_data['agent_name'], + action_type=action_data['action_type'], + action_args=action_data['action_args'] + ) + total_actions += 1 + round_action_count += 1 + + if action_logger: + action_logger.log_round_end(round_num + 1, round_action_count) + + if (round_num + 1) % 20 == 0: + progress = (round_num + 1) / total_rounds * 100 + log_info(f"Day {simulated_day}, {simulated_hour:02d}:00 - Round {round_num + 1}/{total_rounds} ({progress:.1f}%)") + + # 注意:不关闭环境,保留给Interview使用 + + if action_logger: + action_logger.log_simulation_end(total_rounds, total_actions) + + result.total_actions = total_actions + elapsed = (datetime.now() - start_time).total_seconds() + log_info(f"模拟循环完成! 耗时: {elapsed:.1f}秒, 总动作: {total_actions}") + + return result + + +async def main(): + parser = argparse.ArgumentParser(description='OASIS双平台并行模拟') + parser.add_argument( + '--config', + type=str, + required=True, + help='配置文件路径 (simulation_config.json)' + ) + parser.add_argument( + '--twitter-only', + action='store_true', + help='只运行Twitter模拟' + ) + parser.add_argument( + '--reddit-only', + action='store_true', + help='只运行Reddit模拟' + ) + parser.add_argument( + '--max-rounds', + type=int, + default=None, + help='最大模拟轮数(可选,用于截断过长的模拟)' + ) + parser.add_argument( + '--no-wait', + action='store_true', + default=False, + help='模拟完成后立即关闭环境,不进入等待命令模式' + ) + + args = parser.parse_args() + + # 在 main 函数开始时创建 shutdown 事件,确保整个程序都能响应退出信号 + global _shutdown_event + _shutdown_event = asyncio.Event() + + if not os.path.exists(args.config): + print(f"错误: 配置文件不存在: {args.config}") + sys.exit(1) + + config = load_config(args.config) + simulation_dir = os.path.dirname(args.config) or "." + wait_for_commands = not args.no_wait + + # 初始化日志配置(禁用 OASIS 日志,清理旧文件) + init_logging_for_simulation(simulation_dir) + + # 创建日志管理器 + log_manager = SimulationLogManager(simulation_dir) + twitter_logger = log_manager.get_twitter_logger() + reddit_logger = log_manager.get_reddit_logger() + + log_manager.info("=" * 60) + log_manager.info("OASIS 双平台并行模拟") + log_manager.info(f"配置文件: {args.config}") + log_manager.info(f"模拟ID: {config.get('simulation_id', 'unknown')}") + log_manager.info(f"等待命令模式: {'启用' if wait_for_commands else '禁用'}") + log_manager.info("=" * 60) + + time_config = config.get("time_config", {}) + total_hours = time_config.get('total_simulation_hours', 72) + minutes_per_round = time_config.get('minutes_per_round', 30) + config_total_rounds = (total_hours * 60) // minutes_per_round + + log_manager.info(f"模拟参数:") + log_manager.info(f" - 总模拟时长: {total_hours}小时") + log_manager.info(f" - 每轮时间: {minutes_per_round}分钟") + log_manager.info(f" - 配置总轮数: {config_total_rounds}") + if args.max_rounds: + log_manager.info(f" - 最大轮数限制: {args.max_rounds}") + if args.max_rounds < config_total_rounds: + log_manager.info(f" - 实际执行轮数: {args.max_rounds} (已截断)") + log_manager.info(f" - Agent数量: {len(config.get('agent_configs', []))}") + + log_manager.info("日志结构:") + log_manager.info(f" - 主日志: simulation.log") + log_manager.info(f" - Twitter动作: twitter/actions.jsonl") + log_manager.info(f" - Reddit动作: reddit/actions.jsonl") + log_manager.info("=" * 60) + + start_time = datetime.now() + + # 存储两个平台的模拟结果 + twitter_result: Optional[PlatformSimulation] = None + reddit_result: Optional[PlatformSimulation] = None + + if args.twitter_only: + twitter_result = await run_twitter_simulation(config, simulation_dir, twitter_logger, log_manager, args.max_rounds) + elif args.reddit_only: + reddit_result = await run_reddit_simulation(config, simulation_dir, reddit_logger, log_manager, args.max_rounds) + else: + # 并行运行(每个平台使用独立的日志记录器) + results = await asyncio.gather( + run_twitter_simulation(config, simulation_dir, twitter_logger, log_manager, args.max_rounds), + run_reddit_simulation(config, simulation_dir, reddit_logger, log_manager, args.max_rounds), + ) + twitter_result, reddit_result = results + + total_elapsed = (datetime.now() - start_time).total_seconds() + log_manager.info("=" * 60) + log_manager.info(f"模拟循环完成! 总耗时: {total_elapsed:.1f}秒") + + # 是否进入等待命令模式 + if wait_for_commands: + log_manager.info("") + log_manager.info("=" * 60) + log_manager.info("进入等待命令模式 - 环境保持运行") + log_manager.info("支持的命令: interview, batch_interview, close_env") + log_manager.info("=" * 60) + + # 创建IPC处理器 + ipc_handler = ParallelIPCHandler( + simulation_dir=simulation_dir, + twitter_env=twitter_result.env if twitter_result else None, + twitter_agent_graph=twitter_result.agent_graph if twitter_result else None, + reddit_env=reddit_result.env if reddit_result else None, + reddit_agent_graph=reddit_result.agent_graph if reddit_result else None + ) + ipc_handler.update_status("alive") + + # 等待命令循环(使用全局 _shutdown_event) + try: + while not _shutdown_event.is_set(): + should_continue = await ipc_handler.process_commands() + if not should_continue: + break + # 使用 wait_for 替代 sleep,这样可以响应 shutdown_event + try: + await asyncio.wait_for(_shutdown_event.wait(), timeout=0.5) + break # 收到退出信号 + except asyncio.TimeoutError: + pass # 超时继续循环 + except KeyboardInterrupt: + print("\n收到中断信号") + except asyncio.CancelledError: + print("\n任务被取消") + except Exception as e: + print(f"\n命令处理出错: {e}") + + log_manager.info("\n关闭环境...") + ipc_handler.update_status("stopped") + + # 关闭环境 + if twitter_result and twitter_result.env: + await twitter_result.env.close() + log_manager.info("[Twitter] 环境已关闭") + + if reddit_result and reddit_result.env: + await reddit_result.env.close() + log_manager.info("[Reddit] 环境已关闭") + + log_manager.info("=" * 60) + log_manager.info(f"全部完成!") + log_manager.info(f"日志文件:") + log_manager.info(f" - {os.path.join(simulation_dir, 'simulation.log')}") + log_manager.info(f" - {os.path.join(simulation_dir, 'twitter', 'actions.jsonl')}") + log_manager.info(f" - {os.path.join(simulation_dir, 'reddit', 'actions.jsonl')}") + log_manager.info("=" * 60) + + +def setup_signal_handlers(loop=None): + """ + 设置信号处理器,确保收到 SIGTERM/SIGINT 时能够正确退出 + + 持久化模拟场景:模拟完成后不退出,等待 interview 命令 + 当收到终止信号时,需要: + 1. 通知 asyncio 循环退出等待 + 2. 让程序有机会正常清理资源(关闭数据库、环境等) + 3. 然后才退出 + """ + def signal_handler(signum, frame): + global _cleanup_done + sig_name = "SIGTERM" if signum == signal.SIGTERM else "SIGINT" + print(f"\n收到 {sig_name} 信号,正在退出...") + + if not _cleanup_done: + _cleanup_done = True + # 设置事件通知 asyncio 循环退出(让循环有机会清理资源) + if _shutdown_event: + _shutdown_event.set() + + # 不要直接 sys.exit(),让 asyncio 循环正常退出并清理资源 + # 如果是重复收到信号,才强制退出 + else: + print("强制退出...") + sys.exit(1) + + signal.signal(signal.SIGTERM, signal_handler) + signal.signal(signal.SIGINT, signal_handler) + + +if __name__ == "__main__": + setup_signal_handlers() + try: + asyncio.run(main()) + except KeyboardInterrupt: + print("\n程序被中断") + except SystemExit: + pass + finally: + # 清理 multiprocessing 资源跟踪器(防止退出时的警告) + try: + from multiprocessing import resource_tracker + resource_tracker._resource_tracker._stop() + except Exception: + pass + print("模拟进程已退出") diff --git a/backend/scripts/run_reddit_simulation.py b/backend/scripts/run_reddit_simulation.py new file mode 100644 index 00000000..14907cbd --- /dev/null +++ b/backend/scripts/run_reddit_simulation.py @@ -0,0 +1,769 @@ +""" +OASIS Reddit模拟预设脚本 +此脚本读取配置文件中的参数来执行模拟,实现全程自动化 + +功能特性: +- 完成模拟后不立即关闭环境,进入等待命令模式 +- 支持通过IPC接收Interview命令 +- 支持单个Agent采访和批量采访 +- 支持远程关闭环境命令 + +使用方式: + python run_reddit_simulation.py --config /path/to/simulation_config.json + python run_reddit_simulation.py --config /path/to/simulation_config.json --no-wait # 完成后立即关闭 +""" + +import argparse +import asyncio +import json +import logging +import os +import random +import signal +import sys +import sqlite3 +from datetime import datetime +from typing import Dict, Any, List, Optional + +# 全局变量:用于信号处理 +_shutdown_event = None +_cleanup_done = False + +# 添加项目路径 +_scripts_dir = os.path.dirname(os.path.abspath(__file__)) +_backend_dir = os.path.abspath(os.path.join(_scripts_dir, '..')) +_project_root = os.path.abspath(os.path.join(_backend_dir, '..')) +sys.path.insert(0, _scripts_dir) +sys.path.insert(0, _backend_dir) + +# 加载项目根目录的 .env 文件(包含 LLM_API_KEY 等配置) +from dotenv import load_dotenv +_env_file = os.path.join(_project_root, '.env') +if os.path.exists(_env_file): + load_dotenv(_env_file) +else: + _backend_env = os.path.join(_backend_dir, '.env') + if os.path.exists(_backend_env): + load_dotenv(_backend_env) + + +import re + + +class UnicodeFormatter(logging.Formatter): + """自定义格式化器,将 Unicode 转义序列转换为可读字符""" + + UNICODE_ESCAPE_PATTERN = re.compile(r'\\u([0-9a-fA-F]{4})') + + def format(self, record): + result = super().format(record) + + def replace_unicode(match): + try: + return chr(int(match.group(1), 16)) + except (ValueError, OverflowError): + return match.group(0) + + return self.UNICODE_ESCAPE_PATTERN.sub(replace_unicode, result) + + +class MaxTokensWarningFilter(logging.Filter): + """过滤掉 camel-ai 关于 max_tokens 的警告(我们故意不设置 max_tokens,让模型自行决定)""" + + def filter(self, record): + # 过滤掉包含 max_tokens 警告的日志 + if "max_tokens" in record.getMessage() and "Invalid or missing" in record.getMessage(): + return False + return True + + +# 在模块加载时立即添加过滤器,确保在 camel 代码执行前生效 +logging.getLogger().addFilter(MaxTokensWarningFilter()) + + +def setup_oasis_logging(log_dir: str): + """配置 OASIS 的日志,使用固定名称的日志文件""" + os.makedirs(log_dir, exist_ok=True) + + # 清理旧的日志文件 + for f in os.listdir(log_dir): + old_log = os.path.join(log_dir, f) + if os.path.isfile(old_log) and f.endswith('.log'): + try: + os.remove(old_log) + except OSError: + pass + + formatter = UnicodeFormatter("%(levelname)s - %(asctime)s - %(name)s - %(message)s") + + loggers_config = { + "social.agent": os.path.join(log_dir, "social.agent.log"), + "social.twitter": os.path.join(log_dir, "social.twitter.log"), + "social.rec": os.path.join(log_dir, "social.rec.log"), + "oasis.env": os.path.join(log_dir, "oasis.env.log"), + "table": os.path.join(log_dir, "table.log"), + } + + for logger_name, log_file in loggers_config.items(): + logger = logging.getLogger(logger_name) + logger.setLevel(logging.DEBUG) + logger.handlers.clear() + file_handler = logging.FileHandler(log_file, encoding='utf-8', mode='w') + file_handler.setLevel(logging.DEBUG) + file_handler.setFormatter(formatter) + logger.addHandler(file_handler) + logger.propagate = False + + +try: + from camel.models import ModelFactory + from camel.types import ModelPlatformType + import oasis + from oasis import ( + ActionType, + LLMAction, + ManualAction, + generate_reddit_agent_graph + ) +except ImportError as e: + print(f"错误: 缺少依赖 {e}") + print("请先安装: pip install oasis-ai camel-ai") + sys.exit(1) + + +# IPC相关常量 +IPC_COMMANDS_DIR = "ipc_commands" +IPC_RESPONSES_DIR = "ipc_responses" +ENV_STATUS_FILE = "env_status.json" + +class CommandType: + """命令类型常量""" + INTERVIEW = "interview" + BATCH_INTERVIEW = "batch_interview" + CLOSE_ENV = "close_env" + + +class IPCHandler: + """IPC命令处理器""" + + def __init__(self, simulation_dir: str, env, agent_graph): + self.simulation_dir = simulation_dir + self.env = env + self.agent_graph = agent_graph + self.commands_dir = os.path.join(simulation_dir, IPC_COMMANDS_DIR) + self.responses_dir = os.path.join(simulation_dir, IPC_RESPONSES_DIR) + self.status_file = os.path.join(simulation_dir, ENV_STATUS_FILE) + self._running = True + + # 确保目录存在 + os.makedirs(self.commands_dir, exist_ok=True) + os.makedirs(self.responses_dir, exist_ok=True) + + def update_status(self, status: str): + """更新环境状态""" + with open(self.status_file, 'w', encoding='utf-8') as f: + json.dump({ + "status": status, + "timestamp": datetime.now().isoformat() + }, f, ensure_ascii=False, indent=2) + + def poll_command(self) -> Optional[Dict[str, Any]]: + """轮询获取待处理命令""" + if not os.path.exists(self.commands_dir): + return None + + # 获取命令文件(按时间排序) + command_files = [] + for filename in os.listdir(self.commands_dir): + if filename.endswith('.json'): + filepath = os.path.join(self.commands_dir, filename) + command_files.append((filepath, os.path.getmtime(filepath))) + + command_files.sort(key=lambda x: x[1]) + + for filepath, _ in command_files: + try: + with open(filepath, 'r', encoding='utf-8') as f: + return json.load(f) + except (json.JSONDecodeError, OSError): + continue + + return None + + def send_response(self, command_id: str, status: str, result: Dict = None, error: str = None): + """发送响应""" + response = { + "command_id": command_id, + "status": status, + "result": result, + "error": error, + "timestamp": datetime.now().isoformat() + } + + response_file = os.path.join(self.responses_dir, f"{command_id}.json") + with open(response_file, 'w', encoding='utf-8') as f: + json.dump(response, f, ensure_ascii=False, indent=2) + + # 删除命令文件 + command_file = os.path.join(self.commands_dir, f"{command_id}.json") + try: + os.remove(command_file) + except OSError: + pass + + async def handle_interview(self, command_id: str, agent_id: int, prompt: str) -> bool: + """ + 处理单个Agent采访命令 + + Returns: + True 表示成功,False 表示失败 + """ + try: + # 获取Agent + agent = self.agent_graph.get_agent(agent_id) + + # 创建Interview动作 + interview_action = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + + # 执行Interview + actions = {agent: interview_action} + await self.env.step(actions) + + # 从数据库获取结果 + result = self._get_interview_result(agent_id) + + self.send_response(command_id, "completed", result=result) + print(f" Interview完成: agent_id={agent_id}") + return True + + except Exception as e: + error_msg = str(e) + print(f" Interview失败: agent_id={agent_id}, error={error_msg}") + self.send_response(command_id, "failed", error=error_msg) + return False + + async def handle_batch_interview(self, command_id: str, interviews: List[Dict]) -> bool: + """ + 处理批量采访命令 + + Args: + interviews: [{"agent_id": int, "prompt": str}, ...] + """ + try: + # 构建动作字典 + actions = {} + agent_prompts = {} # 记录每个agent的prompt + + for interview in interviews: + agent_id = interview.get("agent_id") + prompt = interview.get("prompt", "") + + try: + agent = self.agent_graph.get_agent(agent_id) + actions[agent] = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + agent_prompts[agent_id] = prompt + except Exception as e: + print(f" 警告: 无法获取Agent {agent_id}: {e}") + + if not actions: + self.send_response(command_id, "failed", error="没有有效的Agent") + return False + + # 执行批量Interview + await self.env.step(actions) + + # 获取所有结果 + results = {} + for agent_id in agent_prompts.keys(): + result = self._get_interview_result(agent_id) + results[agent_id] = result + + self.send_response(command_id, "completed", result={ + "interviews_count": len(results), + "results": results + }) + print(f" 批量Interview完成: {len(results)} 个Agent") + return True + + except Exception as e: + error_msg = str(e) + print(f" 批量Interview失败: {error_msg}") + self.send_response(command_id, "failed", error=error_msg) + return False + + def _get_interview_result(self, agent_id: int) -> Dict[str, Any]: + """从数据库获取最新的Interview结果""" + db_path = os.path.join(self.simulation_dir, "reddit_simulation.db") + + result = { + "agent_id": agent_id, + "response": None, + "timestamp": None + } + + if not os.path.exists(db_path): + return result + + try: + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + # 查询最新的Interview记录 + cursor.execute(""" + SELECT user_id, info, created_at + FROM trace + WHERE action = ? AND user_id = ? + ORDER BY created_at DESC + LIMIT 1 + """, (ActionType.INTERVIEW.value, agent_id)) + + row = cursor.fetchone() + if row: + user_id, info_json, created_at = row + try: + info = json.loads(info_json) if info_json else {} + result["response"] = info.get("response", info) + result["timestamp"] = created_at + except json.JSONDecodeError: + result["response"] = info_json + + conn.close() + + except Exception as e: + print(f" 读取Interview结果失败: {e}") + + return result + + async def process_commands(self) -> bool: + """ + 处理所有待处理命令 + + Returns: + True 表示继续运行,False 表示应该退出 + """ + command = self.poll_command() + if not command: + return True + + command_id = command.get("command_id") + command_type = command.get("command_type") + args = command.get("args", {}) + + print(f"\n收到IPC命令: {command_type}, id={command_id}") + + if command_type == CommandType.INTERVIEW: + await self.handle_interview( + command_id, + args.get("agent_id", 0), + args.get("prompt", "") + ) + return True + + elif command_type == CommandType.BATCH_INTERVIEW: + await self.handle_batch_interview( + command_id, + args.get("interviews", []) + ) + return True + + elif command_type == CommandType.CLOSE_ENV: + print("收到关闭环境命令") + self.send_response(command_id, "completed", result={"message": "环境即将关闭"}) + return False + + else: + self.send_response(command_id, "failed", error=f"未知命令类型: {command_type}") + return True + + +class RedditSimulationRunner: + """Reddit模拟运行器""" + + # Reddit可用动作(不包含INTERVIEW,INTERVIEW只能通过ManualAction手动触发) + AVAILABLE_ACTIONS = [ + ActionType.LIKE_POST, + ActionType.DISLIKE_POST, + ActionType.CREATE_POST, + ActionType.CREATE_COMMENT, + ActionType.LIKE_COMMENT, + ActionType.DISLIKE_COMMENT, + ActionType.SEARCH_POSTS, + ActionType.SEARCH_USER, + ActionType.TREND, + ActionType.REFRESH, + ActionType.DO_NOTHING, + ActionType.FOLLOW, + ActionType.MUTE, + ] + + def __init__(self, config_path: str, wait_for_commands: bool = True): + """ + 初始化模拟运行器 + + Args: + config_path: 配置文件路径 (simulation_config.json) + wait_for_commands: 模拟完成后是否等待命令(默认True) + """ + self.config_path = config_path + self.config = self._load_config() + self.simulation_dir = os.path.dirname(config_path) + self.wait_for_commands = wait_for_commands + self.env = None + self.agent_graph = None + self.ipc_handler = None + + def _load_config(self) -> Dict[str, Any]: + """加载配置文件""" + with open(self.config_path, 'r', encoding='utf-8') as f: + return json.load(f) + + def _get_profile_path(self) -> str: + """获取Profile文件路径""" + return os.path.join(self.simulation_dir, "reddit_profiles.json") + + def _get_db_path(self) -> str: + """获取数据库路径""" + return os.path.join(self.simulation_dir, "reddit_simulation.db") + + def _create_model(self): + """ + 创建LLM模型 + + 统一使用项目根目录 .env 文件中的配置(优先级最高): + - LLM_API_KEY: API密钥 + - LLM_BASE_URL: API基础URL + - LLM_MODEL_NAME: 模型名称 + """ + # 优先从 .env 读取配置 + llm_api_key = os.environ.get("LLM_API_KEY", "") + llm_base_url = os.environ.get("LLM_BASE_URL", "") + llm_model = os.environ.get("LLM_MODEL_NAME", "") + + # 如果 .env 中没有,则使用 config 作为备用 + if not llm_model: + llm_model = self.config.get("llm_model", "gpt-4o-mini") + + # 设置 camel-ai 所需的环境变量 + if llm_api_key: + os.environ["OPENAI_API_KEY"] = llm_api_key + + if not os.environ.get("OPENAI_API_KEY"): + raise ValueError("缺少 API Key 配置,请在项目根目录 .env 文件中设置 LLM_API_KEY") + + if llm_base_url: + os.environ["OPENAI_API_BASE_URL"] = llm_base_url + + print(f"LLM配置: model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...") + + return ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=llm_model, + ) + + def _get_active_agents_for_round( + self, + env, + current_hour: int, + round_num: int + ) -> List: + """ + 根据时间和配置决定本轮激活哪些Agent + """ + time_config = self.config.get("time_config", {}) + agent_configs = self.config.get("agent_configs", []) + + base_min = time_config.get("agents_per_hour_min", 5) + base_max = time_config.get("agents_per_hour_max", 20) + + peak_hours = time_config.get("peak_hours", [9, 10, 11, 14, 15, 20, 21, 22]) + off_peak_hours = time_config.get("off_peak_hours", [0, 1, 2, 3, 4, 5]) + + if current_hour in peak_hours: + multiplier = time_config.get("peak_activity_multiplier", 1.5) + elif current_hour in off_peak_hours: + multiplier = time_config.get("off_peak_activity_multiplier", 0.3) + else: + multiplier = 1.0 + + target_count = int(random.uniform(base_min, base_max) * multiplier) + + candidates = [] + for cfg in agent_configs: + agent_id = cfg.get("agent_id", 0) + active_hours = cfg.get("active_hours", list(range(8, 23))) + activity_level = cfg.get("activity_level", 0.5) + + if current_hour not in active_hours: + continue + + if random.random() < activity_level: + candidates.append(agent_id) + + selected_ids = random.sample( + candidates, + min(target_count, len(candidates)) + ) if candidates else [] + + active_agents = [] + for agent_id in selected_ids: + try: + agent = env.agent_graph.get_agent(agent_id) + active_agents.append((agent_id, agent)) + except Exception: + pass + + return active_agents + + async def run(self, max_rounds: int = None): + """运行Reddit模拟 + + Args: + max_rounds: 最大模拟轮数(可选,用于截断过长的模拟) + """ + print("=" * 60) + print("OASIS Reddit模拟") + print(f"配置文件: {self.config_path}") + print(f"模拟ID: {self.config.get('simulation_id', 'unknown')}") + print(f"等待命令模式: {'启用' if self.wait_for_commands else '禁用'}") + print("=" * 60) + + time_config = self.config.get("time_config", {}) + total_hours = time_config.get("total_simulation_hours", 72) + minutes_per_round = time_config.get("minutes_per_round", 30) + total_rounds = (total_hours * 60) // minutes_per_round + + # 如果指定了最大轮数,则截断 + if max_rounds is not None and max_rounds > 0: + original_rounds = total_rounds + total_rounds = min(total_rounds, max_rounds) + if total_rounds < original_rounds: + print(f"\n轮数已截断: {original_rounds} -> {total_rounds} (max_rounds={max_rounds})") + + print(f"\n模拟参数:") + print(f" - 总模拟时长: {total_hours}小时") + print(f" - 每轮时间: {minutes_per_round}分钟") + print(f" - 总轮数: {total_rounds}") + if max_rounds: + print(f" - 最大轮数限制: {max_rounds}") + print(f" - Agent数量: {len(self.config.get('agent_configs', []))}") + + print("\n初始化LLM模型...") + model = self._create_model() + + print("加载Agent Profile...") + profile_path = self._get_profile_path() + if not os.path.exists(profile_path): + print(f"错误: Profile文件不存在: {profile_path}") + return + + self.agent_graph = await generate_reddit_agent_graph( + profile_path=profile_path, + model=model, + available_actions=self.AVAILABLE_ACTIONS, + ) + + db_path = self._get_db_path() + if os.path.exists(db_path): + os.remove(db_path) + print(f"已删除旧数据库: {db_path}") + + print("创建OASIS环境...") + self.env = oasis.make( + agent_graph=self.agent_graph, + platform=oasis.DefaultPlatformType.REDDIT, + database_path=db_path, + semaphore=30, # 限制最大并发 LLM 请求数,防止 API 过载 + ) + + await self.env.reset() + print("环境初始化完成\n") + + # 初始化IPC处理器 + self.ipc_handler = IPCHandler(self.simulation_dir, self.env, self.agent_graph) + self.ipc_handler.update_status("running") + + # 执行初始事件 + event_config = self.config.get("event_config", {}) + initial_posts = event_config.get("initial_posts", []) + + if initial_posts: + print(f"执行初始事件 ({len(initial_posts)}条初始帖子)...") + initial_actions = {} + for post in initial_posts: + agent_id = post.get("poster_agent_id", 0) + content = post.get("content", "") + try: + agent = self.env.agent_graph.get_agent(agent_id) + if agent in initial_actions: + if not isinstance(initial_actions[agent], list): + initial_actions[agent] = [initial_actions[agent]] + initial_actions[agent].append(ManualAction( + action_type=ActionType.CREATE_POST, + action_args={"content": content} + )) + else: + initial_actions[agent] = ManualAction( + action_type=ActionType.CREATE_POST, + action_args={"content": content} + ) + except Exception as e: + print(f" 警告: 无法为Agent {agent_id}创建初始帖子: {e}") + + if initial_actions: + await self.env.step(initial_actions) + print(f" 已发布 {len(initial_actions)} 条初始帖子") + + # 主模拟循环 + print("\n开始模拟循环...") + start_time = datetime.now() + + for round_num in range(total_rounds): + simulated_minutes = round_num * minutes_per_round + simulated_hour = (simulated_minutes // 60) % 24 + simulated_day = simulated_minutes // (60 * 24) + 1 + + active_agents = self._get_active_agents_for_round( + self.env, simulated_hour, round_num + ) + + if not active_agents: + continue + + actions = { + agent: LLMAction() + for _, agent in active_agents + } + + await self.env.step(actions) + + if (round_num + 1) % 10 == 0 or round_num == 0: + elapsed = (datetime.now() - start_time).total_seconds() + progress = (round_num + 1) / total_rounds * 100 + print(f" [Day {simulated_day}, {simulated_hour:02d}:00] " + f"Round {round_num + 1}/{total_rounds} ({progress:.1f}%) " + f"- {len(active_agents)} agents active " + f"- elapsed: {elapsed:.1f}s") + + total_elapsed = (datetime.now() - start_time).total_seconds() + print(f"\n模拟循环完成!") + print(f" - 总耗时: {total_elapsed:.1f}秒") + print(f" - 数据库: {db_path}") + + # 是否进入等待命令模式 + if self.wait_for_commands: + print("\n" + "=" * 60) + print("进入等待命令模式 - 环境保持运行") + print("支持的命令: interview, batch_interview, close_env") + print("=" * 60) + + self.ipc_handler.update_status("alive") + + # 等待命令循环(使用全局 _shutdown_event) + try: + while not _shutdown_event.is_set(): + should_continue = await self.ipc_handler.process_commands() + if not should_continue: + break + try: + await asyncio.wait_for(_shutdown_event.wait(), timeout=0.5) + break # 收到退出信号 + except asyncio.TimeoutError: + pass + except KeyboardInterrupt: + print("\n收到中断信号") + except asyncio.CancelledError: + print("\n任务被取消") + except Exception as e: + print(f"\n命令处理出错: {e}") + + print("\n关闭环境...") + + # 关闭环境 + self.ipc_handler.update_status("stopped") + await self.env.close() + + print("环境已关闭") + print("=" * 60) + + +async def main(): + parser = argparse.ArgumentParser(description='OASIS Reddit模拟') + parser.add_argument( + '--config', + type=str, + required=True, + help='配置文件路径 (simulation_config.json)' + ) + parser.add_argument( + '--max-rounds', + type=int, + default=None, + help='最大模拟轮数(可选,用于截断过长的模拟)' + ) + parser.add_argument( + '--no-wait', + action='store_true', + default=False, + help='模拟完成后立即关闭环境,不进入等待命令模式' + ) + + args = parser.parse_args() + + # 在 main 函数开始时创建 shutdown 事件 + global _shutdown_event + _shutdown_event = asyncio.Event() + + if not os.path.exists(args.config): + print(f"错误: 配置文件不存在: {args.config}") + sys.exit(1) + + # 初始化日志配置(使用固定文件名,清理旧日志) + simulation_dir = os.path.dirname(args.config) or "." + setup_oasis_logging(os.path.join(simulation_dir, "log")) + + runner = RedditSimulationRunner( + config_path=args.config, + wait_for_commands=not args.no_wait + ) + await runner.run(max_rounds=args.max_rounds) + + +def setup_signal_handlers(): + """ + 设置信号处理器,确保收到 SIGTERM/SIGINT 时能够正确退出 + 让程序有机会正常清理资源(关闭数据库、环境等) + """ + def signal_handler(signum, frame): + global _cleanup_done + sig_name = "SIGTERM" if signum == signal.SIGTERM else "SIGINT" + print(f"\n收到 {sig_name} 信号,正在退出...") + if not _cleanup_done: + _cleanup_done = True + if _shutdown_event: + _shutdown_event.set() + else: + # 重复收到信号才强制退出 + print("强制退出...") + sys.exit(1) + + signal.signal(signal.SIGTERM, signal_handler) + signal.signal(signal.SIGINT, signal_handler) + + +if __name__ == "__main__": + setup_signal_handlers() + try: + asyncio.run(main()) + except KeyboardInterrupt: + print("\n程序被中断") + except SystemExit: + pass + finally: + print("模拟进程已退出") + diff --git a/backend/scripts/run_twitter_simulation.py b/backend/scripts/run_twitter_simulation.py new file mode 100644 index 00000000..caab9e9d --- /dev/null +++ b/backend/scripts/run_twitter_simulation.py @@ -0,0 +1,780 @@ +""" +OASIS Twitter模拟预设脚本 +此脚本读取配置文件中的参数来执行模拟,实现全程自动化 + +功能特性: +- 完成模拟后不立即关闭环境,进入等待命令模式 +- 支持通过IPC接收Interview命令 +- 支持单个Agent采访和批量采访 +- 支持远程关闭环境命令 + +使用方式: + python run_twitter_simulation.py --config /path/to/simulation_config.json + python run_twitter_simulation.py --config /path/to/simulation_config.json --no-wait # 完成后立即关闭 +""" + +import argparse +import asyncio +import json +import logging +import os +import random +import signal +import sys +import sqlite3 +from datetime import datetime +from typing import Dict, Any, List, Optional + +# 全局变量:用于信号处理 +_shutdown_event = None +_cleanup_done = False + +# 添加项目路径 +_scripts_dir = os.path.dirname(os.path.abspath(__file__)) +_backend_dir = os.path.abspath(os.path.join(_scripts_dir, '..')) +_project_root = os.path.abspath(os.path.join(_backend_dir, '..')) +sys.path.insert(0, _scripts_dir) +sys.path.insert(0, _backend_dir) + +# 加载项目根目录的 .env 文件(包含 LLM_API_KEY 等配置) +from dotenv import load_dotenv +_env_file = os.path.join(_project_root, '.env') +if os.path.exists(_env_file): + load_dotenv(_env_file) +else: + _backend_env = os.path.join(_backend_dir, '.env') + if os.path.exists(_backend_env): + load_dotenv(_backend_env) + + +import re + + +class UnicodeFormatter(logging.Formatter): + """自定义格式化器,将 Unicode 转义序列转换为可读字符""" + + UNICODE_ESCAPE_PATTERN = re.compile(r'\\u([0-9a-fA-F]{4})') + + def format(self, record): + result = super().format(record) + + def replace_unicode(match): + try: + return chr(int(match.group(1), 16)) + except (ValueError, OverflowError): + return match.group(0) + + return self.UNICODE_ESCAPE_PATTERN.sub(replace_unicode, result) + + +class MaxTokensWarningFilter(logging.Filter): + """过滤掉 camel-ai 关于 max_tokens 的警告(我们故意不设置 max_tokens,让模型自行决定)""" + + def filter(self, record): + # 过滤掉包含 max_tokens 警告的日志 + if "max_tokens" in record.getMessage() and "Invalid or missing" in record.getMessage(): + return False + return True + + +# 在模块加载时立即添加过滤器,确保在 camel 代码执行前生效 +logging.getLogger().addFilter(MaxTokensWarningFilter()) + + +def setup_oasis_logging(log_dir: str): + """配置 OASIS 的日志,使用固定名称的日志文件""" + os.makedirs(log_dir, exist_ok=True) + + # 清理旧的日志文件 + for f in os.listdir(log_dir): + old_log = os.path.join(log_dir, f) + if os.path.isfile(old_log) and f.endswith('.log'): + try: + os.remove(old_log) + except OSError: + pass + + formatter = UnicodeFormatter("%(levelname)s - %(asctime)s - %(name)s - %(message)s") + + loggers_config = { + "social.agent": os.path.join(log_dir, "social.agent.log"), + "social.twitter": os.path.join(log_dir, "social.twitter.log"), + "social.rec": os.path.join(log_dir, "social.rec.log"), + "oasis.env": os.path.join(log_dir, "oasis.env.log"), + "table": os.path.join(log_dir, "table.log"), + } + + for logger_name, log_file in loggers_config.items(): + logger = logging.getLogger(logger_name) + logger.setLevel(logging.DEBUG) + logger.handlers.clear() + file_handler = logging.FileHandler(log_file, encoding='utf-8', mode='w') + file_handler.setLevel(logging.DEBUG) + file_handler.setFormatter(formatter) + logger.addHandler(file_handler) + logger.propagate = False + + +try: + from camel.models import ModelFactory + from camel.types import ModelPlatformType + import oasis + from oasis import ( + ActionType, + LLMAction, + ManualAction, + generate_twitter_agent_graph + ) +except ImportError as e: + print(f"错误: 缺少依赖 {e}") + print("请先安装: pip install oasis-ai camel-ai") + sys.exit(1) + + +# IPC相关常量 +IPC_COMMANDS_DIR = "ipc_commands" +IPC_RESPONSES_DIR = "ipc_responses" +ENV_STATUS_FILE = "env_status.json" + +class CommandType: + """命令类型常量""" + INTERVIEW = "interview" + BATCH_INTERVIEW = "batch_interview" + CLOSE_ENV = "close_env" + + +class IPCHandler: + """IPC命令处理器""" + + def __init__(self, simulation_dir: str, env, agent_graph): + self.simulation_dir = simulation_dir + self.env = env + self.agent_graph = agent_graph + self.commands_dir = os.path.join(simulation_dir, IPC_COMMANDS_DIR) + self.responses_dir = os.path.join(simulation_dir, IPC_RESPONSES_DIR) + self.status_file = os.path.join(simulation_dir, ENV_STATUS_FILE) + self._running = True + + # 确保目录存在 + os.makedirs(self.commands_dir, exist_ok=True) + os.makedirs(self.responses_dir, exist_ok=True) + + def update_status(self, status: str): + """更新环境状态""" + with open(self.status_file, 'w', encoding='utf-8') as f: + json.dump({ + "status": status, + "timestamp": datetime.now().isoformat() + }, f, ensure_ascii=False, indent=2) + + def poll_command(self) -> Optional[Dict[str, Any]]: + """轮询获取待处理命令""" + if not os.path.exists(self.commands_dir): + return None + + # 获取命令文件(按时间排序) + command_files = [] + for filename in os.listdir(self.commands_dir): + if filename.endswith('.json'): + filepath = os.path.join(self.commands_dir, filename) + command_files.append((filepath, os.path.getmtime(filepath))) + + command_files.sort(key=lambda x: x[1]) + + for filepath, _ in command_files: + try: + with open(filepath, 'r', encoding='utf-8') as f: + return json.load(f) + except (json.JSONDecodeError, OSError): + continue + + return None + + def send_response(self, command_id: str, status: str, result: Dict = None, error: str = None): + """发送响应""" + response = { + "command_id": command_id, + "status": status, + "result": result, + "error": error, + "timestamp": datetime.now().isoformat() + } + + response_file = os.path.join(self.responses_dir, f"{command_id}.json") + with open(response_file, 'w', encoding='utf-8') as f: + json.dump(response, f, ensure_ascii=False, indent=2) + + # 删除命令文件 + command_file = os.path.join(self.commands_dir, f"{command_id}.json") + try: + os.remove(command_file) + except OSError: + pass + + async def handle_interview(self, command_id: str, agent_id: int, prompt: str) -> bool: + """ + 处理单个Agent采访命令 + + Returns: + True 表示成功,False 表示失败 + """ + try: + # 获取Agent + agent = self.agent_graph.get_agent(agent_id) + + # 创建Interview动作 + interview_action = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + + # 执行Interview + actions = {agent: interview_action} + await self.env.step(actions) + + # 从数据库获取结果 + result = self._get_interview_result(agent_id) + + self.send_response(command_id, "completed", result=result) + print(f" Interview完成: agent_id={agent_id}") + return True + + except Exception as e: + error_msg = str(e) + print(f" Interview失败: agent_id={agent_id}, error={error_msg}") + self.send_response(command_id, "failed", error=error_msg) + return False + + async def handle_batch_interview(self, command_id: str, interviews: List[Dict]) -> bool: + """ + 处理批量采访命令 + + Args: + interviews: [{"agent_id": int, "prompt": str}, ...] + """ + try: + # 构建动作字典 + actions = {} + agent_prompts = {} # 记录每个agent的prompt + + for interview in interviews: + agent_id = interview.get("agent_id") + prompt = interview.get("prompt", "") + + try: + agent = self.agent_graph.get_agent(agent_id) + actions[agent] = ManualAction( + action_type=ActionType.INTERVIEW, + action_args={"prompt": prompt} + ) + agent_prompts[agent_id] = prompt + except Exception as e: + print(f" 警告: 无法获取Agent {agent_id}: {e}") + + if not actions: + self.send_response(command_id, "failed", error="没有有效的Agent") + return False + + # 执行批量Interview + await self.env.step(actions) + + # 获取所有结果 + results = {} + for agent_id in agent_prompts.keys(): + result = self._get_interview_result(agent_id) + results[agent_id] = result + + self.send_response(command_id, "completed", result={ + "interviews_count": len(results), + "results": results + }) + print(f" 批量Interview完成: {len(results)} 个Agent") + return True + + except Exception as e: + error_msg = str(e) + print(f" 批量Interview失败: {error_msg}") + self.send_response(command_id, "failed", error=error_msg) + return False + + def _get_interview_result(self, agent_id: int) -> Dict[str, Any]: + """从数据库获取最新的Interview结果""" + db_path = os.path.join(self.simulation_dir, "twitter_simulation.db") + + result = { + "agent_id": agent_id, + "response": None, + "timestamp": None + } + + if not os.path.exists(db_path): + return result + + try: + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + # 查询最新的Interview记录 + cursor.execute(""" + SELECT user_id, info, created_at + FROM trace + WHERE action = ? AND user_id = ? + ORDER BY created_at DESC + LIMIT 1 + """, (ActionType.INTERVIEW.value, agent_id)) + + row = cursor.fetchone() + if row: + user_id, info_json, created_at = row + try: + info = json.loads(info_json) if info_json else {} + result["response"] = info.get("response", info) + result["timestamp"] = created_at + except json.JSONDecodeError: + result["response"] = info_json + + conn.close() + + except Exception as e: + print(f" 读取Interview结果失败: {e}") + + return result + + async def process_commands(self) -> bool: + """ + 处理所有待处理命令 + + Returns: + True 表示继续运行,False 表示应该退出 + """ + command = self.poll_command() + if not command: + return True + + command_id = command.get("command_id") + command_type = command.get("command_type") + args = command.get("args", {}) + + print(f"\n收到IPC命令: {command_type}, id={command_id}") + + if command_type == CommandType.INTERVIEW: + await self.handle_interview( + command_id, + args.get("agent_id", 0), + args.get("prompt", "") + ) + return True + + elif command_type == CommandType.BATCH_INTERVIEW: + await self.handle_batch_interview( + command_id, + args.get("interviews", []) + ) + return True + + elif command_type == CommandType.CLOSE_ENV: + print("收到关闭环境命令") + self.send_response(command_id, "completed", result={"message": "环境即将关闭"}) + return False + + else: + self.send_response(command_id, "failed", error=f"未知命令类型: {command_type}") + return True + + +class TwitterSimulationRunner: + """Twitter模拟运行器""" + + # Twitter可用动作(不包含INTERVIEW,INTERVIEW只能通过ManualAction手动触发) + AVAILABLE_ACTIONS = [ + ActionType.CREATE_POST, + ActionType.LIKE_POST, + ActionType.REPOST, + ActionType.FOLLOW, + ActionType.DO_NOTHING, + ActionType.QUOTE_POST, + ] + + def __init__(self, config_path: str, wait_for_commands: bool = True): + """ + 初始化模拟运行器 + + Args: + config_path: 配置文件路径 (simulation_config.json) + wait_for_commands: 模拟完成后是否等待命令(默认True) + """ + self.config_path = config_path + self.config = self._load_config() + self.simulation_dir = os.path.dirname(config_path) + self.wait_for_commands = wait_for_commands + self.env = None + self.agent_graph = None + self.ipc_handler = None + + def _load_config(self) -> Dict[str, Any]: + """加载配置文件""" + with open(self.config_path, 'r', encoding='utf-8') as f: + return json.load(f) + + def _get_profile_path(self) -> str: + """获取Profile文件路径(OASIS Twitter使用CSV格式)""" + return os.path.join(self.simulation_dir, "twitter_profiles.csv") + + def _get_db_path(self) -> str: + """获取数据库路径""" + return os.path.join(self.simulation_dir, "twitter_simulation.db") + + def _create_model(self): + """ + 创建LLM模型 + + 统一使用项目根目录 .env 文件中的配置(优先级最高): + - LLM_API_KEY: API密钥 + - LLM_BASE_URL: API基础URL + - LLM_MODEL_NAME: 模型名称 + """ + # 优先从 .env 读取配置 + llm_api_key = os.environ.get("LLM_API_KEY", "") + llm_base_url = os.environ.get("LLM_BASE_URL", "") + llm_model = os.environ.get("LLM_MODEL_NAME", "") + + # 如果 .env 中没有,则使用 config 作为备用 + if not llm_model: + llm_model = self.config.get("llm_model", "gpt-4o-mini") + + # 设置 camel-ai 所需的环境变量 + if llm_api_key: + os.environ["OPENAI_API_KEY"] = llm_api_key + + if not os.environ.get("OPENAI_API_KEY"): + raise ValueError("缺少 API Key 配置,请在项目根目录 .env 文件中设置 LLM_API_KEY") + + if llm_base_url: + os.environ["OPENAI_API_BASE_URL"] = llm_base_url + + print(f"LLM配置: model={llm_model}, base_url={llm_base_url[:40] if llm_base_url else '默认'}...") + + return ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=llm_model, + ) + + def _get_active_agents_for_round( + self, + env, + current_hour: int, + round_num: int + ) -> List: + """ + 根据时间和配置决定本轮激活哪些Agent + + Args: + env: OASIS环境 + current_hour: 当前模拟小时(0-23) + round_num: 当前轮数 + + Returns: + 激活的Agent列表 + """ + time_config = self.config.get("time_config", {}) + agent_configs = self.config.get("agent_configs", []) + + # 基础激活数量 + base_min = time_config.get("agents_per_hour_min", 5) + base_max = time_config.get("agents_per_hour_max", 20) + + # 根据时段调整 + peak_hours = time_config.get("peak_hours", [9, 10, 11, 14, 15, 20, 21, 22]) + off_peak_hours = time_config.get("off_peak_hours", [0, 1, 2, 3, 4, 5]) + + if current_hour in peak_hours: + multiplier = time_config.get("peak_activity_multiplier", 1.5) + elif current_hour in off_peak_hours: + multiplier = time_config.get("off_peak_activity_multiplier", 0.3) + else: + multiplier = 1.0 + + target_count = int(random.uniform(base_min, base_max) * multiplier) + + # 根据每个Agent的配置计算激活概率 + candidates = [] + for cfg in agent_configs: + agent_id = cfg.get("agent_id", 0) + active_hours = cfg.get("active_hours", list(range(8, 23))) + activity_level = cfg.get("activity_level", 0.5) + + # 检查是否在活跃时间 + if current_hour not in active_hours: + continue + + # 根据活跃度计算概率 + if random.random() < activity_level: + candidates.append(agent_id) + + # 随机选择 + selected_ids = random.sample( + candidates, + min(target_count, len(candidates)) + ) if candidates else [] + + # 转换为Agent对象 + active_agents = [] + for agent_id in selected_ids: + try: + agent = env.agent_graph.get_agent(agent_id) + active_agents.append((agent_id, agent)) + except Exception: + pass + + return active_agents + + async def run(self, max_rounds: int = None): + """运行Twitter模拟 + + Args: + max_rounds: 最大模拟轮数(可选,用于截断过长的模拟) + """ + print("=" * 60) + print("OASIS Twitter模拟") + print(f"配置文件: {self.config_path}") + print(f"模拟ID: {self.config.get('simulation_id', 'unknown')}") + print(f"等待命令模式: {'启用' if self.wait_for_commands else '禁用'}") + print("=" * 60) + + # 加载时间配置 + time_config = self.config.get("time_config", {}) + total_hours = time_config.get("total_simulation_hours", 72) + minutes_per_round = time_config.get("minutes_per_round", 30) + + # 计算总轮数 + total_rounds = (total_hours * 60) // minutes_per_round + + # 如果指定了最大轮数,则截断 + if max_rounds is not None and max_rounds > 0: + original_rounds = total_rounds + total_rounds = min(total_rounds, max_rounds) + if total_rounds < original_rounds: + print(f"\n轮数已截断: {original_rounds} -> {total_rounds} (max_rounds={max_rounds})") + + print(f"\n模拟参数:") + print(f" - 总模拟时长: {total_hours}小时") + print(f" - 每轮时间: {minutes_per_round}分钟") + print(f" - 总轮数: {total_rounds}") + if max_rounds: + print(f" - 最大轮数限制: {max_rounds}") + print(f" - Agent数量: {len(self.config.get('agent_configs', []))}") + + # 创建模型 + print("\n初始化LLM模型...") + model = self._create_model() + + # 加载Agent图 + print("加载Agent Profile...") + profile_path = self._get_profile_path() + if not os.path.exists(profile_path): + print(f"错误: Profile文件不存在: {profile_path}") + return + + self.agent_graph = await generate_twitter_agent_graph( + profile_path=profile_path, + model=model, + available_actions=self.AVAILABLE_ACTIONS, + ) + + # 数据库路径 + db_path = self._get_db_path() + if os.path.exists(db_path): + os.remove(db_path) + print(f"已删除旧数据库: {db_path}") + + # 创建环境 + print("创建OASIS环境...") + self.env = oasis.make( + agent_graph=self.agent_graph, + platform=oasis.DefaultPlatformType.TWITTER, + database_path=db_path, + semaphore=30, # 限制最大并发 LLM 请求数,防止 API 过载 + ) + + await self.env.reset() + print("环境初始化完成\n") + + # 初始化IPC处理器 + self.ipc_handler = IPCHandler(self.simulation_dir, self.env, self.agent_graph) + self.ipc_handler.update_status("running") + + # 执行初始事件 + event_config = self.config.get("event_config", {}) + initial_posts = event_config.get("initial_posts", []) + + if initial_posts: + print(f"执行初始事件 ({len(initial_posts)}条初始帖子)...") + initial_actions = {} + for post in initial_posts: + agent_id = post.get("poster_agent_id", 0) + content = post.get("content", "") + try: + agent = self.env.agent_graph.get_agent(agent_id) + initial_actions[agent] = ManualAction( + action_type=ActionType.CREATE_POST, + action_args={"content": content} + ) + except Exception as e: + print(f" 警告: 无法为Agent {agent_id}创建初始帖子: {e}") + + if initial_actions: + await self.env.step(initial_actions) + print(f" 已发布 {len(initial_actions)} 条初始帖子") + + # 主模拟循环 + print("\n开始模拟循环...") + start_time = datetime.now() + + for round_num in range(total_rounds): + # 计算当前模拟时间 + simulated_minutes = round_num * minutes_per_round + simulated_hour = (simulated_minutes // 60) % 24 + simulated_day = simulated_minutes // (60 * 24) + 1 + + # 获取本轮激活的Agent + active_agents = self._get_active_agents_for_round( + self.env, simulated_hour, round_num + ) + + if not active_agents: + continue + + # 构建动作 + actions = { + agent: LLMAction() + for _, agent in active_agents + } + + # 执行动作 + await self.env.step(actions) + + # 打印进度 + if (round_num + 1) % 10 == 0 or round_num == 0: + elapsed = (datetime.now() - start_time).total_seconds() + progress = (round_num + 1) / total_rounds * 100 + print(f" [Day {simulated_day}, {simulated_hour:02d}:00] " + f"Round {round_num + 1}/{total_rounds} ({progress:.1f}%) " + f"- {len(active_agents)} agents active " + f"- elapsed: {elapsed:.1f}s") + + total_elapsed = (datetime.now() - start_time).total_seconds() + print(f"\n模拟循环完成!") + print(f" - 总耗时: {total_elapsed:.1f}秒") + print(f" - 数据库: {db_path}") + + # 是否进入等待命令模式 + if self.wait_for_commands: + print("\n" + "=" * 60) + print("进入等待命令模式 - 环境保持运行") + print("支持的命令: interview, batch_interview, close_env") + print("=" * 60) + + self.ipc_handler.update_status("alive") + + # 等待命令循环(使用全局 _shutdown_event) + try: + while not _shutdown_event.is_set(): + should_continue = await self.ipc_handler.process_commands() + if not should_continue: + break + try: + await asyncio.wait_for(_shutdown_event.wait(), timeout=0.5) + break # 收到退出信号 + except asyncio.TimeoutError: + pass + except KeyboardInterrupt: + print("\n收到中断信号") + except asyncio.CancelledError: + print("\n任务被取消") + except Exception as e: + print(f"\n命令处理出错: {e}") + + print("\n关闭环境...") + + # 关闭环境 + self.ipc_handler.update_status("stopped") + await self.env.close() + + print("环境已关闭") + print("=" * 60) + + +async def main(): + parser = argparse.ArgumentParser(description='OASIS Twitter模拟') + parser.add_argument( + '--config', + type=str, + required=True, + help='配置文件路径 (simulation_config.json)' + ) + parser.add_argument( + '--max-rounds', + type=int, + default=None, + help='最大模拟轮数(可选,用于截断过长的模拟)' + ) + parser.add_argument( + '--no-wait', + action='store_true', + default=False, + help='模拟完成后立即关闭环境,不进入等待命令模式' + ) + + args = parser.parse_args() + + # 在 main 函数开始时创建 shutdown 事件 + global _shutdown_event + _shutdown_event = asyncio.Event() + + if not os.path.exists(args.config): + print(f"错误: 配置文件不存在: {args.config}") + sys.exit(1) + + # 初始化日志配置(使用固定文件名,清理旧日志) + simulation_dir = os.path.dirname(args.config) or "." + setup_oasis_logging(os.path.join(simulation_dir, "log")) + + runner = TwitterSimulationRunner( + config_path=args.config, + wait_for_commands=not args.no_wait + ) + await runner.run(max_rounds=args.max_rounds) + + +def setup_signal_handlers(): + """ + 设置信号处理器,确保收到 SIGTERM/SIGINT 时能够正确退出 + 让程序有机会正常清理资源(关闭数据库、环境等) + """ + def signal_handler(signum, frame): + global _cleanup_done + sig_name = "SIGTERM" if signum == signal.SIGTERM else "SIGINT" + print(f"\n收到 {sig_name} 信号,正在退出...") + if not _cleanup_done: + _cleanup_done = True + if _shutdown_event: + _shutdown_event.set() + else: + # 重复收到信号才强制退出 + print("强制退出...") + sys.exit(1) + + signal.signal(signal.SIGTERM, signal_handler) + signal.signal(signal.SIGINT, signal_handler) + + +if __name__ == "__main__": + setup_signal_handlers() + try: + asyncio.run(main()) + except KeyboardInterrupt: + print("\n程序被中断") + except SystemExit: + pass + finally: + print("模拟进程已退出") diff --git a/backend/scripts/test_profile_format.py b/backend/scripts/test_profile_format.py new file mode 100644 index 00000000..354e8b5c --- /dev/null +++ b/backend/scripts/test_profile_format.py @@ -0,0 +1,166 @@ +""" +测试Profile格式生成是否符合OASIS要求 +验证: +1. Twitter Profile生成CSV格式 +2. Reddit Profile生成JSON详细格式 +""" + +import os +import sys +import json +import csv +import tempfile + +# 添加项目路径 +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from app.services.oasis_profile_generator import OasisProfileGenerator, OasisAgentProfile + + +def test_profile_formats(): + """测试Profile格式""" + print("=" * 60) + print("OASIS Profile格式测试") + print("=" * 60) + + # 创建测试Profile数据 + test_profiles = [ + OasisAgentProfile( + user_id=0, + user_name="test_user_123", + name="Test User", + bio="A test user for validation", + persona="Test User is an enthusiastic participant in social discussions.", + karma=1500, + friend_count=100, + follower_count=200, + statuses_count=500, + age=25, + gender="male", + mbti="INTJ", + country="China", + profession="Student", + interested_topics=["Technology", "Education"], + source_entity_uuid="test-uuid-123", + source_entity_type="Student", + ), + OasisAgentProfile( + user_id=1, + user_name="org_official_456", + name="Official Organization", + bio="Official account for Organization", + persona="This is an official institutional account that communicates official positions.", + karma=5000, + friend_count=50, + follower_count=10000, + statuses_count=200, + profession="Organization", + interested_topics=["Public Policy", "Announcements"], + source_entity_uuid="test-uuid-456", + source_entity_type="University", + ), + ] + + generator = OasisProfileGenerator.__new__(OasisProfileGenerator) + + # 使用临时目录 + with tempfile.TemporaryDirectory() as temp_dir: + twitter_path = os.path.join(temp_dir, "twitter_profiles.csv") + reddit_path = os.path.join(temp_dir, "reddit_profiles.json") + + # 测试Twitter CSV格式 + print("\n1. 测试Twitter Profile (CSV格式)") + print("-" * 40) + generator._save_twitter_csv(test_profiles, twitter_path) + + # 读取并验证CSV + with open(twitter_path, 'r', encoding='utf-8') as f: + reader = csv.DictReader(f) + rows = list(reader) + + print(f" 文件: {twitter_path}") + print(f" 行数: {len(rows)}") + print(f" 表头: {list(rows[0].keys())}") + print(f"\n 示例数据 (第1行):") + for key, value in rows[0].items(): + print(f" {key}: {value}") + + # 验证必需字段 + required_twitter_fields = ['user_id', 'user_name', 'name', 'bio', + 'friend_count', 'follower_count', 'statuses_count', 'created_at'] + missing = set(required_twitter_fields) - set(rows[0].keys()) + if missing: + print(f"\n [错误] 缺少字段: {missing}") + else: + print(f"\n [通过] 所有必需字段都存在") + + # 测试Reddit JSON格式 + print("\n2. 测试Reddit Profile (JSON详细格式)") + print("-" * 40) + generator._save_reddit_json(test_profiles, reddit_path) + + # 读取并验证JSON + with open(reddit_path, 'r', encoding='utf-8') as f: + reddit_data = json.load(f) + + print(f" 文件: {reddit_path}") + print(f" 条目数: {len(reddit_data)}") + print(f" 字段: {list(reddit_data[0].keys())}") + print(f"\n 示例数据 (第1条):") + print(json.dumps(reddit_data[0], ensure_ascii=False, indent=4)) + + # 验证详细格式字段 + required_reddit_fields = ['realname', 'username', 'bio', 'persona'] + optional_reddit_fields = ['age', 'gender', 'mbti', 'country', 'profession', 'interested_topics'] + + missing = set(required_reddit_fields) - set(reddit_data[0].keys()) + if missing: + print(f"\n [错误] 缺少必需字段: {missing}") + else: + print(f"\n [通过] 所有必需字段都存在") + + present_optional = set(optional_reddit_fields) & set(reddit_data[0].keys()) + print(f" [信息] 可选字段: {present_optional}") + + print("\n" + "=" * 60) + print("测试完成!") + print("=" * 60) + + +def show_expected_formats(): + """显示OASIS期望的格式""" + print("\n" + "=" * 60) + print("OASIS 期望的Profile格式参考") + print("=" * 60) + + print("\n1. Twitter Profile (CSV格式)") + print("-" * 40) + twitter_example = """user_id,user_name,name,bio,friend_count,follower_count,statuses_count,created_at +0,user0,User Zero,I am user zero with interests in technology.,100,150,500,2023-01-01 +1,user1,User One,Tech enthusiast and coffee lover.,200,250,1000,2023-01-02""" + print(twitter_example) + + print("\n2. Reddit Profile (JSON详细格式)") + print("-" * 40) + reddit_example = [ + { + "realname": "James Miller", + "username": "millerhospitality", + "bio": "Passionate about hospitality & tourism.", + "persona": "James is a seasoned professional in the Hospitality & Tourism industry...", + "age": 40, + "gender": "male", + "mbti": "ESTJ", + "country": "UK", + "profession": "Hospitality & Tourism", + "interested_topics": ["Economics", "Business"] + } + ] + print(json.dumps(reddit_example, ensure_ascii=False, indent=2)) + + +if __name__ == "__main__": + test_profile_formats() + show_expected_formats() + + diff --git a/backend/uv.lock b/backend/uv.lock new file mode 100644 index 00000000..642dd9c3 --- /dev/null +++ b/backend/uv.lock @@ -0,0 +1,2789 @@ +version = 1 +revision = 3 +requires-python = ">=3.11, <3.13" +resolution-markers = [ + "python_full_version >= '3.12'", + "python_full_version < '3.12'", +] + +[[package]] +name = "aiofiles" +version = "25.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/41/c3/534eac40372d8ee36ef40df62ec129bee4fdb5ad9706e58a29be53b2c970/aiofiles-25.1.0.tar.gz", hash = "sha256:a8d728f0a29de45dc521f18f07297428d56992a742f0cd2701ba86e44d23d5b2", size = 46354, upload-time = "2025-10-09T20:51:04.358Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bc/8a/340a1555ae33d7354dbca4faa54948d76d89a27ceef032c8c3bc661d003e/aiofiles-25.1.0-py3-none-any.whl", hash = "sha256:abe311e527c862958650f9438e859c1fa7568a141b22abcd015e120e86a85695", size = 14668, upload-time = "2025-10-09T20:51:03.174Z" }, +] + +[[package]] +name = "annotated-types" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, +] + +[[package]] +name = "anyio" +version = "4.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/16/ce/8a777047513153587e5434fd752e89334ac33e379aa3497db860eeb60377/anyio-4.12.0.tar.gz", hash = "sha256:73c693b567b0c55130c104d0b43a9baf3aa6a31fc6110116509f27bf75e21ec0", size = 228266, upload-time = "2025-11-28T23:37:38.911Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7f/9c/36c5c37947ebfb8c7f22e0eb6e4d188ee2d53aa3880f3f2744fb894f0cb1/anyio-4.12.0-py3-none-any.whl", hash = "sha256:dad2376a628f98eeca4881fc56cd06affd18f659b17a747d3ff0307ced94b1bb", size = 113362, upload-time = "2025-11-28T23:36:57.897Z" }, +] + +[[package]] +name = "appnope" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/35/5d/752690df9ef5b76e169e68d6a129fa6d08a7100ca7f754c89495db3c6019/appnope-0.1.4.tar.gz", hash = "sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee", size = 4170, upload-time = "2024-02-06T09:43:11.258Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/29/5ecc3a15d5a33e31b26c11426c45c501e439cb865d0bff96315d86443b78/appnope-0.1.4-py2.py3-none-any.whl", hash = "sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c", size = 4321, upload-time = "2024-02-06T09:43:09.663Z" }, +] + +[[package]] +name = "astor" +version = "0.8.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/21/75b771132fee241dfe601d39ade629548a9626d1d39f333fde31bc46febe/astor-0.8.1.tar.gz", hash = "sha256:6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e", size = 35090, upload-time = "2019-12-10T01:50:35.51Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c3/88/97eef84f48fa04fbd6750e62dcceafba6c63c81b7ac1420856c8dcc0a3f9/astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5", size = 27488, upload-time = "2019-12-10T01:50:33.628Z" }, +] + +[[package]] +name = "asttokens" +version = "3.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/be/a5/8e3f9b6771b0b408517c82d97aed8f2036509bc247d46114925e32fe33f0/asttokens-3.0.1.tar.gz", hash = "sha256:71a4ee5de0bde6a31d64f6b13f2293ac190344478f081c3d1bccfcf5eacb0cb7", size = 62308, upload-time = "2025-11-15T16:43:48.578Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/39/e7eaf1799466a4aef85b6a4fe7bd175ad2b1c6345066aa33f1f58d4b18d0/asttokens-3.0.1-py3-none-any.whl", hash = "sha256:15a3ebc0f43c2d0a50eeafea25e19046c68398e487b9f1f5b517f7c0f40f976a", size = 27047, upload-time = "2025-11-15T16:43:16.109Z" }, +] + +[[package]] +name = "attrs" +version = "25.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6b/5c/685e6633917e101e5dcb62b9dd76946cbb57c26e133bae9e0cd36033c0a9/attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11", size = 934251, upload-time = "2025-10-06T13:54:44.725Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3a/2a/7cc015f5b9f5db42b7d48157e23356022889fc354a2813c15934b7cb5c0e/attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373", size = 67615, upload-time = "2025-10-06T13:54:43.17Z" }, +] + +[[package]] +name = "backcall" +version = "0.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/40/764a663805d84deee23043e1426a9175567db89c8b3287b5c2ad9f71aa93/backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e", size = 18041, upload-time = "2020-06-09T15:11:32.931Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4c/1c/ff6546b6c12603d8dd1070aa3c3d273ad4c07f5771689a7b69a550e8c951/backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255", size = 11157, upload-time = "2020-06-09T15:11:30.87Z" }, +] + +[[package]] +name = "backoff" +version = "2.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/47/d7/5bbeb12c44d7c4f2fb5b56abce497eb5ed9f34d85701de869acedd602619/backoff-2.2.1.tar.gz", hash = "sha256:03f829f5bb1923180821643f8753b0502c3b682293992485b0eef2807afa5cba", size = 17001, upload-time = "2022-10-05T19:19:32.061Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/df/73/b6e24bd22e6720ca8ee9a85a0c4a2971af8497d8f3193fa05390cbd46e09/backoff-2.2.1-py3-none-any.whl", hash = "sha256:63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8", size = 15148, upload-time = "2022-10-05T19:19:30.546Z" }, +] + +[[package]] +name = "beautifulsoup4" +version = "4.14.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "soupsieve" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c3/b0/1c6a16426d389813b48d95e26898aff79abbde42ad353958ad95cc8c9b21/beautifulsoup4-4.14.3.tar.gz", hash = "sha256:6292b1c5186d356bba669ef9f7f051757099565ad9ada5dd630bd9de5fa7fb86", size = 627737, upload-time = "2025-11-30T15:08:26.084Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1a/39/47f9197bdd44df24d67ac8893641e16f386c984a0619ef2ee4c51fbbc019/beautifulsoup4-4.14.3-py3-none-any.whl", hash = "sha256:0918bfe44902e6ad8d57732ba310582e98da931428d231a5ecb9e7c703a735bb", size = 107721, upload-time = "2025-11-30T15:08:24.087Z" }, +] + +[[package]] +name = "bleach" +version = "6.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "webencodings" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/07/18/3c8523962314be6bf4c8989c79ad9531c825210dd13a8669f6b84336e8bd/bleach-6.3.0.tar.gz", hash = "sha256:6f3b91b1c0a02bb9a78b5a454c92506aa0fdf197e1d5e114d2e00c6f64306d22", size = 203533, upload-time = "2025-10-27T17:57:39.211Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cd/3a/577b549de0cc09d95f11087ee63c739bba856cd3952697eec4c4bb91350a/bleach-6.3.0-py3-none-any.whl", hash = "sha256:fe10ec77c93ddf3d13a73b035abaac7a9f5e436513864ccdad516693213c65d6", size = 164437, upload-time = "2025-10-27T17:57:37.538Z" }, +] + +[package.optional-dependencies] +css = [ + { name = "tinycss2" }, +] + +[[package]] +name = "blinker" +version = "1.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/28/9b3f50ce0e048515135495f198351908d99540d69bfdc8c1d15b73dc55ce/blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf", size = 22460, upload-time = "2024-11-08T17:25:47.436Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/10/cb/f2ad4230dc2eb1a74edf38f1a38b9b52277f75bef262d8908e60d957e13c/blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc", size = 8458, upload-time = "2024-11-08T17:25:46.184Z" }, +] + +[[package]] +name = "cairocffi" +version = "1.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/70/c5/1a4dc131459e68a173cbdab5fad6b524f53f9c1ef7861b7698e998b837cc/cairocffi-1.7.1.tar.gz", hash = "sha256:2e48ee864884ec4a3a34bfa8c9ab9999f688286eb714a15a43ec9d068c36557b", size = 88096, upload-time = "2024-06-18T10:56:06.741Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/93/d8/ba13451aa6b745c49536e87b6bf8f629b950e84bd0e8308f7dc6883b67e2/cairocffi-1.7.1-py3-none-any.whl", hash = "sha256:9803a0e11f6c962f3b0ae2ec8ba6ae45e957a146a004697a1ac1bbf16b073b3f", size = 75611, upload-time = "2024-06-18T10:55:59.489Z" }, +] + +[[package]] +name = "camel-ai" +version = "0.2.78" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "astor" }, + { name = "colorama" }, + { name = "docstring-parser" }, + { name = "httpx" }, + { name = "jsonschema" }, + { name = "mcp" }, + { name = "openai" }, + { name = "pillow" }, + { name = "psutil" }, + { name = "pydantic" }, + { name = "tiktoken" }, + { name = "websockets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3b/2b/cd5181bfd0ebcf567a088ee5c1e3768b132ba4b1489ee19d5fb0bd679586/camel_ai-0.2.78.tar.gz", hash = "sha256:24745da225da7da96dcd85f72d143c6104569c17f14280c369d7e82b86851284", size = 964632, upload-time = "2025-10-15T17:20:54.181Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/01/81/0cfb1c0d9da589665e2eb4471887967e70bba428638c37fb4f6a78baf300/camel_ai-0.2.78-py3-none-any.whl", hash = "sha256:356624da13dfe0c55ef43dc509c18ce029f67fe3997966495a4ce9be931078d5", size = 1415578, upload-time = "2025-10-15T17:20:51.727Z" }, +] + +[[package]] +name = "camel-oasis" +version = "0.2.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cairocffi" }, + { name = "camel-ai" }, + { name = "igraph" }, + { name = "neo4j" }, + { name = "openapi-spec-validator" }, + { name = "pandas" }, + { name = "pillow" }, + { name = "prance" }, + { name = "pre-commit" }, + { name = "pytest" }, + { name = "pytest-asyncio" }, + { name = "requests-oauthlib" }, + { name = "sentence-transformers" }, + { name = "slack-sdk" }, + { name = "unstructured" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d9/6f/b36240380c65397f3e18829fce8ed0a1d19893b32d3596aa0902c7b3ad81/camel_oasis-0.2.5.tar.gz", hash = "sha256:f667dec86f9f7823d50f76b07733a34afc1427b923f1a673519206bb41a57f8c", size = 56966, upload-time = "2025-12-04T11:58:19.43Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/77/d0/6d62173602433937d0228b7809e2b244e09c11cfb1be9c6754ae3b20d887/camel_oasis-0.2.5-py3-none-any.whl", hash = "sha256:9ebd6ba8e331495ee56b25cc63982188b94125dde499e5e9c00398a1d47e606d", size = 75954, upload-time = "2025-12-04T11:58:18.363Z" }, +] + +[[package]] +name = "certifi" +version = "2025.11.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/8c/58f469717fa48465e4a50c014a0400602d3c437d7c0c468e17ada824da3a/certifi-2025.11.12.tar.gz", hash = "sha256:d8ab5478f2ecd78af242878415affce761ca6bc54a22a27e026d7c25357c3316", size = 160538, upload-time = "2025-11-12T02:54:51.517Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/70/7d/9bc192684cea499815ff478dfcdc13835ddf401365057044fb721ec6bddb/certifi-2025.11.12-py3-none-any.whl", hash = "sha256:97de8790030bbd5c2d96b7ec782fc2f7820ef8dba6db909ccf95449f2d062d4b", size = 159438, upload-time = "2025-11-12T02:54:49.735Z" }, +] + +[[package]] +name = "cffi" +version = "2.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pycparser", marker = "implementation_name != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/eb/56/b1ba7935a17738ae8453301356628e8147c79dbb825bcbc73dc7401f9846/cffi-2.0.0.tar.gz", hash = "sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529", size = 523588, upload-time = "2025-09-08T23:24:04.541Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/12/4a/3dfd5f7850cbf0d06dc84ba9aa00db766b52ca38d8b86e3a38314d52498c/cffi-2.0.0-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:b4c854ef3adc177950a8dfc81a86f5115d2abd545751a304c5bcf2c2c7283cfe", size = 184344, upload-time = "2025-09-08T23:22:26.456Z" }, + { url = "https://files.pythonhosted.org/packages/4f/8b/f0e4c441227ba756aafbe78f117485b25bb26b1c059d01f137fa6d14896b/cffi-2.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2de9a304e27f7596cd03d16f1b7c72219bd944e99cc52b84d0145aefb07cbd3c", size = 180560, upload-time = "2025-09-08T23:22:28.197Z" }, + { url = "https://files.pythonhosted.org/packages/b1/b7/1200d354378ef52ec227395d95c2576330fd22a869f7a70e88e1447eb234/cffi-2.0.0-cp311-cp311-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:baf5215e0ab74c16e2dd324e8ec067ef59e41125d3eade2b863d294fd5035c92", size = 209613, upload-time = "2025-09-08T23:22:29.475Z" }, + { url = "https://files.pythonhosted.org/packages/b8/56/6033f5e86e8cc9bb629f0077ba71679508bdf54a9a5e112a3c0b91870332/cffi-2.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:730cacb21e1bdff3ce90babf007d0a0917cc3e6492f336c2f0134101e0944f93", size = 216476, upload-time = "2025-09-08T23:22:31.063Z" }, + { url = "https://files.pythonhosted.org/packages/dc/7f/55fecd70f7ece178db2f26128ec41430d8720f2d12ca97bf8f0a628207d5/cffi-2.0.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:6824f87845e3396029f3820c206e459ccc91760e8fa24422f8b0c3d1731cbec5", size = 203374, upload-time = "2025-09-08T23:22:32.507Z" }, + { url = "https://files.pythonhosted.org/packages/84/ef/a7b77c8bdc0f77adc3b46888f1ad54be8f3b7821697a7b89126e829e676a/cffi-2.0.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:9de40a7b0323d889cf8d23d1ef214f565ab154443c42737dfe52ff82cf857664", size = 202597, upload-time = "2025-09-08T23:22:34.132Z" }, + { url = "https://files.pythonhosted.org/packages/d7/91/500d892b2bf36529a75b77958edfcd5ad8e2ce4064ce2ecfeab2125d72d1/cffi-2.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8941aaadaf67246224cee8c3803777eed332a19d909b47e29c9842ef1e79ac26", size = 215574, upload-time = "2025-09-08T23:22:35.443Z" }, + { url = "https://files.pythonhosted.org/packages/44/64/58f6255b62b101093d5df22dcb752596066c7e89dd725e0afaed242a61be/cffi-2.0.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:a05d0c237b3349096d3981b727493e22147f934b20f6f125a3eba8f994bec4a9", size = 218971, upload-time = "2025-09-08T23:22:36.805Z" }, + { url = "https://files.pythonhosted.org/packages/ab/49/fa72cebe2fd8a55fbe14956f9970fe8eb1ac59e5df042f603ef7c8ba0adc/cffi-2.0.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:94698a9c5f91f9d138526b48fe26a199609544591f859c870d477351dc7b2414", size = 211972, upload-time = "2025-09-08T23:22:38.436Z" }, + { url = "https://files.pythonhosted.org/packages/0b/28/dd0967a76aab36731b6ebfe64dec4e981aff7e0608f60c2d46b46982607d/cffi-2.0.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:5fed36fccc0612a53f1d4d9a816b50a36702c28a2aa880cb8a122b3466638743", size = 217078, upload-time = "2025-09-08T23:22:39.776Z" }, + { url = "https://files.pythonhosted.org/packages/2b/c0/015b25184413d7ab0a410775fdb4a50fca20f5589b5dab1dbbfa3baad8ce/cffi-2.0.0-cp311-cp311-win32.whl", hash = "sha256:c649e3a33450ec82378822b3dad03cc228b8f5963c0c12fc3b1e0ab940f768a5", size = 172076, upload-time = "2025-09-08T23:22:40.95Z" }, + { url = "https://files.pythonhosted.org/packages/ae/8f/dc5531155e7070361eb1b7e4c1a9d896d0cb21c49f807a6c03fd63fc877e/cffi-2.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:66f011380d0e49ed280c789fbd08ff0d40968ee7b665575489afa95c98196ab5", size = 182820, upload-time = "2025-09-08T23:22:42.463Z" }, + { url = "https://files.pythonhosted.org/packages/95/5c/1b493356429f9aecfd56bc171285a4c4ac8697f76e9bbbbb105e537853a1/cffi-2.0.0-cp311-cp311-win_arm64.whl", hash = "sha256:c6638687455baf640e37344fe26d37c404db8b80d037c3d29f58fe8d1c3b194d", size = 177635, upload-time = "2025-09-08T23:22:43.623Z" }, + { url = "https://files.pythonhosted.org/packages/ea/47/4f61023ea636104d4f16ab488e268b93008c3d0bb76893b1b31db1f96802/cffi-2.0.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:6d02d6655b0e54f54c4ef0b94eb6be0607b70853c45ce98bd278dc7de718be5d", size = 185271, upload-time = "2025-09-08T23:22:44.795Z" }, + { url = "https://files.pythonhosted.org/packages/df/a2/781b623f57358e360d62cdd7a8c681f074a71d445418a776eef0aadb4ab4/cffi-2.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8eca2a813c1cb7ad4fb74d368c2ffbbb4789d377ee5bb8df98373c2cc0dee76c", size = 181048, upload-time = "2025-09-08T23:22:45.938Z" }, + { url = "https://files.pythonhosted.org/packages/ff/df/a4f0fbd47331ceeba3d37c2e51e9dfc9722498becbeec2bd8bc856c9538a/cffi-2.0.0-cp312-cp312-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:21d1152871b019407d8ac3985f6775c079416c282e431a4da6afe7aefd2bccbe", size = 212529, upload-time = "2025-09-08T23:22:47.349Z" }, + { url = "https://files.pythonhosted.org/packages/d5/72/12b5f8d3865bf0f87cf1404d8c374e7487dcf097a1c91c436e72e6badd83/cffi-2.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:b21e08af67b8a103c71a250401c78d5e0893beff75e28c53c98f4de42f774062", size = 220097, upload-time = "2025-09-08T23:22:48.677Z" }, + { url = "https://files.pythonhosted.org/packages/c2/95/7a135d52a50dfa7c882ab0ac17e8dc11cec9d55d2c18dda414c051c5e69e/cffi-2.0.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:1e3a615586f05fc4065a8b22b8152f0c1b00cdbc60596d187c2a74f9e3036e4e", size = 207983, upload-time = "2025-09-08T23:22:50.06Z" }, + { url = "https://files.pythonhosted.org/packages/3a/c8/15cb9ada8895957ea171c62dc78ff3e99159ee7adb13c0123c001a2546c1/cffi-2.0.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:81afed14892743bbe14dacb9e36d9e0e504cd204e0b165062c488942b9718037", size = 206519, upload-time = "2025-09-08T23:22:51.364Z" }, + { url = "https://files.pythonhosted.org/packages/78/2d/7fa73dfa841b5ac06c7b8855cfc18622132e365f5b81d02230333ff26e9e/cffi-2.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3e17ed538242334bf70832644a32a7aae3d83b57567f9fd60a26257e992b79ba", size = 219572, upload-time = "2025-09-08T23:22:52.902Z" }, + { url = "https://files.pythonhosted.org/packages/07/e0/267e57e387b4ca276b90f0434ff88b2c2241ad72b16d31836adddfd6031b/cffi-2.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3925dd22fa2b7699ed2617149842d2e6adde22b262fcbfada50e3d195e4b3a94", size = 222963, upload-time = "2025-09-08T23:22:54.518Z" }, + { url = "https://files.pythonhosted.org/packages/b6/75/1f2747525e06f53efbd878f4d03bac5b859cbc11c633d0fb81432d98a795/cffi-2.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2c8f814d84194c9ea681642fd164267891702542f028a15fc97d4674b6206187", size = 221361, upload-time = "2025-09-08T23:22:55.867Z" }, + { url = "https://files.pythonhosted.org/packages/7b/2b/2b6435f76bfeb6bbf055596976da087377ede68df465419d192acf00c437/cffi-2.0.0-cp312-cp312-win32.whl", hash = "sha256:da902562c3e9c550df360bfa53c035b2f241fed6d9aef119048073680ace4a18", size = 172932, upload-time = "2025-09-08T23:22:57.188Z" }, + { url = "https://files.pythonhosted.org/packages/f8/ed/13bd4418627013bec4ed6e54283b1959cf6db888048c7cf4b4c3b5b36002/cffi-2.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:da68248800ad6320861f129cd9c1bf96ca849a2771a59e0344e88681905916f5", size = 183557, upload-time = "2025-09-08T23:22:58.351Z" }, + { url = "https://files.pythonhosted.org/packages/95/31/9f7f93ad2f8eff1dbc1c3656d7ca5bfd8fb52c9d786b4dcf19b2d02217fa/cffi-2.0.0-cp312-cp312-win_arm64.whl", hash = "sha256:4671d9dd5ec934cb9a73e7ee9676f9362aba54f7f34910956b84d727b0d73fb6", size = 177762, upload-time = "2025-09-08T23:22:59.668Z" }, +] + +[[package]] +name = "cfgv" +version = "3.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4e/b5/721b8799b04bf9afe054a3899c6cf4e880fcf8563cc71c15610242490a0c/cfgv-3.5.0.tar.gz", hash = "sha256:d5b1034354820651caa73ede66a6294d6e95c1b00acc5e9b098e917404669132", size = 7334, upload-time = "2025-11-19T20:55:51.612Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/db/3c/33bac158f8ab7f89b2e59426d5fe2e4f63f7ed25df84c036890172b412b5/cfgv-3.5.0-py2.py3-none-any.whl", hash = "sha256:a8dc6b26ad22ff227d2634a65cb388215ce6cc96bbcc5cfde7641ae87e8dacc0", size = 7445, upload-time = "2025-11-19T20:55:50.744Z" }, +] + +[[package]] +name = "chardet" +version = "5.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f3/0d/f7b6ab21ec75897ed80c17d79b15951a719226b9fababf1e40ea74d69079/chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7", size = 2069618, upload-time = "2023-08-01T19:23:02.662Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/6f/f5fbc992a329ee4e0f288c1fe0e2ad9485ed064cac731ed2fe47dcc38cbf/chardet-5.2.0-py3-none-any.whl", hash = "sha256:e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970", size = 199385, upload-time = "2023-08-01T19:23:00.661Z" }, +] + +[[package]] +name = "charset-normalizer" +version = "3.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/13/69/33ddede1939fdd074bce5434295f38fae7136463422fe4fd3e0e89b98062/charset_normalizer-3.4.4.tar.gz", hash = "sha256:94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a", size = 129418, upload-time = "2025-10-14T04:42:32.879Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ed/27/c6491ff4954e58a10f69ad90aca8a1b6fe9c5d3c6f380907af3c37435b59/charset_normalizer-3.4.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6e1fcf0720908f200cd21aa4e6750a48ff6ce4afe7ff5a79a90d5ed8a08296f8", size = 206988, upload-time = "2025-10-14T04:40:33.79Z" }, + { url = "https://files.pythonhosted.org/packages/94/59/2e87300fe67ab820b5428580a53cad894272dbb97f38a7a814a2a1ac1011/charset_normalizer-3.4.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5f819d5fe9234f9f82d75bdfa9aef3a3d72c4d24a6e57aeaebba32a704553aa0", size = 147324, upload-time = "2025-10-14T04:40:34.961Z" }, + { url = "https://files.pythonhosted.org/packages/07/fb/0cf61dc84b2b088391830f6274cb57c82e4da8bbc2efeac8c025edb88772/charset_normalizer-3.4.4-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a59cb51917aa591b1c4e6a43c132f0cdc3c76dbad6155df4e28ee626cc77a0a3", size = 142742, upload-time = "2025-10-14T04:40:36.105Z" }, + { url = "https://files.pythonhosted.org/packages/62/8b/171935adf2312cd745d290ed93cf16cf0dfe320863ab7cbeeae1dcd6535f/charset_normalizer-3.4.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8ef3c867360f88ac904fd3f5e1f902f13307af9052646963ee08ff4f131adafc", size = 160863, upload-time = "2025-10-14T04:40:37.188Z" }, + { url = "https://files.pythonhosted.org/packages/09/73/ad875b192bda14f2173bfc1bc9a55e009808484a4b256748d931b6948442/charset_normalizer-3.4.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d9e45d7faa48ee908174d8fe84854479ef838fc6a705c9315372eacbc2f02897", size = 157837, upload-time = "2025-10-14T04:40:38.435Z" }, + { url = "https://files.pythonhosted.org/packages/6d/fc/de9cce525b2c5b94b47c70a4b4fb19f871b24995c728e957ee68ab1671ea/charset_normalizer-3.4.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:840c25fb618a231545cbab0564a799f101b63b9901f2569faecd6b222ac72381", size = 151550, upload-time = "2025-10-14T04:40:40.053Z" }, + { url = "https://files.pythonhosted.org/packages/55/c2/43edd615fdfba8c6f2dfbd459b25a6b3b551f24ea21981e23fb768503ce1/charset_normalizer-3.4.4-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ca5862d5b3928c4940729dacc329aa9102900382fea192fc5e52eb69d6093815", size = 149162, upload-time = "2025-10-14T04:40:41.163Z" }, + { url = "https://files.pythonhosted.org/packages/03/86/bde4ad8b4d0e9429a4e82c1e8f5c659993a9a863ad62c7df05cf7b678d75/charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d9c7f57c3d666a53421049053eaacdd14bbd0a528e2186fcb2e672effd053bb0", size = 150019, upload-time = "2025-10-14T04:40:42.276Z" }, + { url = "https://files.pythonhosted.org/packages/1f/86/a151eb2af293a7e7bac3a739b81072585ce36ccfb4493039f49f1d3cae8c/charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:277e970e750505ed74c832b4bf75dac7476262ee2a013f5574dd49075879e161", size = 143310, upload-time = "2025-10-14T04:40:43.439Z" }, + { url = "https://files.pythonhosted.org/packages/b5/fe/43dae6144a7e07b87478fdfc4dbe9efd5defb0e7ec29f5f58a55aeef7bf7/charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:31fd66405eaf47bb62e8cd575dc621c56c668f27d46a61d975a249930dd5e2a4", size = 162022, upload-time = "2025-10-14T04:40:44.547Z" }, + { url = "https://files.pythonhosted.org/packages/80/e6/7aab83774f5d2bca81f42ac58d04caf44f0cc2b65fc6db2b3b2e8a05f3b3/charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:0d3d8f15c07f86e9ff82319b3d9ef6f4bf907608f53fe9d92b28ea9ae3d1fd89", size = 149383, upload-time = "2025-10-14T04:40:46.018Z" }, + { url = "https://files.pythonhosted.org/packages/4f/e8/b289173b4edae05c0dde07f69f8db476a0b511eac556dfe0d6bda3c43384/charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:9f7fcd74d410a36883701fafa2482a6af2ff5ba96b9a620e9e0721e28ead5569", size = 159098, upload-time = "2025-10-14T04:40:47.081Z" }, + { url = "https://files.pythonhosted.org/packages/d8/df/fe699727754cae3f8478493c7f45f777b17c3ef0600e28abfec8619eb49c/charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ebf3e58c7ec8a8bed6d66a75d7fb37b55e5015b03ceae72a8e7c74495551e224", size = 152991, upload-time = "2025-10-14T04:40:48.246Z" }, + { url = "https://files.pythonhosted.org/packages/1a/86/584869fe4ddb6ffa3bd9f491b87a01568797fb9bd8933f557dba9771beaf/charset_normalizer-3.4.4-cp311-cp311-win32.whl", hash = "sha256:eecbc200c7fd5ddb9a7f16c7decb07b566c29fa2161a16cf67b8d068bd21690a", size = 99456, upload-time = "2025-10-14T04:40:49.376Z" }, + { url = "https://files.pythonhosted.org/packages/65/f6/62fdd5feb60530f50f7e38b4f6a1d5203f4d16ff4f9f0952962c044e919a/charset_normalizer-3.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:5ae497466c7901d54b639cf42d5b8c1b6a4fead55215500d2f486d34db48d016", size = 106978, upload-time = "2025-10-14T04:40:50.844Z" }, + { url = "https://files.pythonhosted.org/packages/7a/9d/0710916e6c82948b3be62d9d398cb4fcf4e97b56d6a6aeccd66c4b2f2bd5/charset_normalizer-3.4.4-cp311-cp311-win_arm64.whl", hash = "sha256:65e2befcd84bc6f37095f5961e68a6f077bf44946771354a28ad434c2cce0ae1", size = 99969, upload-time = "2025-10-14T04:40:52.272Z" }, + { url = "https://files.pythonhosted.org/packages/f3/85/1637cd4af66fa687396e757dec650f28025f2a2f5a5531a3208dc0ec43f2/charset_normalizer-3.4.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0a98e6759f854bd25a58a73fa88833fba3b7c491169f86ce1180c948ab3fd394", size = 208425, upload-time = "2025-10-14T04:40:53.353Z" }, + { url = "https://files.pythonhosted.org/packages/9d/6a/04130023fef2a0d9c62d0bae2649b69f7b7d8d24ea5536feef50551029df/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b5b290ccc2a263e8d185130284f8501e3e36c5e02750fc6b6bdeb2e9e96f1e25", size = 148162, upload-time = "2025-10-14T04:40:54.558Z" }, + { url = "https://files.pythonhosted.org/packages/78/29/62328d79aa60da22c9e0b9a66539feae06ca0f5a4171ac4f7dc285b83688/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74bb723680f9f7a6234dcf67aea57e708ec1fbdf5699fb91dfd6f511b0a320ef", size = 144558, upload-time = "2025-10-14T04:40:55.677Z" }, + { url = "https://files.pythonhosted.org/packages/86/bb/b32194a4bf15b88403537c2e120b817c61cd4ecffa9b6876e941c3ee38fe/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f1e34719c6ed0b92f418c7c780480b26b5d9c50349e9a9af7d76bf757530350d", size = 161497, upload-time = "2025-10-14T04:40:57.217Z" }, + { url = "https://files.pythonhosted.org/packages/19/89/a54c82b253d5b9b111dc74aca196ba5ccfcca8242d0fb64146d4d3183ff1/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2437418e20515acec67d86e12bf70056a33abdacb5cb1655042f6538d6b085a8", size = 159240, upload-time = "2025-10-14T04:40:58.358Z" }, + { url = "https://files.pythonhosted.org/packages/c0/10/d20b513afe03acc89ec33948320a5544d31f21b05368436d580dec4e234d/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:11d694519d7f29d6cd09f6ac70028dba10f92f6cdd059096db198c283794ac86", size = 153471, upload-time = "2025-10-14T04:40:59.468Z" }, + { url = "https://files.pythonhosted.org/packages/61/fa/fbf177b55bdd727010f9c0a3c49eefa1d10f960e5f09d1d887bf93c2e698/charset_normalizer-3.4.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ac1c4a689edcc530fc9d9aa11f5774b9e2f33f9a0c6a57864e90908f5208d30a", size = 150864, upload-time = "2025-10-14T04:41:00.623Z" }, + { url = "https://files.pythonhosted.org/packages/05/12/9fbc6a4d39c0198adeebbde20b619790e9236557ca59fc40e0e3cebe6f40/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:21d142cc6c0ec30d2efee5068ca36c128a30b0f2c53c1c07bd78cb6bc1d3be5f", size = 150647, upload-time = "2025-10-14T04:41:01.754Z" }, + { url = "https://files.pythonhosted.org/packages/ad/1f/6a9a593d52e3e8c5d2b167daf8c6b968808efb57ef4c210acb907c365bc4/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:5dbe56a36425d26d6cfb40ce79c314a2e4dd6211d51d6d2191c00bed34f354cc", size = 145110, upload-time = "2025-10-14T04:41:03.231Z" }, + { url = "https://files.pythonhosted.org/packages/30/42/9a52c609e72471b0fc54386dc63c3781a387bb4fe61c20231a4ebcd58bdd/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:5bfbb1b9acf3334612667b61bd3002196fe2a1eb4dd74d247e0f2a4d50ec9bbf", size = 162839, upload-time = "2025-10-14T04:41:04.715Z" }, + { url = "https://files.pythonhosted.org/packages/c4/5b/c0682bbf9f11597073052628ddd38344a3d673fda35a36773f7d19344b23/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d055ec1e26e441f6187acf818b73564e6e6282709e9bcb5b63f5b23068356a15", size = 150667, upload-time = "2025-10-14T04:41:05.827Z" }, + { url = "https://files.pythonhosted.org/packages/e4/24/a41afeab6f990cf2daf6cb8c67419b63b48cf518e4f56022230840c9bfb2/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:af2d8c67d8e573d6de5bc30cdb27e9b95e49115cd9baad5ddbd1a6207aaa82a9", size = 160535, upload-time = "2025-10-14T04:41:06.938Z" }, + { url = "https://files.pythonhosted.org/packages/2a/e5/6a4ce77ed243c4a50a1fecca6aaaab419628c818a49434be428fe24c9957/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:780236ac706e66881f3b7f2f32dfe90507a09e67d1d454c762cf642e6e1586e0", size = 154816, upload-time = "2025-10-14T04:41:08.101Z" }, + { url = "https://files.pythonhosted.org/packages/a8/ef/89297262b8092b312d29cdb2517cb1237e51db8ecef2e9af5edbe7b683b1/charset_normalizer-3.4.4-cp312-cp312-win32.whl", hash = "sha256:5833d2c39d8896e4e19b689ffc198f08ea58116bee26dea51e362ecc7cd3ed26", size = 99694, upload-time = "2025-10-14T04:41:09.23Z" }, + { url = "https://files.pythonhosted.org/packages/3d/2d/1e5ed9dd3b3803994c155cd9aacb60c82c331bad84daf75bcb9c91b3295e/charset_normalizer-3.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:a79cfe37875f822425b89a82333404539ae63dbdddf97f84dcbc3d339aae9525", size = 107131, upload-time = "2025-10-14T04:41:10.467Z" }, + { url = "https://files.pythonhosted.org/packages/d0/d9/0ed4c7098a861482a7b6a95603edce4c0d9db2311af23da1fb2b75ec26fc/charset_normalizer-3.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:376bec83a63b8021bb5c8ea75e21c4ccb86e7e45ca4eb81146091b56599b80c3", size = 100390, upload-time = "2025-10-14T04:41:11.915Z" }, + { url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" }, +] + +[[package]] +name = "click" +version = "8.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "cryptography" +version = "46.0.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "platform_python_implementation != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9f/33/c00162f49c0e2fe8064a62cb92b93e50c74a72bc370ab92f86112b33ff62/cryptography-46.0.3.tar.gz", hash = "sha256:a8b17438104fed022ce745b362294d9ce35b4c2e45c1d958ad4a4b019285f4a1", size = 749258, upload-time = "2025-10-15T23:18:31.74Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/42/9c391dd801d6cf0d561b5890549d4b27bafcc53b39c31a817e69d87c625b/cryptography-46.0.3-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:109d4ddfadf17e8e7779c39f9b18111a09efb969a301a31e987416a0191ed93a", size = 7225004, upload-time = "2025-10-15T23:16:52.239Z" }, + { url = "https://files.pythonhosted.org/packages/1c/67/38769ca6b65f07461eb200e85fc1639b438bdc667be02cf7f2cd6a64601c/cryptography-46.0.3-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:09859af8466b69bc3c27bdf4f5d84a665e0f7ab5088412e9e2ec49758eca5cbc", size = 4296667, upload-time = "2025-10-15T23:16:54.369Z" }, + { url = "https://files.pythonhosted.org/packages/5c/49/498c86566a1d80e978b42f0d702795f69887005548c041636df6ae1ca64c/cryptography-46.0.3-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:01ca9ff2885f3acc98c29f1860552e37f6d7c7d013d7334ff2a9de43a449315d", size = 4450807, upload-time = "2025-10-15T23:16:56.414Z" }, + { url = "https://files.pythonhosted.org/packages/4b/0a/863a3604112174c8624a2ac3c038662d9e59970c7f926acdcfaed8d61142/cryptography-46.0.3-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:6eae65d4c3d33da080cff9c4ab1f711b15c1d9760809dad6ea763f3812d254cb", size = 4299615, upload-time = "2025-10-15T23:16:58.442Z" }, + { url = "https://files.pythonhosted.org/packages/64/02/b73a533f6b64a69f3cd3872acb6ebc12aef924d8d103133bb3ea750dc703/cryptography-46.0.3-cp311-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:e5bf0ed4490068a2e72ac03d786693adeb909981cc596425d09032d372bcc849", size = 4016800, upload-time = "2025-10-15T23:17:00.378Z" }, + { url = "https://files.pythonhosted.org/packages/25/d5/16e41afbfa450cde85a3b7ec599bebefaef16b5c6ba4ec49a3532336ed72/cryptography-46.0.3-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:5ecfccd2329e37e9b7112a888e76d9feca2347f12f37918facbb893d7bb88ee8", size = 4984707, upload-time = "2025-10-15T23:17:01.98Z" }, + { url = "https://files.pythonhosted.org/packages/c9/56/e7e69b427c3878352c2fb9b450bd0e19ed552753491d39d7d0a2f5226d41/cryptography-46.0.3-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:a2c0cd47381a3229c403062f764160d57d4d175e022c1df84e168c6251a22eec", size = 4482541, upload-time = "2025-10-15T23:17:04.078Z" }, + { url = "https://files.pythonhosted.org/packages/78/f6/50736d40d97e8483172f1bb6e698895b92a223dba513b0ca6f06b2365339/cryptography-46.0.3-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:549e234ff32571b1f4076ac269fcce7a808d3bf98b76c8dd560e42dbc66d7d91", size = 4299464, upload-time = "2025-10-15T23:17:05.483Z" }, + { url = "https://files.pythonhosted.org/packages/00/de/d8e26b1a855f19d9994a19c702fa2e93b0456beccbcfe437eda00e0701f2/cryptography-46.0.3-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:c0a7bb1a68a5d3471880e264621346c48665b3bf1c3759d682fc0864c540bd9e", size = 4950838, upload-time = "2025-10-15T23:17:07.425Z" }, + { url = "https://files.pythonhosted.org/packages/8f/29/798fc4ec461a1c9e9f735f2fc58741b0daae30688f41b2497dcbc9ed1355/cryptography-46.0.3-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:10b01676fc208c3e6feeb25a8b83d81767e8059e1fe86e1dc62d10a3018fa926", size = 4481596, upload-time = "2025-10-15T23:17:09.343Z" }, + { url = "https://files.pythonhosted.org/packages/15/8d/03cd48b20a573adfff7652b76271078e3045b9f49387920e7f1f631d125e/cryptography-46.0.3-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:0abf1ffd6e57c67e92af68330d05760b7b7efb243aab8377e583284dbab72c71", size = 4426782, upload-time = "2025-10-15T23:17:11.22Z" }, + { url = "https://files.pythonhosted.org/packages/fa/b1/ebacbfe53317d55cf33165bda24c86523497a6881f339f9aae5c2e13e57b/cryptography-46.0.3-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a04bee9ab6a4da801eb9b51f1b708a1b5b5c9eb48c03f74198464c66f0d344ac", size = 4698381, upload-time = "2025-10-15T23:17:12.829Z" }, + { url = "https://files.pythonhosted.org/packages/96/92/8a6a9525893325fc057a01f654d7efc2c64b9de90413adcf605a85744ff4/cryptography-46.0.3-cp311-abi3-win32.whl", hash = "sha256:f260d0d41e9b4da1ed1e0f1ce571f97fe370b152ab18778e9e8f67d6af432018", size = 3055988, upload-time = "2025-10-15T23:17:14.65Z" }, + { url = "https://files.pythonhosted.org/packages/7e/bf/80fbf45253ea585a1e492a6a17efcb93467701fa79e71550a430c5e60df0/cryptography-46.0.3-cp311-abi3-win_amd64.whl", hash = "sha256:a9a3008438615669153eb86b26b61e09993921ebdd75385ddd748702c5adfddb", size = 3514451, upload-time = "2025-10-15T23:17:16.142Z" }, + { url = "https://files.pythonhosted.org/packages/2e/af/9b302da4c87b0beb9db4e756386a7c6c5b8003cd0e742277888d352ae91d/cryptography-46.0.3-cp311-abi3-win_arm64.whl", hash = "sha256:5d7f93296ee28f68447397bf5198428c9aeeab45705a55d53a6343455dcb2c3c", size = 2928007, upload-time = "2025-10-15T23:17:18.04Z" }, + { url = "https://files.pythonhosted.org/packages/fd/23/45fe7f376a7df8daf6da3556603b36f53475a99ce4faacb6ba2cf3d82021/cryptography-46.0.3-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:cb3d760a6117f621261d662bccc8ef5bc32ca673e037c83fbe565324f5c46936", size = 7218248, upload-time = "2025-10-15T23:17:46.294Z" }, + { url = "https://files.pythonhosted.org/packages/27/32/b68d27471372737054cbd34c84981f9edbc24fe67ca225d389799614e27f/cryptography-46.0.3-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:4b7387121ac7d15e550f5cb4a43aef2559ed759c35df7336c402bb8275ac9683", size = 4294089, upload-time = "2025-10-15T23:17:48.269Z" }, + { url = "https://files.pythonhosted.org/packages/26/42/fa8389d4478368743e24e61eea78846a0006caffaf72ea24a15159215a14/cryptography-46.0.3-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:15ab9b093e8f09daab0f2159bb7e47532596075139dd74365da52ecc9cb46c5d", size = 4440029, upload-time = "2025-10-15T23:17:49.837Z" }, + { url = "https://files.pythonhosted.org/packages/5f/eb/f483db0ec5ac040824f269e93dd2bd8a21ecd1027e77ad7bdf6914f2fd80/cryptography-46.0.3-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:46acf53b40ea38f9c6c229599a4a13f0d46a6c3fa9ef19fc1a124d62e338dfa0", size = 4297222, upload-time = "2025-10-15T23:17:51.357Z" }, + { url = "https://files.pythonhosted.org/packages/fd/cf/da9502c4e1912cb1da3807ea3618a6829bee8207456fbbeebc361ec38ba3/cryptography-46.0.3-cp38-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:10ca84c4668d066a9878890047f03546f3ae0a6b8b39b697457b7757aaf18dbc", size = 4012280, upload-time = "2025-10-15T23:17:52.964Z" }, + { url = "https://files.pythonhosted.org/packages/6b/8f/9adb86b93330e0df8b3dcf03eae67c33ba89958fc2e03862ef1ac2b42465/cryptography-46.0.3-cp38-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:36e627112085bb3b81b19fed209c05ce2a52ee8b15d161b7c643a7d5a88491f3", size = 4978958, upload-time = "2025-10-15T23:17:54.965Z" }, + { url = "https://files.pythonhosted.org/packages/d1/a0/5fa77988289c34bdb9f913f5606ecc9ada1adb5ae870bd0d1054a7021cc4/cryptography-46.0.3-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:1000713389b75c449a6e979ffc7dcc8ac90b437048766cef052d4d30b8220971", size = 4473714, upload-time = "2025-10-15T23:17:56.754Z" }, + { url = "https://files.pythonhosted.org/packages/14/e5/fc82d72a58d41c393697aa18c9abe5ae1214ff6f2a5c18ac470f92777895/cryptography-46.0.3-cp38-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:b02cf04496f6576afffef5ddd04a0cb7d49cf6be16a9059d793a30b035f6b6ac", size = 4296970, upload-time = "2025-10-15T23:17:58.588Z" }, + { url = "https://files.pythonhosted.org/packages/78/06/5663ed35438d0b09056973994f1aec467492b33bd31da36e468b01ec1097/cryptography-46.0.3-cp38-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:71e842ec9bc7abf543b47cf86b9a743baa95f4677d22baa4c7d5c69e49e9bc04", size = 4940236, upload-time = "2025-10-15T23:18:00.897Z" }, + { url = "https://files.pythonhosted.org/packages/fc/59/873633f3f2dcd8a053b8dd1d38f783043b5fce589c0f6988bf55ef57e43e/cryptography-46.0.3-cp38-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:402b58fc32614f00980b66d6e56a5b4118e6cb362ae8f3fda141ba4689bd4506", size = 4472642, upload-time = "2025-10-15T23:18:02.749Z" }, + { url = "https://files.pythonhosted.org/packages/3d/39/8e71f3930e40f6877737d6f69248cf74d4e34b886a3967d32f919cc50d3b/cryptography-46.0.3-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ef639cb3372f69ec44915fafcd6698b6cc78fbe0c2ea41be867f6ed612811963", size = 4423126, upload-time = "2025-10-15T23:18:04.85Z" }, + { url = "https://files.pythonhosted.org/packages/cd/c7/f65027c2810e14c3e7268353b1681932b87e5a48e65505d8cc17c99e36ae/cryptography-46.0.3-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:3b51b8ca4f1c6453d8829e1eb7299499ca7f313900dd4d89a24b8b87c0a780d4", size = 4686573, upload-time = "2025-10-15T23:18:06.908Z" }, + { url = "https://files.pythonhosted.org/packages/0a/6e/1c8331ddf91ca4730ab3086a0f1be19c65510a33b5a441cb334e7a2d2560/cryptography-46.0.3-cp38-abi3-win32.whl", hash = "sha256:6276eb85ef938dc035d59b87c8a7dc559a232f954962520137529d77b18ff1df", size = 3036695, upload-time = "2025-10-15T23:18:08.672Z" }, + { url = "https://files.pythonhosted.org/packages/90/45/b0d691df20633eff80955a0fc7695ff9051ffce8b69741444bd9ed7bd0db/cryptography-46.0.3-cp38-abi3-win_amd64.whl", hash = "sha256:416260257577718c05135c55958b674000baef9a1c7d9e8f306ec60d71db850f", size = 3501720, upload-time = "2025-10-15T23:18:10.632Z" }, + { url = "https://files.pythonhosted.org/packages/e8/cb/2da4cc83f5edb9c3257d09e1e7ab7b23f049c7962cae8d842bbef0a9cec9/cryptography-46.0.3-cp38-abi3-win_arm64.whl", hash = "sha256:d89c3468de4cdc4f08a57e214384d0471911a3830fcdaf7a8cc587e42a866372", size = 2918740, upload-time = "2025-10-15T23:18:12.277Z" }, + { url = "https://files.pythonhosted.org/packages/06/8a/e60e46adab4362a682cf142c7dcb5bf79b782ab2199b0dcb81f55970807f/cryptography-46.0.3-pp311-pypy311_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7ce938a99998ed3c8aa7e7272dca1a610401ede816d36d0693907d863b10d9ea", size = 3698132, upload-time = "2025-10-15T23:18:17.056Z" }, + { url = "https://files.pythonhosted.org/packages/da/38/f59940ec4ee91e93d3311f7532671a5cef5570eb04a144bf203b58552d11/cryptography-46.0.3-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:191bb60a7be5e6f54e30ba16fdfae78ad3a342a0599eb4193ba88e3f3d6e185b", size = 4243992, upload-time = "2025-10-15T23:18:18.695Z" }, + { url = "https://files.pythonhosted.org/packages/b0/0c/35b3d92ddebfdfda76bb485738306545817253d0a3ded0bfe80ef8e67aa5/cryptography-46.0.3-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:c70cc23f12726be8f8bc72e41d5065d77e4515efae3690326764ea1b07845cfb", size = 4409944, upload-time = "2025-10-15T23:18:20.597Z" }, + { url = "https://files.pythonhosted.org/packages/99/55/181022996c4063fc0e7666a47049a1ca705abb9c8a13830f074edb347495/cryptography-46.0.3-pp311-pypy311_pp73-manylinux_2_34_aarch64.whl", hash = "sha256:9394673a9f4de09e28b5356e7fff97d778f8abad85c9d5ac4a4b7e25a0de7717", size = 4242957, upload-time = "2025-10-15T23:18:22.18Z" }, + { url = "https://files.pythonhosted.org/packages/ba/af/72cd6ef29f9c5f731251acadaeb821559fe25f10852f44a63374c9ca08c1/cryptography-46.0.3-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl", hash = "sha256:94cd0549accc38d1494e1f8de71eca837d0509d0d44bf11d158524b0e12cebf9", size = 4409447, upload-time = "2025-10-15T23:18:24.209Z" }, + { url = "https://files.pythonhosted.org/packages/0d/c3/e90f4a4feae6410f914f8ebac129b9ae7a8c92eb60a638012dde42030a9d/cryptography-46.0.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:6b5063083824e5509fdba180721d55909ffacccc8adbec85268b48439423d78c", size = 3438528, upload-time = "2025-10-15T23:18:26.227Z" }, +] + +[[package]] +name = "dataclasses-json" +version = "0.6.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "marshmallow" }, + { name = "typing-inspect" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/64/a4/f71d9cf3a5ac257c993b5ca3f93df5f7fb395c725e7f1e6479d2514173c3/dataclasses_json-0.6.7.tar.gz", hash = "sha256:b6b3e528266ea45b9535223bc53ca645f5208833c29229e847b3f26a1cc55fc0", size = 32227, upload-time = "2024-06-09T16:20:19.103Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c3/be/d0d44e092656fe7a06b55e6103cbce807cdbdee17884a5367c68c9860853/dataclasses_json-0.6.7-py3-none-any.whl", hash = "sha256:0dbf33f26c8d5305befd61b39d2b3414e8a407bedc2834dea9b8d642666fb40a", size = 28686, upload-time = "2024-06-09T16:20:16.715Z" }, +] + +[[package]] +name = "decorator" +version = "5.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/fa/6d96a0978d19e17b68d634497769987b16c8f4cd0a7a05048bec693caa6b/decorator-5.2.1.tar.gz", hash = "sha256:65f266143752f734b0a7cc83c46f4618af75b8c5911b00ccb61d0ac9b6da0360", size = 56711, upload-time = "2025-02-24T04:41:34.073Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190, upload-time = "2025-02-24T04:41:32.565Z" }, +] + +[[package]] +name = "defusedxml" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0f/d5/c66da9b79e5bdb124974bfe172b4daf3c984ebd9c2a06e2b8a4dc7331c72/defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69", size = 75520, upload-time = "2021-03-08T10:59:26.269Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/07/6c/aa3f2f849e01cb6a001cd8554a88d4c77c5c1a31c95bdf1cf9301e6d9ef4/defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61", size = 25604, upload-time = "2021-03-08T10:59:24.45Z" }, +] + +[[package]] +name = "distlib" +version = "0.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/96/8e/709914eb2b5749865801041647dc7f4e6d00b549cfe88b65ca192995f07c/distlib-0.4.0.tar.gz", hash = "sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d", size = 614605, upload-time = "2025-07-17T16:52:00.465Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/6b/e0547afaf41bf2c42e52430072fa5658766e3d65bd4b03a563d1b6336f57/distlib-0.4.0-py2.py3-none-any.whl", hash = "sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16", size = 469047, upload-time = "2025-07-17T16:51:58.613Z" }, +] + +[[package]] +name = "distro" +version = "1.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, +] + +[[package]] +name = "docopt" +version = "0.6.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz", hash = "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491", size = 25901, upload-time = "2014-06-16T11:18:57.406Z" } + +[[package]] +name = "docstring-parser" +version = "0.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b2/9d/c3b43da9515bd270df0f80548d9944e389870713cc1fe2b8fb35fe2bcefd/docstring_parser-0.17.0.tar.gz", hash = "sha256:583de4a309722b3315439bb31d64ba3eebada841f2e2cee23b99df001434c912", size = 27442, upload-time = "2025-07-21T07:35:01.868Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/55/e2/2537ebcff11c1ee1ff17d8d0b6f4db75873e3b0fb32c2d4a2ee31ecb310a/docstring_parser-0.17.0-py3-none-any.whl", hash = "sha256:cf2569abd23dce8099b300f9b4fa8191e9582dda731fd533daf54c4551658708", size = 36896, upload-time = "2025-07-21T07:35:00.684Z" }, +] + +[[package]] +name = "emoji" +version = "2.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/78/0d2db9382c92a163d7095fc08efff7800880f830a152cfced40161e7638d/emoji-2.15.0.tar.gz", hash = "sha256:eae4ab7d86456a70a00a985125a03263a5eac54cd55e51d7e184b1ed3b6757e4", size = 615483, upload-time = "2025-09-21T12:13:02.755Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e1/5e/4b5aaaabddfacfe36ba7768817bd1f71a7a810a43705e531f3ae4c690767/emoji-2.15.0-py3-none-any.whl", hash = "sha256:205296793d66a89d88af4688fa57fd6496732eb48917a87175a023c8138995eb", size = 608433, upload-time = "2025-09-21T12:13:01.197Z" }, +] + +[[package]] +name = "executing" +version = "2.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cc/28/c14e053b6762b1044f34a13aab6859bbf40456d37d23aa286ac24cfd9a5d/executing-2.2.1.tar.gz", hash = "sha256:3632cc370565f6648cc328b32435bd120a1e4ebb20c77e3fdde9a13cd1e533c4", size = 1129488, upload-time = "2025-09-01T09:48:10.866Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/ea/53f2148663b321f21b5a606bd5f191517cf40b7072c0497d3c92c4a13b1e/executing-2.2.1-py2.py3-none-any.whl", hash = "sha256:760643d3452b4d777d295bb167ccc74c64a81df23fb5e08eff250c425a4b2017", size = 28317, upload-time = "2025-09-01T09:48:08.5Z" }, +] + +[[package]] +name = "fastjsonschema" +version = "2.21.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/20/b5/23b216d9d985a956623b6bd12d4086b60f0059b27799f23016af04a74ea1/fastjsonschema-2.21.2.tar.gz", hash = "sha256:b1eb43748041c880796cd077f1a07c3d94e93ae84bba5ed36800a33554ae05de", size = 374130, upload-time = "2025-08-14T18:49:36.666Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/a8/20d0723294217e47de6d9e2e40fd4a9d2f7c4b6ef974babd482a59743694/fastjsonschema-2.21.2-py3-none-any.whl", hash = "sha256:1c797122d0a86c5cace2e54bf4e819c36223b552017172f32c5c024a6b77e463", size = 24024, upload-time = "2025-08-14T18:49:34.776Z" }, +] + +[[package]] +name = "filelock" +version = "3.20.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a7/23/ce7a1126827cedeb958fc043d61745754464eb56c5937c35bbf2b8e26f34/filelock-3.20.1.tar.gz", hash = "sha256:b8360948b351b80f420878d8516519a2204b07aefcdcfd24912a5d33127f188c", size = 19476, upload-time = "2025-12-15T23:54:28.027Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e3/7f/a1a97644e39e7316d850784c642093c99df1290a460df4ede27659056834/filelock-3.20.1-py3-none-any.whl", hash = "sha256:15d9e9a67306188a44baa72f569d2bfd803076269365fdea0934385da4dc361a", size = 16666, upload-time = "2025-12-15T23:54:26.874Z" }, +] + +[[package]] +name = "filetype" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bb/29/745f7d30d47fe0f251d3ad3dc2978a23141917661998763bebb6da007eb1/filetype-1.2.0.tar.gz", hash = "sha256:66b56cd6474bf41d8c54660347d37afcc3f7d1970648de365c102ef77548aadb", size = 998020, upload-time = "2022-11-02T17:34:04.141Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/79/1b8fa1bb3568781e84c9200f951c735f3f157429f44be0495da55894d620/filetype-1.2.0-py2.py3-none-any.whl", hash = "sha256:7ce71b6880181241cf7ac8697a2f1eb6a8bd9b429f7ad6d27b8db9ba5f1c2d25", size = 19970, upload-time = "2022-11-02T17:34:01.425Z" }, +] + +[[package]] +name = "flask" +version = "3.1.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "blinker" }, + { name = "click" }, + { name = "itsdangerous" }, + { name = "jinja2" }, + { name = "markupsafe" }, + { name = "werkzeug" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/dc/6d/cfe3c0fcc5e477df242b98bfe186a4c34357b4847e87ecaef04507332dab/flask-3.1.2.tar.gz", hash = "sha256:bf656c15c80190ed628ad08cdfd3aaa35beb087855e2f494910aa3774cc4fd87", size = 720160, upload-time = "2025-08-19T21:03:21.205Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/f9/7f9263c5695f4bd0023734af91bedb2ff8209e8de6ead162f35d8dc762fd/flask-3.1.2-py3-none-any.whl", hash = "sha256:ca1d8112ec8a6158cc29ea4858963350011b5c846a414cdb7a954aa9e967d03c", size = 103308, upload-time = "2025-08-19T21:03:19.499Z" }, +] + +[[package]] +name = "flask-cors" +version = "6.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flask" }, + { name = "werkzeug" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/70/74/0fc0fa68d62f21daef41017dafab19ef4b36551521260987eb3a5394c7ba/flask_cors-6.0.2.tar.gz", hash = "sha256:6e118f3698249ae33e429760db98ce032a8bf9913638d085ca0f4c5534ad2423", size = 13472, upload-time = "2025-12-12T20:31:42.861Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4f/af/72ad54402e599152de6d067324c46fe6a4f531c7c65baf7e96c63db55eaf/flask_cors-6.0.2-py3-none-any.whl", hash = "sha256:e57544d415dfd7da89a9564e1e3a9e515042df76e12130641ca6f3f2f03b699a", size = 13257, upload-time = "2025-12-12T20:31:41.3Z" }, +] + +[[package]] +name = "fsspec" +version = "2025.12.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b6/27/954057b0d1f53f086f681755207dda6de6c660ce133c829158e8e8fe7895/fsspec-2025.12.0.tar.gz", hash = "sha256:c505de011584597b1060ff778bb664c1bc022e87921b0e4f10cc9c44f9635973", size = 309748, upload-time = "2025-12-03T15:23:42.687Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/c7/b64cae5dba3a1b138d7123ec36bb5ccd39d39939f18454407e5468f4763f/fsspec-2025.12.0-py3-none-any.whl", hash = "sha256:8bf1fe301b7d8acfa6e8571e3b1c3d158f909666642431cc78a1b7b4dbc5ec5b", size = 201422, upload-time = "2025-12-03T15:23:41.434Z" }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "hf-xet" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5e/6e/0f11bacf08a67f7fb5ee09740f2ca54163863b07b70d579356e9222ce5d8/hf_xet-1.2.0.tar.gz", hash = "sha256:a8c27070ca547293b6890c4bf389f713f80e8c478631432962bb7f4bc0bd7d7f", size = 506020, upload-time = "2025-10-24T19:04:32.129Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/96/2d/22338486473df5923a9ab7107d375dbef9173c338ebef5098ef593d2b560/hf_xet-1.2.0-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:46740d4ac024a7ca9b22bebf77460ff43332868b661186a8e46c227fdae01848", size = 2866099, upload-time = "2025-10-24T19:04:15.366Z" }, + { url = "https://files.pythonhosted.org/packages/7f/8c/c5becfa53234299bc2210ba314eaaae36c2875e0045809b82e40a9544f0c/hf_xet-1.2.0-cp37-abi3-macosx_11_0_arm64.whl", hash = "sha256:27df617a076420d8845bea087f59303da8be17ed7ec0cd7ee3b9b9f579dff0e4", size = 2722178, upload-time = "2025-10-24T19:04:13.695Z" }, + { url = "https://files.pythonhosted.org/packages/9a/92/cf3ab0b652b082e66876d08da57fcc6fa2f0e6c70dfbbafbd470bb73eb47/hf_xet-1.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3651fd5bfe0281951b988c0facbe726aa5e347b103a675f49a3fa8144c7968fd", size = 3320214, upload-time = "2025-10-24T19:04:03.596Z" }, + { url = "https://files.pythonhosted.org/packages/46/92/3f7ec4a1b6a65bf45b059b6d4a5d38988f63e193056de2f420137e3c3244/hf_xet-1.2.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:d06fa97c8562fb3ee7a378dd9b51e343bc5bc8190254202c9771029152f5e08c", size = 3229054, upload-time = "2025-10-24T19:04:01.949Z" }, + { url = "https://files.pythonhosted.org/packages/0b/dd/7ac658d54b9fb7999a0ccb07ad863b413cbaf5cf172f48ebcd9497ec7263/hf_xet-1.2.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:4c1428c9ae73ec0939410ec73023c4f842927f39db09b063b9482dac5a3bb737", size = 3413812, upload-time = "2025-10-24T19:04:24.585Z" }, + { url = "https://files.pythonhosted.org/packages/92/68/89ac4e5b12a9ff6286a12174c8538a5930e2ed662091dd2572bbe0a18c8a/hf_xet-1.2.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a55558084c16b09b5ed32ab9ed38421e2d87cf3f1f89815764d1177081b99865", size = 3508920, upload-time = "2025-10-24T19:04:26.927Z" }, + { url = "https://files.pythonhosted.org/packages/cb/44/870d44b30e1dcfb6a65932e3e1506c103a8a5aea9103c337e7a53180322c/hf_xet-1.2.0-cp37-abi3-win_amd64.whl", hash = "sha256:e6584a52253f72c9f52f9e549d5895ca7a471608495c4ecaa6cc73dba2b24d69", size = 2905735, upload-time = "2025-10-24T19:04:35.928Z" }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, +] + +[[package]] +name = "httpx-sse" +version = "0.4.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0f/4c/751061ffa58615a32c31b2d82e8482be8dd4a89154f003147acee90f2be9/httpx_sse-0.4.3.tar.gz", hash = "sha256:9b1ed0127459a66014aec3c56bebd93da3c1bc8bb6618c8082039a44889a755d", size = 15943, upload-time = "2025-10-10T21:48:22.271Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/fd/6668e5aec43ab844de6fc74927e155a3b37bf40d7c3790e49fc0406b6578/httpx_sse-0.4.3-py3-none-any.whl", hash = "sha256:0ac1c9fe3c0afad2e0ebb25a934a59f4c7823b60792691f779fad2c5568830fc", size = 8960, upload-time = "2025-10-10T21:48:21.158Z" }, +] + +[[package]] +name = "huggingface-hub" +version = "0.36.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "filelock" }, + { name = "fsspec" }, + { name = "hf-xet", marker = "platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'" }, + { name = "packaging" }, + { name = "pyyaml" }, + { name = "requests" }, + { name = "tqdm" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/98/63/4910c5fa9128fdadf6a9c5ac138e8b1b6cee4ca44bf7915bbfbce4e355ee/huggingface_hub-0.36.0.tar.gz", hash = "sha256:47b3f0e2539c39bf5cde015d63b72ec49baff67b6931c3d97f3f84532e2b8d25", size = 463358, upload-time = "2025-10-23T12:12:01.413Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/bd/1a875e0d592d447cbc02805fd3fe0f497714d6a2583f59d14fa9ebad96eb/huggingface_hub-0.36.0-py3-none-any.whl", hash = "sha256:7bcc9ad17d5b3f07b57c78e79d527102d08313caa278a641993acddcb894548d", size = 566094, upload-time = "2025-10-23T12:11:59.557Z" }, +] + +[[package]] +name = "identify" +version = "2.6.15" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ff/e7/685de97986c916a6d93b3876139e00eef26ad5bbbd61925d670ae8013449/identify-2.6.15.tar.gz", hash = "sha256:e4f4864b96c6557ef2a1e1c951771838f4edc9df3a72ec7118b338801b11c7bf", size = 99311, upload-time = "2025-10-02T17:43:40.631Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0f/1c/e5fd8f973d4f375adb21565739498e2e9a1e54c858a97b9a8ccfdc81da9b/identify-2.6.15-py2.py3-none-any.whl", hash = "sha256:1181ef7608e00704db228516541eb83a88a9f94433a8c80bb9b5bd54b1d81757", size = 99183, upload-time = "2025-10-02T17:43:39.137Z" }, +] + +[[package]] +name = "idna" +version = "3.11" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, +] + +[[package]] +name = "igraph" +version = "0.11.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "texttable" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5f/a0/1f70c34a96dcb0acf428319e83655e92ab2955d73a33f711852a5fb79681/igraph-0.11.6.tar.gz", hash = "sha256:837f233256c3319f2a35a6a80d94eafe47b43791ef4c6f9e9871061341ac8e28", size = 4559252, upload-time = "2024-07-08T23:38:32.722Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/f5/2de2ff541a014c3387c0c570a91e51b80643d9a2a3e0dec8030bcec3083d/igraph-0.11.6-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:8aabef03d787b519d1075dfc0da4a1109fb113b941334883e3e7947ac30a459e", size = 1945799, upload-time = "2024-07-08T23:37:32.692Z" }, + { url = "https://files.pythonhosted.org/packages/e4/3b/5cf3b131d433dea61608ea2c27bebf74de9cc7a50ced0b26311d6288294e/igraph-0.11.6-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:1f2cc4a518d99cdf6cae514f85e93e56852bc8c325b3abb96037d1d690b5975f", size = 1751328, upload-time = "2024-07-08T23:37:34.415Z" }, + { url = "https://files.pythonhosted.org/packages/fc/71/71cd93c1b26e6051ef5dfad94333690188e663942e54bea6bbfff79d2dbe/igraph-0.11.6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1e859238be52ab8ccc614d18f9362942bc88ce543afc12548f81ae99b10801d", size = 2974608, upload-time = "2024-07-08T23:37:36.076Z" }, + { url = "https://files.pythonhosted.org/packages/19/ec/02e596595776367f5fd07c65a56ff1593680273f935c481975fe6a55e67f/igraph-0.11.6-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d61fbe5e85eb4ae9efe08c461f9bdeedb02a2b5739fbc223d324a71f40a28be2", size = 3054685, upload-time = "2024-07-08T23:37:38.121Z" }, + { url = "https://files.pythonhosted.org/packages/02/f2/70849b7ff0fbfd3e7c964ac737ea973d0121d30a32a18894df6d0843bd0c/igraph-0.11.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b6620ba39df29fd42151becf82309b54e57148233c9c3ef890eed62e25eed8a5", size = 3134936, upload-time = "2024-07-08T23:37:40.497Z" }, + { url = "https://files.pythonhosted.org/packages/ef/49/579f3a5daea1a672f05c95ead488e779f1479a8efb78715c1508f7dae58a/igraph-0.11.6-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:59666589bb3d07f310cda2c5106a8adeeb77c2ef27fecf1c6438b6091f4ca69d", size = 3887705, upload-time = "2024-07-08T23:37:42.914Z" }, + { url = "https://files.pythonhosted.org/packages/ef/d2/66203ba13f90ea77f541c0f5b5ae095a7ced0a564486f576e5adce0d0bd7/igraph-0.11.6-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:8750b6d6caebf199cf7dc41c931f58e330153779707391e30f0a29f02666fb6e", size = 4158876, upload-time = "2024-07-08T23:37:45.708Z" }, + { url = "https://files.pythonhosted.org/packages/53/e7/3fbe83625efb1dd5f387a9da9ec0ac779a2dc42e6db0ac7eb54c44943b2f/igraph-0.11.6-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:967d6f2c30fe94317da15e459374d0fb8ca3e56020412f201ecd07dd5b5352f2", size = 4050715, upload-time = "2024-07-08T23:37:48.478Z" }, + { url = "https://files.pythonhosted.org/packages/ab/91/2535aa81a1de36f5b21df129b3434a18710d31ea56efbf0ec6e1f1958fda/igraph-0.11.6-cp39-abi3-win32.whl", hash = "sha256:9744f95a67319eb6cb487ceabf30f5d7940de34bada51f0ba63adbd23e0f94ad", size = 1589990, upload-time = "2024-07-08T23:37:50.825Z" }, + { url = "https://files.pythonhosted.org/packages/08/4a/e781867fa2fb41d823a8f1978ac464aef3d78bb73c6f40589a74cc47bf42/igraph-0.11.6-cp39-abi3-win_amd64.whl", hash = "sha256:b80e69eb11faa9c57330a9ffebdde5808966efe1c1f638d4d4827ea04df7aca8", size = 1965492, upload-time = "2024-07-08T23:37:53.203Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, +] + +[[package]] +name = "ipython" +version = "8.12.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "appnope", marker = "sys_platform == 'darwin'" }, + { name = "backcall" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "decorator" }, + { name = "jedi" }, + { name = "matplotlib-inline" }, + { name = "pexpect", marker = "sys_platform != 'win32'" }, + { name = "pickleshare" }, + { name = "prompt-toolkit" }, + { name = "pygments" }, + { name = "stack-data" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/6a/44ef299b1762f5a73841e87fae8a73a8cc8aee538d6dc8c77a5afe1fd2ce/ipython-8.12.3.tar.gz", hash = "sha256:3910c4b54543c2ad73d06579aa771041b7d5707b033bd488669b4cf544e3b363", size = 5470171, upload-time = "2023-09-29T09:14:37.468Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8d/97/8fe103906cd81bc42d3b0175b5534a9f67dccae47d6451131cf8d0d70bb2/ipython-8.12.3-py3-none-any.whl", hash = "sha256:b0340d46a933d27c657b211a329d0be23793c36595acf9e6ef4164bc01a1804c", size = 798307, upload-time = "2023-09-29T09:14:34.431Z" }, +] + +[[package]] +name = "itsdangerous" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload-time = "2024-04-16T21:28:15.614Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload-time = "2024-04-16T21:28:14.499Z" }, +] + +[[package]] +name = "jedi" +version = "0.19.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "parso" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/72/3a/79a912fbd4d8dd6fbb02bf69afd3bb72cf0c729bb3063c6f4498603db17a/jedi-0.19.2.tar.gz", hash = "sha256:4770dc3de41bde3966b02eb84fbcf557fb33cce26ad23da12c742fb50ecb11f0", size = 1231287, upload-time = "2024-11-11T01:41:42.873Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whl", hash = "sha256:a8ef22bde8490f57fe5c7681a3c83cb58874daf72b4784de3cce5b6ef6edb5b9", size = 1572278, upload-time = "2024-11-11T01:41:40.175Z" }, +] + +[[package]] +name = "jinja2" +version = "3.1.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload-time = "2025-03-05T20:05:02.478Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" }, +] + +[[package]] +name = "jiter" +version = "0.12.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/45/9d/e0660989c1370e25848bb4c52d061c71837239738ad937e83edca174c273/jiter-0.12.0.tar.gz", hash = "sha256:64dfcd7d5c168b38d3f9f8bba7fc639edb3418abcc74f22fdbe6b8938293f30b", size = 168294, upload-time = "2025-11-09T20:49:23.302Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/f9/eaca4633486b527ebe7e681c431f529b63fe2709e7c5242fc0f43f77ce63/jiter-0.12.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d8f8a7e317190b2c2d60eb2e8aa835270b008139562d70fe732e1c0020ec53c9", size = 316435, upload-time = "2025-11-09T20:47:02.087Z" }, + { url = "https://files.pythonhosted.org/packages/10/c1/40c9f7c22f5e6ff715f28113ebaba27ab85f9af2660ad6e1dd6425d14c19/jiter-0.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2218228a077e784c6c8f1a8e5d6b8cb1dea62ce25811c356364848554b2056cd", size = 320548, upload-time = "2025-11-09T20:47:03.409Z" }, + { url = "https://files.pythonhosted.org/packages/6b/1b/efbb68fe87e7711b00d2cfd1f26bb4bfc25a10539aefeaa7727329ffb9cb/jiter-0.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9354ccaa2982bf2188fd5f57f79f800ef622ec67beb8329903abf6b10da7d423", size = 351915, upload-time = "2025-11-09T20:47:05.171Z" }, + { url = "https://files.pythonhosted.org/packages/15/2d/c06e659888c128ad1e838123d0638f0efad90cc30860cb5f74dd3f2fc0b3/jiter-0.12.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8f2607185ea89b4af9a604d4c7ec40e45d3ad03ee66998b031134bc510232bb7", size = 368966, upload-time = "2025-11-09T20:47:06.508Z" }, + { url = "https://files.pythonhosted.org/packages/6b/20/058db4ae5fb07cf6a4ab2e9b9294416f606d8e467fb74c2184b2a1eeacba/jiter-0.12.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3a585a5e42d25f2e71db5f10b171f5e5ea641d3aa44f7df745aa965606111cc2", size = 482047, upload-time = "2025-11-09T20:47:08.382Z" }, + { url = "https://files.pythonhosted.org/packages/49/bb/dc2b1c122275e1de2eb12905015d61e8316b2f888bdaac34221c301495d6/jiter-0.12.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd9e21d34edff5a663c631f850edcb786719c960ce887a5661e9c828a53a95d9", size = 380835, upload-time = "2025-11-09T20:47:09.81Z" }, + { url = "https://files.pythonhosted.org/packages/23/7d/38f9cd337575349de16da575ee57ddb2d5a64d425c9367f5ef9e4612e32e/jiter-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a612534770470686cd5431478dc5a1b660eceb410abade6b1b74e320ca98de6", size = 364587, upload-time = "2025-11-09T20:47:11.529Z" }, + { url = "https://files.pythonhosted.org/packages/f0/a3/b13e8e61e70f0bb06085099c4e2462647f53cc2ca97614f7fedcaa2bb9f3/jiter-0.12.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:3985aea37d40a908f887b34d05111e0aae822943796ebf8338877fee2ab67725", size = 390492, upload-time = "2025-11-09T20:47:12.993Z" }, + { url = "https://files.pythonhosted.org/packages/07/71/e0d11422ed027e21422f7bc1883c61deba2d9752b720538430c1deadfbca/jiter-0.12.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b1207af186495f48f72529f8d86671903c8c10127cac6381b11dddc4aaa52df6", size = 522046, upload-time = "2025-11-09T20:47:14.6Z" }, + { url = "https://files.pythonhosted.org/packages/9f/59/b968a9aa7102a8375dbbdfbd2aeebe563c7e5dddf0f47c9ef1588a97e224/jiter-0.12.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ef2fb241de583934c9915a33120ecc06d94aa3381a134570f59eed784e87001e", size = 513392, upload-time = "2025-11-09T20:47:16.011Z" }, + { url = "https://files.pythonhosted.org/packages/ca/e4/7df62002499080dbd61b505c5cb351aa09e9959d176cac2aa8da6f93b13b/jiter-0.12.0-cp311-cp311-win32.whl", hash = "sha256:453b6035672fecce8007465896a25b28a6b59cfe8fbc974b2563a92f5a92a67c", size = 206096, upload-time = "2025-11-09T20:47:17.344Z" }, + { url = "https://files.pythonhosted.org/packages/bb/60/1032b30ae0572196b0de0e87dce3b6c26a1eff71aad5fe43dee3082d32e0/jiter-0.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:ca264b9603973c2ad9435c71a8ec8b49f8f715ab5ba421c85a51cde9887e421f", size = 204899, upload-time = "2025-11-09T20:47:19.365Z" }, + { url = "https://files.pythonhosted.org/packages/49/d5/c145e526fccdb834063fb45c071df78b0cc426bbaf6de38b0781f45d956f/jiter-0.12.0-cp311-cp311-win_arm64.whl", hash = "sha256:cb00ef392e7d684f2754598c02c409f376ddcef857aae796d559e6cacc2d78a5", size = 188070, upload-time = "2025-11-09T20:47:20.75Z" }, + { url = "https://files.pythonhosted.org/packages/92/c9/5b9f7b4983f1b542c64e84165075335e8a236fa9e2ea03a0c79780062be8/jiter-0.12.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:305e061fa82f4680607a775b2e8e0bcb071cd2205ac38e6ef48c8dd5ebe1cf37", size = 314449, upload-time = "2025-11-09T20:47:22.999Z" }, + { url = "https://files.pythonhosted.org/packages/98/6e/e8efa0e78de00db0aee82c0cf9e8b3f2027efd7f8a71f859d8f4be8e98ef/jiter-0.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5c1860627048e302a528333c9307c818c547f214d8659b0705d2195e1a94b274", size = 319855, upload-time = "2025-11-09T20:47:24.779Z" }, + { url = "https://files.pythonhosted.org/packages/20/26/894cd88e60b5d58af53bec5c6759d1292bd0b37a8b5f60f07abf7a63ae5f/jiter-0.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:df37577a4f8408f7e0ec3205d2a8f87672af8f17008358063a4d6425b6081ce3", size = 350171, upload-time = "2025-11-09T20:47:26.469Z" }, + { url = "https://files.pythonhosted.org/packages/f5/27/a7b818b9979ac31b3763d25f3653ec3a954044d5e9f5d87f2f247d679fd1/jiter-0.12.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:75fdd787356c1c13a4f40b43c2156276ef7a71eb487d98472476476d803fb2cf", size = 365590, upload-time = "2025-11-09T20:47:27.918Z" }, + { url = "https://files.pythonhosted.org/packages/ba/7e/e46195801a97673a83746170b17984aa8ac4a455746354516d02ca5541b4/jiter-0.12.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1eb5db8d9c65b112aacf14fcd0faae9913d07a8afea5ed06ccdd12b724e966a1", size = 479462, upload-time = "2025-11-09T20:47:29.654Z" }, + { url = "https://files.pythonhosted.org/packages/ca/75/f833bfb009ab4bd11b1c9406d333e3b4357709ed0570bb48c7c06d78c7dd/jiter-0.12.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:73c568cc27c473f82480abc15d1301adf333a7ea4f2e813d6a2c7d8b6ba8d0df", size = 378983, upload-time = "2025-11-09T20:47:31.026Z" }, + { url = "https://files.pythonhosted.org/packages/71/b3/7a69d77943cc837d30165643db753471aff5df39692d598da880a6e51c24/jiter-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4321e8a3d868919bcb1abb1db550d41f2b5b326f72df29e53b2df8b006eb9403", size = 361328, upload-time = "2025-11-09T20:47:33.286Z" }, + { url = "https://files.pythonhosted.org/packages/b0/ac/a78f90caf48d65ba70d8c6efc6f23150bc39dc3389d65bbec2a95c7bc628/jiter-0.12.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:0a51bad79f8cc9cac2b4b705039f814049142e0050f30d91695a2d9a6611f126", size = 386740, upload-time = "2025-11-09T20:47:34.703Z" }, + { url = "https://files.pythonhosted.org/packages/39/b6/5d31c2cc8e1b6a6bcf3c5721e4ca0a3633d1ab4754b09bc7084f6c4f5327/jiter-0.12.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:2a67b678f6a5f1dd6c36d642d7db83e456bc8b104788262aaefc11a22339f5a9", size = 520875, upload-time = "2025-11-09T20:47:36.058Z" }, + { url = "https://files.pythonhosted.org/packages/30/b5/4df540fae4e9f68c54b8dab004bd8c943a752f0b00efd6e7d64aa3850339/jiter-0.12.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efe1a211fe1fd14762adea941e3cfd6c611a136e28da6c39272dbb7a1bbe6a86", size = 511457, upload-time = "2025-11-09T20:47:37.932Z" }, + { url = "https://files.pythonhosted.org/packages/07/65/86b74010e450a1a77b2c1aabb91d4a91dd3cd5afce99f34d75fd1ac64b19/jiter-0.12.0-cp312-cp312-win32.whl", hash = "sha256:d779d97c834b4278276ec703dc3fc1735fca50af63eb7262f05bdb4e62203d44", size = 204546, upload-time = "2025-11-09T20:47:40.47Z" }, + { url = "https://files.pythonhosted.org/packages/1c/c7/6659f537f9562d963488e3e55573498a442503ced01f7e169e96a6110383/jiter-0.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:e8269062060212b373316fe69236096aaf4c49022d267c6736eebd66bbbc60bb", size = 205196, upload-time = "2025-11-09T20:47:41.794Z" }, + { url = "https://files.pythonhosted.org/packages/21/f4/935304f5169edadfec7f9c01eacbce4c90bb9a82035ac1de1f3bd2d40be6/jiter-0.12.0-cp312-cp312-win_arm64.whl", hash = "sha256:06cb970936c65de926d648af0ed3d21857f026b1cf5525cb2947aa5e01e05789", size = 186100, upload-time = "2025-11-09T20:47:43.007Z" }, + { url = "https://files.pythonhosted.org/packages/fe/54/5339ef1ecaa881c6948669956567a64d2670941925f245c434f494ffb0e5/jiter-0.12.0-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:4739a4657179ebf08f85914ce50332495811004cc1747852e8b2041ed2aab9b8", size = 311144, upload-time = "2025-11-09T20:49:10.503Z" }, + { url = "https://files.pythonhosted.org/packages/27/74/3446c652bffbd5e81ab354e388b1b5fc1d20daac34ee0ed11ff096b1b01a/jiter-0.12.0-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:41da8def934bf7bec16cb24bd33c0ca62126d2d45d81d17b864bd5ad721393c3", size = 305877, upload-time = "2025-11-09T20:49:12.269Z" }, + { url = "https://files.pythonhosted.org/packages/a1/f4/ed76ef9043450f57aac2d4fbeb27175aa0eb9c38f833be6ef6379b3b9a86/jiter-0.12.0-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c44ee814f499c082e69872d426b624987dbc5943ab06e9bbaa4f81989fdb79e", size = 340419, upload-time = "2025-11-09T20:49:13.803Z" }, + { url = "https://files.pythonhosted.org/packages/21/01/857d4608f5edb0664aa791a3d45702e1a5bcfff9934da74035e7b9803846/jiter-0.12.0-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cd2097de91cf03eaa27b3cbdb969addf83f0179c6afc41bbc4513705e013c65d", size = 347212, upload-time = "2025-11-09T20:49:15.643Z" }, + { url = "https://files.pythonhosted.org/packages/cb/f5/12efb8ada5f5c9edc1d4555fe383c1fb2eac05ac5859258a72d61981d999/jiter-0.12.0-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:e8547883d7b96ef2e5fe22b88f8a4c8725a56e7f4abafff20fd5272d634c7ecb", size = 309974, upload-time = "2025-11-09T20:49:17.187Z" }, + { url = "https://files.pythonhosted.org/packages/85/15/d6eb3b770f6a0d332675141ab3962fd4a7c270ede3515d9f3583e1d28276/jiter-0.12.0-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:89163163c0934854a668ed783a2546a0617f71706a2551a4a0666d91ab365d6b", size = 304233, upload-time = "2025-11-09T20:49:18.734Z" }, + { url = "https://files.pythonhosted.org/packages/8c/3e/e7e06743294eea2cf02ced6aa0ff2ad237367394e37a0e2b4a1108c67a36/jiter-0.12.0-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d96b264ab7d34bbb2312dedc47ce07cd53f06835eacbc16dde3761f47c3a9e7f", size = 338537, upload-time = "2025-11-09T20:49:20.317Z" }, + { url = "https://files.pythonhosted.org/packages/2f/9c/6753e6522b8d0ef07d3a3d239426669e984fb0eba15a315cdbc1253904e4/jiter-0.12.0-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c24e864cb30ab82311c6425655b0cdab0a98c5d973b065c66a3f020740c2324c", size = 346110, upload-time = "2025-11-09T20:49:21.817Z" }, +] + +[[package]] +name = "joblib" +version = "1.5.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/41/f2/d34e8b3a08a9cc79a50b2208a93dce981fe615b64d5a4d4abee421d898df/joblib-1.5.3.tar.gz", hash = "sha256:8561a3269e6801106863fd0d6d84bb737be9e7631e33aaed3fb9ce5953688da3", size = 331603, upload-time = "2025-12-15T08:41:46.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/91/984aca2ec129e2757d1e4e3c81c3fcda9d0f85b74670a094cc443d9ee949/joblib-1.5.3-py3-none-any.whl", hash = "sha256:5fc3c5039fc5ca8c0276333a188bbd59d6b7ab37fe6632daa76bc7f9ec18e713", size = 309071, upload-time = "2025-12-15T08:41:44.973Z" }, +] + +[[package]] +name = "jsonschema" +version = "4.25.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "jsonschema-specifications" }, + { name = "referencing" }, + { name = "rpds-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/74/69/f7185de793a29082a9f3c7728268ffb31cb5095131a9c139a74078e27336/jsonschema-4.25.1.tar.gz", hash = "sha256:e4a9655ce0da0c0b67a085847e00a3a51449e1157f4f75e9fb5aa545e122eb85", size = 357342, upload-time = "2025-08-18T17:03:50.038Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bf/9c/8c95d856233c1f82500c2450b8c68576b4cf1c871db3afac5c34ff84e6fd/jsonschema-4.25.1-py3-none-any.whl", hash = "sha256:3fba0169e345c7175110351d456342c364814cfcf3b964ba4587f22915230a63", size = 90040, upload-time = "2025-08-18T17:03:48.373Z" }, +] + +[[package]] +name = "jsonschema-path" +version = "0.3.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pathable" }, + { name = "pyyaml" }, + { name = "referencing" }, + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/6e/45/41ebc679c2a4fced6a722f624c18d658dee42612b83ea24c1caf7c0eb3a8/jsonschema_path-0.3.4.tar.gz", hash = "sha256:8365356039f16cc65fddffafda5f58766e34bebab7d6d105616ab52bc4297001", size = 11159, upload-time = "2025-01-24T14:33:16.547Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/58/3485da8cb93d2f393bce453adeef16896751f14ba3e2024bc21dc9597646/jsonschema_path-0.3.4-py3-none-any.whl", hash = "sha256:f502191fdc2b22050f9a81c9237be9d27145b9001c55842bece5e94e382e52f8", size = 14810, upload-time = "2025-01-24T14:33:14.652Z" }, +] + +[[package]] +name = "jsonschema-specifications" +version = "2025.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "referencing" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", hash = "sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d", size = 32855, upload-time = "2025-09-08T01:34:59.186Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" }, +] + +[[package]] +name = "jupyter-client" +version = "8.7.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jupyter-core" }, + { name = "python-dateutil" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a6/27/d10de45e8ad4ce872372c4a3a37b7b35b6b064f6f023a5c14ffcced4d59d/jupyter_client-8.7.0.tar.gz", hash = "sha256:3357212d9cbe01209e59190f67a3a7e1f387a4f4e88d1e0433ad84d7b262531d", size = 344691, upload-time = "2025-12-09T18:37:01.953Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bb/f5/fddaec430367be9d62a7ed125530e133bfd4a1c0350fe221149ee0f2b526/jupyter_client-8.7.0-py3-none-any.whl", hash = "sha256:3671a94fd25e62f5f2f554f5e95389c2294d89822378a5f2dd24353e1494a9e0", size = 106215, upload-time = "2025-12-09T18:37:00.024Z" }, +] + +[[package]] +name = "jupyter-core" +version = "5.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "platformdirs" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/02/49/9d1284d0dc65e2c757b74c6687b6d319b02f822ad039e5c512df9194d9dd/jupyter_core-5.9.1.tar.gz", hash = "sha256:4d09aaff303b9566c3ce657f580bd089ff5c91f5f89cf7d8846c3cdf465b5508", size = 89814, upload-time = "2025-10-16T19:19:18.444Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/e7/80988e32bf6f73919a113473a604f5a8f09094de312b9d52b79c2df7612b/jupyter_core-5.9.1-py3-none-any.whl", hash = "sha256:ebf87fdc6073d142e114c72c9e29a9d7ca03fad818c5d300ce2adc1fb0743407", size = 29032, upload-time = "2025-10-16T19:19:16.783Z" }, +] + +[[package]] +name = "jupyterlab-pygments" +version = "0.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/90/51/9187be60d989df97f5f0aba133fa54e7300f17616e065d1ada7d7646b6d6/jupyterlab_pygments-0.3.0.tar.gz", hash = "sha256:721aca4d9029252b11cfa9d185e5b5af4d54772bb8072f9b7036f4170054d35d", size = 512900, upload-time = "2023-11-23T09:26:37.44Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b1/dd/ead9d8ea85bf202d90cc513b533f9c363121c7792674f78e0d8a854b63b4/jupyterlab_pygments-0.3.0-py3-none-any.whl", hash = "sha256:841a89020971da1d8693f1a99997aefc5dc424bb1b251fd6322462a1b8842780", size = 15884, upload-time = "2023-11-23T09:26:34.325Z" }, +] + +[[package]] +name = "langdetect" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0e/72/a3add0e4eec4eb9e2569554f7c70f4a3c27712f40e3284d483e88094cc0e/langdetect-1.0.9.tar.gz", hash = "sha256:cbc1fef89f8d062739774bd51eda3da3274006b3661d199c2655f6b3f6d605a0", size = 981474, upload-time = "2021-05-07T07:54:13.562Z" } + +[[package]] +name = "lazy-object-proxy" +version = "1.12.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/08/a2/69df9c6ba6d316cfd81fe2381e464db3e6de5db45f8c43c6a23504abf8cb/lazy_object_proxy-1.12.0.tar.gz", hash = "sha256:1f5a462d92fd0cfb82f1fab28b51bfb209fabbe6aabf7f0d51472c0c124c0c61", size = 43681, upload-time = "2025-08-22T13:50:06.783Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/01/b3/4684b1e128a87821e485f5a901b179790e6b5bc02f89b7ee19c23be36ef3/lazy_object_proxy-1.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1cf69cd1a6c7fe2dbcc3edaa017cf010f4192e53796538cc7d5e1fedbfa4bcff", size = 26656, upload-time = "2025-08-22T13:42:30.605Z" }, + { url = "https://files.pythonhosted.org/packages/3a/03/1bdc21d9a6df9ff72d70b2ff17d8609321bea4b0d3cffd2cea92fb2ef738/lazy_object_proxy-1.12.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:efff4375a8c52f55a145dc8487a2108c2140f0bec4151ab4e1843e52eb9987ad", size = 68832, upload-time = "2025-08-22T13:42:31.675Z" }, + { url = "https://files.pythonhosted.org/packages/3d/4b/5788e5e8bd01d19af71e50077ab020bc5cce67e935066cd65e1215a09ff9/lazy_object_proxy-1.12.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1192e8c2f1031a6ff453ee40213afa01ba765b3dc861302cd91dbdb2e2660b00", size = 69148, upload-time = "2025-08-22T13:42:32.876Z" }, + { url = "https://files.pythonhosted.org/packages/79/0e/090bf070f7a0de44c61659cb7f74c2fe02309a77ca8c4b43adfe0b695f66/lazy_object_proxy-1.12.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:3605b632e82a1cbc32a1e5034278a64db555b3496e0795723ee697006b980508", size = 67800, upload-time = "2025-08-22T13:42:34.054Z" }, + { url = "https://files.pythonhosted.org/packages/cf/d2/b320325adbb2d119156f7c506a5fbfa37fcab15c26d13cf789a90a6de04e/lazy_object_proxy-1.12.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a61095f5d9d1a743e1e20ec6d6db6c2ca511961777257ebd9b288951b23b44fa", size = 68085, upload-time = "2025-08-22T13:42:35.197Z" }, + { url = "https://files.pythonhosted.org/packages/6a/48/4b718c937004bf71cd82af3713874656bcb8d0cc78600bf33bb9619adc6c/lazy_object_proxy-1.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:997b1d6e10ecc6fb6fe0f2c959791ae59599f41da61d652f6c903d1ee58b7370", size = 26535, upload-time = "2025-08-22T13:42:36.521Z" }, + { url = "https://files.pythonhosted.org/packages/0d/1b/b5f5bd6bda26f1e15cd3232b223892e4498e34ec70a7f4f11c401ac969f1/lazy_object_proxy-1.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8ee0d6027b760a11cc18281e702c0309dd92da458a74b4c15025d7fc490deede", size = 26746, upload-time = "2025-08-22T13:42:37.572Z" }, + { url = "https://files.pythonhosted.org/packages/55/64/314889b618075c2bfc19293ffa9153ce880ac6153aacfd0a52fcabf21a66/lazy_object_proxy-1.12.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:4ab2c584e3cc8be0dfca422e05ad30a9abe3555ce63e9ab7a559f62f8dbc6ff9", size = 71457, upload-time = "2025-08-22T13:42:38.743Z" }, + { url = "https://files.pythonhosted.org/packages/11/53/857fc2827fc1e13fbdfc0ba2629a7d2579645a06192d5461809540b78913/lazy_object_proxy-1.12.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:14e348185adbd03ec17d051e169ec45686dcd840a3779c9d4c10aabe2ca6e1c0", size = 71036, upload-time = "2025-08-22T13:42:40.184Z" }, + { url = "https://files.pythonhosted.org/packages/2b/24/e581ffed864cd33c1b445b5763d617448ebb880f48675fc9de0471a95cbc/lazy_object_proxy-1.12.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:c4fcbe74fb85df8ba7825fa05eddca764138da752904b378f0ae5ab33a36c308", size = 69329, upload-time = "2025-08-22T13:42:41.311Z" }, + { url = "https://files.pythonhosted.org/packages/78/be/15f8f5a0b0b2e668e756a152257d26370132c97f2f1943329b08f057eff0/lazy_object_proxy-1.12.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:563d2ec8e4d4b68ee7848c5ab4d6057a6d703cb7963b342968bb8758dda33a23", size = 70690, upload-time = "2025-08-22T13:42:42.51Z" }, + { url = "https://files.pythonhosted.org/packages/5d/aa/f02be9bbfb270e13ee608c2b28b8771f20a5f64356c6d9317b20043c6129/lazy_object_proxy-1.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:53c7fd99eb156bbb82cbc5d5188891d8fdd805ba6c1e3b92b90092da2a837073", size = 26563, upload-time = "2025-08-22T13:42:43.685Z" }, + { url = "https://files.pythonhosted.org/packages/41/a0/b91504515c1f9a299fc157967ffbd2f0321bce0516a3d5b89f6f4cad0355/lazy_object_proxy-1.12.0-pp39.pp310.pp311.graalpy311-none-any.whl", hash = "sha256:c3b2e0af1f7f77c4263759c4824316ce458fabe0fceadcd24ef8ca08b2d1e402", size = 15072, upload-time = "2025-08-22T13:50:05.498Z" }, +] + +[[package]] +name = "lxml" +version = "6.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/aa/88/262177de60548e5a2bfc46ad28232c9e9cbde697bd94132aeb80364675cb/lxml-6.0.2.tar.gz", hash = "sha256:cd79f3367bd74b317dda655dc8fcfa304d9eb6e4fb06b7168c5cf27f96e0cd62", size = 4073426, upload-time = "2025-09-22T04:04:59.287Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/77/d5/becbe1e2569b474a23f0c672ead8a29ac50b2dc1d5b9de184831bda8d14c/lxml-6.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:13e35cbc684aadf05d8711a5d1b5857c92e5e580efa9a0d2be197199c8def607", size = 8634365, upload-time = "2025-09-22T04:00:45.672Z" }, + { url = "https://files.pythonhosted.org/packages/28/66/1ced58f12e804644426b85d0bb8a4478ca77bc1761455da310505f1a3526/lxml-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3b1675e096e17c6fe9c0e8c81434f5736c0739ff9ac6123c87c2d452f48fc938", size = 4650793, upload-time = "2025-09-22T04:00:47.783Z" }, + { url = "https://files.pythonhosted.org/packages/11/84/549098ffea39dfd167e3f174b4ce983d0eed61f9d8d25b7bf2a57c3247fc/lxml-6.0.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8ac6e5811ae2870953390452e3476694196f98d447573234592d30488147404d", size = 4944362, upload-time = "2025-09-22T04:00:49.845Z" }, + { url = "https://files.pythonhosted.org/packages/ac/bd/f207f16abf9749d2037453d56b643a7471d8fde855a231a12d1e095c4f01/lxml-6.0.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5aa0fc67ae19d7a64c3fe725dc9a1bb11f80e01f78289d05c6f62545affec438", size = 5083152, upload-time = "2025-09-22T04:00:51.709Z" }, + { url = "https://files.pythonhosted.org/packages/15/ae/bd813e87d8941d52ad5b65071b1affb48da01c4ed3c9c99e40abb266fbff/lxml-6.0.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:de496365750cc472b4e7902a485d3f152ecf57bd3ba03ddd5578ed8ceb4c5964", size = 5023539, upload-time = "2025-09-22T04:00:53.593Z" }, + { url = "https://files.pythonhosted.org/packages/02/cd/9bfef16bd1d874fbe0cb51afb00329540f30a3283beb9f0780adbb7eec03/lxml-6.0.2-cp311-cp311-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:200069a593c5e40b8f6fc0d84d86d970ba43138c3e68619ffa234bc9bb806a4d", size = 5344853, upload-time = "2025-09-22T04:00:55.524Z" }, + { url = "https://files.pythonhosted.org/packages/b8/89/ea8f91594bc5dbb879734d35a6f2b0ad50605d7fb419de2b63d4211765cc/lxml-6.0.2-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7d2de809c2ee3b888b59f995625385f74629707c9355e0ff856445cdcae682b7", size = 5225133, upload-time = "2025-09-22T04:00:57.269Z" }, + { url = "https://files.pythonhosted.org/packages/b9/37/9c735274f5dbec726b2db99b98a43950395ba3d4a1043083dba2ad814170/lxml-6.0.2-cp311-cp311-manylinux_2_31_armv7l.whl", hash = "sha256:b2c3da8d93cf5db60e8858c17684c47d01fee6405e554fb55018dd85fc23b178", size = 4677944, upload-time = "2025-09-22T04:00:59.052Z" }, + { url = "https://files.pythonhosted.org/packages/20/28/7dfe1ba3475d8bfca3878365075abe002e05d40dfaaeb7ec01b4c587d533/lxml-6.0.2-cp311-cp311-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:442de7530296ef5e188373a1ea5789a46ce90c4847e597856570439621d9c553", size = 5284535, upload-time = "2025-09-22T04:01:01.335Z" }, + { url = "https://files.pythonhosted.org/packages/e7/cf/5f14bc0de763498fc29510e3532bf2b4b3a1c1d5d0dff2e900c16ba021ef/lxml-6.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:2593c77efde7bfea7f6389f1ab249b15ed4aa5bc5cb5131faa3b843c429fbedb", size = 5067343, upload-time = "2025-09-22T04:01:03.13Z" }, + { url = "https://files.pythonhosted.org/packages/1c/b0/bb8275ab5472f32b28cfbbcc6db7c9d092482d3439ca279d8d6fa02f7025/lxml-6.0.2-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:3e3cb08855967a20f553ff32d147e14329b3ae70ced6edc2f282b94afbc74b2a", size = 4725419, upload-time = "2025-09-22T04:01:05.013Z" }, + { url = "https://files.pythonhosted.org/packages/25/4c/7c222753bc72edca3b99dbadba1b064209bc8ed4ad448af990e60dcce462/lxml-6.0.2-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:2ed6c667fcbb8c19c6791bbf40b7268ef8ddf5a96940ba9404b9f9a304832f6c", size = 5275008, upload-time = "2025-09-22T04:01:07.327Z" }, + { url = "https://files.pythonhosted.org/packages/6c/8c/478a0dc6b6ed661451379447cdbec77c05741a75736d97e5b2b729687828/lxml-6.0.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b8f18914faec94132e5b91e69d76a5c1d7b0c73e2489ea8929c4aaa10b76bbf7", size = 5248906, upload-time = "2025-09-22T04:01:09.452Z" }, + { url = "https://files.pythonhosted.org/packages/2d/d9/5be3a6ab2784cdf9accb0703b65e1b64fcdd9311c9f007630c7db0cfcce1/lxml-6.0.2-cp311-cp311-win32.whl", hash = "sha256:6605c604e6daa9e0d7f0a2137bdc47a2e93b59c60a65466353e37f8272f47c46", size = 3610357, upload-time = "2025-09-22T04:01:11.102Z" }, + { url = "https://files.pythonhosted.org/packages/e2/7d/ca6fb13349b473d5732fb0ee3eec8f6c80fc0688e76b7d79c1008481bf1f/lxml-6.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:e5867f2651016a3afd8dd2c8238baa66f1e2802f44bc17e236f547ace6647078", size = 4036583, upload-time = "2025-09-22T04:01:12.766Z" }, + { url = "https://files.pythonhosted.org/packages/ab/a2/51363b5ecd3eab46563645f3a2c3836a2fc67d01a1b87c5017040f39f567/lxml-6.0.2-cp311-cp311-win_arm64.whl", hash = "sha256:4197fb2534ee05fd3e7afaab5d8bfd6c2e186f65ea7f9cd6a82809c887bd1285", size = 3680591, upload-time = "2025-09-22T04:01:14.874Z" }, + { url = "https://files.pythonhosted.org/packages/f3/c8/8ff2bc6b920c84355146cd1ab7d181bc543b89241cfb1ebee824a7c81457/lxml-6.0.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:a59f5448ba2ceccd06995c95ea59a7674a10de0810f2ce90c9006f3cbc044456", size = 8661887, upload-time = "2025-09-22T04:01:17.265Z" }, + { url = "https://files.pythonhosted.org/packages/37/6f/9aae1008083bb501ef63284220ce81638332f9ccbfa53765b2b7502203cf/lxml-6.0.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e8113639f3296706fbac34a30813929e29247718e88173ad849f57ca59754924", size = 4667818, upload-time = "2025-09-22T04:01:19.688Z" }, + { url = "https://files.pythonhosted.org/packages/f1/ca/31fb37f99f37f1536c133476674c10b577e409c0a624384147653e38baf2/lxml-6.0.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a8bef9b9825fa8bc816a6e641bb67219489229ebc648be422af695f6e7a4fa7f", size = 4950807, upload-time = "2025-09-22T04:01:21.487Z" }, + { url = "https://files.pythonhosted.org/packages/da/87/f6cb9442e4bada8aab5ae7e1046264f62fdbeaa6e3f6211b93f4c0dd97f1/lxml-6.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:65ea18d710fd14e0186c2f973dc60bb52039a275f82d3c44a0e42b43440ea534", size = 5109179, upload-time = "2025-09-22T04:01:23.32Z" }, + { url = "https://files.pythonhosted.org/packages/c8/20/a7760713e65888db79bbae4f6146a6ae5c04e4a204a3c48896c408cd6ed2/lxml-6.0.2-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c371aa98126a0d4c739ca93ceffa0fd7a5d732e3ac66a46e74339acd4d334564", size = 5023044, upload-time = "2025-09-22T04:01:25.118Z" }, + { url = "https://files.pythonhosted.org/packages/a2/b0/7e64e0460fcb36471899f75831509098f3fd7cd02a3833ac517433cb4f8f/lxml-6.0.2-cp312-cp312-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:700efd30c0fa1a3581d80a748157397559396090a51d306ea59a70020223d16f", size = 5359685, upload-time = "2025-09-22T04:01:27.398Z" }, + { url = "https://files.pythonhosted.org/packages/b9/e1/e5df362e9ca4e2f48ed6411bd4b3a0ae737cc842e96877f5bf9428055ab4/lxml-6.0.2-cp312-cp312-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c33e66d44fe60e72397b487ee92e01da0d09ba2d66df8eae42d77b6d06e5eba0", size = 5654127, upload-time = "2025-09-22T04:01:29.629Z" }, + { url = "https://files.pythonhosted.org/packages/c6/d1/232b3309a02d60f11e71857778bfcd4acbdb86c07db8260caf7d008b08f8/lxml-6.0.2-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:90a345bbeaf9d0587a3aaffb7006aa39ccb6ff0e96a57286c0cb2fd1520ea192", size = 5253958, upload-time = "2025-09-22T04:01:31.535Z" }, + { url = "https://files.pythonhosted.org/packages/35/35/d955a070994725c4f7d80583a96cab9c107c57a125b20bb5f708fe941011/lxml-6.0.2-cp312-cp312-manylinux_2_31_armv7l.whl", hash = "sha256:064fdadaf7a21af3ed1dcaa106b854077fbeada827c18f72aec9346847cd65d0", size = 4711541, upload-time = "2025-09-22T04:01:33.801Z" }, + { url = "https://files.pythonhosted.org/packages/1e/be/667d17363b38a78c4bd63cfd4b4632029fd68d2c2dc81f25ce9eb5224dd5/lxml-6.0.2-cp312-cp312-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fbc74f42c3525ac4ffa4b89cbdd00057b6196bcefe8bce794abd42d33a018092", size = 5267426, upload-time = "2025-09-22T04:01:35.639Z" }, + { url = "https://files.pythonhosted.org/packages/ea/47/62c70aa4a1c26569bc958c9ca86af2bb4e1f614e8c04fb2989833874f7ae/lxml-6.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6ddff43f702905a4e32bc24f3f2e2edfe0f8fde3277d481bffb709a4cced7a1f", size = 5064917, upload-time = "2025-09-22T04:01:37.448Z" }, + { url = "https://files.pythonhosted.org/packages/bd/55/6ceddaca353ebd0f1908ef712c597f8570cc9c58130dbb89903198e441fd/lxml-6.0.2-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:6da5185951d72e6f5352166e3da7b0dc27aa70bd1090b0eb3f7f7212b53f1bb8", size = 4788795, upload-time = "2025-09-22T04:01:39.165Z" }, + { url = "https://files.pythonhosted.org/packages/cf/e8/fd63e15da5e3fd4c2146f8bbb3c14e94ab850589beab88e547b2dbce22e1/lxml-6.0.2-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:57a86e1ebb4020a38d295c04fc79603c7899e0df71588043eb218722dabc087f", size = 5676759, upload-time = "2025-09-22T04:01:41.506Z" }, + { url = "https://files.pythonhosted.org/packages/76/47/b3ec58dc5c374697f5ba37412cd2728f427d056315d124dd4b61da381877/lxml-6.0.2-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:2047d8234fe735ab77802ce5f2297e410ff40f5238aec569ad7c8e163d7b19a6", size = 5255666, upload-time = "2025-09-22T04:01:43.363Z" }, + { url = "https://files.pythonhosted.org/packages/19/93/03ba725df4c3d72afd9596eef4a37a837ce8e4806010569bedfcd2cb68fd/lxml-6.0.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:6f91fd2b2ea15a6800c8e24418c0775a1694eefc011392da73bc6cef2623b322", size = 5277989, upload-time = "2025-09-22T04:01:45.215Z" }, + { url = "https://files.pythonhosted.org/packages/c6/80/c06de80bfce881d0ad738576f243911fccf992687ae09fd80b734712b39c/lxml-6.0.2-cp312-cp312-win32.whl", hash = "sha256:3ae2ce7d6fedfb3414a2b6c5e20b249c4c607f72cb8d2bb7cc9c6ec7c6f4e849", size = 3611456, upload-time = "2025-09-22T04:01:48.243Z" }, + { url = "https://files.pythonhosted.org/packages/f7/d7/0cdfb6c3e30893463fb3d1e52bc5f5f99684a03c29a0b6b605cfae879cd5/lxml-6.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:72c87e5ee4e58a8354fb9c7c84cbf95a1c8236c127a5d1b7683f04bed8361e1f", size = 4011793, upload-time = "2025-09-22T04:01:50.042Z" }, + { url = "https://files.pythonhosted.org/packages/ea/7b/93c73c67db235931527301ed3785f849c78991e2e34f3fd9a6663ffda4c5/lxml-6.0.2-cp312-cp312-win_arm64.whl", hash = "sha256:61cb10eeb95570153e0c0e554f58df92ecf5109f75eacad4a95baa709e26c3d6", size = 3672836, upload-time = "2025-09-22T04:01:52.145Z" }, + { url = "https://files.pythonhosted.org/packages/0b/11/29d08bc103a62c0eba8016e7ed5aeebbf1e4312e83b0b1648dd203b0e87d/lxml-6.0.2-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:1c06035eafa8404b5cf475bb37a9f6088b0aca288d4ccc9d69389750d5543700", size = 3949829, upload-time = "2025-09-22T04:04:45.608Z" }, + { url = "https://files.pythonhosted.org/packages/12/b3/52ab9a3b31e5ab8238da241baa19eec44d2ab426532441ee607165aebb52/lxml-6.0.2-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c7d13103045de1bdd6fe5d61802565f1a3537d70cd3abf596aa0af62761921ee", size = 4226277, upload-time = "2025-09-22T04:04:47.754Z" }, + { url = "https://files.pythonhosted.org/packages/a0/33/1eaf780c1baad88224611df13b1c2a9dfa460b526cacfe769103ff50d845/lxml-6.0.2-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0a3c150a95fbe5ac91de323aa756219ef9cf7fde5a3f00e2281e30f33fa5fa4f", size = 4330433, upload-time = "2025-09-22T04:04:49.907Z" }, + { url = "https://files.pythonhosted.org/packages/7a/c1/27428a2ff348e994ab4f8777d3a0ad510b6b92d37718e5887d2da99952a2/lxml-6.0.2-pp311-pypy311_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:60fa43be34f78bebb27812ed90f1925ec99560b0fa1decdb7d12b84d857d31e9", size = 4272119, upload-time = "2025-09-22T04:04:51.801Z" }, + { url = "https://files.pythonhosted.org/packages/f0/d0/3020fa12bcec4ab62f97aab026d57c2f0cfd480a558758d9ca233bb6a79d/lxml-6.0.2-pp311-pypy311_pp73-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:21c73b476d3cfe836be731225ec3421fa2f048d84f6df6a8e70433dff1376d5a", size = 4417314, upload-time = "2025-09-22T04:04:55.024Z" }, + { url = "https://files.pythonhosted.org/packages/6c/77/d7f491cbc05303ac6801651aabeb262d43f319288c1ea96c66b1d2692ff3/lxml-6.0.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:27220da5be049e936c3aca06f174e8827ca6445a4353a1995584311487fc4e3e", size = 3518768, upload-time = "2025-09-22T04:04:57.097Z" }, +] + +[[package]] +name = "markupsafe" +version = "3.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload-time = "2025-09-27T18:37:40.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/08/db/fefacb2136439fc8dd20e797950e749aa1f4997ed584c62cfb8ef7c2be0e/markupsafe-3.0.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1cc7ea17a6824959616c525620e387f6dd30fec8cb44f649e31712db02123dad", size = 11631, upload-time = "2025-09-27T18:36:18.185Z" }, + { url = "https://files.pythonhosted.org/packages/e1/2e/5898933336b61975ce9dc04decbc0a7f2fee78c30353c5efba7f2d6ff27a/markupsafe-3.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4bd4cd07944443f5a265608cc6aab442e4f74dff8088b0dfc8238647b8f6ae9a", size = 12058, upload-time = "2025-09-27T18:36:19.444Z" }, + { url = "https://files.pythonhosted.org/packages/1d/09/adf2df3699d87d1d8184038df46a9c80d78c0148492323f4693df54e17bb/markupsafe-3.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b5420a1d9450023228968e7e6a9ce57f65d148ab56d2313fcd589eee96a7a50", size = 24287, upload-time = "2025-09-27T18:36:20.768Z" }, + { url = "https://files.pythonhosted.org/packages/30/ac/0273f6fcb5f42e314c6d8cd99effae6a5354604d461b8d392b5ec9530a54/markupsafe-3.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0bf2a864d67e76e5c9a34dc26ec616a66b9888e25e7b9460e1c76d3293bd9dbf", size = 22940, upload-time = "2025-09-27T18:36:22.249Z" }, + { url = "https://files.pythonhosted.org/packages/19/ae/31c1be199ef767124c042c6c3e904da327a2f7f0cd63a0337e1eca2967a8/markupsafe-3.0.3-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:bc51efed119bc9cfdf792cdeaa4d67e8f6fcccab66ed4bfdd6bde3e59bfcbb2f", size = 21887, upload-time = "2025-09-27T18:36:23.535Z" }, + { url = "https://files.pythonhosted.org/packages/b2/76/7edcab99d5349a4532a459e1fe64f0b0467a3365056ae550d3bcf3f79e1e/markupsafe-3.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:068f375c472b3e7acbe2d5318dea141359e6900156b5b2ba06a30b169086b91a", size = 23692, upload-time = "2025-09-27T18:36:24.823Z" }, + { url = "https://files.pythonhosted.org/packages/a4/28/6e74cdd26d7514849143d69f0bf2399f929c37dc2b31e6829fd2045b2765/markupsafe-3.0.3-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:7be7b61bb172e1ed687f1754f8e7484f1c8019780f6f6b0786e76bb01c2ae115", size = 21471, upload-time = "2025-09-27T18:36:25.95Z" }, + { url = "https://files.pythonhosted.org/packages/62/7e/a145f36a5c2945673e590850a6f8014318d5577ed7e5920a4b3448e0865d/markupsafe-3.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f9e130248f4462aaa8e2552d547f36ddadbeaa573879158d721bbd33dfe4743a", size = 22923, upload-time = "2025-09-27T18:36:27.109Z" }, + { url = "https://files.pythonhosted.org/packages/0f/62/d9c46a7f5c9adbeeeda52f5b8d802e1094e9717705a645efc71b0913a0a8/markupsafe-3.0.3-cp311-cp311-win32.whl", hash = "sha256:0db14f5dafddbb6d9208827849fad01f1a2609380add406671a26386cdf15a19", size = 14572, upload-time = "2025-09-27T18:36:28.045Z" }, + { url = "https://files.pythonhosted.org/packages/83/8a/4414c03d3f891739326e1783338e48fb49781cc915b2e0ee052aa490d586/markupsafe-3.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:de8a88e63464af587c950061a5e6a67d3632e36df62b986892331d4620a35c01", size = 15077, upload-time = "2025-09-27T18:36:29.025Z" }, + { url = "https://files.pythonhosted.org/packages/35/73/893072b42e6862f319b5207adc9ae06070f095b358655f077f69a35601f0/markupsafe-3.0.3-cp311-cp311-win_arm64.whl", hash = "sha256:3b562dd9e9ea93f13d53989d23a7e775fdfd1066c33494ff43f5418bc8c58a5c", size = 13876, upload-time = "2025-09-27T18:36:29.954Z" }, + { url = "https://files.pythonhosted.org/packages/5a/72/147da192e38635ada20e0a2e1a51cf8823d2119ce8883f7053879c2199b5/markupsafe-3.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e", size = 11615, upload-time = "2025-09-27T18:36:30.854Z" }, + { url = "https://files.pythonhosted.org/packages/9a/81/7e4e08678a1f98521201c3079f77db69fb552acd56067661f8c2f534a718/markupsafe-3.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce", size = 12020, upload-time = "2025-09-27T18:36:31.971Z" }, + { url = "https://files.pythonhosted.org/packages/1e/2c/799f4742efc39633a1b54a92eec4082e4f815314869865d876824c257c1e/markupsafe-3.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d", size = 24332, upload-time = "2025-09-27T18:36:32.813Z" }, + { url = "https://files.pythonhosted.org/packages/3c/2e/8d0c2ab90a8c1d9a24f0399058ab8519a3279d1bd4289511d74e909f060e/markupsafe-3.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d", size = 22947, upload-time = "2025-09-27T18:36:33.86Z" }, + { url = "https://files.pythonhosted.org/packages/2c/54/887f3092a85238093a0b2154bd629c89444f395618842e8b0c41783898ea/markupsafe-3.0.3-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a", size = 21962, upload-time = "2025-09-27T18:36:35.099Z" }, + { url = "https://files.pythonhosted.org/packages/c9/2f/336b8c7b6f4a4d95e91119dc8521402461b74a485558d8f238a68312f11c/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b", size = 23760, upload-time = "2025-09-27T18:36:36.001Z" }, + { url = "https://files.pythonhosted.org/packages/32/43/67935f2b7e4982ffb50a4d169b724d74b62a3964bc1a9a527f5ac4f1ee2b/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f", size = 21529, upload-time = "2025-09-27T18:36:36.906Z" }, + { url = "https://files.pythonhosted.org/packages/89/e0/4486f11e51bbba8b0c041098859e869e304d1c261e59244baa3d295d47b7/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b", size = 23015, upload-time = "2025-09-27T18:36:37.868Z" }, + { url = "https://files.pythonhosted.org/packages/2f/e1/78ee7a023dac597a5825441ebd17170785a9dab23de95d2c7508ade94e0e/markupsafe-3.0.3-cp312-cp312-win32.whl", hash = "sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d", size = 14540, upload-time = "2025-09-27T18:36:38.761Z" }, + { url = "https://files.pythonhosted.org/packages/aa/5b/bec5aa9bbbb2c946ca2733ef9c4ca91c91b6a24580193e891b5f7dbe8e1e/markupsafe-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c", size = 15105, upload-time = "2025-09-27T18:36:39.701Z" }, + { url = "https://files.pythonhosted.org/packages/e5/f1/216fc1bbfd74011693a4fd837e7026152e89c4bcf3e77b6692fba9923123/markupsafe-3.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f", size = 13906, upload-time = "2025-09-27T18:36:40.689Z" }, +] + +[[package]] +name = "marshmallow" +version = "3.26.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ab/5e/5e53d26b42ab75491cda89b871dab9e97c840bf12c63ec58a1919710cd06/marshmallow-3.26.1.tar.gz", hash = "sha256:e6d8affb6cb61d39d26402096dc0aee12d5a26d490a121f118d2e81dc0719dc6", size = 221825, upload-time = "2025-02-03T15:32:25.093Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/34/75/51952c7b2d3873b44a0028b1bd26a25078c18f92f256608e8d1dc61b39fd/marshmallow-3.26.1-py3-none-any.whl", hash = "sha256:3350409f20a70a7e4e11a27661187b77cdcaeb20abca41c1454fe33636bea09c", size = 50878, upload-time = "2025-02-03T15:32:22.295Z" }, +] + +[[package]] +name = "matplotlib-inline" +version = "0.2.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c7/74/97e72a36efd4ae2bccb3463284300f8953f199b5ffbc04cbbb0ec78f74b1/matplotlib_inline-0.2.1.tar.gz", hash = "sha256:e1ee949c340d771fc39e241ea75683deb94762c8fa5f2927ec57c83c4dffa9fe", size = 8110, upload-time = "2025-10-23T09:00:22.126Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/33/ee4519fa02ed11a94aef9559552f3b17bb863f2ecfe1a35dc7f548cde231/matplotlib_inline-0.2.1-py3-none-any.whl", hash = "sha256:d56ce5156ba6085e00a9d54fead6ed29a9c47e215cd1bba2e976ef39f5710a76", size = 9516, upload-time = "2025-10-23T09:00:20.675Z" }, +] + +[[package]] +name = "mcp" +version = "1.24.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "httpx" }, + { name = "httpx-sse" }, + { name = "jsonschema" }, + { name = "pydantic" }, + { name = "pydantic-settings" }, + { name = "pyjwt", extra = ["crypto"] }, + { name = "python-multipart" }, + { name = "pywin32", marker = "sys_platform == 'win32'" }, + { name = "sse-starlette" }, + { name = "starlette" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, + { name = "uvicorn", marker = "sys_platform != 'emscripten'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d6/2c/db9ae5ab1fcdd9cd2bcc7ca3b7361b712e30590b64d5151a31563af8f82d/mcp-1.24.0.tar.gz", hash = "sha256:aeaad134664ce56f2721d1abf300666a1e8348563f4d3baff361c3b652448efc", size = 604375, upload-time = "2025-12-12T14:19:38.205Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/61/0d/5cf14e177c8ae655a2fd9324a6ef657ca4cafd3fc2201c87716055e29641/mcp-1.24.0-py3-none-any.whl", hash = "sha256:db130e103cc50ddc3dffc928382f33ba3eaef0b711f7a87c05e7ded65b1ca062", size = 232896, upload-time = "2025-12-12T14:19:36.14Z" }, +] + +[[package]] +name = "mirofish-backend" +version = "0.1.0" +source = { editable = "." } +dependencies = [ + { name = "camel-ai" }, + { name = "camel-oasis" }, + { name = "chardet" }, + { name = "charset-normalizer" }, + { name = "flask" }, + { name = "flask-cors" }, + { name = "openai" }, + { name = "pydantic" }, + { name = "pymupdf" }, + { name = "python-dotenv" }, + { name = "zep-cloud" }, +] + +[package.optional-dependencies] +dev = [ + { name = "pipreqs" }, + { name = "pytest" }, + { name = "pytest-asyncio" }, +] + +[package.dev-dependencies] +dev = [ + { name = "pytest" }, + { name = "pytest-asyncio" }, +] + +[package.metadata] +requires-dist = [ + { name = "camel-ai", specifier = "==0.2.78" }, + { name = "camel-oasis", specifier = "==0.2.5" }, + { name = "chardet", specifier = ">=5.0.0" }, + { name = "charset-normalizer", specifier = ">=3.0.0" }, + { name = "flask", specifier = ">=3.0.0" }, + { name = "flask-cors", specifier = ">=6.0.0" }, + { name = "openai", specifier = ">=1.0.0" }, + { name = "pipreqs", marker = "extra == 'dev'", specifier = ">=0.5.0" }, + { name = "pydantic", specifier = ">=2.0.0" }, + { name = "pymupdf", specifier = ">=1.24.0" }, + { name = "pytest", marker = "extra == 'dev'", specifier = ">=8.0.0" }, + { name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.23.0" }, + { name = "python-dotenv", specifier = ">=1.0.0" }, + { name = "zep-cloud", specifier = "==3.13.0" }, +] +provides-extras = ["dev"] + +[package.metadata.requires-dev] +dev = [ + { name = "pytest", specifier = ">=8.0.0" }, + { name = "pytest-asyncio", specifier = ">=0.23.0" }, +] + +[[package]] +name = "mistune" +version = "3.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/02/a7fb8b21d4d55ac93cdcde9d3638da5dd0ebdd3a4fed76c7725e10b81cbe/mistune-3.1.4.tar.gz", hash = "sha256:b5a7f801d389f724ec702840c11d8fc48f2b33519102fc7ee739e8177b672164", size = 94588, upload-time = "2025-08-29T07:20:43.594Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7a/f0/8282d9641415e9e33df173516226b404d367a0fc55e1a60424a152913abc/mistune-3.1.4-py3-none-any.whl", hash = "sha256:93691da911e5d9d2e23bc54472892aff676df27a75274962ff9edc210364266d", size = 53481, upload-time = "2025-08-29T07:20:42.218Z" }, +] + +[[package]] +name = "mpmath" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e0/47/dd32fa426cc72114383ac549964eecb20ecfd886d1e5ccf5340b55b02f57/mpmath-1.3.0.tar.gz", hash = "sha256:7a28eb2a9774d00c7bc92411c19a89209d5da7c4c9a9e227be8330a23a25b91f", size = 508106, upload-time = "2023-03-07T16:47:11.061Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c", size = 536198, upload-time = "2023-03-07T16:47:09.197Z" }, +] + +[[package]] +name = "mypy-extensions" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, +] + +[[package]] +name = "nbclient" +version = "0.10.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jupyter-client" }, + { name = "jupyter-core" }, + { name = "nbformat" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/87/66/7ffd18d58eae90d5721f9f39212327695b749e23ad44b3881744eaf4d9e8/nbclient-0.10.2.tar.gz", hash = "sha256:90b7fc6b810630db87a6d0c2250b1f0ab4cf4d3c27a299b0cde78a4ed3fd9193", size = 62424, upload-time = "2024-12-19T10:32:27.164Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/34/6d/e7fa07f03a4a7b221d94b4d586edb754a9b0dc3c9e2c93353e9fa4e0d117/nbclient-0.10.2-py3-none-any.whl", hash = "sha256:4ffee11e788b4a27fabeb7955547e4318a5298f34342a4bfd01f2e1faaeadc3d", size = 25434, upload-time = "2024-12-19T10:32:24.139Z" }, +] + +[[package]] +name = "nbconvert" +version = "7.16.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "beautifulsoup4" }, + { name = "bleach", extra = ["css"] }, + { name = "defusedxml" }, + { name = "jinja2" }, + { name = "jupyter-core" }, + { name = "jupyterlab-pygments" }, + { name = "markupsafe" }, + { name = "mistune" }, + { name = "nbclient" }, + { name = "nbformat" }, + { name = "packaging" }, + { name = "pandocfilters" }, + { name = "pygments" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a3/59/f28e15fc47ffb73af68a8d9b47367a8630d76e97ae85ad18271b9db96fdf/nbconvert-7.16.6.tar.gz", hash = "sha256:576a7e37c6480da7b8465eefa66c17844243816ce1ccc372633c6b71c3c0f582", size = 857715, upload-time = "2025-01-28T09:29:14.724Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cc/9a/cd673b2f773a12c992f41309ef81b99da1690426bd2f96957a7ade0d3ed7/nbconvert-7.16.6-py3-none-any.whl", hash = "sha256:1375a7b67e0c2883678c48e506dc320febb57685e5ee67faa51b18a90f3a712b", size = 258525, upload-time = "2025-01-28T09:29:12.551Z" }, +] + +[[package]] +name = "nbformat" +version = "5.10.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "fastjsonschema" }, + { name = "jsonschema" }, + { name = "jupyter-core" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/6d/fd/91545e604bc3dad7dca9ed03284086039b294c6b3d75c0d2fa45f9e9caf3/nbformat-5.10.4.tar.gz", hash = "sha256:322168b14f937a5d11362988ecac2a4952d3d8e3a2cbeb2319584631226d5b3a", size = 142749, upload-time = "2024-04-04T11:20:37.371Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/82/0340caa499416c78e5d8f5f05947ae4bc3cba53c9f038ab6e9ed964e22f1/nbformat-5.10.4-py3-none-any.whl", hash = "sha256:3b48d6c8fbca4b299bf3982ea7db1af21580e4fec269ad087b9e81588891200b", size = 78454, upload-time = "2024-04-04T11:20:34.895Z" }, +] + +[[package]] +name = "neo4j" +version = "5.23.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytz" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e1/14/86f149430f2e6ffe63f5726951720b7cf4136ee1676eb077c4ade94959df/neo4j-5.23.0.tar.gz", hash = "sha256:26b06dac3a4b93d882a61714c5ca8d06fe68f697cbdfe113ab840d651a2d46a2", size = 215255, upload-time = "2024-07-29T10:22:29.973Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6f/10/0feaa10a342f5c06ffc5bfe3e5e52a9950094186889208251de39092237b/neo4j-5.23.0-py3-none-any.whl", hash = "sha256:5d8d2f45227c12d6ba564720cbc3e2f57aac472e4fa14fe69270e4f952791020", size = 293671, upload-time = "2024-07-29T10:22:24.874Z" }, +] + +[[package]] +name = "networkx" +version = "3.6.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6a/51/63fe664f3908c97be9d2e4f1158eb633317598cfa6e1fc14af5383f17512/networkx-3.6.1.tar.gz", hash = "sha256:26b7c357accc0c8cde558ad486283728b65b6a95d85ee1cd66bafab4c8168509", size = 2517025, upload-time = "2025-12-08T17:02:39.908Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9e/c9/b2622292ea83fbb4ec318f5b9ab867d0a28ab43c5717bb85b0a5f6b3b0a4/networkx-3.6.1-py3-none-any.whl", hash = "sha256:d47fbf302e7d9cbbb9e2555a0d267983d2aa476bac30e90dfbe5669bd57f3762", size = 2068504, upload-time = "2025-12-08T17:02:38.159Z" }, +] + +[[package]] +name = "nltk" +version = "3.9.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "joblib" }, + { name = "regex" }, + { name = "tqdm" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f9/76/3a5e4312c19a028770f86fd7c058cf9f4ec4321c6cf7526bab998a5b683c/nltk-3.9.2.tar.gz", hash = "sha256:0f409e9b069ca4177c1903c3e843eef90c7e92992fa4931ae607da6de49e1419", size = 2887629, upload-time = "2025-10-01T07:19:23.764Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/60/90/81ac364ef94209c100e12579629dc92bf7a709a84af32f8c551b02c07e94/nltk-3.9.2-py3-none-any.whl", hash = "sha256:1e209d2b3009110635ed9709a67a1a3e33a10f799490fa71cf4bec218c11c88a", size = 1513404, upload-time = "2025-10-01T07:19:21.648Z" }, +] + +[[package]] +name = "nodeenv" +version = "1.9.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437, upload-time = "2024-06-04T18:44:11.171Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, +] + +[[package]] +name = "numpy" +version = "2.3.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/76/65/21b3bc86aac7b8f2862db1e808f1ea22b028e30a225a34a5ede9bf8678f2/numpy-2.3.5.tar.gz", hash = "sha256:784db1dcdab56bf0517743e746dfb0f885fc68d948aba86eeec2cba234bdf1c0", size = 20584950, upload-time = "2025-11-16T22:52:42.067Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/43/77/84dd1d2e34d7e2792a236ba180b5e8fcc1e3e414e761ce0253f63d7f572e/numpy-2.3.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:de5672f4a7b200c15a4127042170a694d4df43c992948f5e1af57f0174beed10", size = 17034641, upload-time = "2025-11-16T22:49:19.336Z" }, + { url = "https://files.pythonhosted.org/packages/2a/ea/25e26fa5837106cde46ae7d0b667e20f69cbbc0efd64cba8221411ab26ae/numpy-2.3.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:acfd89508504a19ed06ef963ad544ec6664518c863436306153e13e94605c218", size = 12528324, upload-time = "2025-11-16T22:49:22.582Z" }, + { url = "https://files.pythonhosted.org/packages/4d/1a/e85f0eea4cf03d6a0228f5c0256b53f2df4bc794706e7df019fc622e47f1/numpy-2.3.5-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:ffe22d2b05504f786c867c8395de703937f934272eb67586817b46188b4ded6d", size = 5356872, upload-time = "2025-11-16T22:49:25.408Z" }, + { url = "https://files.pythonhosted.org/packages/5c/bb/35ef04afd567f4c989c2060cde39211e4ac5357155c1833bcd1166055c61/numpy-2.3.5-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:872a5cf366aec6bb1147336480fef14c9164b154aeb6542327de4970282cd2f5", size = 6893148, upload-time = "2025-11-16T22:49:27.549Z" }, + { url = "https://files.pythonhosted.org/packages/f2/2b/05bbeb06e2dff5eab512dfc678b1cc5ee94d8ac5956a0885c64b6b26252b/numpy-2.3.5-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3095bdb8dd297e5920b010e96134ed91d852d81d490e787beca7e35ae1d89cf7", size = 14557282, upload-time = "2025-11-16T22:49:30.964Z" }, + { url = "https://files.pythonhosted.org/packages/65/fb/2b23769462b34398d9326081fad5655198fcf18966fcb1f1e49db44fbf31/numpy-2.3.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8cba086a43d54ca804ce711b2a940b16e452807acebe7852ff327f1ecd49b0d4", size = 16897903, upload-time = "2025-11-16T22:49:34.191Z" }, + { url = "https://files.pythonhosted.org/packages/ac/14/085f4cf05fc3f1e8aa95e85404e984ffca9b2275a5dc2b1aae18a67538b8/numpy-2.3.5-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6cf9b429b21df6b99f4dee7a1218b8b7ffbbe7df8764dc0bd60ce8a0708fed1e", size = 16341672, upload-time = "2025-11-16T22:49:37.2Z" }, + { url = "https://files.pythonhosted.org/packages/6f/3b/1f73994904142b2aa290449b3bb99772477b5fd94d787093e4f24f5af763/numpy-2.3.5-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:396084a36abdb603546b119d96528c2f6263921c50df3c8fd7cb28873a237748", size = 18838896, upload-time = "2025-11-16T22:49:39.727Z" }, + { url = "https://files.pythonhosted.org/packages/cd/b9/cf6649b2124f288309ffc353070792caf42ad69047dcc60da85ee85fea58/numpy-2.3.5-cp311-cp311-win32.whl", hash = "sha256:b0c7088a73aef3d687c4deef8452a3ac7c1be4e29ed8bf3b366c8111128ac60c", size = 6563608, upload-time = "2025-11-16T22:49:42.079Z" }, + { url = "https://files.pythonhosted.org/packages/aa/44/9fe81ae1dcc29c531843852e2874080dc441338574ccc4306b39e2ff6e59/numpy-2.3.5-cp311-cp311-win_amd64.whl", hash = "sha256:a414504bef8945eae5f2d7cb7be2d4af77c5d1cb5e20b296c2c25b61dff2900c", size = 13078442, upload-time = "2025-11-16T22:49:43.99Z" }, + { url = "https://files.pythonhosted.org/packages/6d/a7/f99a41553d2da82a20a2f22e93c94f928e4490bb447c9ff3c4ff230581d3/numpy-2.3.5-cp311-cp311-win_arm64.whl", hash = "sha256:0cd00b7b36e35398fa2d16af7b907b65304ef8bb4817a550e06e5012929830fa", size = 10458555, upload-time = "2025-11-16T22:49:47.092Z" }, + { url = "https://files.pythonhosted.org/packages/44/37/e669fe6cbb2b96c62f6bbedc6a81c0f3b7362f6a59230b23caa673a85721/numpy-2.3.5-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:74ae7b798248fe62021dbf3c914245ad45d1a6b0cb4a29ecb4b31d0bfbc4cc3e", size = 16733873, upload-time = "2025-11-16T22:49:49.84Z" }, + { url = "https://files.pythonhosted.org/packages/c5/65/df0db6c097892c9380851ab9e44b52d4f7ba576b833996e0080181c0c439/numpy-2.3.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ee3888d9ff7c14604052b2ca5535a30216aa0a58e948cdd3eeb8d3415f638769", size = 12259838, upload-time = "2025-11-16T22:49:52.863Z" }, + { url = "https://files.pythonhosted.org/packages/5b/e1/1ee06e70eb2136797abe847d386e7c0e830b67ad1d43f364dd04fa50d338/numpy-2.3.5-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:612a95a17655e213502f60cfb9bf9408efdc9eb1d5f50535cc6eb365d11b42b5", size = 5088378, upload-time = "2025-11-16T22:49:55.055Z" }, + { url = "https://files.pythonhosted.org/packages/6d/9c/1ca85fb86708724275103b81ec4cf1ac1d08f465368acfc8da7ab545bdae/numpy-2.3.5-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:3101e5177d114a593d79dd79658650fe28b5a0d8abeb8ce6f437c0e6df5be1a4", size = 6628559, upload-time = "2025-11-16T22:49:57.371Z" }, + { url = "https://files.pythonhosted.org/packages/74/78/fcd41e5a0ce4f3f7b003da85825acddae6d7ecb60cf25194741b036ca7d6/numpy-2.3.5-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8b973c57ff8e184109db042c842423ff4f60446239bd585a5131cc47f06f789d", size = 14250702, upload-time = "2025-11-16T22:49:59.632Z" }, + { url = "https://files.pythonhosted.org/packages/b6/23/2a1b231b8ff672b4c450dac27164a8b2ca7d9b7144f9c02d2396518352eb/numpy-2.3.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0d8163f43acde9a73c2a33605353a4f1bc4798745a8b1d73183b28e5b435ae28", size = 16606086, upload-time = "2025-11-16T22:50:02.127Z" }, + { url = "https://files.pythonhosted.org/packages/a0/c5/5ad26fbfbe2012e190cc7d5003e4d874b88bb18861d0829edc140a713021/numpy-2.3.5-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:51c1e14eb1e154ebd80e860722f9e6ed6ec89714ad2db2d3aa33c31d7c12179b", size = 16025985, upload-time = "2025-11-16T22:50:04.536Z" }, + { url = "https://files.pythonhosted.org/packages/d2/fa/dd48e225c46c819288148d9d060b047fd2a6fb1eb37eae25112ee4cb4453/numpy-2.3.5-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b46b4ec24f7293f23adcd2d146960559aaf8020213de8ad1909dba6c013bf89c", size = 18542976, upload-time = "2025-11-16T22:50:07.557Z" }, + { url = "https://files.pythonhosted.org/packages/05/79/ccbd23a75862d95af03d28b5c6901a1b7da4803181513d52f3b86ed9446e/numpy-2.3.5-cp312-cp312-win32.whl", hash = "sha256:3997b5b3c9a771e157f9aae01dd579ee35ad7109be18db0e85dbdbe1de06e952", size = 6285274, upload-time = "2025-11-16T22:50:10.746Z" }, + { url = "https://files.pythonhosted.org/packages/2d/57/8aeaf160312f7f489dea47ab61e430b5cb051f59a98ae68b7133ce8fa06a/numpy-2.3.5-cp312-cp312-win_amd64.whl", hash = "sha256:86945f2ee6d10cdfd67bcb4069c1662dd711f7e2a4343db5cecec06b87cf31aa", size = 12782922, upload-time = "2025-11-16T22:50:12.811Z" }, + { url = "https://files.pythonhosted.org/packages/78/a6/aae5cc2ca78c45e64b9ef22f089141d661516856cf7c8a54ba434576900d/numpy-2.3.5-cp312-cp312-win_arm64.whl", hash = "sha256:f28620fe26bee16243be2b7b874da327312240a7cdc38b769a697578d2100013", size = 10194667, upload-time = "2025-11-16T22:50:16.16Z" }, + { url = "https://files.pythonhosted.org/packages/c6/65/f9dea8e109371ade9c782b4e4756a82edf9d3366bca495d84d79859a0b79/numpy-2.3.5-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:f0963b55cdd70fad460fa4c1341f12f976bb26cb66021a5580329bd498988310", size = 16910689, upload-time = "2025-11-16T22:52:23.247Z" }, + { url = "https://files.pythonhosted.org/packages/00/4f/edb00032a8fb92ec0a679d3830368355da91a69cab6f3e9c21b64d0bb986/numpy-2.3.5-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:f4255143f5160d0de972d28c8f9665d882b5f61309d8362fdd3e103cf7bf010c", size = 12457053, upload-time = "2025-11-16T22:52:26.367Z" }, + { url = "https://files.pythonhosted.org/packages/16/a4/e8a53b5abd500a63836a29ebe145fc1ab1f2eefe1cfe59276020373ae0aa/numpy-2.3.5-pp311-pypy311_pp73-macosx_14_0_arm64.whl", hash = "sha256:a4b9159734b326535f4dd01d947f919c6eefd2d9827466a696c44ced82dfbc18", size = 5285635, upload-time = "2025-11-16T22:52:29.266Z" }, + { url = "https://files.pythonhosted.org/packages/a3/2f/37eeb9014d9c8b3e9c55bc599c68263ca44fdbc12a93e45a21d1d56df737/numpy-2.3.5-pp311-pypy311_pp73-macosx_14_0_x86_64.whl", hash = "sha256:2feae0d2c91d46e59fcd62784a3a83b3fb677fead592ce51b5a6fbb4f95965ff", size = 6801770, upload-time = "2025-11-16T22:52:31.421Z" }, + { url = "https://files.pythonhosted.org/packages/7d/e4/68d2f474df2cb671b2b6c2986a02e520671295647dad82484cde80ca427b/numpy-2.3.5-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ffac52f28a7849ad7576293c0cb7b9f08304e8f7d738a8cb8a90ec4c55a998eb", size = 14391768, upload-time = "2025-11-16T22:52:33.593Z" }, + { url = "https://files.pythonhosted.org/packages/b8/50/94ccd8a2b141cb50651fddd4f6a48874acb3c91c8f0842b08a6afc4b0b21/numpy-2.3.5-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:63c0e9e7eea69588479ebf4a8a270d5ac22763cc5854e9a7eae952a3908103f7", size = 16729263, upload-time = "2025-11-16T22:52:36.369Z" }, + { url = "https://files.pythonhosted.org/packages/2d/ee/346fa473e666fe14c52fcdd19ec2424157290a032d4c41f98127bfb31ac7/numpy-2.3.5-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:f16417ec91f12f814b10bafe79ef77e70113a2f5f7018640e7425ff979253425", size = 12967213, upload-time = "2025-11-16T22:52:39.38Z" }, +] + +[[package]] +name = "nvidia-cublas-cu12" +version = "12.8.4.1" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dc/61/e24b560ab2e2eaeb3c839129175fb330dfcfc29e5203196e5541a4c44682/nvidia_cublas_cu12-12.8.4.1-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:8ac4e771d5a348c551b2a426eda6193c19aa630236b418086020df5ba9667142", size = 594346921, upload-time = "2025-03-07T01:44:31.254Z" }, +] + +[[package]] +name = "nvidia-cuda-cupti-cu12" +version = "12.8.90" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f8/02/2adcaa145158bf1a8295d83591d22e4103dbfd821bcaf6f3f53151ca4ffa/nvidia_cuda_cupti_cu12-12.8.90-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ea0cb07ebda26bb9b29ba82cda34849e73c166c18162d3913575b0c9db9a6182", size = 10248621, upload-time = "2025-03-07T01:40:21.213Z" }, +] + +[[package]] +name = "nvidia-cuda-nvrtc-cu12" +version = "12.8.93" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/05/6b/32f747947df2da6994e999492ab306a903659555dddc0fbdeb9d71f75e52/nvidia_cuda_nvrtc_cu12-12.8.93-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl", hash = "sha256:a7756528852ef889772a84c6cd89d41dfa74667e24cca16bb31f8f061e3e9994", size = 88040029, upload-time = "2025-03-07T01:42:13.562Z" }, +] + +[[package]] +name = "nvidia-cuda-runtime-cu12" +version = "12.8.90" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0d/9b/a997b638fcd068ad6e4d53b8551a7d30fe8b404d6f1804abf1df69838932/nvidia_cuda_runtime_cu12-12.8.90-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:adade8dcbd0edf427b7204d480d6066d33902cab2a4707dcfc48a2d0fd44ab90", size = 954765, upload-time = "2025-03-07T01:40:01.615Z" }, +] + +[[package]] +name = "nvidia-cudnn-cu12" +version = "9.10.2.21" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-cublas-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/ba/51/e123d997aa098c61d029f76663dedbfb9bc8dcf8c60cbd6adbe42f76d049/nvidia_cudnn_cu12-9.10.2.21-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:949452be657fa16687d0930933f032835951ef0892b37d2d53824d1a84dc97a8", size = 706758467, upload-time = "2025-06-06T21:54:08.597Z" }, +] + +[[package]] +name = "nvidia-cufft-cu12" +version = "11.3.3.83" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-nvjitlink-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/1f/13/ee4e00f30e676b66ae65b4f08cb5bcbb8392c03f54f2d5413ea99a5d1c80/nvidia_cufft_cu12-11.3.3.83-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4d2dd21ec0b88cf61b62e6b43564355e5222e4a3fb394cac0db101f2dd0d4f74", size = 193118695, upload-time = "2025-03-07T01:45:27.821Z" }, +] + +[[package]] +name = "nvidia-cufile-cu12" +version = "1.13.1.3" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bb/fe/1bcba1dfbfb8d01be8d93f07bfc502c93fa23afa6fd5ab3fc7c1df71038a/nvidia_cufile_cu12-1.13.1.3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1d069003be650e131b21c932ec3d8969c1715379251f8d23a1860554b1cb24fc", size = 1197834, upload-time = "2025-03-07T01:45:50.723Z" }, +] + +[[package]] +name = "nvidia-curand-cu12" +version = "10.3.9.90" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/aa/6584b56dc84ebe9cf93226a5cde4d99080c8e90ab40f0c27bda7a0f29aa1/nvidia_curand_cu12-10.3.9.90-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:b32331d4f4df5d6eefa0554c565b626c7216f87a06a4f56fab27c3b68a830ec9", size = 63619976, upload-time = "2025-03-07T01:46:23.323Z" }, +] + +[[package]] +name = "nvidia-cusolver-cu12" +version = "11.7.3.90" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-cublas-cu12" }, + { name = "nvidia-cusparse-cu12" }, + { name = "nvidia-nvjitlink-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/85/48/9a13d2975803e8cf2777d5ed57b87a0b6ca2cc795f9a4f59796a910bfb80/nvidia_cusolver_cu12-11.7.3.90-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:4376c11ad263152bd50ea295c05370360776f8c3427b30991df774f9fb26c450", size = 267506905, upload-time = "2025-03-07T01:47:16.273Z" }, +] + +[[package]] +name = "nvidia-cusparse-cu12" +version = "12.5.8.93" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-nvjitlink-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/c2/f5/e1854cb2f2bcd4280c44736c93550cc300ff4b8c95ebe370d0aa7d2b473d/nvidia_cusparse_cu12-12.5.8.93-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1ec05d76bbbd8b61b06a80e1eaf8cf4959c3d4ce8e711b65ebd0443bb0ebb13b", size = 288216466, upload-time = "2025-03-07T01:48:13.779Z" }, +] + +[[package]] +name = "nvidia-cusparselt-cu12" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/56/79/12978b96bd44274fe38b5dde5cfb660b1d114f70a65ef962bcbbed99b549/nvidia_cusparselt_cu12-0.7.1-py3-none-manylinux2014_x86_64.whl", hash = "sha256:f1bb701d6b930d5a7cea44c19ceb973311500847f81b634d802b7b539dc55623", size = 287193691, upload-time = "2025-02-26T00:15:44.104Z" }, +] + +[[package]] +name = "nvidia-nccl-cu12" +version = "2.27.5" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6e/89/f7a07dc961b60645dbbf42e80f2bc85ade7feb9a491b11a1e973aa00071f/nvidia_nccl_cu12-2.27.5-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ad730cf15cb5d25fe849c6e6ca9eb5b76db16a80f13f425ac68d8e2e55624457", size = 322348229, upload-time = "2025-06-26T04:11:28.385Z" }, +] + +[[package]] +name = "nvidia-nvjitlink-cu12" +version = "12.8.93" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f6/74/86a07f1d0f42998ca31312f998bd3b9a7eff7f52378f4f270c8679c77fb9/nvidia_nvjitlink_cu12-12.8.93-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl", hash = "sha256:81ff63371a7ebd6e6451970684f916be2eab07321b73c9d244dc2b4da7f73b88", size = 39254836, upload-time = "2025-03-07T01:49:55.661Z" }, +] + +[[package]] +name = "nvidia-nvshmem-cu12" +version = "3.3.20" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3b/6c/99acb2f9eb85c29fc6f3a7ac4dccfd992e22666dd08a642b303311326a97/nvidia_nvshmem_cu12-3.3.20-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d00f26d3f9b2e3c3065be895e3059d6479ea5c638a3f38c9fec49b1b9dd7c1e5", size = 124657145, upload-time = "2025-08-04T20:25:19.995Z" }, +] + +[[package]] +name = "nvidia-nvtx-cu12" +version = "12.8.90" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a2/eb/86626c1bbc2edb86323022371c39aa48df6fd8b0a1647bc274577f72e90b/nvidia_nvtx_cu12-12.8.90-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5b17e2001cc0d751a5bc2c6ec6d26ad95913324a4adb86788c944f8ce9ba441f", size = 89954, upload-time = "2025-03-07T01:42:44.131Z" }, +] + +[[package]] +name = "oauthlib" +version = "3.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0b/5f/19930f824ffeb0ad4372da4812c50edbd1434f678c90c2733e1188edfc63/oauthlib-3.3.1.tar.gz", hash = "sha256:0f0f8aa759826a193cf66c12ea1af1637f87b9b4622d46e866952bb022e538c9", size = 185918, upload-time = "2025-06-19T22:48:08.269Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/be/9c/92789c596b8df838baa98fa71844d84283302f7604ed565dafe5a6b5041a/oauthlib-3.3.1-py3-none-any.whl", hash = "sha256:88119c938d2b8fb88561af5f6ee0eec8cc8d552b7bb1f712743136eb7523b7a1", size = 160065, upload-time = "2025-06-19T22:48:06.508Z" }, +] + +[[package]] +name = "openai" +version = "1.109.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "distro" }, + { name = "httpx" }, + { name = "jiter" }, + { name = "pydantic" }, + { name = "sniffio" }, + { name = "tqdm" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c6/a1/a303104dc55fc546a3f6914c842d3da471c64eec92043aef8f652eb6c524/openai-1.109.1.tar.gz", hash = "sha256:d173ed8dbca665892a6db099b4a2dfac624f94d20a93f46eb0b56aae940ed869", size = 564133, upload-time = "2025-09-24T13:00:53.075Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/2a/7dd3d207ec669cacc1f186fd856a0f61dbc255d24f6fdc1a6715d6051b0f/openai-1.109.1-py3-none-any.whl", hash = "sha256:6bcaf57086cf59159b8e27447e4e7dd019db5d29a438072fbd49c290c7e65315", size = 948627, upload-time = "2025-09-24T13:00:50.754Z" }, +] + +[[package]] +name = "openapi-schema-validator" +version = "0.6.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jsonschema" }, + { name = "jsonschema-specifications" }, + { name = "rfc3339-validator" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8b/f3/5507ad3325169347cd8ced61c232ff3df70e2b250c49f0fe140edb4973c6/openapi_schema_validator-0.6.3.tar.gz", hash = "sha256:f37bace4fc2a5d96692f4f8b31dc0f8d7400fd04f3a937798eaf880d425de6ee", size = 11550, upload-time = "2025-01-10T18:08:22.268Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/21/c6/ad0fba32775ae749016829dace42ed80f4407b171da41313d1a3a5f102e4/openapi_schema_validator-0.6.3-py3-none-any.whl", hash = "sha256:f3b9870f4e556b5a62a1c39da72a6b4b16f3ad9c73dc80084b1b11e74ba148a3", size = 8755, upload-time = "2025-01-10T18:08:19.758Z" }, +] + +[[package]] +name = "openapi-spec-validator" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jsonschema" }, + { name = "jsonschema-path" }, + { name = "lazy-object-proxy" }, + { name = "openapi-schema-validator" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/67/fe/21954ff978239dc29ebb313f5c87eeb4ec929b694b9667323086730998e2/openapi_spec_validator-0.7.1.tar.gz", hash = "sha256:8577b85a8268685da6f8aa30990b83b7960d4d1117e901d451b5d572605e5ec7", size = 37985, upload-time = "2023-10-13T11:43:40.53Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2b/4d/e744fff95aaf3aeafc968d5ba7297c8cda0d1ecb8e3acd21b25adae4d835/openapi_spec_validator-0.7.1-py3-none-any.whl", hash = "sha256:3c81825043f24ccbcd2f4b149b11e8231abce5ba84f37065e14ec947d8f4e959", size = 38998, upload-time = "2023-10-13T11:43:38.371Z" }, +] + +[[package]] +name = "packaging" +version = "25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, +] + +[[package]] +name = "pandas" +version = "2.2.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, + { name = "python-dateutil" }, + { name = "pytz" }, + { name = "tzdata" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/88/d9/ecf715f34c73ccb1d8ceb82fc01cd1028a65a5f6dbc57bfa6ea155119058/pandas-2.2.2.tar.gz", hash = "sha256:9e79019aba43cb4fda9e4d983f8e88ca0373adbb697ae9c6c43093218de28b54", size = 4398391, upload-time = "2024-04-10T19:45:48.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1b/70/61704497903d43043e288017cb2b82155c0d41e15f5c17807920877b45c2/pandas-2.2.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:696039430f7a562b74fa45f540aca068ea85fa34c244d0deee539cb6d70aa288", size = 12574808, upload-time = "2024-04-10T19:44:35.516Z" }, + { url = "https://files.pythonhosted.org/packages/16/c6/75231fd47afd6b3f89011e7077f1a3958441264aca7ae9ff596e3276a5d0/pandas-2.2.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8e90497254aacacbc4ea6ae5e7a8cd75629d6ad2b30025a4a8b09aa4faf55151", size = 11304876, upload-time = "2024-04-10T19:44:39.37Z" }, + { url = "https://files.pythonhosted.org/packages/97/2d/7b54f80b93379ff94afb3bd9b0cd1d17b48183a0d6f98045bc01ce1e06a7/pandas-2.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:58b84b91b0b9f4bafac2a0ac55002280c094dfc6402402332c0913a59654ab2b", size = 15602548, upload-time = "2024-04-10T19:44:42.902Z" }, + { url = "https://files.pythonhosted.org/packages/fc/a5/4d82be566f069d7a9a702dcdf6f9106df0e0b042e738043c0cc7ddd7e3f6/pandas-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2123dc9ad6a814bcdea0f099885276b31b24f7edf40f6cdbc0912672e22eee", size = 13031332, upload-time = "2024-04-10T19:44:46.98Z" }, + { url = "https://files.pythonhosted.org/packages/92/a2/b79c48f530673567805e607712b29814b47dcaf0d167e87145eb4b0118c6/pandas-2.2.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:2925720037f06e89af896c70bca73459d7e6a4be96f9de79e2d440bd499fe0db", size = 16286054, upload-time = "2024-04-10T19:44:50.51Z" }, + { url = "https://files.pythonhosted.org/packages/40/c7/47e94907f1d8fdb4868d61bd6c93d57b3784a964d52691b77ebfdb062842/pandas-2.2.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0cace394b6ea70c01ca1595f839cf193df35d1575986e484ad35c4aeae7266c1", size = 13879507, upload-time = "2024-04-10T19:44:54.412Z" }, + { url = "https://files.pythonhosted.org/packages/ab/63/966db1321a0ad55df1d1fe51505d2cdae191b84c907974873817b0a6e849/pandas-2.2.2-cp311-cp311-win_amd64.whl", hash = "sha256:873d13d177501a28b2756375d59816c365e42ed8417b41665f346289adc68d24", size = 11634249, upload-time = "2024-04-10T19:44:58.183Z" }, + { url = "https://files.pythonhosted.org/packages/dd/49/de869130028fb8d90e25da3b7d8fb13e40f5afa4c4af1781583eb1ff3839/pandas-2.2.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:9dfde2a0ddef507a631dc9dc4af6a9489d5e2e740e226ad426a05cabfbd7c8ef", size = 12500886, upload-time = "2024-04-10T19:45:01.808Z" }, + { url = "https://files.pythonhosted.org/packages/db/7c/9a60add21b96140e22465d9adf09832feade45235cd22f4cb1668a25e443/pandas-2.2.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e9b79011ff7a0f4b1d6da6a61aa1aa604fb312d6647de5bad20013682d1429ce", size = 11340320, upload-time = "2024-04-11T18:36:14.398Z" }, + { url = "https://files.pythonhosted.org/packages/b0/85/f95b5f322e1ae13b7ed7e97bd999160fa003424711ab4dc8344b8772c270/pandas-2.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1cb51fe389360f3b5a4d57dbd2848a5f033350336ca3b340d1c53a1fad33bcad", size = 15204346, upload-time = "2024-04-10T19:45:05.903Z" }, + { url = "https://files.pythonhosted.org/packages/40/10/79e52ef01dfeb1c1ca47a109a01a248754ebe990e159a844ece12914de83/pandas-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eee3a87076c0756de40b05c5e9a6069c035ba43e8dd71c379e68cab2c20f16ad", size = 12733396, upload-time = "2024-04-10T19:45:09.282Z" }, + { url = "https://files.pythonhosted.org/packages/35/9d/208febf8c4eb5c1d9ea3314d52d8bd415fd0ef0dd66bb24cc5bdbc8fa71a/pandas-2.2.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3e374f59e440d4ab45ca2fffde54b81ac3834cf5ae2cdfa69c90bc03bde04d76", size = 15858913, upload-time = "2024-04-10T19:45:12.514Z" }, + { url = "https://files.pythonhosted.org/packages/99/d1/2d9bd05def7a9e08a92ec929b5a4c8d5556ec76fae22b0fa486cbf33ea63/pandas-2.2.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:43498c0bdb43d55cb162cdc8c06fac328ccb5d2eabe3cadeb3529ae6f0517c32", size = 13417786, upload-time = "2024-04-10T19:45:16.275Z" }, + { url = "https://files.pythonhosted.org/packages/22/a5/a0b255295406ed54269814bc93723cfd1a0da63fb9aaf99e1364f07923e5/pandas-2.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:d187d355ecec3629624fccb01d104da7d7f391db0311145817525281e2804d23", size = 11498828, upload-time = "2024-04-10T19:45:19.85Z" }, +] + +[[package]] +name = "pandocfilters" +version = "1.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/70/6f/3dd4940bbe001c06a65f88e36bad298bc7a0de5036115639926b0c5c0458/pandocfilters-1.5.1.tar.gz", hash = "sha256:002b4a555ee4ebc03f8b66307e287fa492e4a77b4ea14d3f934328297bb4939e", size = 8454, upload-time = "2024-01-18T20:08:13.726Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/af/4fbc8cab944db5d21b7e2a5b8e9211a03a79852b1157e2c102fcc61ac440/pandocfilters-1.5.1-py2.py3-none-any.whl", hash = "sha256:93be382804a9cdb0a7267585f157e5d1731bbe5545a85b268d6f5fe6232de2bc", size = 8663, upload-time = "2024-01-18T20:08:11.28Z" }, +] + +[[package]] +name = "parso" +version = "0.8.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d4/de/53e0bcf53d13e005bd8c92e7855142494f41171b34c2536b86187474184d/parso-0.8.5.tar.gz", hash = "sha256:034d7354a9a018bdce352f48b2a8a450f05e9d6ee85db84764e9b6bd96dafe5a", size = 401205, upload-time = "2025-08-23T15:15:28.028Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/16/32/f8e3c85d1d5250232a5d3477a2a28cc291968ff175caeadaf3cc19ce0e4a/parso-0.8.5-py2.py3-none-any.whl", hash = "sha256:646204b5ee239c396d040b90f9e272e9a8017c630092bf59980beb62fd033887", size = 106668, upload-time = "2025-08-23T15:15:25.663Z" }, +] + +[[package]] +name = "pathable" +version = "0.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/67/93/8f2c2075b180c12c1e9f6a09d1a985bc2036906b13dff1d8917e395f2048/pathable-0.4.4.tar.gz", hash = "sha256:6905a3cd17804edfac7875b5f6c9142a218c7caef78693c2dbbbfbac186d88b2", size = 8124, upload-time = "2025-01-10T18:43:13.247Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7d/eb/b6260b31b1a96386c0a880edebe26f89669098acea8e0318bff6adb378fd/pathable-0.4.4-py3-none-any.whl", hash = "sha256:5ae9e94793b6ef5a4cbe0a7ce9dbbefc1eec38df253763fd0aeeacf2762dbbc2", size = 9592, upload-time = "2025-01-10T18:43:11.88Z" }, +] + +[[package]] +name = "pexpect" +version = "4.9.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ptyprocess" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" }, +] + +[[package]] +name = "pickleshare" +version = "0.7.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/b6/df3c1c9b616e9c0edbc4fbab6ddd09df9535849c64ba51fcb6531c32d4d8/pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", size = 6161, upload-time = "2018-09-25T19:17:37.249Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl", hash = "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56", size = 6877, upload-time = "2018-09-25T19:17:35.817Z" }, +] + +[[package]] +name = "pillow" +version = "10.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ef/43/c50c17c5f7d438e836c169e343695534c38c77f60e7c90389bd77981bc21/pillow-10.3.0.tar.gz", hash = "sha256:9d2455fbf44c914840c793e89aa82d0e1763a14253a000743719ae5946814b2d", size = 46572854, upload-time = "2024-04-01T12:19:40.048Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/51/e4b35e394b4e5ca24983e50361a1db3d7da05b1758074f9c4f5b4be4b22a/pillow-10.3.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:5f77cf66e96ae734717d341c145c5949c63180842a545c47a0ce7ae52ca83795", size = 3528936, upload-time = "2024-04-01T12:17:29.322Z" }, + { url = "https://files.pythonhosted.org/packages/00/5c/7633f291def20082bad31b844fe5ed07742aae8504e4cfe2f331ee727178/pillow-10.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e4b878386c4bf293578b48fc570b84ecfe477d3b77ba39a6e87150af77f40c57", size = 3352899, upload-time = "2024-04-01T12:17:31.843Z" }, + { url = "https://files.pythonhosted.org/packages/1d/29/abda81a079cccd1840b0b7b13ad67ffac87cc66395ae20973027280e9f9f/pillow-10.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fdcbb4068117dfd9ce0138d068ac512843c52295ed996ae6dd1faf537b6dbc27", size = 4317733, upload-time = "2024-04-01T12:17:34.494Z" }, + { url = "https://files.pythonhosted.org/packages/77/cd/5205fb43a6000d424291b0525b8201004700d9a34e034517ac4dfdc6eed5/pillow-10.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9797a6c8fe16f25749b371c02e2ade0efb51155e767a971c61734b1bf6293994", size = 4429430, upload-time = "2024-04-01T12:17:37.112Z" }, + { url = "https://files.pythonhosted.org/packages/8c/bb/9e8d2b1b54235bd44139ee387beeb65ad9d8d755b5c01f817070c6dabea7/pillow-10.3.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:9e91179a242bbc99be65e139e30690e081fe6cb91a8e77faf4c409653de39451", size = 4341711, upload-time = "2024-04-01T12:17:39.151Z" }, + { url = "https://files.pythonhosted.org/packages/81/ff/ad3c942d865f9e45ce84eeb31795e6d4d94e1f1eea51026d5154028510d7/pillow-10.3.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:1b87bd9d81d179bd8ab871603bd80d8645729939f90b71e62914e816a76fc6bd", size = 4507469, upload-time = "2024-04-01T12:17:41.159Z" }, + { url = "https://files.pythonhosted.org/packages/ab/ab/30cd50a12d9afa2c412efcb8b37dd3f5f1da4bc77b984ddfbc776d96cf5b/pillow-10.3.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:81d09caa7b27ef4e61cb7d8fbf1714f5aec1c6b6c5270ee53504981e6e9121ad", size = 4533491, upload-time = "2024-04-01T12:17:43.813Z" }, + { url = "https://files.pythonhosted.org/packages/1f/f0/07419615ffa852cded35dfa3337bf70788f232a3dfe622b97d5eb0c32674/pillow-10.3.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:048ad577748b9fa4a99a0548c64f2cb8d672d5bf2e643a739ac8faff1164238c", size = 4598334, upload-time = "2024-04-01T12:17:46.271Z" }, + { url = "https://files.pythonhosted.org/packages/9c/f3/6e923786f2b2d167d16783fc079c003aadbcedc4995f54e8429d91aabfc4/pillow-10.3.0-cp311-cp311-win32.whl", hash = "sha256:7161ec49ef0800947dc5570f86568a7bb36fa97dd09e9827dc02b718c5643f09", size = 2217293, upload-time = "2024-04-01T12:17:48.292Z" }, + { url = "https://files.pythonhosted.org/packages/0a/16/c83877524c47976f16703d2e05c363244bc1e60ab439e078b3cd046d07db/pillow-10.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:8eb0908e954d093b02a543dc963984d6e99ad2b5e36503d8a0aaf040505f747d", size = 2531332, upload-time = "2024-04-01T12:17:50.844Z" }, + { url = "https://files.pythonhosted.org/packages/a8/3b/f64454549af90818774c3210b48987c3aeca5285787dbd69869d9a05b58f/pillow-10.3.0-cp311-cp311-win_arm64.whl", hash = "sha256:4e6f7d1c414191c1199f8996d3f2282b9ebea0945693fb67392c75a3a320941f", size = 2229546, upload-time = "2024-04-01T12:17:53.237Z" }, + { url = "https://files.pythonhosted.org/packages/cc/5d/b7fcd38cba0f7706f64c1674fc9f018e4c64f791770598c44affadea7c2f/pillow-10.3.0-cp312-cp312-macosx_10_10_x86_64.whl", hash = "sha256:e46f38133e5a060d46bd630faa4d9fa0202377495df1f068a8299fd78c84de84", size = 3528535, upload-time = "2024-04-01T12:17:55.891Z" }, + { url = "https://files.pythonhosted.org/packages/5e/77/4cf407e7b033b4d8e5fcaac295b6e159cf1c70fa105d769f01ea2e1e5eca/pillow-10.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:50b8eae8f7334ec826d6eeffaeeb00e36b5e24aa0b9df322c247539714c6df19", size = 3352281, upload-time = "2024-04-01T12:17:58.527Z" }, + { url = "https://files.pythonhosted.org/packages/53/7b/4f7b153a776725a87797d744ea1c73b83ac0b723f5e379297605dee118eb/pillow-10.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9d3bea1c75f8c53ee4d505c3e67d8c158ad4df0d83170605b50b64025917f338", size = 4321427, upload-time = "2024-04-01T12:18:00.809Z" }, + { url = "https://files.pythonhosted.org/packages/45/08/d2cc751b790e77464f8648aa707e2327d6da5d95cf236a532e99c2e7a499/pillow-10.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:19aeb96d43902f0a783946a0a87dbdad5c84c936025b8419da0a0cd7724356b1", size = 4435915, upload-time = "2024-04-01T12:18:03.084Z" }, + { url = "https://files.pythonhosted.org/packages/ef/97/f69d1932cf45bf5bd9fa1e2ae57bdf716524faa4fa9fb7dc62cdb1a19113/pillow-10.3.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:74d28c17412d9caa1066f7a31df8403ec23d5268ba46cd0ad2c50fb82ae40462", size = 4347392, upload-time = "2024-04-01T12:18:05.319Z" }, + { url = "https://files.pythonhosted.org/packages/c6/c1/3521ddb9c1f3ac106af3e4512a98c785b6ed8a39e0f778480b8a4d340165/pillow-10.3.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:ff61bfd9253c3915e6d41c651d5f962da23eda633cf02262990094a18a55371a", size = 4514536, upload-time = "2024-04-01T12:18:08.039Z" }, + { url = "https://files.pythonhosted.org/packages/c0/6f/347c241904a6514e59515284b01ba6f61765269a0d1a19fd2e6cbe331c8a/pillow-10.3.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d886f5d353333b4771d21267c7ecc75b710f1a73d72d03ca06df49b09015a9ef", size = 4555987, upload-time = "2024-04-01T12:18:10.106Z" }, + { url = "https://files.pythonhosted.org/packages/c3/e2/3cc490c6b2e262713da82ce849c34bd8e6c31242afb53be8595d820b9877/pillow-10.3.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4b5ec25d8b17217d635f8935dbc1b9aa5907962fae29dff220f2659487891cd3", size = 4623526, upload-time = "2024-04-01T12:18:12.172Z" }, + { url = "https://files.pythonhosted.org/packages/c1/b3/0209f70fa29b383e7618e47db95712a45788dea03bb960601753262a2883/pillow-10.3.0-cp312-cp312-win32.whl", hash = "sha256:51243f1ed5161b9945011a7360e997729776f6e5d7005ba0c6879267d4c5139d", size = 2217547, upload-time = "2024-04-01T12:18:14.188Z" }, + { url = "https://files.pythonhosted.org/packages/d3/23/3927d888481ff7c44fdbca3bc2a2e97588c933db46723bf115201377c436/pillow-10.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:412444afb8c4c7a6cc11a47dade32982439925537e483be7c0ae0cf96c4f6a0b", size = 2531641, upload-time = "2024-04-01T12:18:16.081Z" }, + { url = "https://files.pythonhosted.org/packages/db/36/1ecaa0541d3a1b1362f937d386eeb1875847bfa06d5225f1b0e1588d1007/pillow-10.3.0-cp312-cp312-win_arm64.whl", hash = "sha256:798232c92e7665fe82ac085f9d8e8ca98826f8e27859d9a96b41d519ecd2e49a", size = 2229746, upload-time = "2024-04-01T12:18:18.174Z" }, +] + +[[package]] +name = "pipreqs" +version = "0.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "docopt" }, + { name = "ipython" }, + { name = "nbconvert" }, + { name = "yarg" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/12/4c/0a335b1b70c7e1821140ac6f884b51d47f049bcb600fa19bb374922f73aa/pipreqs-0.5.0.tar.gz", hash = "sha256:f33298d235ff76def369cb9a3594d084d9badc70cebba1e8cb271fcd4fdc0183", size = 35240, upload-time = "2024-02-18T17:49:36.607Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/36/38/cc1343c3a63655e18328e51e00c6e6851be648f1b8babffc5131f1b9f226/pipreqs-0.5.0-py3-none-any.whl", hash = "sha256:0809f6217028e35785f80e90217e18043e58c99ba28175e28320f9074dd03874", size = 33496, upload-time = "2024-02-18T17:49:34.148Z" }, +] + +[[package]] +name = "platformdirs" +version = "4.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cf/86/0248f086a84f01b37aaec0fa567b397df1a119f73c16f6c7a9aac73ea309/platformdirs-4.5.1.tar.gz", hash = "sha256:61d5cdcc6065745cdd94f0f878977f8de9437be93de97c1c12f853c9c0cdcbda", size = 21715, upload-time = "2025-12-05T13:52:58.638Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/28/3bfe2fa5a7b9c46fe7e13c97bda14c895fb10fa2ebf1d0abb90e0cea7ee1/platformdirs-4.5.1-py3-none-any.whl", hash = "sha256:d03afa3963c806a9bed9d5125c8f4cb2fdaf74a55ab60e5d59b3fde758104d31", size = 18731, upload-time = "2025-12-05T13:52:56.823Z" }, +] + +[[package]] +name = "pluggy" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, +] + +[[package]] +name = "prance" +version = "23.6.21.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "chardet" }, + { name = "packaging" }, + { name = "requests" }, + { name = "ruamel-yaml" }, + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/73/f0/bcb5ffc8b7ab8e3d02dbef3bd945cf8fd6e12c146774f900659406b9fce1/prance-23.6.21.0.tar.gz", hash = "sha256:d8c15f8ac34019751cc4945f866d8d964d7888016d10de3592e339567177cabe", size = 2798776, upload-time = "2023-06-21T20:01:57.142Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c9/db/4fb4901ee61274d0ab97746461fc5f2637e5d73aa73f34ee28e941a699a1/prance-23.6.21.0-py3-none-any.whl", hash = "sha256:6a4276fa07ed9f22feda4331097d7503c4adc3097e46ffae97425f2c1026bd9f", size = 36279, upload-time = "2023-06-21T20:01:54.936Z" }, +] + +[[package]] +name = "pre-commit" +version = "3.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cfgv" }, + { name = "identify" }, + { name = "nodeenv" }, + { name = "pyyaml" }, + { name = "virtualenv" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/aa/46/cc214ef6514270328910083d0119d0a80a6d2c4ec8c6608c0219db0b74cf/pre_commit-3.7.1.tar.gz", hash = "sha256:8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a", size = 177317, upload-time = "2024-05-11T01:25:19.473Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b9/0f/d6d0b4e2f5b2933a557087fc0560371aa545a18232d4d3427eb3bb3af12e/pre_commit-3.7.1-py2.py3-none-any.whl", hash = "sha256:fae36fd1d7ad7d6a5a1c0b0d5adb2ed1a3bda5a21bf6c3e5372073d7a11cd4c5", size = 204268, upload-time = "2024-05-11T01:25:16.845Z" }, +] + +[[package]] +name = "prompt-toolkit" +version = "3.0.52" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "wcwidth" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a1/96/06e01a7b38dce6fe1db213e061a4602dd6032a8a97ef6c1a862537732421/prompt_toolkit-3.0.52.tar.gz", hash = "sha256:28cde192929c8e7321de85de1ddbe736f1375148b02f2e17edd840042b1be855", size = 434198, upload-time = "2025-08-27T15:24:02.057Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/84/03/0d3ce49e2505ae70cf43bc5bb3033955d2fc9f932163e84dc0779cc47f48/prompt_toolkit-3.0.52-py3-none-any.whl", hash = "sha256:9aac639a3bbd33284347de5ad8d68ecc044b91a762dc39b7c21095fcd6a19955", size = 391431, upload-time = "2025-08-27T15:23:59.498Z" }, +] + +[[package]] +name = "psutil" +version = "5.9.8" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/90/c7/6dc0a455d111f68ee43f27793971cf03fe29b6ef972042549db29eec39a2/psutil-5.9.8.tar.gz", hash = "sha256:6be126e3225486dff286a8fb9a06246a5253f4c7c53b475ea5f5ac934e64194c", size = 503247, upload-time = "2024-01-19T20:47:09.517Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/e3/07ae864a636d70a8a6f58da27cb1179192f1140d5d1da10886ade9405797/psutil-5.9.8-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:aee678c8720623dc456fa20659af736241f575d79429a0e5e9cf88ae0605cc81", size = 248702, upload-time = "2024-01-19T20:47:36.303Z" }, + { url = "https://files.pythonhosted.org/packages/b3/bd/28c5f553667116b2598b9cc55908ec435cb7f77a34f2bff3e3ca765b0f78/psutil-5.9.8-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8cb6403ce6d8e047495a701dc7c5bd788add903f8986d523e3e20b98b733e421", size = 285242, upload-time = "2024-01-19T20:47:39.65Z" }, + { url = "https://files.pythonhosted.org/packages/c5/4f/0e22aaa246f96d6ac87fe5ebb9c5a693fbe8877f537a1022527c47ca43c5/psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d06016f7f8625a1825ba3732081d77c94589dca78b7a3fc072194851e88461a4", size = 288191, upload-time = "2024-01-19T20:47:43.078Z" }, + { url = "https://files.pythonhosted.org/packages/6e/f5/2aa3a4acdc1e5940b59d421742356f133185667dd190b166dbcfcf5d7b43/psutil-5.9.8-cp37-abi3-win32.whl", hash = "sha256:bc56c2a1b0d15aa3eaa5a60c9f3f8e3e565303b465dbf57a1b730e7a2b9844e0", size = 251252, upload-time = "2024-01-19T20:47:52.88Z" }, + { url = "https://files.pythonhosted.org/packages/93/52/3e39d26feae7df0aa0fd510b14012c3678b36ed068f7d78b8d8784d61f0e/psutil-5.9.8-cp37-abi3-win_amd64.whl", hash = "sha256:8db4c1b57507eef143a15a6884ca10f7c73876cdf5d51e713151c1236a0e68cf", size = 255090, upload-time = "2024-01-19T20:47:56.019Z" }, + { url = "https://files.pythonhosted.org/packages/05/33/2d74d588408caedd065c2497bdb5ef83ce6082db01289a1e1147f6639802/psutil-5.9.8-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:d16bbddf0693323b8c6123dd804100241da461e41d6e332fb0ba6058f630f8c8", size = 249898, upload-time = "2024-01-19T20:47:59.238Z" }, +] + +[[package]] +name = "ptyprocess" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/20/e5/16ff212c1e452235a90aeb09066144d0c5a6a8c0834397e03f5224495c4e/ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220", size = 70762, upload-time = "2020-12-28T15:15:30.155Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", size = 13993, upload-time = "2020-12-28T15:15:28.35Z" }, +] + +[[package]] +name = "pure-eval" +version = "0.2.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cd/05/0a34433a064256a578f1783a10da6df098ceaa4a57bbeaa96a6c0352786b/pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42", size = 19752, upload-time = "2024-07-21T12:58:21.801Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8e/37/efad0257dc6e593a18957422533ff0f87ede7c9c6ea010a2177d738fb82f/pure_eval-0.2.3-py3-none-any.whl", hash = "sha256:1db8e35b67b3d218d818ae653e27f06c3aa420901fa7b081ca98cbedc874e0d0", size = 11842, upload-time = "2024-07-21T12:58:20.04Z" }, +] + +[[package]] +name = "pycparser" +version = "2.23" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fe/cf/d2d3b9f5699fb1e4615c8e32ff220203e43b248e1dfcc6736ad9057731ca/pycparser-2.23.tar.gz", hash = "sha256:78816d4f24add8f10a06d6f05b4d424ad9e96cfebf68a4ddc99c65c0720d00c2", size = 173734, upload-time = "2025-09-09T13:23:47.91Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/e3/59cd50310fc9b59512193629e1984c1f95e5c8ae6e5d8c69532ccc65a7fe/pycparser-2.23-py3-none-any.whl", hash = "sha256:e5c6e8d3fbad53479cab09ac03729e0a9faf2bee3db8208a550daf5af81a5934", size = 118140, upload-time = "2025-09-09T13:23:46.651Z" }, +] + +[[package]] +name = "pydantic" +version = "2.12.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/69/44/36f1a6e523abc58ae5f928898e4aca2e0ea509b5aa6f6f392a5d882be928/pydantic-2.12.5.tar.gz", hash = "sha256:4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49", size = 821591, upload-time = "2025-11-26T15:11:46.471Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5a/87/b70ad306ebb6f9b585f114d0ac2137d792b48be34d732d60e597c2f8465a/pydantic-2.12.5-py3-none-any.whl", hash = "sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d", size = 463580, upload-time = "2025-11-26T15:11:44.605Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.41.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz", hash = "sha256:08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e", size = 460952, upload-time = "2025-11-04T13:43:49.098Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e8/72/74a989dd9f2084b3d9530b0915fdda64ac48831c30dbf7c72a41a5232db8/pydantic_core-2.41.5-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:a3a52f6156e73e7ccb0f8cced536adccb7042be67cb45f9562e12b319c119da6", size = 2105873, upload-time = "2025-11-04T13:39:31.373Z" }, + { url = "https://files.pythonhosted.org/packages/12/44/37e403fd9455708b3b942949e1d7febc02167662bf1a7da5b78ee1ea2842/pydantic_core-2.41.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7f3bf998340c6d4b0c9a2f02d6a400e51f123b59565d74dc60d252ce888c260b", size = 1899826, upload-time = "2025-11-04T13:39:32.897Z" }, + { url = "https://files.pythonhosted.org/packages/33/7f/1d5cab3ccf44c1935a359d51a8a2a9e1a654b744b5e7f80d41b88d501eec/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:378bec5c66998815d224c9ca994f1e14c0c21cb95d2f52b6021cc0b2a58f2a5a", size = 1917869, upload-time = "2025-11-04T13:39:34.469Z" }, + { url = "https://files.pythonhosted.org/packages/6e/6a/30d94a9674a7fe4f4744052ed6c5e083424510be1e93da5bc47569d11810/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7b576130c69225432866fe2f4a469a85a54ade141d96fd396dffcf607b558f8", size = 2063890, upload-time = "2025-11-04T13:39:36.053Z" }, + { url = "https://files.pythonhosted.org/packages/50/be/76e5d46203fcb2750e542f32e6c371ffa9b8ad17364cf94bb0818dbfb50c/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6cb58b9c66f7e4179a2d5e0f849c48eff5c1fca560994d6eb6543abf955a149e", size = 2229740, upload-time = "2025-11-04T13:39:37.753Z" }, + { url = "https://files.pythonhosted.org/packages/d3/ee/fed784df0144793489f87db310a6bbf8118d7b630ed07aa180d6067e653a/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:88942d3a3dff3afc8288c21e565e476fc278902ae4d6d134f1eeda118cc830b1", size = 2350021, upload-time = "2025-11-04T13:39:40.94Z" }, + { url = "https://files.pythonhosted.org/packages/c8/be/8fed28dd0a180dca19e72c233cbf58efa36df055e5b9d90d64fd1740b828/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f31d95a179f8d64d90f6831d71fa93290893a33148d890ba15de25642c5d075b", size = 2066378, upload-time = "2025-11-04T13:39:42.523Z" }, + { url = "https://files.pythonhosted.org/packages/b0/3b/698cf8ae1d536a010e05121b4958b1257f0b5522085e335360e53a6b1c8b/pydantic_core-2.41.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c1df3d34aced70add6f867a8cf413e299177e0c22660cc767218373d0779487b", size = 2175761, upload-time = "2025-11-04T13:39:44.553Z" }, + { url = "https://files.pythonhosted.org/packages/b8/ba/15d537423939553116dea94ce02f9c31be0fa9d0b806d427e0308ec17145/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:4009935984bd36bd2c774e13f9a09563ce8de4abaa7226f5108262fa3e637284", size = 2146303, upload-time = "2025-11-04T13:39:46.238Z" }, + { url = "https://files.pythonhosted.org/packages/58/7f/0de669bf37d206723795f9c90c82966726a2ab06c336deba4735b55af431/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:34a64bc3441dc1213096a20fe27e8e128bd3ff89921706e83c0b1ac971276594", size = 2340355, upload-time = "2025-11-04T13:39:48.002Z" }, + { url = "https://files.pythonhosted.org/packages/e5/de/e7482c435b83d7e3c3ee5ee4451f6e8973cff0eb6007d2872ce6383f6398/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c9e19dd6e28fdcaa5a1de679aec4141f691023916427ef9bae8584f9c2fb3b0e", size = 2319875, upload-time = "2025-11-04T13:39:49.705Z" }, + { url = "https://files.pythonhosted.org/packages/fe/e6/8c9e81bb6dd7560e33b9053351c29f30c8194b72f2d6932888581f503482/pydantic_core-2.41.5-cp311-cp311-win32.whl", hash = "sha256:2c010c6ded393148374c0f6f0bf89d206bf3217f201faa0635dcd56bd1520f6b", size = 1987549, upload-time = "2025-11-04T13:39:51.842Z" }, + { url = "https://files.pythonhosted.org/packages/11/66/f14d1d978ea94d1bc21fc98fcf570f9542fe55bfcc40269d4e1a21c19bf7/pydantic_core-2.41.5-cp311-cp311-win_amd64.whl", hash = "sha256:76ee27c6e9c7f16f47db7a94157112a2f3a00e958bc626e2f4ee8bec5c328fbe", size = 2011305, upload-time = "2025-11-04T13:39:53.485Z" }, + { url = "https://files.pythonhosted.org/packages/56/d8/0e271434e8efd03186c5386671328154ee349ff0354d83c74f5caaf096ed/pydantic_core-2.41.5-cp311-cp311-win_arm64.whl", hash = "sha256:4bc36bbc0b7584de96561184ad7f012478987882ebf9f9c389b23f432ea3d90f", size = 1972902, upload-time = "2025-11-04T13:39:56.488Z" }, + { url = "https://files.pythonhosted.org/packages/5f/5d/5f6c63eebb5afee93bcaae4ce9a898f3373ca23df3ccaef086d0233a35a7/pydantic_core-2.41.5-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f41a7489d32336dbf2199c8c0a215390a751c5b014c2c1c5366e817202e9cdf7", size = 2110990, upload-time = "2025-11-04T13:39:58.079Z" }, + { url = "https://files.pythonhosted.org/packages/aa/32/9c2e8ccb57c01111e0fd091f236c7b371c1bccea0fa85247ac55b1e2b6b6/pydantic_core-2.41.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:070259a8818988b9a84a449a2a7337c7f430a22acc0859c6b110aa7212a6d9c0", size = 1896003, upload-time = "2025-11-04T13:39:59.956Z" }, + { url = "https://files.pythonhosted.org/packages/68/b8/a01b53cb0e59139fbc9e4fda3e9724ede8de279097179be4ff31f1abb65a/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e96cea19e34778f8d59fe40775a7a574d95816eb150850a85a7a4c8f4b94ac69", size = 1919200, upload-time = "2025-11-04T13:40:02.241Z" }, + { url = "https://files.pythonhosted.org/packages/38/de/8c36b5198a29bdaade07b5985e80a233a5ac27137846f3bc2d3b40a47360/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed2e99c456e3fadd05c991f8f437ef902e00eedf34320ba2b0842bd1c3ca3a75", size = 2052578, upload-time = "2025-11-04T13:40:04.401Z" }, + { url = "https://files.pythonhosted.org/packages/00/b5/0e8e4b5b081eac6cb3dbb7e60a65907549a1ce035a724368c330112adfdd/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:65840751b72fbfd82c3c640cff9284545342a4f1eb1586ad0636955b261b0b05", size = 2208504, upload-time = "2025-11-04T13:40:06.072Z" }, + { url = "https://files.pythonhosted.org/packages/77/56/87a61aad59c7c5b9dc8caad5a41a5545cba3810c3e828708b3d7404f6cef/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e536c98a7626a98feb2d3eaf75944ef6f3dbee447e1f841eae16f2f0a72d8ddc", size = 2335816, upload-time = "2025-11-04T13:40:07.835Z" }, + { url = "https://files.pythonhosted.org/packages/0d/76/941cc9f73529988688a665a5c0ecff1112b3d95ab48f81db5f7606f522d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eceb81a8d74f9267ef4081e246ffd6d129da5d87e37a77c9bde550cb04870c1c", size = 2075366, upload-time = "2025-11-04T13:40:09.804Z" }, + { url = "https://files.pythonhosted.org/packages/d3/43/ebef01f69baa07a482844faaa0a591bad1ef129253ffd0cdaa9d8a7f72d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d38548150c39b74aeeb0ce8ee1d8e82696f4a4e16ddc6de7b1d8823f7de4b9b5", size = 2171698, upload-time = "2025-11-04T13:40:12.004Z" }, + { url = "https://files.pythonhosted.org/packages/b1/87/41f3202e4193e3bacfc2c065fab7706ebe81af46a83d3e27605029c1f5a6/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c23e27686783f60290e36827f9c626e63154b82b116d7fe9adba1fda36da706c", size = 2132603, upload-time = "2025-11-04T13:40:13.868Z" }, + { url = "https://files.pythonhosted.org/packages/49/7d/4c00df99cb12070b6bccdef4a195255e6020a550d572768d92cc54dba91a/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:482c982f814460eabe1d3bb0adfdc583387bd4691ef00b90575ca0d2b6fe2294", size = 2329591, upload-time = "2025-11-04T13:40:15.672Z" }, + { url = "https://files.pythonhosted.org/packages/cc/6a/ebf4b1d65d458f3cda6a7335d141305dfa19bdc61140a884d165a8a1bbc7/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:bfea2a5f0b4d8d43adf9d7b8bf019fb46fdd10a2e5cde477fbcb9d1fa08c68e1", size = 2319068, upload-time = "2025-11-04T13:40:17.532Z" }, + { url = "https://files.pythonhosted.org/packages/49/3b/774f2b5cd4192d5ab75870ce4381fd89cf218af999515baf07e7206753f0/pydantic_core-2.41.5-cp312-cp312-win32.whl", hash = "sha256:b74557b16e390ec12dca509bce9264c3bbd128f8a2c376eaa68003d7f327276d", size = 1985908, upload-time = "2025-11-04T13:40:19.309Z" }, + { url = "https://files.pythonhosted.org/packages/86/45/00173a033c801cacf67c190fef088789394feaf88a98a7035b0e40d53dc9/pydantic_core-2.41.5-cp312-cp312-win_amd64.whl", hash = "sha256:1962293292865bca8e54702b08a4f26da73adc83dd1fcf26fbc875b35d81c815", size = 2020145, upload-time = "2025-11-04T13:40:21.548Z" }, + { url = "https://files.pythonhosted.org/packages/f9/22/91fbc821fa6d261b376a3f73809f907cec5ca6025642c463d3488aad22fb/pydantic_core-2.41.5-cp312-cp312-win_arm64.whl", hash = "sha256:1746d4a3d9a794cacae06a5eaaccb4b8643a131d45fbc9af23e353dc0a5ba5c3", size = 1976179, upload-time = "2025-11-04T13:40:23.393Z" }, + { url = "https://files.pythonhosted.org/packages/11/72/90fda5ee3b97e51c494938a4a44c3a35a9c96c19bba12372fb9c634d6f57/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:b96d5f26b05d03cc60f11a7761a5ded1741da411e7fe0909e27a5e6a0cb7b034", size = 2115441, upload-time = "2025-11-04T13:42:39.557Z" }, + { url = "https://files.pythonhosted.org/packages/1f/53/8942f884fa33f50794f119012dc6a1a02ac43a56407adaac20463df8e98f/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:634e8609e89ceecea15e2d61bc9ac3718caaaa71963717bf3c8f38bfde64242c", size = 1930291, upload-time = "2025-11-04T13:42:42.169Z" }, + { url = "https://files.pythonhosted.org/packages/79/c8/ecb9ed9cd942bce09fc888ee960b52654fbdbede4ba6c2d6e0d3b1d8b49c/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:93e8740d7503eb008aa2df04d3b9735f845d43ae845e6dcd2be0b55a2da43cd2", size = 1948632, upload-time = "2025-11-04T13:42:44.564Z" }, + { url = "https://files.pythonhosted.org/packages/2e/1b/687711069de7efa6af934e74f601e2a4307365e8fdc404703afc453eab26/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f15489ba13d61f670dcc96772e733aad1a6f9c429cc27574c6cdaed82d0146ad", size = 2138905, upload-time = "2025-11-04T13:42:47.156Z" }, + { url = "https://files.pythonhosted.org/packages/09/32/59b0c7e63e277fa7911c2fc70ccfb45ce4b98991e7ef37110663437005af/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:7da7087d756b19037bc2c06edc6c170eeef3c3bafcb8f532ff17d64dc427adfd", size = 2110495, upload-time = "2025-11-04T13:42:49.689Z" }, + { url = "https://files.pythonhosted.org/packages/aa/81/05e400037eaf55ad400bcd318c05bb345b57e708887f07ddb2d20e3f0e98/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:aabf5777b5c8ca26f7824cb4a120a740c9588ed58df9b2d196ce92fba42ff8dc", size = 1915388, upload-time = "2025-11-04T13:42:52.215Z" }, + { url = "https://files.pythonhosted.org/packages/6e/0d/e3549b2399f71d56476b77dbf3cf8937cec5cd70536bdc0e374a421d0599/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c007fe8a43d43b3969e8469004e9845944f1a80e6acd47c150856bb87f230c56", size = 1942879, upload-time = "2025-11-04T13:42:56.483Z" }, + { url = "https://files.pythonhosted.org/packages/f7/07/34573da085946b6a313d7c42f82f16e8920bfd730665de2d11c0c37a74b5/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76d0819de158cd855d1cbb8fcafdf6f5cf1eb8e470abe056d5d161106e38062b", size = 2139017, upload-time = "2025-11-04T13:42:59.471Z" }, + { url = "https://files.pythonhosted.org/packages/5f/9b/1b3f0e9f9305839d7e84912f9e8bfbd191ed1b1ef48083609f0dabde978c/pydantic_core-2.41.5-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b2379fa7ed44ddecb5bfe4e48577d752db9fc10be00a6b7446e9663ba143de26", size = 2101980, upload-time = "2025-11-04T13:43:25.97Z" }, + { url = "https://files.pythonhosted.org/packages/a4/ed/d71fefcb4263df0da6a85b5d8a7508360f2f2e9b3bf5814be9c8bccdccc1/pydantic_core-2.41.5-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:266fb4cbf5e3cbd0b53669a6d1b039c45e3ce651fd5442eff4d07c2cc8d66808", size = 1923865, upload-time = "2025-11-04T13:43:28.763Z" }, + { url = "https://files.pythonhosted.org/packages/ce/3a/626b38db460d675f873e4444b4bb030453bbe7b4ba55df821d026a0493c4/pydantic_core-2.41.5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58133647260ea01e4d0500089a8c4f07bd7aa6ce109682b1426394988d8aaacc", size = 2134256, upload-time = "2025-11-04T13:43:31.71Z" }, + { url = "https://files.pythonhosted.org/packages/83/d9/8412d7f06f616bbc053d30cb4e5f76786af3221462ad5eee1f202021eb4e/pydantic_core-2.41.5-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:287dad91cfb551c363dc62899a80e9e14da1f0e2b6ebde82c806612ca2a13ef1", size = 2174762, upload-time = "2025-11-04T13:43:34.744Z" }, + { url = "https://files.pythonhosted.org/packages/55/4c/162d906b8e3ba3a99354e20faa1b49a85206c47de97a639510a0e673f5da/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:03b77d184b9eb40240ae9fd676ca364ce1085f203e1b1256f8ab9984dca80a84", size = 2143141, upload-time = "2025-11-04T13:43:37.701Z" }, + { url = "https://files.pythonhosted.org/packages/1f/f2/f11dd73284122713f5f89fc940f370d035fa8e1e078d446b3313955157fe/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:a668ce24de96165bb239160b3d854943128f4334822900534f2fe947930e5770", size = 2330317, upload-time = "2025-11-04T13:43:40.406Z" }, + { url = "https://files.pythonhosted.org/packages/88/9d/b06ca6acfe4abb296110fb1273a4d848a0bfb2ff65f3ee92127b3244e16b/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f14f8f046c14563f8eb3f45f499cc658ab8d10072961e07225e507adb700e93f", size = 2316992, upload-time = "2025-11-04T13:43:43.602Z" }, + { url = "https://files.pythonhosted.org/packages/36/c7/cfc8e811f061c841d7990b0201912c3556bfeb99cdcb7ed24adc8d6f8704/pydantic_core-2.41.5-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:56121965f7a4dc965bff783d70b907ddf3d57f6eba29b6d2e5dabfaf07799c51", size = 2145302, upload-time = "2025-11-04T13:43:46.64Z" }, +] + +[[package]] +name = "pydantic-settings" +version = "2.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/43/4b/ac7e0aae12027748076d72a8764ff1c9d82ca75a7a52622e67ed3f765c54/pydantic_settings-2.12.0.tar.gz", hash = "sha256:005538ef951e3c2a68e1c08b292b5f2e71490def8589d4221b95dab00dafcfd0", size = 194184, upload-time = "2025-11-10T14:25:47.013Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/60/5d4751ba3f4a40a6891f24eec885f51afd78d208498268c734e256fb13c4/pydantic_settings-2.12.0-py3-none-any.whl", hash = "sha256:fddb9fd99a5b18da837b29710391e945b1e30c135477f484084ee513adb93809", size = 51880, upload-time = "2025-11-10T14:25:45.546Z" }, +] + +[[package]] +name = "pygments" +version = "2.19.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, +] + +[[package]] +name = "pyjwt" +version = "2.10.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/46/bd74733ff231675599650d3e47f361794b22ef3e3770998dda30d3b63726/pyjwt-2.10.1.tar.gz", hash = "sha256:3cc5772eb20009233caf06e9d8a0577824723b44e6648ee0a2aedb6cf9381953", size = 87785, upload-time = "2024-11-28T03:43:29.933Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/61/ad/689f02752eeec26aed679477e80e632ef1b682313be70793d798c1d5fc8f/PyJWT-2.10.1-py3-none-any.whl", hash = "sha256:dcdd193e30abefd5debf142f9adfcdd2b58004e644f25406ffaebd50bd98dacb", size = 22997, upload-time = "2024-11-28T03:43:27.893Z" }, +] + +[package.optional-dependencies] +crypto = [ + { name = "cryptography" }, +] + +[[package]] +name = "pymupdf" +version = "1.26.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/48/d6/09b28f027b510838559f7748807192149c419b30cb90e6d5f0cf916dc9dc/pymupdf-1.26.7.tar.gz", hash = "sha256:71add8bdc8eb1aaa207c69a13400693f06ad9b927bea976f5d5ab9df0bb489c3", size = 84327033, upload-time = "2025-12-11T21:48:50.694Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/35/cd74cea1787b2247702ef8522186bdef32e9cb30a099e6bb864627ef6045/pymupdf-1.26.7-cp310-abi3-macosx_10_9_x86_64.whl", hash = "sha256:07085718dfdae5ab83b05eb5eb397f863bcc538fe05135318a01ea353e7a1353", size = 23179369, upload-time = "2025-12-11T21:47:21.587Z" }, + { url = "https://files.pythonhosted.org/packages/72/74/448b6172927c829c6a3fba80078d7b0a016ebbe2c9ee528821f5ea21677a/pymupdf-1.26.7-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:31aa9c8377ea1eea02934b92f4dcf79fb2abba0bf41f8a46d64c3e31546a3c02", size = 22470101, upload-time = "2025-12-11T21:47:37.105Z" }, + { url = "https://files.pythonhosted.org/packages/65/e7/47af26f3ac76be7ac3dd4d6cc7ee105948a8355d774e5ca39857bf91c11c/pymupdf-1.26.7-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:e419b609996434a14a80fa060adec72c434a1cca6a511ec54db9841bc5d51b3c", size = 23502486, upload-time = "2025-12-12T09:51:25.824Z" }, + { url = "https://files.pythonhosted.org/packages/2a/6b/3de1714d734ff949be1e90a22375d0598d3540b22ae73eb85c2d7d1f36a9/pymupdf-1.26.7-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:69dfc78f206a96e5b3ac22741263ebab945fdf51f0dbe7c5757c3511b23d9d72", size = 24115727, upload-time = "2025-12-11T21:47:51.274Z" }, + { url = "https://files.pythonhosted.org/packages/62/9b/f86224847949577a523be2207315ae0fd3155b5d909cd66c274d095349a3/pymupdf-1.26.7-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:1d5106f46e1ca0d64d46bd51892372a4f82076bdc14a9678d33d630702abca36", size = 24324386, upload-time = "2025-12-12T14:58:45.483Z" }, + { url = "https://files.pythonhosted.org/packages/85/8e/a117d39092ca645fde8b903f4a941d9aa75b370a67b4f1f435f56393dc5a/pymupdf-1.26.7-cp310-abi3-win32.whl", hash = "sha256:7c9645b6f5452629c747690190350213d3e5bbdb6b2eca227d82702b327f6eee", size = 17203888, upload-time = "2025-12-12T13:59:57.613Z" }, + { url = "https://files.pythonhosted.org/packages/dd/c3/d0047678146c294469c33bae167c8ace337deafb736b0bf97b9bc481aa65/pymupdf-1.26.7-cp310-abi3-win_amd64.whl", hash = "sha256:425b1befe40d41b72eb0fe211711c7ae334db5eb60307e9dd09066ed060cceba", size = 18405952, upload-time = "2025-12-11T21:48:02.947Z" }, +] + +[[package]] +name = "pypdf" +version = "6.4.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bd/c2/b59b02ff7f2dc006799d2c5dc3a8877686890abdd915176ef799070edf17/pypdf-6.4.2.tar.gz", hash = "sha256:c466ff1272ffb4712c2348d2bbc3019bc93f1c62ccfaf50808e3b9f13c3dc527", size = 5275502, upload-time = "2025-12-14T14:30:58.58Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/99/3147435e15ccd97c0451efc3d13495dc22602e9887f81e64f1b135bae821/pypdf-6.4.2-py3-none-any.whl", hash = "sha256:014dcff867fd99fc0b6fc90ed1f7e1347ef2317ae038a489c2caa64106d268f4", size = 328212, upload-time = "2025-12-14T14:30:56.701Z" }, +] + +[[package]] +name = "pytest" +version = "8.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/09/9d/78b3785134306efe9329f40815af45b9215068d6ae4747ec0bc91ff1f4aa/pytest-8.2.0.tar.gz", hash = "sha256:d507d4482197eac0ba2bae2e9babf0672eb333017bcedaa5fb1a3d42c1174b3f", size = 1422883, upload-time = "2024-04-27T23:34:55.027Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c4/43/6b1debd95ecdf001bc46789a933f658da3f9738c65f32db3f4e8f2a4ca97/pytest-8.2.0-py3-none-any.whl", hash = "sha256:1733f0620f6cda4095bbf0d9ff8022486e91892245bb9e7d5542c018f612f233", size = 339229, upload-time = "2024-04-27T23:34:52.413Z" }, +] + +[[package]] +name = "pytest-asyncio" +version = "0.23.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cd/ef/80107b9e939875ad613c705d99d91e4510dcf5fed29613ac9aecbcba0a8d/pytest-asyncio-0.23.6.tar.gz", hash = "sha256:ffe523a89c1c222598c76856e76852b787504ddb72dd5d9b6617ffa8aa2cde5f", size = 46203, upload-time = "2024-03-19T07:17:34.888Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e0/c9/de22c040d4c821c6c797ca1d720f1f4b2f4293d5757e811c62ae544496c4/pytest_asyncio-0.23.6-py3-none-any.whl", hash = "sha256:68516fdd1018ac57b846c9846b954f0393b26f094764a28c955eabb0536a4e8a", size = 17552, upload-time = "2024-03-19T07:17:32.951Z" }, +] + +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432, upload-time = "2024-03-01T18:36:20.211Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, +] + +[[package]] +name = "python-dotenv" +version = "1.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" }, +] + +[[package]] +name = "python-iso639" +version = "2025.11.16" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a1/3b/3e07aadeeb7bbb2574d6aa6ccacbc58b17bd2b1fb6c7196bf96ab0e45129/python_iso639-2025.11.16.tar.gz", hash = "sha256:aabe941267898384415a509f5236d7cfc191198c84c5c6f73dac73d9783f5169", size = 174186, upload-time = "2025-11-16T21:53:37.031Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/2d/563849c31e58eb2e273fa0c391a7d9987db32f4d9152fe6ecdac0a8ffe93/python_iso639-2025.11.16-py3-none-any.whl", hash = "sha256:65f6ac6c6d8e8207f6175f8bf7fff7db486c6dc5c1d8866c2b77d2a923370896", size = 167818, upload-time = "2025-11-16T21:53:35.36Z" }, +] + +[[package]] +name = "python-magic" +version = "0.4.27" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/da/db/0b3e28ac047452d079d375ec6798bf76a036a08182dbb39ed38116a49130/python-magic-0.4.27.tar.gz", hash = "sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b", size = 14677, upload-time = "2022-06-07T20:16:59.508Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/73/9f872cb81fc5c3bb48f7227872c28975f998f3e7c2b1c16e95e6432bbb90/python_magic-0.4.27-py2.py3-none-any.whl", hash = "sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3", size = 13840, upload-time = "2022-06-07T20:16:57.763Z" }, +] + +[[package]] +name = "python-multipart" +version = "0.0.21" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/78/96/804520d0850c7db98e5ccb70282e29208723f0964e88ffd9d0da2f52ea09/python_multipart-0.0.21.tar.gz", hash = "sha256:7137ebd4d3bbf70ea1622998f902b97a29434a9e8dc40eb203bbcf7c2a2cba92", size = 37196, upload-time = "2025-12-17T09:24:22.446Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/aa/76/03af049af4dcee5d27442f71b6924f01f3efb5d2bd34f23fcd563f2cc5f5/python_multipart-0.0.21-py3-none-any.whl", hash = "sha256:cf7a6713e01c87aa35387f4774e812c4361150938d20d232800f75ffcf266090", size = 24541, upload-time = "2025-12-17T09:24:21.153Z" }, +] + +[[package]] +name = "pytz" +version = "2025.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f8/bf/abbd3cdfb8fbc7fb3d4d38d320f2441b1e7cbe29be4f23797b4a2b5d8aac/pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3", size = 320884, upload-time = "2025-03-25T02:25:00.538Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/c4/34e93fe5f5429d7570ec1fa436f1986fb1f00c3e0f43a589fe2bbcd22c3f/pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00", size = 509225, upload-time = "2025-03-25T02:24:58.468Z" }, +] + +[[package]] +name = "pywin32" +version = "311" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7c/af/449a6a91e5d6db51420875c54f6aff7c97a86a3b13a0b4f1a5c13b988de3/pywin32-311-cp311-cp311-win32.whl", hash = "sha256:184eb5e436dea364dcd3d2316d577d625c0351bf237c4e9a5fabbcfa5a58b151", size = 8697031, upload-time = "2025-07-14T20:13:13.266Z" }, + { url = "https://files.pythonhosted.org/packages/51/8f/9bb81dd5bb77d22243d33c8397f09377056d5c687aa6d4042bea7fbf8364/pywin32-311-cp311-cp311-win_amd64.whl", hash = "sha256:3ce80b34b22b17ccbd937a6e78e7225d80c52f5ab9940fe0506a1a16f3dab503", size = 9508308, upload-time = "2025-07-14T20:13:15.147Z" }, + { url = "https://files.pythonhosted.org/packages/44/7b/9c2ab54f74a138c491aba1b1cd0795ba61f144c711daea84a88b63dc0f6c/pywin32-311-cp311-cp311-win_arm64.whl", hash = "sha256:a733f1388e1a842abb67ffa8e7aad0e70ac519e09b0f6a784e65a136ec7cefd2", size = 8703930, upload-time = "2025-07-14T20:13:16.945Z" }, + { url = "https://files.pythonhosted.org/packages/e7/ab/01ea1943d4eba0f850c3c61e78e8dd59757ff815ff3ccd0a84de5f541f42/pywin32-311-cp312-cp312-win32.whl", hash = "sha256:750ec6e621af2b948540032557b10a2d43b0cee2ae9758c54154d711cc852d31", size = 8706543, upload-time = "2025-07-14T20:13:20.765Z" }, + { url = "https://files.pythonhosted.org/packages/d1/a8/a0e8d07d4d051ec7502cd58b291ec98dcc0c3fff027caad0470b72cfcc2f/pywin32-311-cp312-cp312-win_amd64.whl", hash = "sha256:b8c095edad5c211ff31c05223658e71bf7116daa0ecf3ad85f3201ea3190d067", size = 9495040, upload-time = "2025-07-14T20:13:22.543Z" }, + { url = "https://files.pythonhosted.org/packages/ba/3a/2ae996277b4b50f17d61f0603efd8253cb2d79cc7ae159468007b586396d/pywin32-311-cp312-cp312-win_arm64.whl", hash = "sha256:e286f46a9a39c4a18b319c28f59b61de793654af2f395c102b4f819e584b5852", size = 8710102, upload-time = "2025-07-14T20:13:24.682Z" }, +] + +[[package]] +name = "pyyaml" +version = "6.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/16/a95b6757765b7b031c9374925bb718d55e0a9ba8a1b6a12d25962ea44347/pyyaml-6.0.3-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e", size = 185826, upload-time = "2025-09-25T21:31:58.655Z" }, + { url = "https://files.pythonhosted.org/packages/16/19/13de8e4377ed53079ee996e1ab0a9c33ec2faf808a4647b7b4c0d46dd239/pyyaml-6.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824", size = 175577, upload-time = "2025-09-25T21:32:00.088Z" }, + { url = "https://files.pythonhosted.org/packages/0c/62/d2eb46264d4b157dae1275b573017abec435397aa59cbcdab6fc978a8af4/pyyaml-6.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c", size = 775556, upload-time = "2025-09-25T21:32:01.31Z" }, + { url = "https://files.pythonhosted.org/packages/10/cb/16c3f2cf3266edd25aaa00d6c4350381c8b012ed6f5276675b9eba8d9ff4/pyyaml-6.0.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00", size = 882114, upload-time = "2025-09-25T21:32:03.376Z" }, + { url = "https://files.pythonhosted.org/packages/71/60/917329f640924b18ff085ab889a11c763e0b573da888e8404ff486657602/pyyaml-6.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d", size = 806638, upload-time = "2025-09-25T21:32:04.553Z" }, + { url = "https://files.pythonhosted.org/packages/dd/6f/529b0f316a9fd167281a6c3826b5583e6192dba792dd55e3203d3f8e655a/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a", size = 767463, upload-time = "2025-09-25T21:32:06.152Z" }, + { url = "https://files.pythonhosted.org/packages/f2/6a/b627b4e0c1dd03718543519ffb2f1deea4a1e6d42fbab8021936a4d22589/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4", size = 794986, upload-time = "2025-09-25T21:32:07.367Z" }, + { url = "https://files.pythonhosted.org/packages/45/91/47a6e1c42d9ee337c4839208f30d9f09caa9f720ec7582917b264defc875/pyyaml-6.0.3-cp311-cp311-win32.whl", hash = "sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b", size = 142543, upload-time = "2025-09-25T21:32:08.95Z" }, + { url = "https://files.pythonhosted.org/packages/da/e3/ea007450a105ae919a72393cb06f122f288ef60bba2dc64b26e2646fa315/pyyaml-6.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf", size = 158763, upload-time = "2025-09-25T21:32:09.96Z" }, + { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" }, + { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" }, + { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" }, + { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" }, + { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" }, + { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" }, + { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" }, + { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" }, + { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" }, + { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" }, +] + +[[package]] +name = "pyzmq" +version = "27.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "implementation_name == 'pypy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/04/0b/3c9baedbdf613ecaa7aa07027780b8867f57b6293b6ee50de316c9f3222b/pyzmq-27.1.0.tar.gz", hash = "sha256:ac0765e3d44455adb6ddbf4417dcce460fc40a05978c08efdf2948072f6db540", size = 281750, upload-time = "2025-09-08T23:10:18.157Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/06/5d/305323ba86b284e6fcb0d842d6adaa2999035f70f8c38a9b6d21ad28c3d4/pyzmq-27.1.0-cp311-cp311-macosx_10_15_universal2.whl", hash = "sha256:226b091818d461a3bef763805e75685e478ac17e9008f49fce2d3e52b3d58b86", size = 1333328, upload-time = "2025-09-08T23:07:45.946Z" }, + { url = "https://files.pythonhosted.org/packages/bd/a0/fc7e78a23748ad5443ac3275943457e8452da67fda347e05260261108cbc/pyzmq-27.1.0-cp311-cp311-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:0790a0161c281ca9723f804871b4027f2e8b5a528d357c8952d08cd1a9c15581", size = 908803, upload-time = "2025-09-08T23:07:47.551Z" }, + { url = "https://files.pythonhosted.org/packages/7e/22/37d15eb05f3bdfa4abea6f6d96eb3bb58585fbd3e4e0ded4e743bc650c97/pyzmq-27.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c895a6f35476b0c3a54e3eb6ccf41bf3018de937016e6e18748317f25d4e925f", size = 668836, upload-time = "2025-09-08T23:07:49.436Z" }, + { url = "https://files.pythonhosted.org/packages/b1/c4/2a6fe5111a01005fc7af3878259ce17684fabb8852815eda6225620f3c59/pyzmq-27.1.0-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5bbf8d3630bf96550b3be8e1fc0fea5cbdc8d5466c1192887bd94869da17a63e", size = 857038, upload-time = "2025-09-08T23:07:51.234Z" }, + { url = "https://files.pythonhosted.org/packages/cb/eb/bfdcb41d0db9cd233d6fb22dc131583774135505ada800ebf14dfb0a7c40/pyzmq-27.1.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:15c8bd0fe0dabf808e2d7a681398c4e5ded70a551ab47482067a572c054c8e2e", size = 1657531, upload-time = "2025-09-08T23:07:52.795Z" }, + { url = "https://files.pythonhosted.org/packages/ab/21/e3180ca269ed4a0de5c34417dfe71a8ae80421198be83ee619a8a485b0c7/pyzmq-27.1.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:bafcb3dd171b4ae9f19ee6380dfc71ce0390fefaf26b504c0e5f628d7c8c54f2", size = 2034786, upload-time = "2025-09-08T23:07:55.047Z" }, + { url = "https://files.pythonhosted.org/packages/3b/b1/5e21d0b517434b7f33588ff76c177c5a167858cc38ef740608898cd329f2/pyzmq-27.1.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:e829529fcaa09937189178115c49c504e69289abd39967cd8a4c215761373394", size = 1894220, upload-time = "2025-09-08T23:07:57.172Z" }, + { url = "https://files.pythonhosted.org/packages/03/f2/44913a6ff6941905efc24a1acf3d3cb6146b636c546c7406c38c49c403d4/pyzmq-27.1.0-cp311-cp311-win32.whl", hash = "sha256:6df079c47d5902af6db298ec92151db82ecb557af663098b92f2508c398bb54f", size = 567155, upload-time = "2025-09-08T23:07:59.05Z" }, + { url = "https://files.pythonhosted.org/packages/23/6d/d8d92a0eb270a925c9b4dd039c0b4dc10abc2fcbc48331788824ef113935/pyzmq-27.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:190cbf120fbc0fc4957b56866830def56628934a9d112aec0e2507aa6a032b97", size = 633428, upload-time = "2025-09-08T23:08:00.663Z" }, + { url = "https://files.pythonhosted.org/packages/ae/14/01afebc96c5abbbd713ecfc7469cfb1bc801c819a74ed5c9fad9a48801cb/pyzmq-27.1.0-cp311-cp311-win_arm64.whl", hash = "sha256:eca6b47df11a132d1745eb3b5b5e557a7dae2c303277aa0e69c6ba91b8736e07", size = 559497, upload-time = "2025-09-08T23:08:02.15Z" }, + { url = "https://files.pythonhosted.org/packages/92/e7/038aab64a946d535901103da16b953c8c9cc9c961dadcbf3609ed6428d23/pyzmq-27.1.0-cp312-abi3-macosx_10_15_universal2.whl", hash = "sha256:452631b640340c928fa343801b0d07eb0c3789a5ffa843f6e1a9cee0ba4eb4fc", size = 1306279, upload-time = "2025-09-08T23:08:03.807Z" }, + { url = "https://files.pythonhosted.org/packages/e8/5e/c3c49fdd0f535ef45eefcc16934648e9e59dace4a37ee88fc53f6cd8e641/pyzmq-27.1.0-cp312-abi3-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:1c179799b118e554b66da67d88ed66cd37a169f1f23b5d9f0a231b4e8d44a113", size = 895645, upload-time = "2025-09-08T23:08:05.301Z" }, + { url = "https://files.pythonhosted.org/packages/f8/e5/b0b2504cb4e903a74dcf1ebae157f9e20ebb6ea76095f6cfffea28c42ecd/pyzmq-27.1.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3837439b7f99e60312f0c926a6ad437b067356dc2bc2ec96eb395fd0fe804233", size = 652574, upload-time = "2025-09-08T23:08:06.828Z" }, + { url = "https://files.pythonhosted.org/packages/f8/9b/c108cdb55560eaf253f0cbdb61b29971e9fb34d9c3499b0e96e4e60ed8a5/pyzmq-27.1.0-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:43ad9a73e3da1fab5b0e7e13402f0b2fb934ae1c876c51d0afff0e7c052eca31", size = 840995, upload-time = "2025-09-08T23:08:08.396Z" }, + { url = "https://files.pythonhosted.org/packages/c2/bb/b79798ca177b9eb0825b4c9998c6af8cd2a7f15a6a1a4272c1d1a21d382f/pyzmq-27.1.0-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:0de3028d69d4cdc475bfe47a6128eb38d8bc0e8f4d69646adfbcd840facbac28", size = 1642070, upload-time = "2025-09-08T23:08:09.989Z" }, + { url = "https://files.pythonhosted.org/packages/9c/80/2df2e7977c4ede24c79ae39dcef3899bfc5f34d1ca7a5b24f182c9b7a9ca/pyzmq-27.1.0-cp312-abi3-musllinux_1_2_i686.whl", hash = "sha256:cf44a7763aea9298c0aa7dbf859f87ed7012de8bda0f3977b6fb1d96745df856", size = 2021121, upload-time = "2025-09-08T23:08:11.907Z" }, + { url = "https://files.pythonhosted.org/packages/46/bd/2d45ad24f5f5ae7e8d01525eb76786fa7557136555cac7d929880519e33a/pyzmq-27.1.0-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f30f395a9e6fbca195400ce833c731e7b64c3919aa481af4d88c3759e0cb7496", size = 1878550, upload-time = "2025-09-08T23:08:13.513Z" }, + { url = "https://files.pythonhosted.org/packages/e6/2f/104c0a3c778d7c2ab8190e9db4f62f0b6957b53c9d87db77c284b69f33ea/pyzmq-27.1.0-cp312-abi3-win32.whl", hash = "sha256:250e5436a4ba13885494412b3da5d518cd0d3a278a1ae640e113c073a5f88edd", size = 559184, upload-time = "2025-09-08T23:08:15.163Z" }, + { url = "https://files.pythonhosted.org/packages/fc/7f/a21b20d577e4100c6a41795842028235998a643b1ad406a6d4163ea8f53e/pyzmq-27.1.0-cp312-abi3-win_amd64.whl", hash = "sha256:9ce490cf1d2ca2ad84733aa1d69ce6855372cb5ce9223802450c9b2a7cba0ccf", size = 619480, upload-time = "2025-09-08T23:08:17.192Z" }, + { url = "https://files.pythonhosted.org/packages/78/c2/c012beae5f76b72f007a9e91ee9401cb88c51d0f83c6257a03e785c81cc2/pyzmq-27.1.0-cp312-abi3-win_arm64.whl", hash = "sha256:75a2f36223f0d535a0c919e23615fc85a1e23b71f40c7eb43d7b1dedb4d8f15f", size = 552993, upload-time = "2025-09-08T23:08:18.926Z" }, + { url = "https://files.pythonhosted.org/packages/4c/c6/c4dcdecdbaa70969ee1fdced6d7b8f60cfabe64d25361f27ac4665a70620/pyzmq-27.1.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:18770c8d3563715387139060d37859c02ce40718d1faf299abddcdcc6a649066", size = 836265, upload-time = "2025-09-08T23:09:49.376Z" }, + { url = "https://files.pythonhosted.org/packages/3e/79/f38c92eeaeb03a2ccc2ba9866f0439593bb08c5e3b714ac1d553e5c96e25/pyzmq-27.1.0-pp311-pypy311_pp73-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:ac25465d42f92e990f8d8b0546b01c391ad431c3bf447683fdc40565941d0604", size = 800208, upload-time = "2025-09-08T23:09:51.073Z" }, + { url = "https://files.pythonhosted.org/packages/49/0e/3f0d0d335c6b3abb9b7b723776d0b21fa7f3a6c819a0db6097059aada160/pyzmq-27.1.0-pp311-pypy311_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:53b40f8ae006f2734ee7608d59ed661419f087521edbfc2149c3932e9c14808c", size = 567747, upload-time = "2025-09-08T23:09:52.698Z" }, + { url = "https://files.pythonhosted.org/packages/a1/cf/f2b3784d536250ffd4be70e049f3b60981235d70c6e8ce7e3ef21e1adb25/pyzmq-27.1.0-pp311-pypy311_pp73-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f605d884e7c8be8fe1aa94e0a783bf3f591b84c24e4bc4f3e7564c82ac25e271", size = 747371, upload-time = "2025-09-08T23:09:54.563Z" }, + { url = "https://files.pythonhosted.org/packages/01/1b/5dbe84eefc86f48473947e2f41711aded97eecef1231f4558f1f02713c12/pyzmq-27.1.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:c9f7f6e13dff2e44a6afeaf2cf54cee5929ad64afaf4d40b50f93c58fc687355", size = 544862, upload-time = "2025-09-08T23:09:56.509Z" }, +] + +[[package]] +name = "rapidfuzz" +version = "3.14.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d3/28/9d808fe62375b9aab5ba92fa9b29371297b067c2790b2d7cda648b1e2f8d/rapidfuzz-3.14.3.tar.gz", hash = "sha256:2491937177868bc4b1e469087601d53f925e8d270ccc21e07404b4b5814b7b5f", size = 57863900, upload-time = "2025-11-01T11:54:52.321Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/76/25/5b0a33ad3332ee1213068c66f7c14e9e221be90bab434f0cb4defa9d6660/rapidfuzz-3.14.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dea2d113e260a5da0c4003e0a5e9fdf24a9dc2bb9eaa43abd030a1e46ce7837d", size = 1953885, upload-time = "2025-11-01T11:52:47.75Z" }, + { url = "https://files.pythonhosted.org/packages/2d/ab/f1181f500c32c8fcf7c966f5920c7e56b9b1d03193386d19c956505c312d/rapidfuzz-3.14.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e6c31a4aa68cfa75d7eede8b0ed24b9e458447db604c2db53f358be9843d81d3", size = 1390200, upload-time = "2025-11-01T11:52:49.491Z" }, + { url = "https://files.pythonhosted.org/packages/14/2a/0f2de974ececad873865c6bb3ea3ad07c976ac293d5025b2d73325aac1d4/rapidfuzz-3.14.3-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:02821366d928e68ddcb567fed8723dad7ea3a979fada6283e6914d5858674850", size = 1389319, upload-time = "2025-11-01T11:52:51.224Z" }, + { url = "https://files.pythonhosted.org/packages/ed/69/309d8f3a0bb3031fd9b667174cc4af56000645298af7c2931be5c3d14bb4/rapidfuzz-3.14.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cfe8df315ab4e6db4e1be72c5170f8e66021acde22cd2f9d04d2058a9fd8162e", size = 3178495, upload-time = "2025-11-01T11:52:53.005Z" }, + { url = "https://files.pythonhosted.org/packages/10/b7/f9c44a99269ea5bf6fd6a40b84e858414b6e241288b9f2b74af470d222b1/rapidfuzz-3.14.3-cp311-cp311-manylinux_2_31_armv7l.whl", hash = "sha256:769f31c60cd79420188fcdb3c823227fc4a6deb35cafec9d14045c7f6743acae", size = 1228443, upload-time = "2025-11-01T11:52:54.991Z" }, + { url = "https://files.pythonhosted.org/packages/f2/0a/3b3137abac7f19c9220e14cd7ce993e35071a7655e7ef697785a3edfea1a/rapidfuzz-3.14.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:54fa03062124e73086dae66a3451c553c1e20a39c077fd704dc7154092c34c63", size = 2411998, upload-time = "2025-11-01T11:52:56.629Z" }, + { url = "https://files.pythonhosted.org/packages/f3/b6/983805a844d44670eaae63831024cdc97ada4e9c62abc6b20703e81e7f9b/rapidfuzz-3.14.3-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:834d1e818005ed0d4ae38f6b87b86fad9b0a74085467ece0727d20e15077c094", size = 2530120, upload-time = "2025-11-01T11:52:58.298Z" }, + { url = "https://files.pythonhosted.org/packages/b4/cc/2c97beb2b1be2d7595d805682472f1b1b844111027d5ad89b65e16bdbaaa/rapidfuzz-3.14.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:948b00e8476a91f510dd1ec07272efc7d78c275d83b630455559671d4e33b678", size = 4283129, upload-time = "2025-11-01T11:53:00.188Z" }, + { url = "https://files.pythonhosted.org/packages/4d/03/2f0e5e94941045aefe7eafab72320e61285c07b752df9884ce88d6b8b835/rapidfuzz-3.14.3-cp311-cp311-win32.whl", hash = "sha256:43d0305c36f504232f18ea04e55f2059bb89f169d3119c4ea96a0e15b59e2a91", size = 1724224, upload-time = "2025-11-01T11:53:02.149Z" }, + { url = "https://files.pythonhosted.org/packages/cf/99/5fa23e204435803875daefda73fd61baeabc3c36b8fc0e34c1705aab8c7b/rapidfuzz-3.14.3-cp311-cp311-win_amd64.whl", hash = "sha256:ef6bf930b947bd0735c550683939a032090f1d688dfd8861d6b45307b96fd5c5", size = 1544259, upload-time = "2025-11-01T11:53:03.66Z" }, + { url = "https://files.pythonhosted.org/packages/48/35/d657b85fcc615a42661b98ac90ce8e95bd32af474603a105643963749886/rapidfuzz-3.14.3-cp311-cp311-win_arm64.whl", hash = "sha256:f3eb0ff3b75d6fdccd40b55e7414bb859a1cda77c52762c9c82b85569f5088e7", size = 814734, upload-time = "2025-11-01T11:53:05.008Z" }, + { url = "https://files.pythonhosted.org/packages/fa/8e/3c215e860b458cfbedb3ed73bc72e98eb7e0ed72f6b48099604a7a3260c2/rapidfuzz-3.14.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:685c93ea961d135893b5984a5a9851637d23767feabe414ec974f43babbd8226", size = 1945306, upload-time = "2025-11-01T11:53:06.452Z" }, + { url = "https://files.pythonhosted.org/packages/36/d9/31b33512015c899f4a6e6af64df8dfe8acddf4c8b40a4b3e0e6e1bcd00e5/rapidfuzz-3.14.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fa7c8f26f009f8c673fbfb443792f0cf8cf50c4e18121ff1e285b5e08a94fbdb", size = 1390788, upload-time = "2025-11-01T11:53:08.721Z" }, + { url = "https://files.pythonhosted.org/packages/a9/67/2ee6f8de6e2081ccd560a571d9c9063184fe467f484a17fa90311a7f4a2e/rapidfuzz-3.14.3-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:57f878330c8d361b2ce76cebb8e3e1dc827293b6abf404e67d53260d27b5d941", size = 1374580, upload-time = "2025-11-01T11:53:10.164Z" }, + { url = "https://files.pythonhosted.org/packages/30/83/80d22997acd928eda7deadc19ccd15883904622396d6571e935993e0453a/rapidfuzz-3.14.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6c5f545f454871e6af05753a0172849c82feaf0f521c5ca62ba09e1b382d6382", size = 3154947, upload-time = "2025-11-01T11:53:12.093Z" }, + { url = "https://files.pythonhosted.org/packages/5b/cf/9f49831085a16384695f9fb096b99662f589e30b89b4a589a1ebc1a19d34/rapidfuzz-3.14.3-cp312-cp312-manylinux_2_31_armv7l.whl", hash = "sha256:07aa0b5d8863e3151e05026a28e0d924accf0a7a3b605da978f0359bb804df43", size = 1223872, upload-time = "2025-11-01T11:53:13.664Z" }, + { url = "https://files.pythonhosted.org/packages/c8/0f/41ee8034e744b871c2e071ef0d360686f5ccfe5659f4fd96c3ec406b3c8b/rapidfuzz-3.14.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:73b07566bc7e010e7b5bd490fb04bb312e820970180df6b5655e9e6224c137db", size = 2392512, upload-time = "2025-11-01T11:53:15.109Z" }, + { url = "https://files.pythonhosted.org/packages/da/86/280038b6b0c2ccec54fb957c732ad6b41cc1fd03b288d76545b9cf98343f/rapidfuzz-3.14.3-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:6de00eb84c71476af7d3110cf25d8fe7c792d7f5fa86764ef0b4ca97e78ca3ed", size = 2521398, upload-time = "2025-11-01T11:53:17.146Z" }, + { url = "https://files.pythonhosted.org/packages/fa/7b/05c26f939607dca0006505e3216248ae2de631e39ef94dd63dbbf0860021/rapidfuzz-3.14.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d7843a1abf0091773a530636fdd2a49a41bcae22f9910b86b4f903e76ddc82dc", size = 4259416, upload-time = "2025-11-01T11:53:19.34Z" }, + { url = "https://files.pythonhosted.org/packages/40/eb/9e3af4103d91788f81111af1b54a28de347cdbed8eaa6c91d5e98a889aab/rapidfuzz-3.14.3-cp312-cp312-win32.whl", hash = "sha256:dea97ac3ca18cd3ba8f3d04b5c1fe4aa60e58e8d9b7793d3bd595fdb04128d7a", size = 1709527, upload-time = "2025-11-01T11:53:20.949Z" }, + { url = "https://files.pythonhosted.org/packages/b8/63/d06ecce90e2cf1747e29aeab9f823d21e5877a4c51b79720b2d3be7848f8/rapidfuzz-3.14.3-cp312-cp312-win_amd64.whl", hash = "sha256:b5100fd6bcee4d27f28f4e0a1c6b5127bc8ba7c2a9959cad9eab0bf4a7ab3329", size = 1538989, upload-time = "2025-11-01T11:53:22.428Z" }, + { url = "https://files.pythonhosted.org/packages/fc/6d/beee32dcda64af8128aab3ace2ccb33d797ed58c434c6419eea015fec779/rapidfuzz-3.14.3-cp312-cp312-win_arm64.whl", hash = "sha256:4e49c9e992bc5fc873bd0fff7ef16a4405130ec42f2ce3d2b735ba5d3d4eb70f", size = 811161, upload-time = "2025-11-01T11:53:23.811Z" }, + { url = "https://files.pythonhosted.org/packages/c9/33/b5bd6475c7c27164b5becc9b0e3eb978f1e3640fea590dd3dced6006ee83/rapidfuzz-3.14.3-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:7cf174b52cb3ef5d49e45d0a1133b7e7d0ecf770ed01f97ae9962c5c91d97d23", size = 1888499, upload-time = "2025-11-01T11:54:42.094Z" }, + { url = "https://files.pythonhosted.org/packages/30/d2/89d65d4db4bb931beade9121bc71ad916b5fa9396e807d11b33731494e8e/rapidfuzz-3.14.3-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:442cba39957a008dfc5bdef21a9c3f4379e30ffb4e41b8555dbaf4887eca9300", size = 1336747, upload-time = "2025-11-01T11:54:43.957Z" }, + { url = "https://files.pythonhosted.org/packages/85/33/cd87d92b23f0b06e8914a61cea6850c6d495ca027f669fab7a379041827a/rapidfuzz-3.14.3-pp311-pypy311_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1faa0f8f76ba75fd7b142c984947c280ef6558b5067af2ae9b8729b0a0f99ede", size = 1352187, upload-time = "2025-11-01T11:54:45.518Z" }, + { url = "https://files.pythonhosted.org/packages/22/20/9d30b4a1ab26aac22fff17d21dec7e9089ccddfe25151d0a8bb57001dc3d/rapidfuzz-3.14.3-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1e6eefec45625c634926a9fd46c9e4f31118ac8f3156fff9494422cee45207e6", size = 3101472, upload-time = "2025-11-01T11:54:47.255Z" }, + { url = "https://files.pythonhosted.org/packages/b1/ad/fa2d3e5c29a04ead7eaa731c7cd1f30f9ec3c77b3a578fdf90280797cbcb/rapidfuzz-3.14.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:56fefb4382bb12250f164250240b9dd7772e41c5c8ae976fd598a32292449cc5", size = 1511361, upload-time = "2025-11-01T11:54:49.057Z" }, +] + +[[package]] +name = "referencing" +version = "0.36.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "rpds-py" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2f/db/98b5c277be99dd18bfd91dd04e1b759cad18d1a338188c936e92f921c7e2/referencing-0.36.2.tar.gz", hash = "sha256:df2e89862cd09deabbdba16944cc3f10feb6b3e6f18e902f7cc25609a34775aa", size = 74744, upload-time = "2025-01-25T08:48:16.138Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/b1/3baf80dc6d2b7bc27a95a67752d0208e410351e3feb4eb78de5f77454d8d/referencing-0.36.2-py3-none-any.whl", hash = "sha256:e8699adbbf8b5c7de96d8ffa0eb5c158b3beafce084968e2ea8bb08c6794dcd0", size = 26775, upload-time = "2025-01-25T08:48:14.241Z" }, +] + +[[package]] +name = "regex" +version = "2025.11.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cc/a9/546676f25e573a4cf00fe8e119b78a37b6a8fe2dc95cda877b30889c9c45/regex-2025.11.3.tar.gz", hash = "sha256:1fedc720f9bb2494ce31a58a1631f9c82df6a09b49c19517ea5cc280b4541e01", size = 414669, upload-time = "2025-11-03T21:34:22.089Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f7/90/4fb5056e5f03a7048abd2b11f598d464f0c167de4f2a51aa868c376b8c70/regex-2025.11.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:eadade04221641516fa25139273505a1c19f9bf97589a05bc4cfcd8b4a618031", size = 488081, upload-time = "2025-11-03T21:31:11.946Z" }, + { url = "https://files.pythonhosted.org/packages/85/23/63e481293fac8b069d84fba0299b6666df720d875110efd0338406b5d360/regex-2025.11.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:feff9e54ec0dd3833d659257f5c3f5322a12eee58ffa360984b716f8b92983f4", size = 290554, upload-time = "2025-11-03T21:31:13.387Z" }, + { url = "https://files.pythonhosted.org/packages/2b/9d/b101d0262ea293a0066b4522dfb722eb6a8785a8c3e084396a5f2c431a46/regex-2025.11.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3b30bc921d50365775c09a7ed446359e5c0179e9e2512beec4a60cbcef6ddd50", size = 288407, upload-time = "2025-11-03T21:31:14.809Z" }, + { url = "https://files.pythonhosted.org/packages/0c/64/79241c8209d5b7e00577ec9dca35cd493cc6be35b7d147eda367d6179f6d/regex-2025.11.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f99be08cfead2020c7ca6e396c13543baea32343b7a9a5780c462e323bd8872f", size = 793418, upload-time = "2025-11-03T21:31:16.556Z" }, + { url = "https://files.pythonhosted.org/packages/3d/e2/23cd5d3573901ce8f9757c92ca4db4d09600b865919b6d3e7f69f03b1afd/regex-2025.11.3-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:6dd329a1b61c0ee95ba95385fb0c07ea0d3fe1a21e1349fa2bec272636217118", size = 860448, upload-time = "2025-11-03T21:31:18.12Z" }, + { url = "https://files.pythonhosted.org/packages/2a/4c/aecf31beeaa416d0ae4ecb852148d38db35391aac19c687b5d56aedf3a8b/regex-2025.11.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4c5238d32f3c5269d9e87be0cf096437b7622b6920f5eac4fd202468aaeb34d2", size = 907139, upload-time = "2025-11-03T21:31:20.753Z" }, + { url = "https://files.pythonhosted.org/packages/61/22/b8cb00df7d2b5e0875f60628594d44dba283e951b1ae17c12f99e332cc0a/regex-2025.11.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:10483eefbfb0adb18ee9474498c9a32fcf4e594fbca0543bb94c48bac6183e2e", size = 800439, upload-time = "2025-11-03T21:31:22.069Z" }, + { url = "https://files.pythonhosted.org/packages/02/a8/c4b20330a5cdc7a8eb265f9ce593f389a6a88a0c5f280cf4d978f33966bc/regex-2025.11.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:78c2d02bb6e1da0720eedc0bad578049cad3f71050ef8cd065ecc87691bed2b0", size = 782965, upload-time = "2025-11-03T21:31:23.598Z" }, + { url = "https://files.pythonhosted.org/packages/b4/4c/ae3e52988ae74af4b04d2af32fee4e8077f26e51b62ec2d12d246876bea2/regex-2025.11.3-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:e6b49cd2aad93a1790ce9cffb18964f6d3a4b0b3dbdbd5de094b65296fce6e58", size = 854398, upload-time = "2025-11-03T21:31:25.008Z" }, + { url = "https://files.pythonhosted.org/packages/06/d1/a8b9cf45874eda14b2e275157ce3b304c87e10fb38d9fc26a6e14eb18227/regex-2025.11.3-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:885b26aa3ee56433b630502dc3d36ba78d186a00cc535d3806e6bfd9ed3c70ab", size = 845897, upload-time = "2025-11-03T21:31:26.427Z" }, + { url = "https://files.pythonhosted.org/packages/ea/fe/1830eb0236be93d9b145e0bd8ab499f31602fe0999b1f19e99955aa8fe20/regex-2025.11.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ddd76a9f58e6a00f8772e72cff8ebcff78e022be95edf018766707c730593e1e", size = 788906, upload-time = "2025-11-03T21:31:28.078Z" }, + { url = "https://files.pythonhosted.org/packages/66/47/dc2577c1f95f188c1e13e2e69d8825a5ac582ac709942f8a03af42ed6e93/regex-2025.11.3-cp311-cp311-win32.whl", hash = "sha256:3e816cc9aac1cd3cc9a4ec4d860f06d40f994b5c7b4d03b93345f44e08cc68bf", size = 265812, upload-time = "2025-11-03T21:31:29.72Z" }, + { url = "https://files.pythonhosted.org/packages/50/1e/15f08b2f82a9bbb510621ec9042547b54d11e83cb620643ebb54e4eb7d71/regex-2025.11.3-cp311-cp311-win_amd64.whl", hash = "sha256:087511f5c8b7dfbe3a03f5d5ad0c2a33861b1fc387f21f6f60825a44865a385a", size = 277737, upload-time = "2025-11-03T21:31:31.422Z" }, + { url = "https://files.pythonhosted.org/packages/f4/fc/6500eb39f5f76c5e47a398df82e6b535a5e345f839581012a418b16f9cc3/regex-2025.11.3-cp311-cp311-win_arm64.whl", hash = "sha256:1ff0d190c7f68ae7769cd0313fe45820ba07ffebfddfaa89cc1eb70827ba0ddc", size = 270290, upload-time = "2025-11-03T21:31:33.041Z" }, + { url = "https://files.pythonhosted.org/packages/e8/74/18f04cb53e58e3fb107439699bd8375cf5a835eec81084e0bddbd122e4c2/regex-2025.11.3-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:bc8ab71e2e31b16e40868a40a69007bc305e1109bd4658eb6cad007e0bf67c41", size = 489312, upload-time = "2025-11-03T21:31:34.343Z" }, + { url = "https://files.pythonhosted.org/packages/78/3f/37fcdd0d2b1e78909108a876580485ea37c91e1acf66d3bb8e736348f441/regex-2025.11.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:22b29dda7e1f7062a52359fca6e58e548e28c6686f205e780b02ad8ef710de36", size = 291256, upload-time = "2025-11-03T21:31:35.675Z" }, + { url = "https://files.pythonhosted.org/packages/bf/26/0a575f58eb23b7ebd67a45fccbc02ac030b737b896b7e7a909ffe43ffd6a/regex-2025.11.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3a91e4a29938bc1a082cc28fdea44be420bf2bebe2665343029723892eb073e1", size = 288921, upload-time = "2025-11-03T21:31:37.07Z" }, + { url = "https://files.pythonhosted.org/packages/ea/98/6a8dff667d1af907150432cf5abc05a17ccd32c72a3615410d5365ac167a/regex-2025.11.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:08b884f4226602ad40c5d55f52bf91a9df30f513864e0054bad40c0e9cf1afb7", size = 798568, upload-time = "2025-11-03T21:31:38.784Z" }, + { url = "https://files.pythonhosted.org/packages/64/15/92c1db4fa4e12733dd5a526c2dd2b6edcbfe13257e135fc0f6c57f34c173/regex-2025.11.3-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3e0b11b2b2433d1c39c7c7a30e3f3d0aeeea44c2a8d0bae28f6b95f639927a69", size = 864165, upload-time = "2025-11-03T21:31:40.559Z" }, + { url = "https://files.pythonhosted.org/packages/f9/e7/3ad7da8cdee1ce66c7cd37ab5ab05c463a86ffeb52b1a25fe7bd9293b36c/regex-2025.11.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:87eb52a81ef58c7ba4d45c3ca74e12aa4b4e77816f72ca25258a85b3ea96cb48", size = 912182, upload-time = "2025-11-03T21:31:42.002Z" }, + { url = "https://files.pythonhosted.org/packages/84/bd/9ce9f629fcb714ffc2c3faf62b6766ecb7a585e1e885eb699bcf130a5209/regex-2025.11.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a12ab1f5c29b4e93db518f5e3872116b7e9b1646c9f9f426f777b50d44a09e8c", size = 803501, upload-time = "2025-11-03T21:31:43.815Z" }, + { url = "https://files.pythonhosted.org/packages/7c/0f/8dc2e4349d8e877283e6edd6c12bdcebc20f03744e86f197ab6e4492bf08/regex-2025.11.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:7521684c8c7c4f6e88e35ec89680ee1aa8358d3f09d27dfbdf62c446f5d4c695", size = 787842, upload-time = "2025-11-03T21:31:45.353Z" }, + { url = "https://files.pythonhosted.org/packages/f9/73/cff02702960bc185164d5619c0c62a2f598a6abff6695d391b096237d4ab/regex-2025.11.3-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:7fe6e5440584e94cc4b3f5f4d98a25e29ca12dccf8873679a635638349831b98", size = 858519, upload-time = "2025-11-03T21:31:46.814Z" }, + { url = "https://files.pythonhosted.org/packages/61/83/0e8d1ae71e15bc1dc36231c90b46ee35f9d52fab2e226b0e039e7ea9c10a/regex-2025.11.3-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:8e026094aa12b43f4fd74576714e987803a315c76edb6b098b9809db5de58f74", size = 850611, upload-time = "2025-11-03T21:31:48.289Z" }, + { url = "https://files.pythonhosted.org/packages/c8/f5/70a5cdd781dcfaa12556f2955bf170cd603cb1c96a1827479f8faea2df97/regex-2025.11.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:435bbad13e57eb5606a68443af62bed3556de2f46deb9f7d4237bc2f1c9fb3a0", size = 789759, upload-time = "2025-11-03T21:31:49.759Z" }, + { url = "https://files.pythonhosted.org/packages/59/9b/7c29be7903c318488983e7d97abcf8ebd3830e4c956c4c540005fcfb0462/regex-2025.11.3-cp312-cp312-win32.whl", hash = "sha256:3839967cf4dc4b985e1570fd8d91078f0c519f30491c60f9ac42a8db039be204", size = 266194, upload-time = "2025-11-03T21:31:51.53Z" }, + { url = "https://files.pythonhosted.org/packages/1a/67/3b92df89f179d7c367be654ab5626ae311cb28f7d5c237b6bb976cd5fbbb/regex-2025.11.3-cp312-cp312-win_amd64.whl", hash = "sha256:e721d1b46e25c481dc5ded6f4b3f66c897c58d2e8cfdf77bbced84339108b0b9", size = 277069, upload-time = "2025-11-03T21:31:53.151Z" }, + { url = "https://files.pythonhosted.org/packages/d7/55/85ba4c066fe5094d35b249c3ce8df0ba623cfd35afb22d6764f23a52a1c5/regex-2025.11.3-cp312-cp312-win_arm64.whl", hash = "sha256:64350685ff08b1d3a6fff33f45a9ca183dc1d58bbfe4981604e70ec9801bbc26", size = 270330, upload-time = "2025-11-03T21:31:54.514Z" }, +] + +[[package]] +name = "requests" +version = "2.32.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "charset-normalizer" }, + { name = "idna" }, + { name = "urllib3" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c9/74/b3ff8e6c8446842c3f5c837e9c3dfcfe2018ea6ecef224c710c85ef728f4/requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf", size = 134517, upload-time = "2025-08-18T20:46:02.573Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/db/4254e3eabe8020b458f1a747140d32277ec7a271daf1d235b70dc0b4e6e3/requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6", size = 64738, upload-time = "2025-08-18T20:46:00.542Z" }, +] + +[[package]] +name = "requests-oauthlib" +version = "2.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "oauthlib" }, + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/42/f2/05f29bc3913aea15eb670be136045bf5c5bbf4b99ecb839da9b422bb2c85/requests-oauthlib-2.0.0.tar.gz", hash = "sha256:b3dffaebd884d8cd778494369603a9e7b58d29111bf6b41bdc2dcd87203af4e9", size = 55650, upload-time = "2024-03-22T20:32:29.939Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3b/5d/63d4ae3b9daea098d5d6f5da83984853c1bbacd5dc826764b249fe119d24/requests_oauthlib-2.0.0-py2.py3-none-any.whl", hash = "sha256:7dd8a5c40426b779b0868c404bdef9768deccf22749cde15852df527e6269b36", size = 24179, upload-time = "2024-03-22T20:32:28.055Z" }, +] + +[[package]] +name = "requests-toolbelt" +version = "1.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f3/61/d7545dafb7ac2230c70d38d31cbfe4cc64f7144dc41f6e4e4b78ecd9f5bb/requests-toolbelt-1.0.0.tar.gz", hash = "sha256:7681a0a3d047012b5bdc0ee37d7f8f07ebe76ab08caeccfc3921ce23c88d5bc6", size = 206888, upload-time = "2023-05-01T04:11:33.229Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3f/51/d4db610ef29373b879047326cbf6fa98b6c1969d6f6dc423279de2b1be2c/requests_toolbelt-1.0.0-py2.py3-none-any.whl", hash = "sha256:cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06", size = 54481, upload-time = "2023-05-01T04:11:28.427Z" }, +] + +[[package]] +name = "rfc3339-validator" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/28/ea/a9387748e2d111c3c2b275ba970b735e04e15cdb1eb30693b6b5708c4dbd/rfc3339_validator-0.1.4.tar.gz", hash = "sha256:138a2abdf93304ad60530167e51d2dfb9549521a836871b88d7f4695d0022f6b", size = 5513, upload-time = "2021-05-12T16:37:54.178Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/44/4e421b96b67b2daff264473f7465db72fbdf36a07e05494f50300cc7b0c6/rfc3339_validator-0.1.4-py2.py3-none-any.whl", hash = "sha256:24f6ec1eda14ef823da9e36ec7113124b39c04d50a4d3d3a3c2859577e7791fa", size = 3490, upload-time = "2021-05-12T16:37:52.536Z" }, +] + +[[package]] +name = "rpds-py" +version = "0.30.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/20/af/3f2f423103f1113b36230496629986e0ef7e199d2aa8392452b484b38ced/rpds_py-0.30.0.tar.gz", hash = "sha256:dd8ff7cf90014af0c0f787eea34794ebf6415242ee1d6fa91eaba725cc441e84", size = 69469, upload-time = "2025-11-30T20:24:38.837Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4d/6e/f964e88b3d2abee2a82c1ac8366da848fce1c6d834dc2132c3fda3970290/rpds_py-0.30.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:a2bffea6a4ca9f01b3f8e548302470306689684e61602aa3d141e34da06cf425", size = 370157, upload-time = "2025-11-30T20:21:53.789Z" }, + { url = "https://files.pythonhosted.org/packages/94/ba/24e5ebb7c1c82e74c4e4f33b2112a5573ddc703915b13a073737b59b86e0/rpds_py-0.30.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:dc4f992dfe1e2bc3ebc7444f6c7051b4bc13cd8e33e43511e8ffd13bf407010d", size = 359676, upload-time = "2025-11-30T20:21:55.475Z" }, + { url = "https://files.pythonhosted.org/packages/84/86/04dbba1b087227747d64d80c3b74df946b986c57af0a9f0c98726d4d7a3b/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:422c3cb9856d80b09d30d2eb255d0754b23e090034e1deb4083f8004bd0761e4", size = 389938, upload-time = "2025-11-30T20:21:57.079Z" }, + { url = "https://files.pythonhosted.org/packages/42/bb/1463f0b1722b7f45431bdd468301991d1328b16cffe0b1c2918eba2c4eee/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:07ae8a593e1c3c6b82ca3292efbe73c30b61332fd612e05abee07c79359f292f", size = 402932, upload-time = "2025-11-30T20:21:58.47Z" }, + { url = "https://files.pythonhosted.org/packages/99/ee/2520700a5c1f2d76631f948b0736cdf9b0acb25abd0ca8e889b5c62ac2e3/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:12f90dd7557b6bd57f40abe7747e81e0c0b119bef015ea7726e69fe550e394a4", size = 525830, upload-time = "2025-11-30T20:21:59.699Z" }, + { url = "https://files.pythonhosted.org/packages/e0/ad/bd0331f740f5705cc555a5e17fdf334671262160270962e69a2bdef3bf76/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:99b47d6ad9a6da00bec6aabe5a6279ecd3c06a329d4aa4771034a21e335c3a97", size = 412033, upload-time = "2025-11-30T20:22:00.991Z" }, + { url = "https://files.pythonhosted.org/packages/f8/1e/372195d326549bb51f0ba0f2ecb9874579906b97e08880e7a65c3bef1a99/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33f559f3104504506a44bb666b93a33f5d33133765b0c216a5bf2f1e1503af89", size = 390828, upload-time = "2025-11-30T20:22:02.723Z" }, + { url = "https://files.pythonhosted.org/packages/ab/2b/d88bb33294e3e0c76bc8f351a3721212713629ffca1700fa94979cb3eae8/rpds_py-0.30.0-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:946fe926af6e44f3697abbc305ea168c2c31d3e3ef1058cf68f379bf0335a78d", size = 404683, upload-time = "2025-11-30T20:22:04.367Z" }, + { url = "https://files.pythonhosted.org/packages/50/32/c759a8d42bcb5289c1fac697cd92f6fe01a018dd937e62ae77e0e7f15702/rpds_py-0.30.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:495aeca4b93d465efde585977365187149e75383ad2684f81519f504f5c13038", size = 421583, upload-time = "2025-11-30T20:22:05.814Z" }, + { url = "https://files.pythonhosted.org/packages/2b/81/e729761dbd55ddf5d84ec4ff1f47857f4374b0f19bdabfcf929164da3e24/rpds_py-0.30.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d9a0ca5da0386dee0655b4ccdf46119df60e0f10da268d04fe7cc87886872ba7", size = 572496, upload-time = "2025-11-30T20:22:07.713Z" }, + { url = "https://files.pythonhosted.org/packages/14/f6/69066a924c3557c9c30baa6ec3a0aa07526305684c6f86c696b08860726c/rpds_py-0.30.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8d6d1cc13664ec13c1b84241204ff3b12f9bb82464b8ad6e7a5d3486975c2eed", size = 598669, upload-time = "2025-11-30T20:22:09.312Z" }, + { url = "https://files.pythonhosted.org/packages/5f/48/905896b1eb8a05630d20333d1d8ffd162394127b74ce0b0784ae04498d32/rpds_py-0.30.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:3896fa1be39912cf0757753826bc8bdc8ca331a28a7c4ae46b7a21280b06bb85", size = 561011, upload-time = "2025-11-30T20:22:11.309Z" }, + { url = "https://files.pythonhosted.org/packages/22/16/cd3027c7e279d22e5eb431dd3c0fbc677bed58797fe7581e148f3f68818b/rpds_py-0.30.0-cp311-cp311-win32.whl", hash = "sha256:55f66022632205940f1827effeff17c4fa7ae1953d2b74a8581baaefb7d16f8c", size = 221406, upload-time = "2025-11-30T20:22:13.101Z" }, + { url = "https://files.pythonhosted.org/packages/fa/5b/e7b7aa136f28462b344e652ee010d4de26ee9fd16f1bfd5811f5153ccf89/rpds_py-0.30.0-cp311-cp311-win_amd64.whl", hash = "sha256:a51033ff701fca756439d641c0ad09a41d9242fa69121c7d8769604a0a629825", size = 236024, upload-time = "2025-11-30T20:22:14.853Z" }, + { url = "https://files.pythonhosted.org/packages/14/a6/364bba985e4c13658edb156640608f2c9e1d3ea3c81b27aa9d889fff0e31/rpds_py-0.30.0-cp311-cp311-win_arm64.whl", hash = "sha256:47b0ef6231c58f506ef0b74d44e330405caa8428e770fec25329ed2cb971a229", size = 229069, upload-time = "2025-11-30T20:22:16.577Z" }, + { url = "https://files.pythonhosted.org/packages/03/e7/98a2f4ac921d82f33e03f3835f5bf3a4a40aa1bfdc57975e74a97b2b4bdd/rpds_py-0.30.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:a161f20d9a43006833cd7068375a94d035714d73a172b681d8881820600abfad", size = 375086, upload-time = "2025-11-30T20:22:17.93Z" }, + { url = "https://files.pythonhosted.org/packages/4d/a1/bca7fd3d452b272e13335db8d6b0b3ecde0f90ad6f16f3328c6fb150c889/rpds_py-0.30.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6abc8880d9d036ecaafe709079969f56e876fcf107f7a8e9920ba6d5a3878d05", size = 359053, upload-time = "2025-11-30T20:22:19.297Z" }, + { url = "https://files.pythonhosted.org/packages/65/1c/ae157e83a6357eceff62ba7e52113e3ec4834a84cfe07fa4b0757a7d105f/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ca28829ae5f5d569bb62a79512c842a03a12576375d5ece7d2cadf8abe96ec28", size = 390763, upload-time = "2025-11-30T20:22:21.661Z" }, + { url = "https://files.pythonhosted.org/packages/d4/36/eb2eb8515e2ad24c0bd43c3ee9cd74c33f7ca6430755ccdb240fd3144c44/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a1010ed9524c73b94d15919ca4d41d8780980e1765babf85f9a2f90d247153dd", size = 408951, upload-time = "2025-11-30T20:22:23.408Z" }, + { url = "https://files.pythonhosted.org/packages/d6/65/ad8dc1784a331fabbd740ef6f71ce2198c7ed0890dab595adb9ea2d775a1/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f8d1736cfb49381ba528cd5baa46f82fdc65c06e843dab24dd70b63d09121b3f", size = 514622, upload-time = "2025-11-30T20:22:25.16Z" }, + { url = "https://files.pythonhosted.org/packages/63/8e/0cfa7ae158e15e143fe03993b5bcd743a59f541f5952e1546b1ac1b5fd45/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d948b135c4693daff7bc2dcfc4ec57237a29bd37e60c2fabf5aff2bbacf3e2f1", size = 414492, upload-time = "2025-11-30T20:22:26.505Z" }, + { url = "https://files.pythonhosted.org/packages/60/1b/6f8f29f3f995c7ffdde46a626ddccd7c63aefc0efae881dc13b6e5d5bb16/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47f236970bccb2233267d89173d3ad2703cd36a0e2a6e92d0560d333871a3d23", size = 394080, upload-time = "2025-11-30T20:22:27.934Z" }, + { url = "https://files.pythonhosted.org/packages/6d/d5/a266341051a7a3ca2f4b750a3aa4abc986378431fc2da508c5034d081b70/rpds_py-0.30.0-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:2e6ecb5a5bcacf59c3f912155044479af1d0b6681280048b338b28e364aca1f6", size = 408680, upload-time = "2025-11-30T20:22:29.341Z" }, + { url = "https://files.pythonhosted.org/packages/10/3b/71b725851df9ab7a7a4e33cf36d241933da66040d195a84781f49c50490c/rpds_py-0.30.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a8fa71a2e078c527c3e9dc9fc5a98c9db40bcc8a92b4e8858e36d329f8684b51", size = 423589, upload-time = "2025-11-30T20:22:31.469Z" }, + { url = "https://files.pythonhosted.org/packages/00/2b/e59e58c544dc9bd8bd8384ecdb8ea91f6727f0e37a7131baeff8d6f51661/rpds_py-0.30.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:73c67f2db7bc334e518d097c6d1e6fed021bbc9b7d678d6cc433478365d1d5f5", size = 573289, upload-time = "2025-11-30T20:22:32.997Z" }, + { url = "https://files.pythonhosted.org/packages/da/3e/a18e6f5b460893172a7d6a680e86d3b6bc87a54c1f0b03446a3c8c7b588f/rpds_py-0.30.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:5ba103fb455be00f3b1c2076c9d4264bfcb037c976167a6047ed82f23153f02e", size = 599737, upload-time = "2025-11-30T20:22:34.419Z" }, + { url = "https://files.pythonhosted.org/packages/5c/e2/714694e4b87b85a18e2c243614974413c60aa107fd815b8cbc42b873d1d7/rpds_py-0.30.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7cee9c752c0364588353e627da8a7e808a66873672bcb5f52890c33fd965b394", size = 563120, upload-time = "2025-11-30T20:22:35.903Z" }, + { url = "https://files.pythonhosted.org/packages/6f/ab/d5d5e3bcedb0a77f4f613706b750e50a5a3ba1c15ccd3665ecc636c968fd/rpds_py-0.30.0-cp312-cp312-win32.whl", hash = "sha256:1ab5b83dbcf55acc8b08fc62b796ef672c457b17dbd7820a11d6c52c06839bdf", size = 223782, upload-time = "2025-11-30T20:22:37.271Z" }, + { url = "https://files.pythonhosted.org/packages/39/3b/f786af9957306fdc38a74cef405b7b93180f481fb48453a114bb6465744a/rpds_py-0.30.0-cp312-cp312-win_amd64.whl", hash = "sha256:a090322ca841abd453d43456ac34db46e8b05fd9b3b4ac0c78bcde8b089f959b", size = 240463, upload-time = "2025-11-30T20:22:39.021Z" }, + { url = "https://files.pythonhosted.org/packages/f3/d2/b91dc748126c1559042cfe41990deb92c4ee3e2b415f6b5234969ffaf0cc/rpds_py-0.30.0-cp312-cp312-win_arm64.whl", hash = "sha256:669b1805bd639dd2989b281be2cfd951c6121b65e729d9b843e9639ef1fd555e", size = 230868, upload-time = "2025-11-30T20:22:40.493Z" }, + { url = "https://files.pythonhosted.org/packages/69/71/3f34339ee70521864411f8b6992e7ab13ac30d8e4e3309e07c7361767d91/rpds_py-0.30.0-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c2262bdba0ad4fc6fb5545660673925c2d2a5d9e2e0fb603aad545427be0fc58", size = 372292, upload-time = "2025-11-30T20:24:16.537Z" }, + { url = "https://files.pythonhosted.org/packages/57/09/f183df9b8f2d66720d2ef71075c59f7e1b336bec7ee4c48f0a2b06857653/rpds_py-0.30.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:ee6af14263f25eedc3bb918a3c04245106a42dfd4f5c2285ea6f997b1fc3f89a", size = 362128, upload-time = "2025-11-30T20:24:18.086Z" }, + { url = "https://files.pythonhosted.org/packages/7a/68/5c2594e937253457342e078f0cc1ded3dd7b2ad59afdbf2d354869110a02/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3adbb8179ce342d235c31ab8ec511e66c73faa27a47e076ccc92421add53e2bb", size = 391542, upload-time = "2025-11-30T20:24:20.092Z" }, + { url = "https://files.pythonhosted.org/packages/49/5c/31ef1afd70b4b4fbdb2800249f34c57c64beb687495b10aec0365f53dfc4/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:250fa00e9543ac9b97ac258bd37367ff5256666122c2d0f2bc97577c60a1818c", size = 404004, upload-time = "2025-11-30T20:24:22.231Z" }, + { url = "https://files.pythonhosted.org/packages/e3/63/0cfbea38d05756f3440ce6534d51a491d26176ac045e2707adc99bb6e60a/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9854cf4f488b3d57b9aaeb105f06d78e5529d3145b1e4a41750167e8c213c6d3", size = 527063, upload-time = "2025-11-30T20:24:24.302Z" }, + { url = "https://files.pythonhosted.org/packages/42/e6/01e1f72a2456678b0f618fc9a1a13f882061690893c192fcad9f2926553a/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:993914b8e560023bc0a8bf742c5f303551992dcb85e247b1e5c7f4a7d145bda5", size = 413099, upload-time = "2025-11-30T20:24:25.916Z" }, + { url = "https://files.pythonhosted.org/packages/b8/25/8df56677f209003dcbb180765520c544525e3ef21ea72279c98b9aa7c7fb/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58edca431fb9b29950807e301826586e5bbf24163677732429770a697ffe6738", size = 392177, upload-time = "2025-11-30T20:24:27.834Z" }, + { url = "https://files.pythonhosted.org/packages/4a/b4/0a771378c5f16f8115f796d1f437950158679bcd2a7c68cf251cfb00ed5b/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_31_riscv64.whl", hash = "sha256:dea5b552272a944763b34394d04577cf0f9bd013207bc32323b5a89a53cf9c2f", size = 406015, upload-time = "2025-11-30T20:24:29.457Z" }, + { url = "https://files.pythonhosted.org/packages/36/d8/456dbba0af75049dc6f63ff295a2f92766b9d521fa00de67a2bd6427d57a/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ba3af48635eb83d03f6c9735dfb21785303e73d22ad03d489e88adae6eab8877", size = 423736, upload-time = "2025-11-30T20:24:31.22Z" }, + { url = "https://files.pythonhosted.org/packages/13/64/b4d76f227d5c45a7e0b796c674fd81b0a6c4fbd48dc29271857d8219571c/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:dff13836529b921e22f15cb099751209a60009731a68519630a24d61f0b1b30a", size = 573981, upload-time = "2025-11-30T20:24:32.934Z" }, + { url = "https://files.pythonhosted.org/packages/20/91/092bacadeda3edf92bf743cc96a7be133e13a39cdbfd7b5082e7ab638406/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_i686.whl", hash = "sha256:1b151685b23929ab7beec71080a8889d4d6d9fa9a983d213f07121205d48e2c4", size = 599782, upload-time = "2025-11-30T20:24:35.169Z" }, + { url = "https://files.pythonhosted.org/packages/d1/b7/b95708304cd49b7b6f82fdd039f1748b66ec2b21d6a45180910802f1abf1/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:ac37f9f516c51e5753f27dfdef11a88330f04de2d564be3991384b2f3535d02e", size = 562191, upload-time = "2025-11-30T20:24:36.853Z" }, +] + +[[package]] +name = "ruamel-yaml" +version = "0.18.17" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ruamel-yaml-clib", marker = "platform_python_implementation == 'CPython'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3a/2b/7a1f1ebcd6b3f14febdc003e658778d81e76b40df2267904ee6b13f0c5c6/ruamel_yaml-0.18.17.tar.gz", hash = "sha256:9091cd6e2d93a3a4b157ddb8fabf348c3de7f1fb1381346d985b6b247dcd8d3c", size = 149602, upload-time = "2025-12-17T20:02:55.757Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/fe/b6045c782f1fd1ae317d2a6ca1884857ce5c20f59befe6ab25a8603c43a7/ruamel_yaml-0.18.17-py3-none-any.whl", hash = "sha256:9c8ba9eb3e793efdf924b60d521820869d5bf0cb9c6f1b82d82de8295e290b9d", size = 121594, upload-time = "2025-12-17T20:02:07.657Z" }, +] + +[[package]] +name = "ruamel-yaml-clib" +version = "0.2.15" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ea/97/60fda20e2fb54b83a61ae14648b0817c8f5d84a3821e40bfbdae1437026a/ruamel_yaml_clib-0.2.15.tar.gz", hash = "sha256:46e4cc8c43ef6a94885f72512094e482114a8a706d3c555a34ed4b0d20200600", size = 225794, upload-time = "2025-11-16T16:12:59.761Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/80/8ce7b9af532aa94dd83360f01ce4716264db73de6bc8efd22c32341f6658/ruamel_yaml_clib-0.2.15-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c583229f336682b7212a43d2fa32c30e643d3076178fb9f7a6a14dde85a2d8bd", size = 147998, upload-time = "2025-11-16T16:13:13.241Z" }, + { url = "https://files.pythonhosted.org/packages/53/09/de9d3f6b6701ced5f276d082ad0f980edf08ca67114523d1b9264cd5e2e0/ruamel_yaml_clib-0.2.15-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56ea19c157ed8c74b6be51b5fa1c3aff6e289a041575f0556f66e5fb848bb137", size = 132743, upload-time = "2025-11-16T16:13:14.265Z" }, + { url = "https://files.pythonhosted.org/packages/0e/f7/73a9b517571e214fe5c246698ff3ed232f1ef863c8ae1667486625ec688a/ruamel_yaml_clib-0.2.15-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:5fea0932358e18293407feb921d4f4457db837b67ec1837f87074667449f9401", size = 731459, upload-time = "2025-11-16T20:22:44.338Z" }, + { url = "https://files.pythonhosted.org/packages/9b/a2/0dc0013169800f1c331a6f55b1282c1f4492a6d32660a0cf7b89e6684919/ruamel_yaml_clib-0.2.15-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ef71831bd61fbdb7aa0399d5c4da06bea37107ab5c79ff884cc07f2450910262", size = 749289, upload-time = "2025-11-16T16:13:15.633Z" }, + { url = "https://files.pythonhosted.org/packages/aa/ed/3fb20a1a96b8dc645d88c4072df481fe06e0289e4d528ebbdcc044ebc8b3/ruamel_yaml_clib-0.2.15-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:617d35dc765715fa86f8c3ccdae1e4229055832c452d4ec20856136acc75053f", size = 777630, upload-time = "2025-11-16T16:13:16.898Z" }, + { url = "https://files.pythonhosted.org/packages/60/50/6842f4628bc98b7aa4733ab2378346e1441e150935ad3b9f3c3c429d9408/ruamel_yaml_clib-0.2.15-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1b45498cc81a4724a2d42273d6cfc243c0547ad7c6b87b4f774cb7bcc131c98d", size = 744368, upload-time = "2025-11-16T16:13:18.117Z" }, + { url = "https://files.pythonhosted.org/packages/d3/b0/128ae8e19a7d794c2e36130a72b3bb650ce1dd13fb7def6cf10656437dcf/ruamel_yaml_clib-0.2.15-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:def5663361f6771b18646620fca12968aae730132e104688766cf8a3b1d65922", size = 745233, upload-time = "2025-11-16T20:22:45.833Z" }, + { url = "https://files.pythonhosted.org/packages/75/05/91130633602d6ba7ce3e07f8fc865b40d2a09efd4751c740df89eed5caf9/ruamel_yaml_clib-0.2.15-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:014181cdec565c8745b7cbc4de3bf2cc8ced05183d986e6d1200168e5bb59490", size = 770963, upload-time = "2025-11-16T16:13:19.344Z" }, + { url = "https://files.pythonhosted.org/packages/fd/4b/fd4542e7f33d7d1bc64cc9ac9ba574ce8cf145569d21f5f20133336cdc8c/ruamel_yaml_clib-0.2.15-cp311-cp311-win32.whl", hash = "sha256:d290eda8f6ada19e1771b54e5706b8f9807e6bb08e873900d5ba114ced13e02c", size = 102640, upload-time = "2025-11-16T16:13:20.498Z" }, + { url = "https://files.pythonhosted.org/packages/bb/eb/00ff6032c19c7537371e3119287999570867a0eafb0154fccc80e74bf57a/ruamel_yaml_clib-0.2.15-cp311-cp311-win_amd64.whl", hash = "sha256:bdc06ad71173b915167702f55d0f3f027fc61abd975bd308a0968c02db4a4c3e", size = 121996, upload-time = "2025-11-16T16:13:21.855Z" }, + { url = "https://files.pythonhosted.org/packages/72/4b/5fde11a0722d676e469d3d6f78c6a17591b9c7e0072ca359801c4bd17eee/ruamel_yaml_clib-0.2.15-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cb15a2e2a90c8475df45c0949793af1ff413acfb0a716b8b94e488ea95ce7cff", size = 149088, upload-time = "2025-11-16T16:13:22.836Z" }, + { url = "https://files.pythonhosted.org/packages/85/82/4d08ac65ecf0ef3b046421985e66301a242804eb9a62c93ca3437dc94ee0/ruamel_yaml_clib-0.2.15-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:64da03cbe93c1e91af133f5bec37fd24d0d4ba2418eaf970d7166b0a26a148a2", size = 134553, upload-time = "2025-11-16T16:13:24.151Z" }, + { url = "https://files.pythonhosted.org/packages/b9/cb/22366d68b280e281a932403b76da7a988108287adff2bfa5ce881200107a/ruamel_yaml_clib-0.2.15-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:f6d3655e95a80325b84c4e14c080b2470fe4f33b6846f288379ce36154993fb1", size = 737468, upload-time = "2025-11-16T20:22:47.335Z" }, + { url = "https://files.pythonhosted.org/packages/71/73/81230babf8c9e33770d43ed9056f603f6f5f9665aea4177a2c30ae48e3f3/ruamel_yaml_clib-0.2.15-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:71845d377c7a47afc6592aacfea738cc8a7e876d586dfba814501d8c53c1ba60", size = 753349, upload-time = "2025-11-16T16:13:26.269Z" }, + { url = "https://files.pythonhosted.org/packages/61/62/150c841f24cda9e30f588ef396ed83f64cfdc13b92d2f925bb96df337ba9/ruamel_yaml_clib-0.2.15-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:11e5499db1ccbc7f4b41f0565e4f799d863ea720e01d3e99fa0b7b5fcd7802c9", size = 788211, upload-time = "2025-11-16T16:13:27.441Z" }, + { url = "https://files.pythonhosted.org/packages/30/93/e79bd9cbecc3267499d9ead919bd61f7ddf55d793fb5ef2b1d7d92444f35/ruamel_yaml_clib-0.2.15-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4b293a37dc97e2b1e8a1aec62792d1e52027087c8eea4fc7b5abd2bdafdd6642", size = 743203, upload-time = "2025-11-16T16:13:28.671Z" }, + { url = "https://files.pythonhosted.org/packages/8d/06/1eb640065c3a27ce92d76157f8efddb184bd484ed2639b712396a20d6dce/ruamel_yaml_clib-0.2.15-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:512571ad41bba04eac7268fe33f7f4742210ca26a81fe0c75357fa682636c690", size = 747292, upload-time = "2025-11-16T20:22:48.584Z" }, + { url = "https://files.pythonhosted.org/packages/a5/21/ee353e882350beab65fcc47a91b6bdc512cace4358ee327af2962892ff16/ruamel_yaml_clib-0.2.15-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e5e9f630c73a490b758bf14d859a39f375e6999aea5ddd2e2e9da89b9953486a", size = 771624, upload-time = "2025-11-16T16:13:29.853Z" }, + { url = "https://files.pythonhosted.org/packages/57/34/cc1b94057aa867c963ecf9ea92ac59198ec2ee3a8d22a126af0b4d4be712/ruamel_yaml_clib-0.2.15-cp312-cp312-win32.whl", hash = "sha256:f4421ab780c37210a07d138e56dd4b51f8642187cdfb433eb687fe8c11de0144", size = 100342, upload-time = "2025-11-16T16:13:31.067Z" }, + { url = "https://files.pythonhosted.org/packages/b3/e5/8925a4208f131b218f9a7e459c0d6fcac8324ae35da269cb437894576366/ruamel_yaml_clib-0.2.15-cp312-cp312-win_amd64.whl", hash = "sha256:2b216904750889133d9222b7b873c199d48ecbb12912aca78970f84a5aa1a4bc", size = 119013, upload-time = "2025-11-16T16:13:32.164Z" }, +] + +[[package]] +name = "safetensors" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/29/9c/6e74567782559a63bd040a236edca26fd71bc7ba88de2ef35d75df3bca5e/safetensors-0.7.0.tar.gz", hash = "sha256:07663963b67e8bd9f0b8ad15bb9163606cd27cc5a1b96235a50d8369803b96b0", size = 200878, upload-time = "2025-11-19T15:18:43.199Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fa/47/aef6c06649039accf914afef490268e1067ed82be62bcfa5b7e886ad15e8/safetensors-0.7.0-cp38-abi3-macosx_10_12_x86_64.whl", hash = "sha256:c82f4d474cf725255d9e6acf17252991c3c8aac038d6ef363a4bf8be2f6db517", size = 467781, upload-time = "2025-11-19T15:18:35.84Z" }, + { url = "https://files.pythonhosted.org/packages/e8/00/374c0c068e30cd31f1e1b46b4b5738168ec79e7689ca82ee93ddfea05109/safetensors-0.7.0-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:94fd4858284736bb67a897a41608b5b0c2496c9bdb3bf2af1fa3409127f20d57", size = 447058, upload-time = "2025-11-19T15:18:34.416Z" }, + { url = "https://files.pythonhosted.org/packages/f1/06/578ffed52c2296f93d7fd2d844cabfa92be51a587c38c8afbb8ae449ca89/safetensors-0.7.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e07d91d0c92a31200f25351f4acb2bc6aff7f48094e13ebb1d0fb995b54b6542", size = 491748, upload-time = "2025-11-19T15:18:09.79Z" }, + { url = "https://files.pythonhosted.org/packages/ae/33/1debbbb70e4791dde185edb9413d1fe01619255abb64b300157d7f15dddd/safetensors-0.7.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8469155f4cb518bafb4acf4865e8bb9d6804110d2d9bdcaa78564b9fd841e104", size = 503881, upload-time = "2025-11-19T15:18:16.145Z" }, + { url = "https://files.pythonhosted.org/packages/8e/1c/40c2ca924d60792c3be509833df711b553c60effbd91da6f5284a83f7122/safetensors-0.7.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:54bef08bf00a2bff599982f6b08e8770e09cc012d7bba00783fc7ea38f1fb37d", size = 623463, upload-time = "2025-11-19T15:18:21.11Z" }, + { url = "https://files.pythonhosted.org/packages/9b/3a/13784a9364bd43b0d61eef4bea2845039bc2030458b16594a1bd787ae26e/safetensors-0.7.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:42cb091236206bb2016d245c377ed383aa7f78691748f3bb6ee1bfa51ae2ce6a", size = 532855, upload-time = "2025-11-19T15:18:25.719Z" }, + { url = "https://files.pythonhosted.org/packages/a0/60/429e9b1cb3fc651937727befe258ea24122d9663e4d5709a48c9cbfceecb/safetensors-0.7.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dac7252938f0696ddea46f5e855dd3138444e82236e3be475f54929f0c510d48", size = 507152, upload-time = "2025-11-19T15:18:33.023Z" }, + { url = "https://files.pythonhosted.org/packages/3c/a8/4b45e4e059270d17af60359713ffd83f97900d45a6afa73aaa0d737d48b6/safetensors-0.7.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1d060c70284127fa805085d8f10fbd0962792aed71879d00864acda69dbab981", size = 541856, upload-time = "2025-11-19T15:18:31.075Z" }, + { url = "https://files.pythonhosted.org/packages/06/87/d26d8407c44175d8ae164a95b5a62707fcc445f3c0c56108e37d98070a3d/safetensors-0.7.0-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:cdab83a366799fa730f90a4ebb563e494f28e9e92c4819e556152ad55e43591b", size = 674060, upload-time = "2025-11-19T15:18:37.211Z" }, + { url = "https://files.pythonhosted.org/packages/11/f5/57644a2ff08dc6325816ba7217e5095f17269dada2554b658442c66aed51/safetensors-0.7.0-cp38-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:672132907fcad9f2aedcb705b2d7b3b93354a2aec1b2f706c4db852abe338f85", size = 771715, upload-time = "2025-11-19T15:18:38.689Z" }, + { url = "https://files.pythonhosted.org/packages/86/31/17883e13a814bd278ae6e266b13282a01049b0c81341da7fd0e3e71a80a3/safetensors-0.7.0-cp38-abi3-musllinux_1_2_i686.whl", hash = "sha256:5d72abdb8a4d56d4020713724ba81dac065fedb7f3667151c4a637f1d3fb26c0", size = 714377, upload-time = "2025-11-19T15:18:40.162Z" }, + { url = "https://files.pythonhosted.org/packages/4a/d8/0c8a7dc9b41dcac53c4cbf9df2b9c83e0e0097203de8b37a712b345c0be5/safetensors-0.7.0-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b0f6d66c1c538d5a94a73aa9ddca8ccc4227e6c9ff555322ea40bdd142391dd4", size = 677368, upload-time = "2025-11-19T15:18:41.627Z" }, + { url = "https://files.pythonhosted.org/packages/05/e5/cb4b713c8a93469e3c5be7c3f8d77d307e65fe89673e731f5c2bfd0a9237/safetensors-0.7.0-cp38-abi3-win32.whl", hash = "sha256:c74af94bf3ac15ac4d0f2a7c7b4663a15f8c2ab15ed0fc7531ca61d0835eccba", size = 326423, upload-time = "2025-11-19T15:18:45.74Z" }, + { url = "https://files.pythonhosted.org/packages/5d/e6/ec8471c8072382cb91233ba7267fd931219753bb43814cbc71757bfd4dab/safetensors-0.7.0-cp38-abi3-win_amd64.whl", hash = "sha256:d1239932053f56f3456f32eb9625590cc7582e905021f94636202a864d470755", size = 341380, upload-time = "2025-11-19T15:18:44.427Z" }, +] + +[[package]] +name = "scikit-learn" +version = "1.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "joblib" }, + { name = "numpy" }, + { name = "scipy" }, + { name = "threadpoolctl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0e/d4/40988bf3b8e34feec1d0e6a051446b1f66225f8529b9309becaeef62b6c4/scikit_learn-1.8.0.tar.gz", hash = "sha256:9bccbb3b40e3de10351f8f5068e105d0f4083b1a65fa07b6634fbc401a6287fd", size = 7335585, upload-time = "2025-12-10T07:08:53.618Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c9/92/53ea2181da8ac6bf27170191028aee7251f8f841f8d3edbfdcaf2008fde9/scikit_learn-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:146b4d36f800c013d267b29168813f7a03a43ecd2895d04861f1240b564421da", size = 8595835, upload-time = "2025-12-10T07:07:39.385Z" }, + { url = "https://files.pythonhosted.org/packages/01/18/d154dc1638803adf987910cdd07097d9c526663a55666a97c124d09fb96a/scikit_learn-1.8.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:f984ca4b14914e6b4094c5d52a32ea16b49832c03bd17a110f004db3c223e8e1", size = 8080381, upload-time = "2025-12-10T07:07:41.93Z" }, + { url = "https://files.pythonhosted.org/packages/8a/44/226142fcb7b7101e64fdee5f49dbe6288d4c7af8abf593237b70fca080a4/scikit_learn-1.8.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5e30adb87f0cc81c7690a84f7932dd66be5bac57cfe16b91cb9151683a4a2d3b", size = 8799632, upload-time = "2025-12-10T07:07:43.899Z" }, + { url = "https://files.pythonhosted.org/packages/36/4d/4a67f30778a45d542bbea5db2dbfa1e9e100bf9ba64aefe34215ba9f11f6/scikit_learn-1.8.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ada8121bcb4dac28d930febc791a69f7cb1673c8495e5eee274190b73a4559c1", size = 9103788, upload-time = "2025-12-10T07:07:45.982Z" }, + { url = "https://files.pythonhosted.org/packages/89/3c/45c352094cfa60050bcbb967b1faf246b22e93cb459f2f907b600f2ceda5/scikit_learn-1.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:c57b1b610bd1f40ba43970e11ce62821c2e6569e4d74023db19c6b26f246cb3b", size = 8081706, upload-time = "2025-12-10T07:07:48.111Z" }, + { url = "https://files.pythonhosted.org/packages/3d/46/5416595bb395757f754feb20c3d776553a386b661658fb21b7c814e89efe/scikit_learn-1.8.0-cp311-cp311-win_arm64.whl", hash = "sha256:2838551e011a64e3053ad7618dda9310175f7515f1742fa2d756f7c874c05961", size = 7688451, upload-time = "2025-12-10T07:07:49.873Z" }, + { url = "https://files.pythonhosted.org/packages/90/74/e6a7cc4b820e95cc38cf36cd74d5aa2b42e8ffc2d21fe5a9a9c45c1c7630/scikit_learn-1.8.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5fb63362b5a7ddab88e52b6dbb47dac3fd7dafeee740dc6c8d8a446ddedade8e", size = 8548242, upload-time = "2025-12-10T07:07:51.568Z" }, + { url = "https://files.pythonhosted.org/packages/49/d8/9be608c6024d021041c7f0b3928d4749a706f4e2c3832bbede4fb4f58c95/scikit_learn-1.8.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:5025ce924beccb28298246e589c691fe1b8c1c96507e6d27d12c5fadd85bfd76", size = 8079075, upload-time = "2025-12-10T07:07:53.697Z" }, + { url = "https://files.pythonhosted.org/packages/dd/47/f187b4636ff80cc63f21cd40b7b2d177134acaa10f6bb73746130ee8c2e5/scikit_learn-1.8.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4496bb2cf7a43ce1a2d7524a79e40bc5da45cf598dbf9545b7e8316ccba47bb4", size = 8660492, upload-time = "2025-12-10T07:07:55.574Z" }, + { url = "https://files.pythonhosted.org/packages/97/74/b7a304feb2b49df9fafa9382d4d09061a96ee9a9449a7cbea7988dda0828/scikit_learn-1.8.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a0bcfe4d0d14aec44921545fd2af2338c7471de9cb701f1da4c9d85906ab847a", size = 8931904, upload-time = "2025-12-10T07:07:57.666Z" }, + { url = "https://files.pythonhosted.org/packages/9f/c4/0ab22726a04ede56f689476b760f98f8f46607caecff993017ac1b64aa5d/scikit_learn-1.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:35c007dedb2ffe38fe3ee7d201ebac4a2deccd2408e8621d53067733e3c74809", size = 8019359, upload-time = "2025-12-10T07:07:59.838Z" }, + { url = "https://files.pythonhosted.org/packages/24/90/344a67811cfd561d7335c1b96ca21455e7e472d281c3c279c4d3f2300236/scikit_learn-1.8.0-cp312-cp312-win_arm64.whl", hash = "sha256:8c497fff237d7b4e07e9ef1a640887fa4fb765647f86fbe00f969ff6280ce2bb", size = 7641898, upload-time = "2025-12-10T07:08:01.36Z" }, +] + +[[package]] +name = "scipy" +version = "1.16.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0a/ca/d8ace4f98322d01abcd52d381134344bf7b431eba7ed8b42bdea5a3c2ac9/scipy-1.16.3.tar.gz", hash = "sha256:01e87659402762f43bd2fee13370553a17ada367d42e7487800bf2916535aecb", size = 30597883, upload-time = "2025-10-28T17:38:54.068Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9b/5f/6f37d7439de1455ce9c5a556b8d1db0979f03a796c030bafdf08d35b7bf9/scipy-1.16.3-cp311-cp311-macosx_10_14_x86_64.whl", hash = "sha256:40be6cf99e68b6c4321e9f8782e7d5ff8265af28ef2cd56e9c9b2638fa08ad97", size = 36630881, upload-time = "2025-10-28T17:31:47.104Z" }, + { url = "https://files.pythonhosted.org/packages/7c/89/d70e9f628749b7e4db2aa4cd89735502ff3f08f7b9b27d2e799485987cd9/scipy-1.16.3-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:8be1ca9170fcb6223cc7c27f4305d680ded114a1567c0bd2bfcbf947d1b17511", size = 28941012, upload-time = "2025-10-28T17:31:53.411Z" }, + { url = "https://files.pythonhosted.org/packages/a8/a8/0e7a9a6872a923505dbdf6bb93451edcac120363131c19013044a1e7cb0c/scipy-1.16.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:bea0a62734d20d67608660f69dcda23e7f90fb4ca20974ab80b6ed40df87a005", size = 20931935, upload-time = "2025-10-28T17:31:57.361Z" }, + { url = "https://files.pythonhosted.org/packages/bd/c7/020fb72bd79ad798e4dbe53938543ecb96b3a9ac3fe274b7189e23e27353/scipy-1.16.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:2a207a6ce9c24f1951241f4693ede2d393f59c07abc159b2cb2be980820e01fb", size = 23534466, upload-time = "2025-10-28T17:32:01.875Z" }, + { url = "https://files.pythonhosted.org/packages/be/a0/668c4609ce6dbf2f948e167836ccaf897f95fb63fa231c87da7558a374cd/scipy-1.16.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:532fb5ad6a87e9e9cd9c959b106b73145a03f04c7d57ea3e6f6bb60b86ab0876", size = 33593618, upload-time = "2025-10-28T17:32:06.902Z" }, + { url = "https://files.pythonhosted.org/packages/ca/6e/8942461cf2636cdae083e3eb72622a7fbbfa5cf559c7d13ab250a5dbdc01/scipy-1.16.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0151a0749efeaaab78711c78422d413c583b8cdd2011a3c1d6c794938ee9fdb2", size = 35899798, upload-time = "2025-10-28T17:32:12.665Z" }, + { url = "https://files.pythonhosted.org/packages/79/e8/d0f33590364cdbd67f28ce79368b373889faa4ee959588beddf6daef9abe/scipy-1.16.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:b7180967113560cca57418a7bc719e30366b47959dd845a93206fbed693c867e", size = 36226154, upload-time = "2025-10-28T17:32:17.961Z" }, + { url = "https://files.pythonhosted.org/packages/39/c1/1903de608c0c924a1749c590064e65810f8046e437aba6be365abc4f7557/scipy-1.16.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:deb3841c925eeddb6afc1e4e4a45e418d19ec7b87c5df177695224078e8ec733", size = 38878540, upload-time = "2025-10-28T17:32:23.907Z" }, + { url = "https://files.pythonhosted.org/packages/f1/d0/22ec7036ba0b0a35bccb7f25ab407382ed34af0b111475eb301c16f8a2e5/scipy-1.16.3-cp311-cp311-win_amd64.whl", hash = "sha256:53c3844d527213631e886621df5695d35e4f6a75f620dca412bcd292f6b87d78", size = 38722107, upload-time = "2025-10-28T17:32:29.921Z" }, + { url = "https://files.pythonhosted.org/packages/7b/60/8a00e5a524bb3bf8898db1650d350f50e6cffb9d7a491c561dc9826c7515/scipy-1.16.3-cp311-cp311-win_arm64.whl", hash = "sha256:9452781bd879b14b6f055b26643703551320aa8d79ae064a71df55c00286a184", size = 25506272, upload-time = "2025-10-28T17:32:34.577Z" }, + { url = "https://files.pythonhosted.org/packages/40/41/5bf55c3f386b1643812f3a5674edf74b26184378ef0f3e7c7a09a7e2ca7f/scipy-1.16.3-cp312-cp312-macosx_10_14_x86_64.whl", hash = "sha256:81fc5827606858cf71446a5e98715ba0e11f0dbc83d71c7409d05486592a45d6", size = 36659043, upload-time = "2025-10-28T17:32:40.285Z" }, + { url = "https://files.pythonhosted.org/packages/1e/0f/65582071948cfc45d43e9870bf7ca5f0e0684e165d7c9ef4e50d783073eb/scipy-1.16.3-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:c97176013d404c7346bf57874eaac5187d969293bf40497140b0a2b2b7482e07", size = 28898986, upload-time = "2025-10-28T17:32:45.325Z" }, + { url = "https://files.pythonhosted.org/packages/96/5e/36bf3f0ac298187d1ceadde9051177d6a4fe4d507e8f59067dc9dd39e650/scipy-1.16.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:2b71d93c8a9936046866acebc915e2af2e292b883ed6e2cbe5c34beb094b82d9", size = 20889814, upload-time = "2025-10-28T17:32:49.277Z" }, + { url = "https://files.pythonhosted.org/packages/80/35/178d9d0c35394d5d5211bbff7ac4f2986c5488b59506fef9e1de13ea28d3/scipy-1.16.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:3d4a07a8e785d80289dfe66b7c27d8634a773020742ec7187b85ccc4b0e7b686", size = 23565795, upload-time = "2025-10-28T17:32:53.337Z" }, + { url = "https://files.pythonhosted.org/packages/fa/46/d1146ff536d034d02f83c8afc3c4bab2eddb634624d6529a8512f3afc9da/scipy-1.16.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0553371015692a898e1aa858fed67a3576c34edefa6b7ebdb4e9dde49ce5c203", size = 33349476, upload-time = "2025-10-28T17:32:58.353Z" }, + { url = "https://files.pythonhosted.org/packages/79/2e/415119c9ab3e62249e18c2b082c07aff907a273741b3f8160414b0e9193c/scipy-1.16.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:72d1717fd3b5e6ec747327ce9bda32d5463f472c9dce9f54499e81fbd50245a1", size = 35676692, upload-time = "2025-10-28T17:33:03.88Z" }, + { url = "https://files.pythonhosted.org/packages/27/82/df26e44da78bf8d2aeaf7566082260cfa15955a5a6e96e6a29935b64132f/scipy-1.16.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1fb2472e72e24d1530debe6ae078db70fb1605350c88a3d14bc401d6306dbffe", size = 36019345, upload-time = "2025-10-28T17:33:09.773Z" }, + { url = "https://files.pythonhosted.org/packages/82/31/006cbb4b648ba379a95c87262c2855cd0d09453e500937f78b30f02fa1cd/scipy-1.16.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c5192722cffe15f9329a3948c4b1db789fbb1f05c97899187dcf009b283aea70", size = 38678975, upload-time = "2025-10-28T17:33:15.809Z" }, + { url = "https://files.pythonhosted.org/packages/c2/7f/acbd28c97e990b421af7d6d6cd416358c9c293fc958b8529e0bd5d2a2a19/scipy-1.16.3-cp312-cp312-win_amd64.whl", hash = "sha256:56edc65510d1331dae01ef9b658d428e33ed48b4f77b1d51caf479a0253f96dc", size = 38555926, upload-time = "2025-10-28T17:33:21.388Z" }, + { url = "https://files.pythonhosted.org/packages/ce/69/c5c7807fd007dad4f48e0a5f2153038dc96e8725d3345b9ee31b2b7bed46/scipy-1.16.3-cp312-cp312-win_arm64.whl", hash = "sha256:a8a26c78ef223d3e30920ef759e25625a0ecdd0d60e5a8818b7513c3e5384cf2", size = 25463014, upload-time = "2025-10-28T17:33:25.975Z" }, +] + +[[package]] +name = "sentence-transformers" +version = "3.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "huggingface-hub" }, + { name = "numpy" }, + { name = "pillow" }, + { name = "scikit-learn" }, + { name = "scipy" }, + { name = "torch" }, + { name = "tqdm" }, + { name = "transformers" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/c0/7051c672a48fe561decf7208cc18bbbdd4efa3323873aa1c86a3fb77fd97/sentence_transformers-3.0.0.tar.gz", hash = "sha256:52d4101654ed107a28e9fa5110fce399084b55e7838fd8256471353ddc299033", size = 174658, upload-time = "2024-05-28T11:53:39.129Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f8/c4/99a9386808025d5a546576243bfd3b1eb669f978b8a0e05a1253eaf89bf0/sentence_transformers-3.0.0-py3-none-any.whl", hash = "sha256:9bf851b688b796e5fb06c920921efd5e5e05ee616e85cb3026fbdfe4dcf15bf3", size = 224681, upload-time = "2024-05-28T11:53:37.037Z" }, +] + +[[package]] +name = "setuptools" +version = "80.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/18/5d/3bf57dcd21979b887f014ea83c24ae194cfcd12b9e0fda66b957c69d1fca/setuptools-80.9.0.tar.gz", hash = "sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c", size = 1319958, upload-time = "2025-05-27T00:56:51.443Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl", hash = "sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922", size = 1201486, upload-time = "2025-05-27T00:56:49.664Z" }, +] + +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, +] + +[[package]] +name = "slack-sdk" +version = "3.31.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a5/e3/4a2491cbf793bb8da8a51120207df8c097faeda42bf720f7acf7c40e4ca8/slack_sdk-3.31.0.tar.gz", hash = "sha256:740d2f9c49cbfcbd46fca56b4be9d527934c225312aac18fd2c0fca0ef6bc935", size = 230928, upload-time = "2024-07-04T16:40:39.019Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/57/04/f4517d8403c49910f45ad91205de352f2eccf12ae28865a27da7d7d05bf6/slack_sdk-3.31.0-py2.py3-none-any.whl", hash = "sha256:a120cc461e8ebb7d9175f171dbe0ded37a6878d9f7b96b28e4bad1227399047b", size = 289845, upload-time = "2024-07-04T16:40:36.34Z" }, +] + +[[package]] +name = "sniffio" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" }, +] + +[[package]] +name = "soupsieve" +version = "2.8" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6d/e6/21ccce3262dd4889aa3332e5a119a3491a95e8f60939870a3a035aabac0d/soupsieve-2.8.tar.gz", hash = "sha256:e2dd4a40a628cb5f28f6d4b0db8800b8f581b65bb380b97de22ba5ca8d72572f", size = 103472, upload-time = "2025-08-27T15:39:51.78Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/14/a0/bb38d3b76b8cae341dad93a2dd83ab7462e6dbcdd84d43f54ee60a8dc167/soupsieve-2.8-py3-none-any.whl", hash = "sha256:0cc76456a30e20f5d7f2e14a98a4ae2ee4e5abdc7c5ea0aafe795f344bc7984c", size = 36679, upload-time = "2025-08-27T15:39:50.179Z" }, +] + +[[package]] +name = "sse-starlette" +version = "3.0.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "starlette" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/17/8b/54651ad49bce99a50fd61a7f19c2b6a79fbb072e693101fbb1194c362054/sse_starlette-3.0.4.tar.gz", hash = "sha256:5e34286862e96ead0eb70f5ddd0bd21ab1f6473a8f44419dd267f431611383dd", size = 22576, upload-time = "2025-12-14T16:22:52.493Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/22/8ab1066358601163e1ac732837adba3672f703818f693e179b24e0d3b65c/sse_starlette-3.0.4-py3-none-any.whl", hash = "sha256:32c80ef0d04506ced4b0b6ab8fe300925edc37d26f666afb1874c754895f5dc3", size = 11764, upload-time = "2025-12-14T16:22:51.453Z" }, +] + +[[package]] +name = "stack-data" +version = "0.6.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "asttokens" }, + { name = "executing" }, + { name = "pure-eval" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/28/e3/55dcc2cfbc3ca9c29519eb6884dd1415ecb53b0e934862d3559ddcb7e20b/stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9", size = 44707, upload-time = "2023-09-30T13:58:05.479Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521, upload-time = "2023-09-30T13:58:03.53Z" }, +] + +[[package]] +name = "starlette" +version = "0.50.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ba/b8/73a0e6a6e079a9d9cfa64113d771e421640b6f679a52eeb9b32f72d871a1/starlette-0.50.0.tar.gz", hash = "sha256:a2a17b22203254bcbc2e1f926d2d55f3f9497f769416b3190768befe598fa3ca", size = 2646985, upload-time = "2025-11-01T15:25:27.516Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl", hash = "sha256:9e5391843ec9b6e472eed1365a78c8098cfceb7a74bfd4d6b1c0c0095efb3bca", size = 74033, upload-time = "2025-11-01T15:25:25.461Z" }, +] + +[[package]] +name = "sympy" +version = "1.14.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mpmath" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/83/d3/803453b36afefb7c2bb238361cd4ae6125a569b4db67cd9e79846ba2d68c/sympy-1.14.0.tar.gz", hash = "sha256:d3d3fe8df1e5a0b42f0e7bdf50541697dbe7d23746e894990c030e2b05e72517", size = 7793921, upload-time = "2025-04-27T18:05:01.611Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl", hash = "sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5", size = 6299353, upload-time = "2025-04-27T18:04:59.103Z" }, +] + +[[package]] +name = "tabulate" +version = "0.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ec/fe/802052aecb21e3797b8f7902564ab6ea0d60ff8ca23952079064155d1ae1/tabulate-0.9.0.tar.gz", hash = "sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c", size = 81090, upload-time = "2022-10-06T17:21:48.54Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/44/4a5f08c96eb108af5cb50b41f76142f0afa346dfa99d5296fe7202a11854/tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f", size = 35252, upload-time = "2022-10-06T17:21:44.262Z" }, +] + +[[package]] +name = "texttable" +version = "1.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1c/dc/0aff23d6036a4d3bf4f1d8c8204c5c79c4437e25e0ae94ffe4bbb55ee3c2/texttable-1.7.0.tar.gz", hash = "sha256:2d2068fb55115807d3ac77a4ca68fa48803e84ebb0ee2340f858107a36522638", size = 12831, upload-time = "2023-10-03T09:48:12.272Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/24/99/4772b8e00a136f3e01236de33b0efda31ee7077203ba5967fcc76da94d65/texttable-1.7.0-py2.py3-none-any.whl", hash = "sha256:72227d592c82b3d7f672731ae73e4d1f88cd8e2ef5b075a7a7f01a23a3743917", size = 10768, upload-time = "2023-10-03T09:48:10.434Z" }, +] + +[[package]] +name = "threadpoolctl" +version = "3.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b7/4d/08c89e34946fce2aec4fbb45c9016efd5f4d7f24af8e5d93296e935631d8/threadpoolctl-3.6.0.tar.gz", hash = "sha256:8ab8b4aa3491d812b623328249fab5302a68d2d71745c8a4c719a2fcaba9f44e", size = 21274, upload-time = "2025-03-13T13:49:23.031Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/d5/f9a850d79b0851d1d4ef6456097579a9005b31fea68726a4ae5f2d82ddd9/threadpoolctl-3.6.0-py3-none-any.whl", hash = "sha256:43a0b8fd5a2928500110039e43a5eed8480b918967083ea48dc3ab9f13c4a7fb", size = 18638, upload-time = "2025-03-13T13:49:21.846Z" }, +] + +[[package]] +name = "tiktoken" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "regex" }, + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c4/4a/abaec53e93e3ef37224a4dd9e2fc6bb871e7a538c2b6b9d2a6397271daf4/tiktoken-0.7.0.tar.gz", hash = "sha256:1077266e949c24e0291f6c350433c6f0971365ece2b173a23bc3b9f9defef6b6", size = 33437, upload-time = "2024-05-13T18:03:28.793Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/eb/57492b2568eea1d546da5cc1ae7559d924275280db80ba07e6f9b89a914b/tiktoken-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:10c7674f81e6e350fcbed7c09a65bca9356eaab27fb2dac65a1e440f2bcfe30f", size = 961468, upload-time = "2024-05-13T18:02:43.788Z" }, + { url = "https://files.pythonhosted.org/packages/30/ef/e07dbfcb2f85c84abaa1b035a9279575a8da0236305491dc22ae099327f7/tiktoken-0.7.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:084cec29713bc9d4189a937f8a35dbdfa785bd1235a34c1124fe2323821ee93f", size = 907005, upload-time = "2024-05-13T18:02:45.327Z" }, + { url = "https://files.pythonhosted.org/packages/ea/9b/f36db825b1e9904c3a2646439cb9923fc1e09208e2e071c6d9dd64ead131/tiktoken-0.7.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:811229fde1652fedcca7c6dfe76724d0908775b353556d8a71ed74d866f73f7b", size = 1049183, upload-time = "2024-05-13T18:02:46.574Z" }, + { url = "https://files.pythonhosted.org/packages/61/b4/b80d1fe33015e782074e96bbbf4108ccd283b8deea86fb43c15d18b7c351/tiktoken-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:86b6e7dc2e7ad1b3757e8a24597415bafcfb454cebf9a33a01f2e6ba2e663992", size = 1080830, upload-time = "2024-05-13T18:02:48.444Z" }, + { url = "https://files.pythonhosted.org/packages/2a/40/c66ff3a21af6d62a7e0ff428d12002c4e0389f776d3ff96dcaa0bb354eee/tiktoken-0.7.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1063c5748be36344c7e18c7913c53e2cca116764c2080177e57d62c7ad4576d1", size = 1092967, upload-time = "2024-05-13T18:02:50.006Z" }, + { url = "https://files.pythonhosted.org/packages/2e/80/f4c9e255ff236e6a69ce44b927629cefc1b63d3a00e2d1c9ed540c9492d2/tiktoken-0.7.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:20295d21419bfcca092644f7e2f2138ff947a6eb8cfc732c09cc7d76988d4a89", size = 1142682, upload-time = "2024-05-13T18:02:51.814Z" }, + { url = "https://files.pythonhosted.org/packages/b1/10/c04b4ff592a5f46b28ebf4c2353f735c02ae7f0ce1b165d00748ced6467e/tiktoken-0.7.0-cp311-cp311-win_amd64.whl", hash = "sha256:959d993749b083acc57a317cbc643fb85c014d055b2119b739487288f4e5d1cb", size = 799009, upload-time = "2024-05-13T18:02:53.057Z" }, + { url = "https://files.pythonhosted.org/packages/1d/46/4cdda4186ce900608f522da34acf442363346688c71b938a90a52d7b84cc/tiktoken-0.7.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:71c55d066388c55a9c00f61d2c456a6086673ab7dec22dd739c23f77195b1908", size = 960446, upload-time = "2024-05-13T18:02:54.409Z" }, + { url = "https://files.pythonhosted.org/packages/b6/30/09ced367d280072d7a3e21f34263dfbbf6378661e7a0f6414e7c18971083/tiktoken-0.7.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:09ed925bccaa8043e34c519fbb2f99110bd07c6fd67714793c21ac298e449410", size = 906652, upload-time = "2024-05-13T18:02:56.25Z" }, + { url = "https://files.pythonhosted.org/packages/e6/7b/c949e4954441a879a67626963dff69096e3c774758b9f2bb0853f7b4e1e7/tiktoken-0.7.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:03c6c40ff1db0f48a7b4d2dafeae73a5607aacb472fa11f125e7baf9dce73704", size = 1047904, upload-time = "2024-05-13T18:02:57.707Z" }, + { url = "https://files.pythonhosted.org/packages/50/81/1842a22f15586072280364c2ab1e40835adaf64e42fe80e52aff921ee021/tiktoken-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d20b5c6af30e621b4aca094ee61777a44118f52d886dbe4f02b70dfe05c15350", size = 1079836, upload-time = "2024-05-13T18:02:59.009Z" }, + { url = "https://files.pythonhosted.org/packages/6d/87/51a133a3d5307cf7ae3754249b0faaa91d3414b85c3d36f80b54d6817aa6/tiktoken-0.7.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d427614c3e074004efa2f2411e16c826f9df427d3c70a54725cae860f09e4bf4", size = 1092472, upload-time = "2024-05-13T18:03:00.597Z" }, + { url = "https://files.pythonhosted.org/packages/a5/1f/c93517dc6d3b2c9e988b8e24f87a8b2d4a4ab28920a3a3f3ea338397ae0c/tiktoken-0.7.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8c46d7af7b8c6987fac9b9f61041b452afe92eb087d29c9ce54951280f899a97", size = 1141881, upload-time = "2024-05-13T18:03:02.743Z" }, + { url = "https://files.pythonhosted.org/packages/bf/4b/48ca098cb580c099b5058bf62c4cb5e90ca6130fa43ef4df27088536245b/tiktoken-0.7.0-cp312-cp312-win_amd64.whl", hash = "sha256:0bc603c30b9e371e7c4c7935aba02af5994a909fc3c0fe66e7004070858d3f8f", size = 799281, upload-time = "2024-05-13T18:03:04.036Z" }, +] + +[[package]] +name = "tinycss2" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "webencodings" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7a/fd/7a5ee21fd08ff70d3d33a5781c255cbe779659bd03278feb98b19ee550f4/tinycss2-1.4.0.tar.gz", hash = "sha256:10c0972f6fc0fbee87c3edb76549357415e94548c1ae10ebccdea16fb404a9b7", size = 87085, upload-time = "2024-10-24T14:58:29.895Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/34/ebdc18bae6aa14fbee1a08b63c015c72b64868ff7dae68808ab500c492e2/tinycss2-1.4.0-py3-none-any.whl", hash = "sha256:3a49cf47b7675da0b15d0c6e1df8df4ebd96e9394bb905a5775adb0d884c5289", size = 26610, upload-time = "2024-10-24T14:58:28.029Z" }, +] + +[[package]] +name = "tokenizers" +version = "0.22.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "huggingface-hub" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/1c/46/fb6854cec3278fbfa4a75b50232c77622bc517ac886156e6afbfa4d8fc6e/tokenizers-0.22.1.tar.gz", hash = "sha256:61de6522785310a309b3407bac22d99c4db5dba349935e99e4d15ea2226af2d9", size = 363123, upload-time = "2025-09-19T09:49:23.424Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bf/33/f4b2d94ada7ab297328fc671fed209368ddb82f965ec2224eb1892674c3a/tokenizers-0.22.1-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:59fdb013df17455e5f950b4b834a7b3ee2e0271e6378ccb33aa74d178b513c73", size = 3069318, upload-time = "2025-09-19T09:49:11.848Z" }, + { url = "https://files.pythonhosted.org/packages/1c/58/2aa8c874d02b974990e89ff95826a4852a8b2a273c7d1b4411cdd45a4565/tokenizers-0.22.1-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:8d4e484f7b0827021ac5f9f71d4794aaef62b979ab7608593da22b1d2e3c4edc", size = 2926478, upload-time = "2025-09-19T09:49:09.759Z" }, + { url = "https://files.pythonhosted.org/packages/1e/3b/55e64befa1e7bfea963cf4b787b2cea1011362c4193f5477047532ce127e/tokenizers-0.22.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:19d2962dd28bc67c1f205ab180578a78eef89ac60ca7ef7cbe9635a46a56422a", size = 3256994, upload-time = "2025-09-19T09:48:56.701Z" }, + { url = "https://files.pythonhosted.org/packages/71/0b/fbfecf42f67d9b7b80fde4aabb2b3110a97fac6585c9470b5bff103a80cb/tokenizers-0.22.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:38201f15cdb1f8a6843e6563e6e79f4abd053394992b9bbdf5213ea3469b4ae7", size = 3153141, upload-time = "2025-09-19T09:48:59.749Z" }, + { url = "https://files.pythonhosted.org/packages/17/a9/b38f4e74e0817af8f8ef925507c63c6ae8171e3c4cb2d5d4624bf58fca69/tokenizers-0.22.1-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d1cbe5454c9a15df1b3443c726063d930c16f047a3cc724b9e6e1a91140e5a21", size = 3508049, upload-time = "2025-09-19T09:49:05.868Z" }, + { url = "https://files.pythonhosted.org/packages/d2/48/dd2b3dac46bb9134a88e35d72e1aa4869579eacc1a27238f1577270773ff/tokenizers-0.22.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e7d094ae6312d69cc2a872b54b91b309f4f6fbce871ef28eb27b52a98e4d0214", size = 3710730, upload-time = "2025-09-19T09:49:01.832Z" }, + { url = "https://files.pythonhosted.org/packages/93/0e/ccabc8d16ae4ba84a55d41345207c1e2ea88784651a5a487547d80851398/tokenizers-0.22.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:afd7594a56656ace95cdd6df4cca2e4059d294c5cfb1679c57824b605556cb2f", size = 3412560, upload-time = "2025-09-19T09:49:03.867Z" }, + { url = "https://files.pythonhosted.org/packages/d0/c6/dc3a0db5a6766416c32c034286d7c2d406da1f498e4de04ab1b8959edd00/tokenizers-0.22.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2ef6063d7a84994129732b47e7915e8710f27f99f3a3260b8a38fc7ccd083f4", size = 3250221, upload-time = "2025-09-19T09:49:07.664Z" }, + { url = "https://files.pythonhosted.org/packages/d7/a6/2c8486eef79671601ff57b093889a345dd3d576713ef047776015dc66de7/tokenizers-0.22.1-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ba0a64f450b9ef412c98f6bcd2a50c6df6e2443b560024a09fa6a03189726879", size = 9345569, upload-time = "2025-09-19T09:49:14.214Z" }, + { url = "https://files.pythonhosted.org/packages/6b/16/32ce667f14c35537f5f605fe9bea3e415ea1b0a646389d2295ec348d5657/tokenizers-0.22.1-cp39-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:331d6d149fa9c7d632cde4490fb8bbb12337fa3a0232e77892be656464f4b446", size = 9271599, upload-time = "2025-09-19T09:49:16.639Z" }, + { url = "https://files.pythonhosted.org/packages/51/7c/a5f7898a3f6baa3fc2685c705e04c98c1094c523051c805cdd9306b8f87e/tokenizers-0.22.1-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:607989f2ea68a46cb1dfbaf3e3aabdf3f21d8748312dbeb6263d1b3b66c5010a", size = 9533862, upload-time = "2025-09-19T09:49:19.146Z" }, + { url = "https://files.pythonhosted.org/packages/36/65/7e75caea90bc73c1dd8d40438adf1a7bc26af3b8d0a6705ea190462506e1/tokenizers-0.22.1-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a0f307d490295717726598ef6fa4f24af9d484809223bbc253b201c740a06390", size = 9681250, upload-time = "2025-09-19T09:49:21.501Z" }, + { url = "https://files.pythonhosted.org/packages/30/2c/959dddef581b46e6209da82df3b78471e96260e2bc463f89d23b1bf0e52a/tokenizers-0.22.1-cp39-abi3-win32.whl", hash = "sha256:b5120eed1442765cd90b903bb6cfef781fd8fe64e34ccaecbae4c619b7b12a82", size = 2472003, upload-time = "2025-09-19T09:49:27.089Z" }, + { url = "https://files.pythonhosted.org/packages/b3/46/e33a8c93907b631a99377ef4c5f817ab453d0b34f93529421f42ff559671/tokenizers-0.22.1-cp39-abi3-win_amd64.whl", hash = "sha256:65fd6e3fb11ca1e78a6a93602490f134d1fdeb13bcef99389d5102ea318ed138", size = 2674684, upload-time = "2025-09-19T09:49:24.953Z" }, +] + +[[package]] +name = "torch" +version = "2.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "filelock" }, + { name = "fsspec" }, + { name = "jinja2" }, + { name = "networkx" }, + { name = "nvidia-cublas-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cuda-cupti-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cuda-nvrtc-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cuda-runtime-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cudnn-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cufft-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cufile-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-curand-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cusolver-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cusparse-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-cusparselt-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-nccl-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-nvjitlink-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-nvshmem-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "nvidia-nvtx-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "setuptools", marker = "python_full_version >= '3.12'" }, + { name = "sympy" }, + { name = "triton", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" }, + { name = "typing-extensions" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/15/db/c064112ac0089af3d2f7a2b5bfbabf4aa407a78b74f87889e524b91c5402/torch-2.9.1-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:62b3fd888277946918cba4478cf849303da5359f0fb4e3bfb86b0533ba2eaf8d", size = 104220430, upload-time = "2025-11-12T15:20:31.705Z" }, + { url = "https://files.pythonhosted.org/packages/56/be/76eaa36c9cd032d3b01b001e2c5a05943df75f26211f68fae79e62f87734/torch-2.9.1-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:d033ff0ac3f5400df862a51bdde9bad83561f3739ea0046e68f5401ebfa67c1b", size = 899821446, upload-time = "2025-11-12T15:20:15.544Z" }, + { url = "https://files.pythonhosted.org/packages/47/cc/7a2949e38dfe3244c4df21f0e1c27bce8aedd6c604a587dd44fc21017cb4/torch-2.9.1-cp311-cp311-win_amd64.whl", hash = "sha256:0d06b30a9207b7c3516a9e0102114024755a07045f0c1d2f2a56b1819ac06bcb", size = 110973074, upload-time = "2025-11-12T15:21:39.958Z" }, + { url = "https://files.pythonhosted.org/packages/1e/ce/7d251155a783fb2c1bb6837b2b7023c622a2070a0a72726ca1df47e7ea34/torch-2.9.1-cp311-none-macosx_11_0_arm64.whl", hash = "sha256:52347912d868653e1528b47cafaf79b285b98be3f4f35d5955389b1b95224475", size = 74463887, upload-time = "2025-11-12T15:20:36.611Z" }, + { url = "https://files.pythonhosted.org/packages/0f/27/07c645c7673e73e53ded71705045d6cb5bae94c4b021b03aa8d03eee90ab/torch-2.9.1-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:da5f6f4d7f4940a173e5572791af238cb0b9e21b1aab592bd8b26da4c99f1cd6", size = 104126592, upload-time = "2025-11-12T15:20:41.62Z" }, + { url = "https://files.pythonhosted.org/packages/19/17/e377a460603132b00760511299fceba4102bd95db1a0ee788da21298ccff/torch-2.9.1-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:27331cd902fb4322252657f3902adf1c4f6acad9dcad81d8df3ae14c7c4f07c4", size = 899742281, upload-time = "2025-11-12T15:22:17.602Z" }, + { url = "https://files.pythonhosted.org/packages/b1/1a/64f5769025db846a82567fa5b7d21dba4558a7234ee631712ee4771c436c/torch-2.9.1-cp312-cp312-win_amd64.whl", hash = "sha256:81a285002d7b8cfd3fdf1b98aa8df138d41f1a8334fd9ea37511517cedf43083", size = 110940568, upload-time = "2025-11-12T15:21:18.689Z" }, + { url = "https://files.pythonhosted.org/packages/6e/ab/07739fd776618e5882661d04c43f5b5586323e2f6a2d7d84aac20d8f20bd/torch-2.9.1-cp312-none-macosx_11_0_arm64.whl", hash = "sha256:c0d25d1d8e531b8343bea0ed811d5d528958f1dcbd37e7245bc686273177ad7e", size = 74479191, upload-time = "2025-11-12T15:21:25.816Z" }, +] + +[[package]] +name = "tornado" +version = "6.5.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/37/1d/0a336abf618272d53f62ebe274f712e213f5a03c0b2339575430b8362ef2/tornado-6.5.4.tar.gz", hash = "sha256:a22fa9047405d03260b483980635f0b041989d8bcc9a313f8fe18b411d84b1d7", size = 513632, upload-time = "2025-12-15T19:21:03.836Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ab/a9/e94a9d5224107d7ce3cc1fab8d5dc97f5ea351ccc6322ee4fb661da94e35/tornado-6.5.4-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:d6241c1a16b1c9e4cc28148b1cda97dd1c6cb4fb7068ac1bedc610768dff0ba9", size = 443909, upload-time = "2025-12-15T19:20:48.382Z" }, + { url = "https://files.pythonhosted.org/packages/db/7e/f7b8d8c4453f305a51f80dbb49014257bb7d28ccb4bbb8dd328ea995ecad/tornado-6.5.4-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:2d50f63dda1d2cac3ae1fa23d254e16b5e38153758470e9956cbc3d813d40843", size = 442163, upload-time = "2025-12-15T19:20:49.791Z" }, + { url = "https://files.pythonhosted.org/packages/ba/b5/206f82d51e1bfa940ba366a8d2f83904b15942c45a78dd978b599870ab44/tornado-6.5.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d1cf66105dc6acb5af613c054955b8137e34a03698aa53272dbda4afe252be17", size = 445746, upload-time = "2025-12-15T19:20:51.491Z" }, + { url = "https://files.pythonhosted.org/packages/8e/9d/1a3338e0bd30ada6ad4356c13a0a6c35fbc859063fa7eddb309183364ac1/tornado-6.5.4-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:50ff0a58b0dc97939d29da29cd624da010e7f804746621c78d14b80238669335", size = 445083, upload-time = "2025-12-15T19:20:52.778Z" }, + { url = "https://files.pythonhosted.org/packages/50/d4/e51d52047e7eb9a582da59f32125d17c0482d065afd5d3bc435ff2120dc5/tornado-6.5.4-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5fb5e04efa54cf0baabdd10061eb4148e0be137166146fff835745f59ab9f7f", size = 445315, upload-time = "2025-12-15T19:20:53.996Z" }, + { url = "https://files.pythonhosted.org/packages/27/07/2273972f69ca63dbc139694a3fc4684edec3ea3f9efabf77ed32483b875c/tornado-6.5.4-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:9c86b1643b33a4cd415f8d0fe53045f913bf07b4a3ef646b735a6a86047dda84", size = 446003, upload-time = "2025-12-15T19:20:56.101Z" }, + { url = "https://files.pythonhosted.org/packages/d1/83/41c52e47502bf7260044413b6770d1a48dda2f0246f95ee1384a3cd9c44a/tornado-6.5.4-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:6eb82872335a53dd063a4f10917b3efd28270b56a33db69009606a0312660a6f", size = 445412, upload-time = "2025-12-15T19:20:57.398Z" }, + { url = "https://files.pythonhosted.org/packages/10/c7/bc96917f06cbee182d44735d4ecde9c432e25b84f4c2086143013e7b9e52/tornado-6.5.4-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:6076d5dda368c9328ff41ab5d9dd3608e695e8225d1cd0fd1e006f05da3635a8", size = 445392, upload-time = "2025-12-15T19:20:58.692Z" }, + { url = "https://files.pythonhosted.org/packages/0c/1a/d7592328d037d36f2d2462f4bc1fbb383eec9278bc786c1b111cbbd44cfa/tornado-6.5.4-cp39-abi3-win32.whl", hash = "sha256:1768110f2411d5cd281bac0a090f707223ce77fd110424361092859e089b38d1", size = 446481, upload-time = "2025-12-15T19:21:00.008Z" }, + { url = "https://files.pythonhosted.org/packages/d6/6d/c69be695a0a64fd37a97db12355a035a6d90f79067a3cf936ec2b1dc38cd/tornado-6.5.4-cp39-abi3-win_amd64.whl", hash = "sha256:fa07d31e0cd85c60713f2b995da613588aa03e1303d75705dca6af8babc18ddc", size = 446886, upload-time = "2025-12-15T19:21:01.287Z" }, + { url = "https://files.pythonhosted.org/packages/50/49/8dc3fd90902f70084bd2cd059d576ddb4f8bb44c2c7c0e33a11422acb17e/tornado-6.5.4-cp39-abi3-win_arm64.whl", hash = "sha256:053e6e16701eb6cbe641f308f4c1a9541f91b6261991160391bfc342e8a551a1", size = 445910, upload-time = "2025-12-15T19:21:02.571Z" }, +] + +[[package]] +name = "tqdm" +version = "4.67.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a8/4b/29b4ef32e036bb34e4ab51796dd745cdba7ed47ad142a9f4a1eb8e0c744d/tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2", size = 169737, upload-time = "2024-11-24T20:12:22.481Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d0/30/dc54f88dd4a2b5dc8a0279bdd7270e735851848b762aeb1c1184ed1f6b14/tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2", size = 78540, upload-time = "2024-11-24T20:12:19.698Z" }, +] + +[[package]] +name = "traitlets" +version = "5.14.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/eb/79/72064e6a701c2183016abbbfedaba506d81e30e232a68c9f0d6f6fcd1574/traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7", size = 161621, upload-time = "2024-04-19T11:11:49.746Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/00/c0/8f5d070730d7836adc9c9b6408dec68c6ced86b304a9b26a14df072a6e8c/traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f", size = 85359, upload-time = "2024-04-19T11:11:46.763Z" }, +] + +[[package]] +name = "transformers" +version = "4.57.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "filelock" }, + { name = "huggingface-hub" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "pyyaml" }, + { name = "regex" }, + { name = "requests" }, + { name = "safetensors" }, + { name = "tokenizers" }, + { name = "tqdm" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/dd/70/d42a739e8dfde3d92bb2fff5819cbf331fe9657323221e79415cd5eb65ee/transformers-4.57.3.tar.gz", hash = "sha256:df4945029aaddd7c09eec5cad851f30662f8bd1746721b34cc031d70c65afebc", size = 10139680, upload-time = "2025-11-25T15:51:30.139Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/6b/2f416568b3c4c91c96e5a365d164f8a4a4a88030aa8ab4644181fdadce97/transformers-4.57.3-py3-none-any.whl", hash = "sha256:c77d353a4851b1880191603d36acb313411d3577f6e2897814f333841f7003f4", size = 11993463, upload-time = "2025-11-25T15:51:26.493Z" }, +] + +[[package]] +name = "triton" +version = "3.5.1" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b0/72/ec90c3519eaf168f22cb1757ad412f3a2add4782ad3a92861c9ad135d886/triton-3.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:61413522a48add32302353fdbaaf92daaaab06f6b5e3229940d21b5207f47579", size = 170425802, upload-time = "2025-11-11T17:40:53.209Z" }, + { url = "https://files.pythonhosted.org/packages/f2/50/9a8358d3ef58162c0a415d173cfb45b67de60176e1024f71fbc4d24c0b6d/triton-3.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d2c6b915a03888ab931a9fd3e55ba36785e1fe70cbea0b40c6ef93b20fc85232", size = 170470207, upload-time = "2025-11-11T17:41:00.253Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, +] + +[[package]] +name = "typing-inspect" +version = "0.9.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mypy-extensions" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/dc/74/1789779d91f1961fa9438e9a8710cdae6bd138c80d7303996933d117264a/typing_inspect-0.9.0.tar.gz", hash = "sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78", size = 13825, upload-time = "2023-05-24T20:25:47.612Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/65/f3/107a22063bf27bdccf2024833d3445f4eea42b2e598abfbd46f6a63b6cb0/typing_inspect-0.9.0-py3-none-any.whl", hash = "sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f", size = 8827, upload-time = "2023-05-24T20:25:45.287Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" }, +] + +[[package]] +name = "tzdata" +version = "2025.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5e/a7/c202b344c5ca7daf398f3b8a477eeb205cf3b6f32e7ec3a6bac0629ca975/tzdata-2025.3.tar.gz", hash = "sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7", size = 196772, upload-time = "2025-12-13T17:45:35.667Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/b0/003792df09decd6849a5e39c28b513c06e84436a54440380862b5aeff25d/tzdata-2025.3-py2.py3-none-any.whl", hash = "sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1", size = 348521, upload-time = "2025-12-13T17:45:33.889Z" }, +] + +[[package]] +name = "unstructured" +version = "0.13.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "backoff" }, + { name = "beautifulsoup4" }, + { name = "chardet" }, + { name = "dataclasses-json" }, + { name = "emoji" }, + { name = "filetype" }, + { name = "langdetect" }, + { name = "lxml" }, + { name = "nltk" }, + { name = "numpy" }, + { name = "python-iso639" }, + { name = "python-magic" }, + { name = "rapidfuzz" }, + { name = "requests" }, + { name = "tabulate" }, + { name = "typing-extensions" }, + { name = "unstructured-client" }, + { name = "wrapt" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a1/e7/f3ff63814226e349a434dec7ede51f0e5af14eed325b3fd1c48be6fb8ff1/unstructured-0.13.7.tar.gz", hash = "sha256:5d59161d353b7006d8c6ee6f1a39154a5a11a5aaa258aac3fe90a8d44016aa6c", size = 1714285, upload-time = "2024-05-08T18:36:49.562Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f5/48/9bdd8aff34c507750a347545bcf26c025b1335c021ac0b9af5a542a8acd5/unstructured-0.13.7-py3-none-any.whl", hash = "sha256:a3d8f3037cb3063661531c6ecc04aca6df93c293ba06e36d67ffc70857a6f208", size = 1915733, upload-time = "2024-05-08T18:36:45.4Z" }, +] + +[[package]] +name = "unstructured-client" +version = "0.42.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "aiofiles" }, + { name = "cryptography" }, + { name = "httpcore" }, + { name = "httpx" }, + { name = "pydantic" }, + { name = "pypdf" }, + { name = "requests-toolbelt" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ff/fe/c6d334d4fb9a4a006125a1a8a3918be643c268290707d48e9cd060b71f7f/unstructured_client-0.42.6.tar.gz", hash = "sha256:ea54f2c4ca3e7a1330f9e77cbc96f88f829518beeec5e1b797b5352f4d76a73a", size = 94179, upload-time = "2025-12-17T03:49:58.38Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5e/12/5aa5d051b32d0c09077a8e83920e794b9bf2315739add4ab821e71fbca58/unstructured_client-0.42.6-py3-none-any.whl", hash = "sha256:c93b1d9d1b9f63a8e961729d00224b3659ef9ef3e14996ea4e53ddc95df671a9", size = 219563, upload-time = "2025-12-17T03:49:56.993Z" }, +] + +[[package]] +name = "urllib3" +version = "2.6.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1e/24/a2a2ed9addd907787d7aa0355ba36a6cadf1768b934c652ea78acbd59dcd/urllib3-2.6.2.tar.gz", hash = "sha256:016f9c98bb7e98085cb2b4b17b87d2c702975664e4f060c6532e64d1c1a5e797", size = 432930, upload-time = "2025-12-11T15:56:40.252Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/b9/4095b668ea3678bf6a0af005527f39de12fb026516fb3df17495a733b7f8/urllib3-2.6.2-py3-none-any.whl", hash = "sha256:ec21cddfe7724fc7cb4ba4bea7aa8e2ef36f607a4bab81aa6ce42a13dc3f03dd", size = 131182, upload-time = "2025-12-11T15:56:38.584Z" }, +] + +[[package]] +name = "uvicorn" +version = "0.38.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cb/ce/f06b84e2697fef4688ca63bdb2fdf113ca0a3be33f94488f2cadb690b0cf/uvicorn-0.38.0.tar.gz", hash = "sha256:fd97093bdd120a2609fc0d3afe931d4d4ad688b6e75f0f929fde1bc36fe0e91d", size = 80605, upload-time = "2025-10-18T13:46:44.63Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl", hash = "sha256:48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02", size = 68109, upload-time = "2025-10-18T13:46:42.958Z" }, +] + +[[package]] +name = "virtualenv" +version = "20.35.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "distlib" }, + { name = "filelock" }, + { name = "platformdirs" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/20/28/e6f1a6f655d620846bd9df527390ecc26b3805a0c5989048c210e22c5ca9/virtualenv-20.35.4.tar.gz", hash = "sha256:643d3914d73d3eeb0c552cbb12d7e82adf0e504dbf86a3182f8771a153a1971c", size = 6028799, upload-time = "2025-10-29T06:57:40.511Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/0c/c05523fa3181fdf0c9c52a6ba91a23fbf3246cc095f26f6516f9c60e6771/virtualenv-20.35.4-py3-none-any.whl", hash = "sha256:c21c9cede36c9753eeade68ba7d523529f228a403463376cf821eaae2b650f1b", size = 6005095, upload-time = "2025-10-29T06:57:37.598Z" }, +] + +[[package]] +name = "wcwidth" +version = "0.2.14" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/24/30/6b0809f4510673dc723187aeaf24c7f5459922d01e2f794277a3dfb90345/wcwidth-0.2.14.tar.gz", hash = "sha256:4d478375d31bc5395a3c55c40ccdf3354688364cd61c4f6adacaa9215d0b3605", size = 102293, upload-time = "2025-09-22T16:29:53.023Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/b5/123f13c975e9f27ab9c0770f514345bd406d0e8d3b7a0723af9d43f710af/wcwidth-0.2.14-py2.py3-none-any.whl", hash = "sha256:a7bb560c8aee30f9957e5f9895805edd20602f2d7f720186dfd906e82b4982e1", size = 37286, upload-time = "2025-09-22T16:29:51.641Z" }, +] + +[[package]] +name = "webencodings" +version = "0.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz", hash = "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923", size = 9721, upload-time = "2017-04-05T20:21:34.189Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", size = 11774, upload-time = "2017-04-05T20:21:32.581Z" }, +] + +[[package]] +name = "websockets" +version = "15.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/e6/26d09fab466b7ca9c7737474c52be4f76a40301b08362eb2dbc19dcc16c1/websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee", size = 177016, upload-time = "2025-03-05T20:03:41.606Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9f/32/18fcd5919c293a398db67443acd33fde142f283853076049824fc58e6f75/websockets-15.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:823c248b690b2fd9303ba00c4f66cd5e2d8c3ba4aa968b2779be9532a4dad431", size = 175423, upload-time = "2025-03-05T20:01:56.276Z" }, + { url = "https://files.pythonhosted.org/packages/76/70/ba1ad96b07869275ef42e2ce21f07a5b0148936688c2baf7e4a1f60d5058/websockets-15.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678999709e68425ae2593acf2e3ebcbcf2e69885a5ee78f9eb80e6e371f1bf57", size = 173082, upload-time = "2025-03-05T20:01:57.563Z" }, + { url = "https://files.pythonhosted.org/packages/86/f2/10b55821dd40eb696ce4704a87d57774696f9451108cff0d2824c97e0f97/websockets-15.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d50fd1ee42388dcfb2b3676132c78116490976f1300da28eb629272d5d93e905", size = 173330, upload-time = "2025-03-05T20:01:59.063Z" }, + { url = "https://files.pythonhosted.org/packages/a5/90/1c37ae8b8a113d3daf1065222b6af61cc44102da95388ac0018fcb7d93d9/websockets-15.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d99e5546bf73dbad5bf3547174cd6cb8ba7273062a23808ffea025ecb1cf8562", size = 182878, upload-time = "2025-03-05T20:02:00.305Z" }, + { url = "https://files.pythonhosted.org/packages/8e/8d/96e8e288b2a41dffafb78e8904ea7367ee4f891dafc2ab8d87e2124cb3d3/websockets-15.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:66dd88c918e3287efc22409d426c8f729688d89a0c587c88971a0faa2c2f3792", size = 181883, upload-time = "2025-03-05T20:02:03.148Z" }, + { url = "https://files.pythonhosted.org/packages/93/1f/5d6dbf551766308f6f50f8baf8e9860be6182911e8106da7a7f73785f4c4/websockets-15.0.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8dd8327c795b3e3f219760fa603dcae1dcc148172290a8ab15158cf85a953413", size = 182252, upload-time = "2025-03-05T20:02:05.29Z" }, + { url = "https://files.pythonhosted.org/packages/d4/78/2d4fed9123e6620cbf1706c0de8a1632e1a28e7774d94346d7de1bba2ca3/websockets-15.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8fdc51055e6ff4adeb88d58a11042ec9a5eae317a0a53d12c062c8a8865909e8", size = 182521, upload-time = "2025-03-05T20:02:07.458Z" }, + { url = "https://files.pythonhosted.org/packages/e7/3b/66d4c1b444dd1a9823c4a81f50231b921bab54eee2f69e70319b4e21f1ca/websockets-15.0.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:693f0192126df6c2327cce3baa7c06f2a117575e32ab2308f7f8216c29d9e2e3", size = 181958, upload-time = "2025-03-05T20:02:09.842Z" }, + { url = "https://files.pythonhosted.org/packages/08/ff/e9eed2ee5fed6f76fdd6032ca5cd38c57ca9661430bb3d5fb2872dc8703c/websockets-15.0.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:54479983bd5fb469c38f2f5c7e3a24f9a4e70594cd68cd1fa6b9340dadaff7cf", size = 181918, upload-time = "2025-03-05T20:02:11.968Z" }, + { url = "https://files.pythonhosted.org/packages/d8/75/994634a49b7e12532be6a42103597b71098fd25900f7437d6055ed39930a/websockets-15.0.1-cp311-cp311-win32.whl", hash = "sha256:16b6c1b3e57799b9d38427dda63edcbe4926352c47cf88588c0be4ace18dac85", size = 176388, upload-time = "2025-03-05T20:02:13.32Z" }, + { url = "https://files.pythonhosted.org/packages/98/93/e36c73f78400a65f5e236cd376713c34182e6663f6889cd45a4a04d8f203/websockets-15.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:27ccee0071a0e75d22cb35849b1db43f2ecd3e161041ac1ee9d2352ddf72f065", size = 176828, upload-time = "2025-03-05T20:02:14.585Z" }, + { url = "https://files.pythonhosted.org/packages/51/6b/4545a0d843594f5d0771e86463606a3988b5a09ca5123136f8a76580dd63/websockets-15.0.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3e90baa811a5d73f3ca0bcbf32064d663ed81318ab225ee4f427ad4e26e5aff3", size = 175437, upload-time = "2025-03-05T20:02:16.706Z" }, + { url = "https://files.pythonhosted.org/packages/f4/71/809a0f5f6a06522af902e0f2ea2757f71ead94610010cf570ab5c98e99ed/websockets-15.0.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:592f1a9fe869c778694f0aa806ba0374e97648ab57936f092fd9d87f8bc03665", size = 173096, upload-time = "2025-03-05T20:02:18.832Z" }, + { url = "https://files.pythonhosted.org/packages/3d/69/1a681dd6f02180916f116894181eab8b2e25b31e484c5d0eae637ec01f7c/websockets-15.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0701bc3cfcb9164d04a14b149fd74be7347a530ad3bbf15ab2c678a2cd3dd9a2", size = 173332, upload-time = "2025-03-05T20:02:20.187Z" }, + { url = "https://files.pythonhosted.org/packages/a6/02/0073b3952f5bce97eafbb35757f8d0d54812b6174ed8dd952aa08429bcc3/websockets-15.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8b56bdcdb4505c8078cb6c7157d9811a85790f2f2b3632c7d1462ab5783d215", size = 183152, upload-time = "2025-03-05T20:02:22.286Z" }, + { url = "https://files.pythonhosted.org/packages/74/45/c205c8480eafd114b428284840da0b1be9ffd0e4f87338dc95dc6ff961a1/websockets-15.0.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0af68c55afbd5f07986df82831c7bff04846928ea8d1fd7f30052638788bc9b5", size = 182096, upload-time = "2025-03-05T20:02:24.368Z" }, + { url = "https://files.pythonhosted.org/packages/14/8f/aa61f528fba38578ec553c145857a181384c72b98156f858ca5c8e82d9d3/websockets-15.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64dee438fed052b52e4f98f76c5790513235efaa1ef7f3f2192c392cd7c91b65", size = 182523, upload-time = "2025-03-05T20:02:25.669Z" }, + { url = "https://files.pythonhosted.org/packages/ec/6d/0267396610add5bc0d0d3e77f546d4cd287200804fe02323797de77dbce9/websockets-15.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d5f6b181bb38171a8ad1d6aa58a67a6aa9d4b38d0f8c5f496b9e42561dfc62fe", size = 182790, upload-time = "2025-03-05T20:02:26.99Z" }, + { url = "https://files.pythonhosted.org/packages/02/05/c68c5adbf679cf610ae2f74a9b871ae84564462955d991178f95a1ddb7dd/websockets-15.0.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:5d54b09eba2bada6011aea5375542a157637b91029687eb4fdb2dab11059c1b4", size = 182165, upload-time = "2025-03-05T20:02:30.291Z" }, + { url = "https://files.pythonhosted.org/packages/29/93/bb672df7b2f5faac89761cb5fa34f5cec45a4026c383a4b5761c6cea5c16/websockets-15.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3be571a8b5afed347da347bfcf27ba12b069d9d7f42cb8c7028b5e98bbb12597", size = 182160, upload-time = "2025-03-05T20:02:31.634Z" }, + { url = "https://files.pythonhosted.org/packages/ff/83/de1f7709376dc3ca9b7eeb4b9a07b4526b14876b6d372a4dc62312bebee0/websockets-15.0.1-cp312-cp312-win32.whl", hash = "sha256:c338ffa0520bdb12fbc527265235639fb76e7bc7faafbb93f6ba80d9c06578a9", size = 176395, upload-time = "2025-03-05T20:02:33.017Z" }, + { url = "https://files.pythonhosted.org/packages/7d/71/abf2ebc3bbfa40f391ce1428c7168fb20582d0ff57019b69ea20fa698043/websockets-15.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:fcd5cf9e305d7b8338754470cf69cf81f420459dbae8a3b40cee57417f4614a7", size = 176841, upload-time = "2025-03-05T20:02:34.498Z" }, + { url = "https://files.pythonhosted.org/packages/fa/a8/5b41e0da817d64113292ab1f8247140aac61cbf6cfd085d6a0fa77f4984f/websockets-15.0.1-py3-none-any.whl", hash = "sha256:f7a866fbc1e97b5c617ee4116daaa09b722101d4a3c170c787450ba409f9736f", size = 169743, upload-time = "2025-03-05T20:03:39.41Z" }, +] + +[[package]] +name = "werkzeug" +version = "3.1.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/45/ea/b0f8eeb287f8df9066e56e831c7824ac6bab645dd6c7a8f4b2d767944f9b/werkzeug-3.1.4.tar.gz", hash = "sha256:cd3cd98b1b92dc3b7b3995038826c68097dcb16f9baa63abe35f20eafeb9fe5e", size = 864687, upload-time = "2025-11-29T02:15:22.841Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/f9/9e082990c2585c744734f85bec79b5dae5df9c974ffee58fe421652c8e91/werkzeug-3.1.4-py3-none-any.whl", hash = "sha256:2ad50fb9ed09cc3af22c54698351027ace879a0b60a3b5edf5730b2f7d876905", size = 224960, upload-time = "2025-11-29T02:15:21.13Z" }, +] + +[[package]] +name = "wrapt" +version = "2.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/49/2a/6de8a50cb435b7f42c46126cf1a54b2aab81784e74c8595c8e025e8f36d3/wrapt-2.0.1.tar.gz", hash = "sha256:9c9c635e78497cacb81e84f8b11b23e0aacac7a136e73b8e5b2109a1d9fc468f", size = 82040, upload-time = "2025-11-07T00:45:33.312Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/98/60/553997acf3939079dab022e37b67b1904b5b0cc235503226898ba573b10c/wrapt-2.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:0e17283f533a0d24d6e5429a7d11f250a58d28b4ae5186f8f47853e3e70d2590", size = 77480, upload-time = "2025-11-07T00:43:30.573Z" }, + { url = "https://files.pythonhosted.org/packages/2d/50/e5b3d30895d77c52105c6d5cbf94d5b38e2a3dd4a53d22d246670da98f7c/wrapt-2.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:85df8d92158cb8f3965aecc27cf821461bb5f40b450b03facc5d9f0d4d6ddec6", size = 60690, upload-time = "2025-11-07T00:43:31.594Z" }, + { url = "https://files.pythonhosted.org/packages/f0/40/660b2898703e5cbbb43db10cdefcc294274458c3ca4c68637c2b99371507/wrapt-2.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c1be685ac7700c966b8610ccc63c3187a72e33cab53526a27b2a285a662cd4f7", size = 61578, upload-time = "2025-11-07T00:43:32.918Z" }, + { url = "https://files.pythonhosted.org/packages/5b/36/825b44c8a10556957bc0c1d84c7b29a40e05fcf1873b6c40aa9dbe0bd972/wrapt-2.0.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:df0b6d3b95932809c5b3fecc18fda0f1e07452d05e2662a0b35548985f256e28", size = 114115, upload-time = "2025-11-07T00:43:35.605Z" }, + { url = "https://files.pythonhosted.org/packages/83/73/0a5d14bb1599677304d3c613a55457d34c344e9b60eda8a737c2ead7619e/wrapt-2.0.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4da7384b0e5d4cae05c97cd6f94faaf78cc8b0f791fc63af43436d98c4ab37bb", size = 116157, upload-time = "2025-11-07T00:43:37.058Z" }, + { url = "https://files.pythonhosted.org/packages/01/22/1c158fe763dbf0a119f985d945711d288994fe5514c0646ebe0eb18b016d/wrapt-2.0.1-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ec65a78fbd9d6f083a15d7613b2800d5663dbb6bb96003899c834beaa68b242c", size = 112535, upload-time = "2025-11-07T00:43:34.138Z" }, + { url = "https://files.pythonhosted.org/packages/5c/28/4f16861af67d6de4eae9927799b559c20ebdd4fe432e89ea7fe6fcd9d709/wrapt-2.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7de3cc939be0e1174969f943f3b44e0d79b6f9a82198133a5b7fc6cc92882f16", size = 115404, upload-time = "2025-11-07T00:43:39.214Z" }, + { url = "https://files.pythonhosted.org/packages/a0/8b/7960122e625fad908f189b59c4aae2d50916eb4098b0fb2819c5a177414f/wrapt-2.0.1-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:fb1a5b72cbd751813adc02ef01ada0b0d05d3dcbc32976ce189a1279d80ad4a2", size = 111802, upload-time = "2025-11-07T00:43:40.476Z" }, + { url = "https://files.pythonhosted.org/packages/3e/73/7881eee5ac31132a713ab19a22c9e5f1f7365c8b1df50abba5d45b781312/wrapt-2.0.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:3fa272ca34332581e00bf7773e993d4f632594eb2d1b0b162a9038df0fd971dd", size = 113837, upload-time = "2025-11-07T00:43:42.921Z" }, + { url = "https://files.pythonhosted.org/packages/45/00/9499a3d14e636d1f7089339f96c4409bbc7544d0889f12264efa25502ae8/wrapt-2.0.1-cp311-cp311-win32.whl", hash = "sha256:fc007fdf480c77301ab1afdbb6ab22a5deee8885f3b1ed7afcb7e5e84a0e27be", size = 58028, upload-time = "2025-11-07T00:43:47.369Z" }, + { url = "https://files.pythonhosted.org/packages/70/5d/8f3d7eea52f22638748f74b102e38fdf88cb57d08ddeb7827c476a20b01b/wrapt-2.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:47434236c396d04875180171ee1f3815ca1eada05e24a1ee99546320d54d1d1b", size = 60385, upload-time = "2025-11-07T00:43:44.34Z" }, + { url = "https://files.pythonhosted.org/packages/14/e2/32195e57a8209003587bbbad44d5922f13e0ced2a493bb46ca882c5b123d/wrapt-2.0.1-cp311-cp311-win_arm64.whl", hash = "sha256:837e31620e06b16030b1d126ed78e9383815cbac914693f54926d816d35d8edf", size = 58893, upload-time = "2025-11-07T00:43:46.161Z" }, + { url = "https://files.pythonhosted.org/packages/cb/73/8cb252858dc8254baa0ce58ce382858e3a1cf616acebc497cb13374c95c6/wrapt-2.0.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:1fdbb34da15450f2b1d735a0e969c24bdb8d8924892380126e2a293d9902078c", size = 78129, upload-time = "2025-11-07T00:43:48.852Z" }, + { url = "https://files.pythonhosted.org/packages/19/42/44a0db2108526ee6e17a5ab72478061158f34b08b793df251d9fbb9a7eb4/wrapt-2.0.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3d32794fe940b7000f0519904e247f902f0149edbe6316c710a8562fb6738841", size = 61205, upload-time = "2025-11-07T00:43:50.402Z" }, + { url = "https://files.pythonhosted.org/packages/4d/8a/5b4b1e44b791c22046e90d9b175f9a7581a8cc7a0debbb930f81e6ae8e25/wrapt-2.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:386fb54d9cd903ee0012c09291336469eb7b244f7183d40dc3e86a16a4bace62", size = 61692, upload-time = "2025-11-07T00:43:51.678Z" }, + { url = "https://files.pythonhosted.org/packages/11/53/3e794346c39f462bcf1f58ac0487ff9bdad02f9b6d5ee2dc84c72e0243b2/wrapt-2.0.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:7b219cb2182f230676308cdcacd428fa837987b89e4b7c5c9025088b8a6c9faf", size = 121492, upload-time = "2025-11-07T00:43:55.017Z" }, + { url = "https://files.pythonhosted.org/packages/c6/7e/10b7b0e8841e684c8ca76b462a9091c45d62e8f2de9c4b1390b690eadf16/wrapt-2.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:641e94e789b5f6b4822bb8d8ebbdfc10f4e4eae7756d648b717d980f657a9eb9", size = 123064, upload-time = "2025-11-07T00:43:56.323Z" }, + { url = "https://files.pythonhosted.org/packages/0e/d1/3c1e4321fc2f5ee7fd866b2d822aa89b84495f28676fd976c47327c5b6aa/wrapt-2.0.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fe21b118b9f58859b5ebaa4b130dee18669df4bd111daad082b7beb8799ad16b", size = 117403, upload-time = "2025-11-07T00:43:53.258Z" }, + { url = "https://files.pythonhosted.org/packages/a4/b0/d2f0a413cf201c8c2466de08414a15420a25aa83f53e647b7255cc2fab5d/wrapt-2.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:17fb85fa4abc26a5184d93b3efd2dcc14deb4b09edcdb3535a536ad34f0b4dba", size = 121500, upload-time = "2025-11-07T00:43:57.468Z" }, + { url = "https://files.pythonhosted.org/packages/bd/45/bddb11d28ca39970a41ed48a26d210505120f925918592283369219f83cc/wrapt-2.0.1-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:b89ef9223d665ab255ae42cc282d27d69704d94be0deffc8b9d919179a609684", size = 116299, upload-time = "2025-11-07T00:43:58.877Z" }, + { url = "https://files.pythonhosted.org/packages/81/af/34ba6dd570ef7a534e7eec0c25e2615c355602c52aba59413411c025a0cb/wrapt-2.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:a453257f19c31b31ba593c30d997d6e5be39e3b5ad9148c2af5a7314061c63eb", size = 120622, upload-time = "2025-11-07T00:43:59.962Z" }, + { url = "https://files.pythonhosted.org/packages/e2/3e/693a13b4146646fb03254636f8bafd20c621955d27d65b15de07ab886187/wrapt-2.0.1-cp312-cp312-win32.whl", hash = "sha256:3e271346f01e9c8b1130a6a3b0e11908049fe5be2d365a5f402778049147e7e9", size = 58246, upload-time = "2025-11-07T00:44:03.169Z" }, + { url = "https://files.pythonhosted.org/packages/a7/36/715ec5076f925a6be95f37917b66ebbeaa1372d1862c2ccd7a751574b068/wrapt-2.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:2da620b31a90cdefa9cd0c2b661882329e2e19d1d7b9b920189956b76c564d75", size = 60492, upload-time = "2025-11-07T00:44:01.027Z" }, + { url = "https://files.pythonhosted.org/packages/ef/3e/62451cd7d80f65cc125f2b426b25fbb6c514bf6f7011a0c3904fc8c8df90/wrapt-2.0.1-cp312-cp312-win_arm64.whl", hash = "sha256:aea9c7224c302bc8bfc892b908537f56c430802560e827b75ecbde81b604598b", size = 58987, upload-time = "2025-11-07T00:44:02.095Z" }, + { url = "https://files.pythonhosted.org/packages/15/d1/b51471c11592ff9c012bd3e2f7334a6ff2f42a7aed2caffcf0bdddc9cb89/wrapt-2.0.1-py3-none-any.whl", hash = "sha256:4d2ce1bf1a48c5277d7969259232b57645aae5686dba1eaeade39442277afbca", size = 44046, upload-time = "2025-11-07T00:45:32.116Z" }, +] + +[[package]] +name = "yarg" +version = "0.1.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d4/c8/cc640404a0981e6c14e2044fc64e43b4c1ddf69e7dddc8f2a02638ba5ae8/yarg-0.1.9.tar.gz", hash = "sha256:55695bf4d1e3e7f756496c36a69ba32c40d18f821e38f61d028f6049e5e15911", size = 11988, upload-time = "2014-08-11T22:01:37.243Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8b/90/89a2ff242ccab6a24fbab18dbbabc67c51a6f0ed01f9a0f41689dc177419/yarg-0.1.9-py2.py3-none-any.whl", hash = "sha256:4f9cebdc00fac946c9bf2783d634e538a71c7d280a4d806d45fd4dc0ef441492", size = 19162, upload-time = "2014-08-11T22:01:41.104Z" }, +] + +[[package]] +name = "zep-cloud" +version = "3.13.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "httpx" }, + { name = "pydantic" }, + { name = "pydantic-core" }, + { name = "python-dateutil" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/32/c7/c835debf13302f8aaf8d0561ac6ff5a9bc15cc140cd692a1330fb1900c55/zep_cloud-3.13.0.tar.gz", hash = "sha256:c55d9c511773bb2177ae8e08546141404f87d2099affafabd7ec4b4505763e48", size = 63116, upload-time = "2025-11-20T15:25:40.745Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f7/e1/bbf03c6c8007c0cb238780e7fc6d8e1a52633893933a41aa09678618985a/zep_cloud-3.13.0-py3-none-any.whl", hash = "sha256:b2fbdeef73e262194c8f67b58f76471de6ee87e1a629541a09d8f7bbf475f12b", size = 110601, upload-time = "2025-11-20T15:25:38.484Z" }, +] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..637f1dfa --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +services: + mirofish: + image: ghcr.io/666ghj/mirofish:latest + # 加速镜像(如拉取缓慢可替换上方地址) + # image: ghcr.nju.edu.cn/666ghj/mirofish:latest + container_name: mirofish + env_file: + - .env + ports: + - "3000:3000" + - "5001:5001" + restart: unless-stopped + volumes: + - ./backend/uploads:/app/backend/uploads \ No newline at end of file diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 00000000..0b80095c --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + MiroFish - 预测万物 + + +
+ + + diff --git a/frontend/package-lock.json b/frontend/package-lock.json new file mode 100644 index 00000000..3e56d752 --- /dev/null +++ b/frontend/package-lock.json @@ -0,0 +1,2185 @@ +{ + "name": "frontend", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "frontend", + "version": "0.1.0", + "dependencies": { + "axios": "^1.14.0", + "d3": "^7.9.0", + "vue": "^3.5.24", + "vue-i18n": "^11.3.0", + "vue-router": "^4.6.3" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^6.0.1", + "vite": "^7.2.4" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", + "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.5" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.5.tgz", + "integrity": "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@intlify/core-base": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-11.3.0.tgz", + "integrity": "sha512-NNX5jIwF4TJBe7RtSKDMOA6JD9mp2mRcBHAwt2X+Q8PvnZub0yj5YYXlFu2AcESdgQpEv/5Yx2uOCV/yh7YkZg==", + "license": "MIT", + "dependencies": { + "@intlify/devtools-types": "11.3.0", + "@intlify/message-compiler": "11.3.0", + "@intlify/shared": "11.3.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/devtools-types": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@intlify/devtools-types/-/devtools-types-11.3.0.tgz", + "integrity": "sha512-G9CNL4WpANWVdUjubOIIS7/D2j/0j+1KJmhBJxHilWNKr9mmt3IjFV3Hq4JoBP23uOoC5ynxz/FHZ42M+YxfGw==", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "11.3.0", + "@intlify/shared": "11.3.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-11.3.0.tgz", + "integrity": "sha512-RAJp3TMsqohg/Wa7bVF3cChRhecSYBLrTCQSj7j0UtWVFLP+6iEJoE2zb7GU5fp+fmG5kCbUdzhmlAUCWXiUJw==", + "license": "MIT", + "dependencies": { + "@intlify/shared": "11.3.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/shared": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-11.3.0.tgz", + "integrity": "sha512-LC6P/uay7rXL5zZ5+5iRJfLs/iUN8apu9tm8YqQVmW3Uq3X4A0dOFUIDuAmB7gAC29wTHOS3EiN/IosNSz0eNQ==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "license": "MIT" + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.50", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.50.tgz", + "integrity": "sha512-5e76wQiQVeL1ICOZVUg4LSOVYg9jyhGCin+icYozhsUzM+fHE7kddi1bdiE0jwVqTfkjba3jUFbEkoC9WkdvyA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.1.tgz", + "integrity": "sha512-d6FinEBLdIiK+1uACUttJKfgZREXrF0Qc2SmLII7W2AD8FfiZ9Wjd+rD/iRuf5s5dWrr1GgwXCvPqOuDquOowA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.60.1.tgz", + "integrity": "sha512-YjG/EwIDvvYI1YvYbHvDz/BYHtkY4ygUIXHnTdLhG+hKIQFBiosfWiACWortsKPKU/+dUwQQCKQM3qrDe8c9BA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.60.1.tgz", + "integrity": "sha512-mjCpF7GmkRtSJwon+Rq1N8+pI+8l7w5g9Z3vWj4T7abguC4Czwi3Yu/pFaLvA3TTeMVjnu3ctigusqWUfjZzvw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.60.1.tgz", + "integrity": "sha512-haZ7hJ1JT4e9hqkoT9R/19XW2QKqjfJVv+i5AGg57S+nLk9lQnJ1F/eZloRO3o9Scy9CM3wQ9l+dkXtcBgN5Ew==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.60.1.tgz", + "integrity": "sha512-czw90wpQq3ZsAVBlinZjAYTKduOjTywlG7fEeWKUA7oCmpA8xdTkxZZlwNJKWqILlq0wehoZcJYfBvOyhPTQ6w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.60.1.tgz", + "integrity": "sha512-KVB2rqsxTHuBtfOeySEyzEOB7ltlB/ux38iu2rBQzkjbwRVlkhAGIEDiiYnO2kFOkJp+Z7pUXKyrRRFuFUKt+g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.60.1.tgz", + "integrity": "sha512-L+34Qqil+v5uC0zEubW7uByo78WOCIrBvci69E7sFASRl0X7b/MB6Cqd1lky/CtcSVTydWa2WZwFuWexjS5o6g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.60.1.tgz", + "integrity": "sha512-n83O8rt4v34hgFzlkb1ycniJh7IR5RCIqt6mz1VRJD6pmhRi0CXdmfnLu9dIUS6buzh60IvACM842Ffb3xd6Gg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.60.1.tgz", + "integrity": "sha512-Nql7sTeAzhTAja3QXeAI48+/+GjBJ+QmAH13snn0AJSNL50JsDqotyudHyMbO2RbJkskbMbFJfIJKWA6R1LCJQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.60.1.tgz", + "integrity": "sha512-+pUymDhd0ys9GcKZPPWlFiZ67sTWV5UU6zOJat02M1+PiuSGDziyRuI/pPue3hoUwm2uGfxdL+trT6Z9rxnlMA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.60.1.tgz", + "integrity": "sha512-VSvgvQeIcsEvY4bKDHEDWcpW4Yw7BtlKG1GUT4FzBUlEKQK0rWHYBqQt6Fm2taXS+1bXvJT6kICu5ZwqKCnvlQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.60.1.tgz", + "integrity": "sha512-4LqhUomJqwe641gsPp6xLfhqWMbQV04KtPp7/dIp0nzPxAkNY1AbwL5W0MQpcalLYk07vaW9Kp1PBhdpZYYcEw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.60.1.tgz", + "integrity": "sha512-tLQQ9aPvkBxOc/EUT6j3pyeMD6Hb8QF2BTBnCQWP/uu1lhc9AIrIjKnLYMEroIz/JvtGYgI9dF3AxHZNaEH0rw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.60.1.tgz", + "integrity": "sha512-RMxFhJwc9fSXP6PqmAz4cbv3kAyvD1etJFjTx4ONqFP9DkTkXsAMU4v3Vyc5BgzC+anz7nS/9tp4obsKfqkDHg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.60.1.tgz", + "integrity": "sha512-QKgFl+Yc1eEk6MmOBfRHYF6lTxiiiV3/z/BRrbSiW2I7AFTXoBFvdMEyglohPj//2mZS4hDOqeB0H1ACh3sBbg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.60.1.tgz", + "integrity": "sha512-RAjXjP/8c6ZtzatZcA1RaQr6O1TRhzC+adn8YZDnChliZHviqIjmvFwHcxi4JKPSDAt6Uhf/7vqcBzQJy0PDJg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.60.1.tgz", + "integrity": "sha512-wcuocpaOlaL1COBYiA89O6yfjlp3RwKDeTIA0hM7OpmhR1Bjo9j31G1uQVpDlTvwxGn2nQs65fBFL5UFd76FcQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.60.1.tgz", + "integrity": "sha512-77PpsFQUCOiZR9+LQEFg9GClyfkNXj1MP6wRnzYs0EeWbPcHs02AXu4xuUbM1zhwn3wqaizle3AEYg5aeoohhg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.60.1.tgz", + "integrity": "sha512-5cIATbk5vynAjqqmyBjlciMJl1+R/CwX9oLk/EyiFXDWd95KpHdrOJT//rnUl4cUcskrd0jCCw3wpZnhIHdD9w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.60.1.tgz", + "integrity": "sha512-cl0w09WsCi17mcmWqqglez9Gk8isgeWvoUZ3WiJFYSR3zjBQc2J5/ihSjpl+VLjPqjQ/1hJRcqBfLjssREQILw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.60.1.tgz", + "integrity": "sha512-4Cv23ZrONRbNtbZa37mLSueXUCtN7MXccChtKpUnQNgF010rjrjfHx3QxkS2PI7LqGT5xXyYs1a7LbzAwT0iCA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.60.1.tgz", + "integrity": "sha512-i1okWYkA4FJICtr7KpYzFpRTHgy5jdDbZiWfvny21iIKky5YExiDXP+zbXzm3dUcFpkEeYNHgQ5fuG236JPq0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.60.1.tgz", + "integrity": "sha512-u09m3CuwLzShA0EYKMNiFgcjjzwqtUMLmuCJLeZWjjOYA3IT2Di09KaxGBTP9xVztWyIWjVdsB2E9goMjZvTQg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.60.1.tgz", + "integrity": "sha512-k+600V9Zl1CM7eZxJgMyTUzmrmhB/0XZnF4pRypKAlAgxmedUA+1v9R+XOFv56W4SlHEzfeMtzujLJD22Uz5zg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.1.tgz", + "integrity": "sha512-lWMnixq/QzxyhTV6NjQJ4SFo1J6PvOX8vUx5Wb4bBPsEb+8xZ89Bz6kOXpfXj9ak9AHTQVQzlgzBEc1SyM27xQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vitejs/plugin-vue": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-6.0.2.tgz", + "integrity": "sha512-iHmwV3QcVGGvSC1BG5bZ4z6iwa1SOpAPWmnjOErd4Ske+lZua5K9TtAVdx0gMBClJ28DViCbSmZitjWZsWO3LA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "1.0.0-beta.50" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.25.tgz", + "integrity": "sha512-vay5/oQJdsNHmliWoZfHPoVZZRmnSWhug0BYT34njkYTPqClh3DNWLkZNJBVSjsNMrg0CCrBfoKkjZQPM/QVUw==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "@vue/shared": "3.5.25", + "entities": "^4.5.0", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.25.tgz", + "integrity": "sha512-4We0OAcMZsKgYoGlMjzYvaoErltdFI2/25wqanuTu+S4gismOTRTBPi4IASOjxWdzIwrYSjnqONfKvuqkXzE2Q==", + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.25", + "@vue/shared": "3.5.25" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.25.tgz", + "integrity": "sha512-PUgKp2rn8fFsI++lF2sO7gwO2d9Yj57Utr5yEsDf3GNaQcowCLKL7sf+LvVFvtJDXUp/03+dC6f2+LCv5aK1ag==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "@vue/compiler-core": "3.5.25", + "@vue/compiler-dom": "3.5.25", + "@vue/compiler-ssr": "3.5.25", + "@vue/shared": "3.5.25", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.6", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.25.tgz", + "integrity": "sha512-ritPSKLBcParnsKYi+GNtbdbrIE1mtuFEJ4U1sWeuOMlIziK5GtOL85t5RhsNy4uWIXPgk+OUdpnXiTdzn8o3A==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.25", + "@vue/shared": "3.5.25" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, + "node_modules/@vue/reactivity": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.25.tgz", + "integrity": "sha512-5xfAypCQepv4Jog1U4zn8cZIcbKKFka3AgWHEFQeK65OW+Ys4XybP6z2kKgws4YB43KGpqp5D/K3go2UPPunLA==", + "license": "MIT", + "dependencies": { + "@vue/shared": "3.5.25" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.25.tgz", + "integrity": "sha512-Z751v203YWwYzy460bzsYQISDfPjHTl+6Zzwo/a3CsAf+0ccEjQ8c+0CdX1WsumRTHeywvyUFtW6KvNukT/smA==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.25", + "@vue/shared": "3.5.25" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.25.tgz", + "integrity": "sha512-a4WrkYFbb19i9pjkz38zJBg8wa/rboNERq3+hRRb0dHiJh13c+6kAbgqCPfMaJ2gg4weWD3APZswASOfmKwamA==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.25", + "@vue/runtime-core": "3.5.25", + "@vue/shared": "3.5.25", + "csstype": "^3.1.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.25.tgz", + "integrity": "sha512-UJaXR54vMG61i8XNIzTSf2Q7MOqZHpp8+x3XLGtE3+fL+nQd+k7O5+X3D/uWrnQXOdMw5VPih+Uremcw+u1woQ==", + "license": "MIT", + "dependencies": { + "@vue/compiler-ssr": "3.5.25", + "@vue/shared": "3.5.25" + }, + "peerDependencies": { + "vue": "3.5.25" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.25.tgz", + "integrity": "sha512-AbOPdQQnAnzs58H2FrrDxYj/TJfmeS2jdfEEhgiKINy+bnOANmVizIEgq1r+C5zsbs6l1CCQxtcj71rwNQ4jWg==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.14.0.tgz", + "integrity": "sha512-3Y8yrqLSwjuzpXuZ0oIYZ/XGgLwUIBU3uLvbcpb0pidD9ctpShJd43KSlEEkVQg6DS0G9NKyzOvBfUtDKEyHvQ==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.11", + "form-data": "^4.0.5", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "license": "MIT" + }, + "node_modules/d3": { + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz", + "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==", + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-axis": "3", + "d3-brush": "3", + "d3-chord": "3", + "d3-color": "3", + "d3-contour": "4", + "d3-delaunay": "6", + "d3-dispatch": "3", + "d3-drag": "3", + "d3-dsv": "3", + "d3-ease": "3", + "d3-fetch": "3", + "d3-force": "3", + "d3-format": "3", + "d3-geo": "3", + "d3-hierarchy": "3", + "d3-interpolate": "3", + "d3-path": "3", + "d3-polygon": "3", + "d3-quadtree": "3", + "d3-random": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "d3-selection": "3", + "d3-shape": "3", + "d3-time": "3", + "d3-time-format": "4", + "d3-timer": "3", + "d3-transition": "3", + "d3-zoom": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-axis": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz", + "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-brush": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz", + "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "3", + "d3-transition": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-chord": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz", + "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==", + "license": "ISC", + "dependencies": { + "d3-path": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-contour": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz", + "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==", + "license": "ISC", + "dependencies": { + "d3-array": "^3.2.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz", + "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==", + "license": "ISC", + "dependencies": { + "commander": "7", + "iconv-lite": "0.6", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json.js", + "csv2tsv": "bin/dsv2dsv.js", + "dsv2dsv": "bin/dsv2dsv.js", + "dsv2json": "bin/dsv2json.js", + "json2csv": "bin/json2dsv.js", + "json2dsv": "bin/json2dsv.js", + "json2tsv": "bin/json2dsv.js", + "tsv2csv": "bin/dsv2dsv.js", + "tsv2json": "bin/dsv2json.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-fetch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz", + "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==", + "license": "ISC", + "dependencies": { + "d3-dsv": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz", + "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz", + "integrity": "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-polygon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz", + "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-random": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz", + "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "license": "ISC", + "peer": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/delaunator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", + "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==", + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/robust-predicates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", + "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==", + "license": "Unlicense" + }, + "node_modules/rollup": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.1.tgz", + "integrity": "sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.60.1", + "@rollup/rollup-android-arm64": "4.60.1", + "@rollup/rollup-darwin-arm64": "4.60.1", + "@rollup/rollup-darwin-x64": "4.60.1", + "@rollup/rollup-freebsd-arm64": "4.60.1", + "@rollup/rollup-freebsd-x64": "4.60.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.60.1", + "@rollup/rollup-linux-arm-musleabihf": "4.60.1", + "@rollup/rollup-linux-arm64-gnu": "4.60.1", + "@rollup/rollup-linux-arm64-musl": "4.60.1", + "@rollup/rollup-linux-loong64-gnu": "4.60.1", + "@rollup/rollup-linux-loong64-musl": "4.60.1", + "@rollup/rollup-linux-ppc64-gnu": "4.60.1", + "@rollup/rollup-linux-ppc64-musl": "4.60.1", + "@rollup/rollup-linux-riscv64-gnu": "4.60.1", + "@rollup/rollup-linux-riscv64-musl": "4.60.1", + "@rollup/rollup-linux-s390x-gnu": "4.60.1", + "@rollup/rollup-linux-x64-gnu": "4.60.1", + "@rollup/rollup-linux-x64-musl": "4.60.1", + "@rollup/rollup-openbsd-x64": "4.60.1", + "@rollup/rollup-openharmony-arm64": "4.60.1", + "@rollup/rollup-win32-arm64-msvc": "4.60.1", + "@rollup/rollup-win32-ia32-msvc": "4.60.1", + "@rollup/rollup-win32-x64-gnu": "4.60.1", + "@rollup/rollup-win32-x64-msvc": "4.60.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/rw": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", + "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", + "license": "BSD-3-Clause" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/vite": { + "version": "7.2.7", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.7.tgz", + "integrity": "sha512-ITcnkFeR3+fI8P1wMgItjGrR10170d8auB4EpMLPqmx6uxElH3a/hHGQabSHKdqd4FXWO1nFIp9rRn7JQ34ACQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vue": { + "version": "3.5.25", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.25.tgz", + "integrity": "sha512-YLVdgv2K13WJ6n+kD5owehKtEXwdwXuj2TTyJMsO7pSeKw2bfRNZGjhB7YzrpbMYj5b5QsUebHpOqR3R3ziy/g==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.25", + "@vue/compiler-sfc": "3.5.25", + "@vue/runtime-dom": "3.5.25", + "@vue/server-renderer": "3.5.25", + "@vue/shared": "3.5.25" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-i18n": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-11.3.0.tgz", + "integrity": "sha512-1J+xDfDJTLhDxElkd3+XUhT7FYSZd2b8pa7IRKGxhWH/8yt6PTvi3xmWhGwhYT5EaXdatui11pF2R6tL73/zPA==", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "11.3.0", + "@intlify/devtools-types": "11.3.0", + "@intlify/shared": "11.3.0", + "@vue/devtools-api": "^6.5.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/vue-router": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.3.tgz", + "integrity": "sha512-ARBedLm9YlbvQomnmq91Os7ck6efydTSpRP3nuOKCvgJOHNrhRoJDSKtee8kcL1Vf7nz6U+PMBL+hTvR3bTVQg==", + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^6.6.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + } + } +} diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 00000000..1501b628 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,22 @@ +{ + "name": "frontend", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite --host", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "axios": "^1.14.0", + "d3": "^7.9.0", + "vue": "^3.5.24", + "vue-i18n": "^11.3.0", + "vue-router": "^4.6.3" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^6.0.1", + "vite": "^7.2.4" + } +} diff --git a/frontend/public/icon.png b/frontend/public/icon.png new file mode 100644 index 00000000..20da2f06 Binary files /dev/null and b/frontend/public/icon.png differ diff --git a/frontend/src/App.vue b/frontend/src/App.vue new file mode 100644 index 00000000..b7cd71ca --- /dev/null +++ b/frontend/src/App.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/frontend/src/api/graph.js b/frontend/src/api/graph.js new file mode 100644 index 00000000..ef90a2b6 --- /dev/null +++ b/frontend/src/api/graph.js @@ -0,0 +1,70 @@ +import service, { requestWithRetry } from './index' + +/** + * 生成本体(上传文档和模拟需求) + * @param {Object} data - 包含files, simulation_requirement, project_name等 + * @returns {Promise} + */ +export function generateOntology(formData) { + return requestWithRetry(() => + service({ + url: '/api/graph/ontology/generate', + method: 'post', + data: formData, + headers: { + 'Content-Type': 'multipart/form-data' + } + }) + ) +} + +/** + * 构建图谱 + * @param {Object} data - 包含project_id, graph_name等 + * @returns {Promise} + */ +export function buildGraph(data) { + return requestWithRetry(() => + service({ + url: '/api/graph/build', + method: 'post', + data + }) + ) +} + +/** + * 查询任务状态 + * @param {String} taskId - 任务ID + * @returns {Promise} + */ +export function getTaskStatus(taskId) { + return service({ + url: `/api/graph/task/${taskId}`, + method: 'get' + }) +} + +/** + * 获取图谱数据 + * @param {String} graphId - 图谱ID + * @returns {Promise} + */ +export function getGraphData(graphId) { + return service({ + url: `/api/graph/data/${graphId}`, + method: 'get' + }) +} + +/** + * 获取项目信息 + * @param {String} projectId - 项目ID + * @returns {Promise} + */ +export function getProject(projectId) { + return service({ + url: `/api/graph/project/${projectId}`, + method: 'get' + }) +} diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js new file mode 100644 index 00000000..e840e116 --- /dev/null +++ b/frontend/src/api/index.js @@ -0,0 +1,69 @@ +import axios from 'axios' +import i18n from '../i18n' + +// 创建axios实例 +const service = axios.create({ + baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:5001', + timeout: 300000, // 5分钟超时(本体生成可能需要较长时间) + headers: { + 'Content-Type': 'application/json' + } +}) + +// 请求拦截器 +service.interceptors.request.use( + config => { + config.headers['Accept-Language'] = i18n.global.locale.value + return config + }, + error => { + console.error('Request error:', error) + return Promise.reject(error) + } +) + +// 响应拦截器(容错重试机制) +service.interceptors.response.use( + response => { + const res = response.data + + // 如果返回的状态码不是success,则抛出错误 + if (!res.success && res.success !== undefined) { + console.error('API Error:', res.error || res.message || 'Unknown error') + return Promise.reject(new Error(res.error || res.message || 'Error')) + } + + return res + }, + error => { + console.error('Response error:', error) + + // 处理超时 + if (error.code === 'ECONNABORTED' && error.message.includes('timeout')) { + console.error('Request timeout') + } + + // 处理网络错误 + if (error.message === 'Network Error') { + console.error('Network error - please check your connection') + } + + return Promise.reject(error) + } +) + +// 带重试的请求函数 +export const requestWithRetry = async (requestFn, maxRetries = 3, delay = 1000) => { + for (let i = 0; i < maxRetries; i++) { + try { + return await requestFn() + } catch (error) { + if (i === maxRetries - 1) throw error + + console.warn(`Request failed, retrying (${i + 1}/${maxRetries})...`) + await new Promise(resolve => setTimeout(resolve, delay * Math.pow(2, i))) + } + } +} + +export default service diff --git a/frontend/src/api/report.js b/frontend/src/api/report.js new file mode 100644 index 00000000..c89a67d8 --- /dev/null +++ b/frontend/src/api/report.js @@ -0,0 +1,51 @@ +import service, { requestWithRetry } from './index' + +/** + * 开始报告生成 + * @param {Object} data - { simulation_id, force_regenerate? } + */ +export const generateReport = (data) => { + return requestWithRetry(() => service.post('/api/report/generate', data), 3, 1000) +} + +/** + * 获取报告生成状态 + * @param {string} reportId + */ +export const getReportStatus = (reportId) => { + return service.get(`/api/report/generate/status`, { params: { report_id: reportId } }) +} + +/** + * 获取 Agent 日志(增量) + * @param {string} reportId + * @param {number} fromLine - 从第几行开始获取 + */ +export const getAgentLog = (reportId, fromLine = 0) => { + return service.get(`/api/report/${reportId}/agent-log`, { params: { from_line: fromLine } }) +} + +/** + * 获取控制台日志(增量) + * @param {string} reportId + * @param {number} fromLine - 从第几行开始获取 + */ +export const getConsoleLog = (reportId, fromLine = 0) => { + return service.get(`/api/report/${reportId}/console-log`, { params: { from_line: fromLine } }) +} + +/** + * 获取报告详情 + * @param {string} reportId + */ +export const getReport = (reportId) => { + return service.get(`/api/report/${reportId}`) +} + +/** + * 与 Report Agent 对话 + * @param {Object} data - { simulation_id, message, chat_history? } + */ +export const chatWithReport = (data) => { + return requestWithRetry(() => service.post('/api/report/chat', data), 3, 1000) +} diff --git a/frontend/src/api/simulation.js b/frontend/src/api/simulation.js new file mode 100644 index 00000000..f878586f --- /dev/null +++ b/frontend/src/api/simulation.js @@ -0,0 +1,187 @@ +import service, { requestWithRetry } from './index' + +/** + * 创建模拟 + * @param {Object} data - { project_id, graph_id?, enable_twitter?, enable_reddit? } + */ +export const createSimulation = (data) => { + return requestWithRetry(() => service.post('/api/simulation/create', data), 3, 1000) +} + +/** + * 准备模拟环境(异步任务) + * @param {Object} data - { simulation_id, entity_types?, use_llm_for_profiles?, parallel_profile_count?, force_regenerate? } + */ +export const prepareSimulation = (data) => { + return requestWithRetry(() => service.post('/api/simulation/prepare', data), 3, 1000) +} + +/** + * 查询准备任务进度 + * @param {Object} data - { task_id?, simulation_id? } + */ +export const getPrepareStatus = (data) => { + return service.post('/api/simulation/prepare/status', data) +} + +/** + * 获取模拟状态 + * @param {string} simulationId + */ +export const getSimulation = (simulationId) => { + return service.get(`/api/simulation/${simulationId}`) +} + +/** + * 获取模拟的 Agent Profiles + * @param {string} simulationId + * @param {string} platform - 'reddit' | 'twitter' + */ +export const getSimulationProfiles = (simulationId, platform = 'reddit') => { + return service.get(`/api/simulation/${simulationId}/profiles`, { params: { platform } }) +} + +/** + * 实时获取生成中的 Agent Profiles + * @param {string} simulationId + * @param {string} platform - 'reddit' | 'twitter' + */ +export const getSimulationProfilesRealtime = (simulationId, platform = 'reddit') => { + return service.get(`/api/simulation/${simulationId}/profiles/realtime`, { params: { platform } }) +} + +/** + * 获取模拟配置 + * @param {string} simulationId + */ +export const getSimulationConfig = (simulationId) => { + return service.get(`/api/simulation/${simulationId}/config`) +} + +/** + * 实时获取生成中的模拟配置 + * @param {string} simulationId + * @returns {Promise} 返回配置信息,包含元数据和配置内容 + */ +export const getSimulationConfigRealtime = (simulationId) => { + return service.get(`/api/simulation/${simulationId}/config/realtime`) +} + +/** + * 列出所有模拟 + * @param {string} projectId - 可选,按项目ID过滤 + */ +export const listSimulations = (projectId) => { + const params = projectId ? { project_id: projectId } : {} + return service.get('/api/simulation/list', { params }) +} + +/** + * 启动模拟 + * @param {Object} data - { simulation_id, platform?, max_rounds?, enable_graph_memory_update? } + */ +export const startSimulation = (data) => { + return requestWithRetry(() => service.post('/api/simulation/start', data), 3, 1000) +} + +/** + * 停止模拟 + * @param {Object} data - { simulation_id } + */ +export const stopSimulation = (data) => { + return service.post('/api/simulation/stop', data) +} + +/** + * 获取模拟运行实时状态 + * @param {string} simulationId + */ +export const getRunStatus = (simulationId) => { + return service.get(`/api/simulation/${simulationId}/run-status`) +} + +/** + * 获取模拟运行详细状态(包含最近动作) + * @param {string} simulationId + */ +export const getRunStatusDetail = (simulationId) => { + return service.get(`/api/simulation/${simulationId}/run-status/detail`) +} + +/** + * 获取模拟中的帖子 + * @param {string} simulationId + * @param {string} platform - 'reddit' | 'twitter' + * @param {number} limit - 返回数量 + * @param {number} offset - 偏移量 + */ +export const getSimulationPosts = (simulationId, platform = 'reddit', limit = 50, offset = 0) => { + return service.get(`/api/simulation/${simulationId}/posts`, { + params: { platform, limit, offset } + }) +} + +/** + * 获取模拟时间线(按轮次汇总) + * @param {string} simulationId + * @param {number} startRound - 起始轮次 + * @param {number} endRound - 结束轮次 + */ +export const getSimulationTimeline = (simulationId, startRound = 0, endRound = null) => { + const params = { start_round: startRound } + if (endRound !== null) { + params.end_round = endRound + } + return service.get(`/api/simulation/${simulationId}/timeline`, { params }) +} + +/** + * 获取Agent统计信息 + * @param {string} simulationId + */ +export const getAgentStats = (simulationId) => { + return service.get(`/api/simulation/${simulationId}/agent-stats`) +} + +/** + * 获取模拟动作历史 + * @param {string} simulationId + * @param {Object} params - { limit, offset, platform, agent_id, round_num } + */ +export const getSimulationActions = (simulationId, params = {}) => { + return service.get(`/api/simulation/${simulationId}/actions`, { params }) +} + +/** + * 关闭模拟环境(优雅退出) + * @param {Object} data - { simulation_id, timeout? } + */ +export const closeSimulationEnv = (data) => { + return service.post('/api/simulation/close-env', data) +} + +/** + * 获取模拟环境状态 + * @param {Object} data - { simulation_id } + */ +export const getEnvStatus = (data) => { + return service.post('/api/simulation/env-status', data) +} + +/** + * 批量采访 Agent + * @param {Object} data - { simulation_id, interviews: [{ agent_id, prompt }] } + */ +export const interviewAgents = (data) => { + return requestWithRetry(() => service.post('/api/simulation/interview/batch', data), 3, 1000) +} + +/** + * 获取历史模拟列表(带项目详情) + * 用于首页历史项目展示 + * @param {number} limit - 返回数量限制 + */ +export const getSimulationHistory = (limit = 20) => { + return service.get('/api/simulation/history', { params: { limit } }) +} + diff --git a/frontend/src/assets/logo/MiroFish_logo_compressed.jpeg b/frontend/src/assets/logo/MiroFish_logo_compressed.jpeg new file mode 100644 index 00000000..eb7bd5af Binary files /dev/null and b/frontend/src/assets/logo/MiroFish_logo_compressed.jpeg differ diff --git a/frontend/src/assets/logo/MiroFish_logo_left.jpeg b/frontend/src/assets/logo/MiroFish_logo_left.jpeg new file mode 100644 index 00000000..a5459350 Binary files /dev/null and b/frontend/src/assets/logo/MiroFish_logo_left.jpeg differ diff --git a/frontend/src/components/GraphPanel.vue b/frontend/src/components/GraphPanel.vue new file mode 100644 index 00000000..db188298 --- /dev/null +++ b/frontend/src/components/GraphPanel.vue @@ -0,0 +1,1423 @@ + + + + + diff --git a/frontend/src/components/HistoryDatabase.vue b/frontend/src/components/HistoryDatabase.vue new file mode 100644 index 00000000..d6c6e9a5 --- /dev/null +++ b/frontend/src/components/HistoryDatabase.vue @@ -0,0 +1,1342 @@ + + + + + diff --git a/frontend/src/components/LanguageSwitcher.vue b/frontend/src/components/LanguageSwitcher.vue new file mode 100644 index 00000000..723d64b7 --- /dev/null +++ b/frontend/src/components/LanguageSwitcher.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/frontend/src/components/Step1GraphBuild.vue b/frontend/src/components/Step1GraphBuild.vue new file mode 100644 index 00000000..687d1c7b --- /dev/null +++ b/frontend/src/components/Step1GraphBuild.vue @@ -0,0 +1,700 @@ + + + + + diff --git a/frontend/src/components/Step2EnvSetup.vue b/frontend/src/components/Step2EnvSetup.vue new file mode 100644 index 00000000..a27ba347 --- /dev/null +++ b/frontend/src/components/Step2EnvSetup.vue @@ -0,0 +1,2605 @@ + + + + + diff --git a/frontend/src/components/Step3Simulation.vue b/frontend/src/components/Step3Simulation.vue new file mode 100644 index 00000000..5b0f968c --- /dev/null +++ b/frontend/src/components/Step3Simulation.vue @@ -0,0 +1,1267 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/Step4Report.vue b/frontend/src/components/Step4Report.vue new file mode 100644 index 00000000..8e53ceb5 --- /dev/null +++ b/frontend/src/components/Step4Report.vue @@ -0,0 +1,5162 @@ + + + + + + + diff --git a/frontend/src/components/Step5Interaction.vue b/frontend/src/components/Step5Interaction.vue new file mode 100644 index 00000000..9eb791a1 --- /dev/null +++ b/frontend/src/components/Step5Interaction.vue @@ -0,0 +1,2584 @@ + + + + + + + diff --git a/frontend/src/i18n/index.js b/frontend/src/i18n/index.js new file mode 100644 index 00000000..aa265535 --- /dev/null +++ b/frontend/src/i18n/index.js @@ -0,0 +1,27 @@ +import { createI18n } from 'vue-i18n' +import languages from '../../../locales/languages.json' + +const localeFiles = import.meta.glob('../../../locales/!(languages).json', { eager: true }) + +const messages = {} +const availableLocales = [] + +for (const path in localeFiles) { + const key = path.match(/\/([^/]+)\.json$/)[1] + if (languages[key]) { + messages[key] = localeFiles[path].default + availableLocales.push({ key, label: languages[key].label }) + } +} + +const savedLocale = localStorage.getItem('locale') || 'zh' + +const i18n = createI18n({ + legacy: false, + locale: savedLocale, + fallbackLocale: 'zh', + messages +}) + +export { availableLocales } +export default i18n diff --git a/frontend/src/main.js b/frontend/src/main.js new file mode 100644 index 00000000..cc3d101e --- /dev/null +++ b/frontend/src/main.js @@ -0,0 +1,11 @@ +import { createApp } from 'vue' +import App from './App.vue' +import router from './router' +import i18n from './i18n' + +const app = createApp(App) + +app.use(router) +app.use(i18n) + +app.mount('#app') diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js new file mode 100644 index 00000000..62d23201 --- /dev/null +++ b/frontend/src/router/index.js @@ -0,0 +1,52 @@ +import { createRouter, createWebHistory } from 'vue-router' +import Home from '../views/Home.vue' +import Process from '../views/MainView.vue' +import SimulationView from '../views/SimulationView.vue' +import SimulationRunView from '../views/SimulationRunView.vue' +import ReportView from '../views/ReportView.vue' +import InteractionView from '../views/InteractionView.vue' + +const routes = [ + { + path: '/', + name: 'Home', + component: Home + }, + { + path: '/process/:projectId', + name: 'Process', + component: Process, + props: true + }, + { + path: '/simulation/:simulationId', + name: 'Simulation', + component: SimulationView, + props: true + }, + { + path: '/simulation/:simulationId/start', + name: 'SimulationRun', + component: SimulationRunView, + props: true + }, + { + path: '/report/:reportId', + name: 'Report', + component: ReportView, + props: true + }, + { + path: '/interaction/:reportId', + name: 'Interaction', + component: InteractionView, + props: true + } +] + +const router = createRouter({ + history: createWebHistory(), + routes +}) + +export default router diff --git a/frontend/src/store/pendingUpload.js b/frontend/src/store/pendingUpload.js new file mode 100644 index 00000000..958c3d0a --- /dev/null +++ b/frontend/src/store/pendingUpload.js @@ -0,0 +1,33 @@ +/** + * 临时存储待上传的文件和需求 + * 用于首页点击启动引擎后立即跳转,在Process页面再进行API调用 + */ +import { reactive } from 'vue' + +const state = reactive({ + files: [], + simulationRequirement: '', + isPending: false +}) + +export function setPendingUpload(files, requirement) { + state.files = files + state.simulationRequirement = requirement + state.isPending = true +} + +export function getPendingUpload() { + return { + files: state.files, + simulationRequirement: state.simulationRequirement, + isPending: state.isPending + } +} + +export function clearPendingUpload() { + state.files = [] + state.simulationRequirement = '' + state.isPending = false +} + +export default state diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue new file mode 100644 index 00000000..ca7ef6ff --- /dev/null +++ b/frontend/src/views/Home.vue @@ -0,0 +1,953 @@ + + + + + + + diff --git a/frontend/src/views/InteractionView.vue b/frontend/src/views/InteractionView.vue new file mode 100644 index 00000000..7e555b26 --- /dev/null +++ b/frontend/src/views/InteractionView.vue @@ -0,0 +1,355 @@ + + + + + diff --git a/frontend/src/views/MainView.vue b/frontend/src/views/MainView.vue new file mode 100644 index 00000000..513c70d8 --- /dev/null +++ b/frontend/src/views/MainView.vue @@ -0,0 +1,545 @@ + + + + + diff --git a/frontend/src/views/Process.vue b/frontend/src/views/Process.vue new file mode 100644 index 00000000..2d2d3cc1 --- /dev/null +++ b/frontend/src/views/Process.vue @@ -0,0 +1,2068 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/ReportView.vue b/frontend/src/views/ReportView.vue new file mode 100644 index 00000000..ac054e47 --- /dev/null +++ b/frontend/src/views/ReportView.vue @@ -0,0 +1,353 @@ + + + + + diff --git a/frontend/src/views/SimulationRunView.vue b/frontend/src/views/SimulationRunView.vue new file mode 100644 index 00000000..c675d877 --- /dev/null +++ b/frontend/src/views/SimulationRunView.vue @@ -0,0 +1,452 @@ + + + + + + diff --git a/frontend/src/views/SimulationView.vue b/frontend/src/views/SimulationView.vue new file mode 100644 index 00000000..f3e1c18e --- /dev/null +++ b/frontend/src/views/SimulationView.vue @@ -0,0 +1,439 @@ + + + + + + diff --git a/frontend/vite.config.js b/frontend/vite.config.js new file mode 100644 index 00000000..8f1e4c11 --- /dev/null +++ b/frontend/vite.config.js @@ -0,0 +1,25 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import path from 'path' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [vue()], + resolve: { + alias: { + '@': path.resolve(__dirname, 'src'), + '@locales': path.resolve(__dirname, '../locales') + } + }, + server: { + port: 3000, + open: true, + proxy: { + '/api': { + target: 'http://localhost:5001', + changeOrigin: true, + secure: false + } + } + } +}) diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 00000000..544c68b1 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,665 @@ +{ + "common": { + "confirm": "Confirm", + "cancel": "Cancel", + "loading": "Loading...", + "error": "Error", + "success": "Success", + "completed": "Completed", + "processing": "Generating", + "pending": "Pending", + "ready": "Ready", + "running": "Running", + "failed": "Failed", + "unknown": "Unknown", + "unknownError": "Unknown error", + "none": "None", + "close": "Close", + "back": "Back", + "next": "Next", + "retry": "Retry", + "noData": "No data available", + "hours": "hours", + "minutes": "minutes", + "rounds": "rounds", + "items": "items", + "files": "files" + }, + "meta": { + "title": "MiroFish - Predict Everything", + "description": "MiroFish - Social Media Opinion Simulation System" + }, + "nav": { + "visitGithub": "Visit our Github page" + }, + "home": { + "tagline": "Concise & Universal Swarm Intelligence Engine", + "version": "/ v0.1-Preview", + "heroTitle1": "Upload Reports,", + "heroTitle2": "Predict the Future", + "heroDesc": "From a single document, {brand} extracts reality seeds to auto-generate a parallel world with up to {agentScale}. Inject variables from a god's-eye view to find the {optimalSolution} in complex group dynamics.", + "heroDescBrand": "MiroFish", + "heroDescAgentScale": "million-scale Agents", + "heroDescOptimalSolution": "\"local optimum\"", + "slogan": "Let Agents rehearse the future, let decisions prevail", + "systemStatus": "System Status", + "systemReady": "Ready", + "systemReadyDesc": "Prediction engine on standby. Upload unstructured data to initialize a simulation sequence.", + "metricLowCost": "Low Cost", + "metricLowCostDesc": "Avg. $5/sim", + "metricHighAvail": "Scalable", + "metricHighAvailDesc": "Millions of Agents", + "workflowSequence": "Workflow", + "step01Title": "Graph Build", + "step01Desc": "Seed extraction & memory injection & GraphRAG construction", + "step02Title": "Env Setup", + "step02Desc": "Entity extraction & persona generation & Agent config injection", + "step03Title": "Simulation", + "step03Desc": "Dual-platform parallel sim & auto-parse requirements & temporal memory", + "step04Title": "Report", + "step04Desc": "ReportAgent interacts with the post-simulation environment via rich tools", + "step05Title": "Interaction", + "step05Desc": "Chat with any simulated individual & converse with ReportAgent", + "realitySeed": "01 / Reality Seed", + "supportedFormats": "Formats: PDF, MD, TXT", + "dragToUpload": "Drag files to upload", + "orBrowse": "or click to browse files", + "inputParams": "Input Parameters", + "simulationPrompt": ">_ 02 / Simulation Prompt", + "promptPlaceholder": "// Describe your simulation or prediction requirement in natural language", + "engineBadge": "Engine: MiroFish-V1.0", + "startEngine": "Start Engine", + "initializing": "Initializing..." + }, + "main": { + "layoutGraph": "Graph", + "layoutSplit": "Split", + "layoutWorkbench": "Workbench", + "stepNames": ["Graph Build", "Env Setup", "Run Simulation", "Report Generation", "Deep Interaction"] + }, + "step1": { + "ontologyGeneration": "Ontology Generation", + "ontologyCompleted": "Completed", + "ontologyGenerating": "Generating", + "ontologyPending": "Pending", + "ontologyDesc": "LLM analyzes document content and simulation requirements, extracts reality seeds, and auto-generates a suitable ontology structure", + "analyzingDocs": "Analyzing documents...", + "graphRagBuild": "GraphRAG Build", + "graphRagDesc": "Based on the generated ontology, documents are auto-chunked and sent to Zep to build a knowledge graph, extracting entities and relations, forming temporal memory and community summaries", + "entityNodes": "Entity Nodes", + "relationEdges": "Relation Edges", + "schemaTypes": "Schema Types", + "buildComplete": "Build Complete", + "buildCompleteDesc": "Graph build is complete. Proceed to the next step for simulation environment setup.", + "inProgress": "In Progress", + "creating": "Creating...", + "enterEnvSetup": "Enter Environment Setup", + "createSimulationFailed": "Failed to create simulation: {error}", + "createSimulationException": "Simulation creation error: {error}" + }, + "step2": { + "simInstanceInit": "Simulation Instance Initialization", + "simInstanceDesc": "Create a new simulation instance and pull world parameter templates", + "asyncTaskDone": "Async task completed", + "generateAgentPersona": "Generate Agent Personas", + "generateAgentPersonaDesc": "Combine context to auto-extract entities and relations from the knowledge graph, initialize simulated individuals, and assign unique behaviors and memories based on reality seeds", + "currentAgentCount": "Current Agents", + "expectedAgentTotal": "Expected Total Agents", + "relatedTopicsCount": "Reality Seed Related Topics", + "generatedAgentPersonas": "Generated Agent Personas", + "unknownProfession": "Unknown profession", + "noBio": "No bio available", + "dualPlatformConfig": "Generate Dual-Platform Config", + "dualPlatformConfigDesc": "LLM intelligently sets world time flow, recommendation algorithms, each individual's active hours, posting frequency, event triggers, and more based on requirements and reality seeds", + "simulationDuration": "Simulation Duration", + "roundDuration": "Round Duration", + "totalRounds": "Total Rounds", + "activePerHour": "Active Per Hour", + "peakHours": "Peak Hours", + "workHours": "Work Hours", + "morningHours": "Morning Hours", + "offPeakHours": "Off-Peak Hours", + "agentConfig": "Agent Config", + "activeTimePeriod": "Active Hours", + "postsPerHour": "Posts/hr", + "commentsPerHour": "Comments/hr", + "responseDelay": "Response Delay", + "activityLevel": "Activity Level", + "sentimentBias": "Sentiment Bias", + "influenceWeight": "Influence", + "recommendAlgoConfig": "Recommendation Algorithm Config", + "platform1Name": "Platform 1: Plaza / Feed", + "platform2Name": "Platform 2: Topic / Community", + "recencyWeight": "Recency Weight", + "popularityWeight": "Popularity Weight", + "relevanceWeight": "Relevance Weight", + "viralThreshold": "Viral Threshold", + "echoChamberStrength": "Echo Chamber Strength", + "llmConfigReasoning": "LLM Config Reasoning", + "initialActivation": "Initial Activation Orchestration", + "initialActivationDesc": "Auto-generate initial activation events and hot topics based on narrative direction to guide the simulation world's initial state", + "orchestrating": "Orchestrating", + "narrativeDirection": "Narrative Direction", + "initialHotTopics": "Initial Hot Topics", + "initialActivationSeq": "Initial Activation Sequence ({count})", + "setupComplete": "Setup Complete", + "setupCompleteDesc": "Simulation environment is ready. You can now start the simulation.", + "roundsConfig": "Simulation Rounds Configuration", + "roundsConfigDesc": "MiroFish auto-plans to simulate {hours} real-world hours, each round representing {minutesPerRound} minutes of elapsed time", + "customToggle": "Custom", + "roundsUnit": "rounds", + "estimatedDuration": "For 100 Agents: est. ~{minutes} minutes", + "estimatedDurationFull": "For 100 Agents: est. {minutes} minutes", + "recommendedRounds": "{rounds} (recommended)", + "customTip": "For first-time runs, we strongly recommend switching to 'Custom Mode' to reduce rounds for a quick preview and lower error risk", + "backToGraphBuild": "Back to Graph Build", + "startDualWorldSim": "Start Dual-World Parallel Simulation", + "profileModalAge": "Apparent Age", + "profileModalGender": "Apparent Gender", + "profileModalCountry": "Country/Region", + "profileModalMbti": "Apparent MBTI", + "profileModalBio": "Persona Bio", + "profileModalTopics": "Reality Seed Related Topics", + "profileModalPersona": "Detailed Persona Background", + "personaDimExperience": "Full Event Experience", + "personaDimExperienceDesc": "Complete behavioral trajectory in this event", + "personaDimBehavior": "Behavioral Profile", + "personaDimBehaviorDesc": "Experience summary and behavioral preferences", + "personaDimMemory": "Unique Memory Imprint", + "personaDimMemoryDesc": "Memories formed from reality seeds", + "personaDimSocial": "Social Network", + "personaDimSocialDesc": "Individual connections and interaction graph", + "genderMale": "Male", + "genderFemale": "Female", + "genderOther": "Other", + "yearsOld": "years old", + "initializing": "Initializing", + "generating": "Generating" + }, + "step3": { + "startGenerateReport": "Generate Report", + "generatingReport": "Starting...", + "waitingForActions": "Waiting for agent actions...", + "errorMissingSimId": "Error: missing simulationId", + "startingDualSim": "Starting dual-platform parallel simulation...", + "graphMemoryUpdateEnabled": "Dynamic graph memory update enabled", + "setMaxRounds": "Max simulation rounds set to: {rounds}", + "oldSimCleared": "Old simulation logs cleared, restarting simulation", + "engineStarted": "Simulation engine started successfully", + "startFailed": "Start failed: {error}", + "startException": "Start error: {error}", + "stoppingSim": "Stopping simulation...", + "simStopped": "Simulation stopped", + "stopFailed": "Stop failed: {error}", + "stopException": "Stop error: {error}", + "allPlatformsCompleted": "All platform simulations have ended", + "simCompleted": "Simulation completed", + "graphRealtimeRefresh": "Graph real-time refresh enabled (30s)", + "graphRefreshStopped": "Graph real-time refresh stopped", + "preparingGoBack": "Preparing to return to Step 2, closing simulation...", + "closingSimEnv": "Closing simulation environment...", + "simEnvClosed": "Simulation environment closed", + "closeFailed": "Failed to close simulation environment, attempting force stop...", + "stoppingProcess": "Stopping simulation process...", + "checkStatusFailed": "Failed to check simulation status: {error}", + "forceStopSuccess": "Simulation force stopped", + "forceStopFailed": "Force stop failed: {error}", + "startGenerateReportBtn": "Generate Report", + "generatingReportBtn": "Starting..." + }, + "step4": { + "generatingSection": "Generating {title}...", + "goToInteraction": "Enter Deep Interaction", + "waitingForReportAgent": "Waiting for Report Agent...", + "collapse": "Collapse ▲", + "expandAll": "Show all {count} ▼", + "expandAllEntities": "Show all {count} ▼", + "scenarioLabel": "Scenario: ", + "tabKeyFacts": "Key Facts ({count})", + "tabCoreEntities": "Core Entities ({count})", + "tabRelationChains": "Relation Chains ({count})", + "tabSubQueries": "Sub-queries ({count})", + "panelKeyFacts": "Latest key facts from temporal memory", + "totalCount": "{count} total", + "totalEntityCount": "{count} total", + "panelCoreEntities": "Core Entities", + "factCount": "{count} facts", + "panelRelationChains": "Relation Chains", + "panelSubQueries": "Drift query analysis sub-questions", + "emptyKeyFacts": "No key facts available", + "emptyCoreEntities": "No core entities available", + "emptyRelationChains": "No relation chains available", + "tabActiveFacts": "Active Facts ({count})", + "tabHistoricalFacts": "Historical Facts ({count})", + "tabEntities": "Entities ({count})", + "panelActiveFacts": "Active Facts", + "emptyActiveFacts": "No active facts available", + "panelHistoricalFacts": "Historical Facts", + "emptyHistoricalFacts": "No historical facts available", + "panelEntities": "Entities", + "emptyEntities": "No entities available", + "searchLabel": "Search: ", + "tabFacts": "Facts ({count})", + "tabEdges": "Edges ({count})", + "tabNodes": "Nodes ({count})", + "panelSearchResults": "Search Results", + "emptySearchResults": "No results found", + "panelRelatedEdges": "Related Edges", + "panelRelatedNodes": "Related Nodes", + "world1": "World 1", + "world2": "World 2" + }, + "step5": { + "interactiveTools": "Interactive Tools", + "agentsAvailable": "{count} agents available", + "chatWithReportAgent": "Chat with Report Agent", + "chatWithAgent": "Chat with any individual in the world", + "selectChatTarget": "Select chat target", + "sendSurvey": "Send survey to the world", + "reportAgentChat": "Report Agent - Chat", + "reportAgentDesc": "A conversational version of the report generation agent with access to 4 professional tools and MiroFish's complete memory", + "toolInsightForge": "InsightForge Deep Attribution", + "toolInsightForgeDesc": "Aligns real-world seed data with simulation state, combining Global/Local Memory for cross-temporal deep attribution analysis", + "toolPanoramaSearch": "PanoramaSearch Full Tracking", + "toolPanoramaSearchDesc": "Graph-based BFS algorithm that reconstructs event propagation paths, capturing the full topology of information flow", + "toolQuickSearch": "QuickSearch Fast Retrieval", + "toolQuickSearchDesc": "GraphRAG-based instant query interface with optimized indexing for fast extraction of node attributes and discrete facts", + "toolInterviewSubAgent": "InterviewSubAgent Virtual Interview", + "toolInterviewSubAgentDesc": "Autonomous interviews that conduct parallel multi-round dialogues with simulated individuals, collecting unstructured opinion data and psychological states", + "profileBio": "Bio", + "chatEmptyReportAgent": "Chat with Report Agent to explore report content in depth", + "chatEmptyAgent": "Chat with simulated individuals to understand their perspectives", + "chatInputPlaceholder": "Type your question...", + "selectSurveyTarget": "Select survey targets", + "selectedCount": "Selected {selected} / {total}", + "surveyQuestions": "Survey Questions", + "surveyInputPlaceholder": "Enter the question you want to ask all selected targets...", + "submitSurvey": "Send Survey", + "surveyResults": "Survey Results", + "surveyResultsCount": "{count} responses", + "selectAll": "Select All", + "clearSelection": "Clear", + "errorOccurred": "Sorry, an error occurred: {error}", + "noResponse": "No response", + "requestFailed": "Request failed", + "selectAgentFirst": "Please select a simulated individual first" + }, + "graph": { + "panelTitle": "Graph Relationship Visualization", + "refreshGraph": "Refresh Graph", + "graphMemoryRealtime": "GraphRAG short/long-term memory updating in real-time", + "realtimeUpdating": "Updating in real-time...", + "pendingContentHint": "Some content is still processing. Consider refreshing the graph manually later.", + "nodeDetails": "Node Details", + "relationship": "Relationship", + "graphDataLoading": "Loading graph data...", + "waitingOntology": "Waiting for ontology generation...", + "toggleMaximize": "Maximize/Restore", + "closeHint": "Close hint" + }, + "history": { + "title": "Simulation History", + "graphBuild": "Graph Build", + "envSetup": "Env Setup", + "analysisReport": "Analysis Report", + "moreFiles": "+{count} files", + "noFiles": "No files", + "loadingText": "Loading...", + "simRequirement": "Simulation Requirement", + "relatedFiles": "Related Files", + "noRelatedFiles": "No related files", + "replayTitle": "Simulation Replay", + "step1Button": "Graph Build", + "step2Button": "Env Setup", + "step4Button": "Analysis Report", + "replayHint": "Step 3 'Run Simulation' and Step 5 'Deep Interaction' must be started during runtime and do not support history replay", + "notStarted": "Not started", + "roundsProgress": "{current}/{total} rounds", + "untitledSimulation": "Untitled simulation", + "unknownFile": "Unknown file" + }, + "api": { + "projectNotFound": "Project not found: {id}", + "projectDeleteFailed": "Project not found or deletion failed: {id}", + "projectDeleted": "Project deleted: {id}", + "projectReset": "Project reset: {id}", + "requireSimulationRequirement": "Please provide a simulation requirement (simulation_requirement)", + "requireFileUpload": "Please upload at least one document file", + "noDocProcessed": "No documents were processed successfully. Please check file formats.", + "requireProjectId": "Please provide project_id", + "configError": "Configuration error: {details}", + "zepApiKeyMissing": "ZEP_API_KEY not configured", + "ontologyNotGenerated": "Ontology not yet generated. Please call /ontology/generate first.", + "graphBuilding": "Graph build in progress. Do not resubmit. To force rebuild, add force: true.", + "textNotFound": "Extracted text content not found", + "ontologyNotFound": "Ontology definition not found", + "graphBuildStarted": "Graph build task started. Query progress via /task/{taskId}.", + "graphBuildComplete": "Graph build complete", + "buildFailed": "Build failed: {error}", + "taskNotFound": "Task not found: {id}", + "graphDeleted": "Graph deleted: {id}", + "entityNotFound": "Entity not found: {id}", + "graphNotBuilt": "Graph not yet built. Please call /api/graph/build first.", + "requireSimulationId": "Please provide simulation_id", + "simulationNotFound": "Simulation not found: {id}", + "projectMissingRequirement": "Project missing simulation requirement (simulation_requirement)", + "prepareStarted": "Preparation task started. Query progress via /api/simulation/prepare/status.", + "alreadyPrepared": "Preparation already complete. No need to regenerate.", + "notStartedPrepare": "Preparation not started. Please call /api/simulation/prepare.", + "taskCompletedPrepared": "Task completed (preparation already exists)", + "requireTaskOrSimId": "Please provide task_id or simulation_id", + "configNotFound": "Simulation config not found. Please call /prepare first.", + "configFileNotFound": "Config file not found. Please call /prepare first.", + "unknownScript": "Unknown script: {name}. Available: {allowed}", + "scriptFileNotFound": "Script file not found: {name}", + "requireGraphId": "Please provide graph_id", + "noMatchingEntities": "No matching entities found", + "maxRoundsPositive": "max_rounds must be a positive integer", + "maxRoundsInvalid": "max_rounds must be a valid integer", + "invalidPlatform": "Invalid platform type: {platform}. Options: twitter/reddit/parallel", + "simRunningForceHint": "Simulation is running. Stop it first via /stop, or use force=true to restart.", + "simNotReady": "Simulation not ready. Current status: {status}. Please call /prepare first.", + "graphIdRequiredForMemory": "Graph memory update requires a valid graph_id. Ensure the graph is built.", + "dbNotExist": "Database does not exist. The simulation may not have run yet.", + "requireMessage": "Please provide a message", + "missingGraphId": "Missing graph ID", + "missingGraphIdEnsure": "Missing graph ID. Please ensure the graph has been built.", + "missingSimRequirement": "Missing simulation requirement description", + "reportAlreadyExists": "Report already exists", + "reportGenerateStarted": "Report generation task started. Query progress via /api/report/generate/status.", + "reportGenerated": "Report generated", + "reportNotFound": "Report not found: {id}", + "noReportForSim": "No report found for this simulation: {id}", + "reportDeleted": "Report deleted: {id}", + "reportGenerateFailed": "Report generation failed", + "sectionNotFound": "Section not found: section_{index}.md", + "reportProgressNotAvail": "Report not found or progress unavailable: {id}", + "requireAgentId": "Please provide agent_id", + "requirePrompt": "Please provide a prompt (interview question)", + "invalidInterviewPlatform": "Platform must be either 'twitter' or 'reddit'", + "envNotRunning": "Simulation environment not running or closed. Ensure simulation is complete and in command-wait mode.", + "interviewTimeout": "Interview response timed out: {error}", + "requireInterviews": "Please provide interviews (interview list)", + "interviewListMissingAgentId": "Interview list item {index} missing agent_id", + "interviewListMissingPrompt": "Interview list item {index} missing prompt", + "interviewListInvalidPlatform": "Interview list item {index} platform must be 'twitter' or 'reddit'", + "batchInterviewTimeout": "Batch interview response timed out: {error}", + "globalInterviewTimeout": "Global interview response timed out: {error}", + "envRunning": "Environment is running and ready for Interview commands", + "envNotRunningShort": "Environment not running or closed", + "requireGraphIdAndQuery": "Please provide graph_id and query", + "initReportAgent": "Initializing Report Agent..." + }, + "progress": { + "initGraphService": "Initializing graph build service...", + "textChunking": "Chunking text...", + "creatingZepGraph": "Creating Zep graph...", + "settingOntology": "Setting ontology definition...", + "addingChunks": "Adding {count} text chunks...", + "waitingZepProcess": "Waiting for Zep to process data...", + "fetchingGraphData": "Fetching graph data...", + "graphBuildComplete": "Graph build complete", + "buildFailed": "Build failed: {error}", + "startBuildingGraph": "Starting graph build...", + "graphCreated": "Graph created: {graphId}", + "ontologySet": "Ontology set", + "textSplit": "Text split into {count} chunks", + "fetchingGraphInfo": "Fetching graph info...", + "sendingBatch": "Sending batch {current}/{total} ({chunks} chunks)...", + "batchFailed": "Batch {batch} failed: {error}", + "noEpisodesWait": "No episodes to wait for", + "waitingEpisodes": "Waiting for {count} text chunks to process...", + "episodesTimeout": "Some chunks timed out, {completed}/{total} completed", + "zepProcessing": "Zep processing... {completed}/{total} done, {pending} pending ({elapsed}s)", + "processingComplete": "Processing complete: {completed}/{total}", + "taskComplete": "Task complete", + "taskFailed": "Task failed", + "startPreparingEnv": "Preparing simulation environment...", + "connectingZepGraph": "Connecting to Zep graph...", + "readingNodeData": "Reading node data...", + "readingComplete": "Done, {count} entities found", + "startGenerating": "Starting generation...", + "analyzingRequirements": "Analyzing simulation requirements...", + "generatingOutline": "Generating report outline...", + "parsingOutline": "Parsing outline structure...", + "outlinePlanComplete": "Outline planning complete", + "deepSearchAndWrite": "Deep search & writing ({current}/{max})", + "initReport": "Initializing report...", + "startPlanningOutline": "Planning report outline...", + "outlineDone": "Outline complete, {count} sections", + "generatingSection": "Generating section: {title} ({current}/{total})", + "sectionDone": "Section {title} complete", + "assemblingReport": "Assembling full report...", + "reportComplete": "Report generation complete", + "reportFailed": "Report generation failed: {error}", + "savingProfiles": "Saving profile files...", + "profilesComplete": "Done, {count} profiles generated", + "callingLLMConfig": "Calling LLM to generate config...", + "savingConfigFiles": "Saving config files...", + "configComplete": "Config generation complete", + "generatingTimeConfig": "Generating time config...", + "generatingEventConfig": "Generating event config and hot topics...", + "generatingAgentConfig": "Generating agent config ({start}-{end}/{total})...", + "generatingPlatformConfig": "Generating platform config...", + "zepSearchQuery": "All information, activities, events, relationships and background about {name}", + "timeConfigLabel": "Time Config", + "eventConfigLabel": "Event Config", + "agentConfigResult": "Agent Config: {count} generated", + "postAssignResult": "Post Assignment: {count} posts assigned", + "profileGenerated": "[Generated] {name} ({type})", + "readingGraphEntities": "Reading Graph Entities", + "generatingProfiles": "Generating Agent Profiles", + "generatingSimConfig": "Generating Simulation Config", + "preparingScripts": "Preparing Scripts" + }, + "log": { + "preparingGoBack": "Preparing to return to Step 2, closing simulation...", + "closingSimEnv": "Closing simulation environment...", + "simEnvClosed": "✓ Simulation environment closed", + "closeSimEnvFailed": "Failed to close simulation environment, attempting force stop...", + "simForceStopSuccess": "✓ Simulation force stopped", + "forceStopFailed": "Force stop failed: {error}", + "stoppingSimProcess": "Stopping simulation process...", + "simStopped": "✓ Simulation stopped", + "stopSimFailed": "Failed to stop simulation: {error}", + "checkStatusFailed": "Failed to check simulation status: {error}", + "enterStep4": "Entering Step 4: Report Generation", + "loadingSimData": "Loading simulation data: {id}", + "timeConfig": "Time config: {minutes} minutes per round", + "timeConfigFetchFailed": "Failed to fetch time config, using default: {minutes} min/round", + "projectLoadSuccess": "Project loaded: {id}", + "loadSimDataFailed": "Failed to load simulation data: {error}", + "loadException": "Load error: {error}", + "graphDataLoadSuccess": "Graph data loaded successfully", + "graphLoadFailed": "Graph load failed: {error}", + "graphRealtimeRefreshStart": "Graph real-time refresh enabled (30s)", + "graphRealtimeRefreshStop": "Graph real-time refresh stopped", + "simRunViewInit": "SimulationRunView initialized", + "customRounds": "Custom simulation rounds: {rounds}", + "enterStep3": "Entering Step 3: Run Simulation", + "customRoundsConfig": "Custom simulation rounds: {rounds} rounds", + "useAutoRounds": "Using auto-configured simulation rounds", + "detectedSimEnvRunning": "Detected running simulation environment, closing...", + "closeSimEnvFailedWithError": "Failed to close simulation environment: {error}", + "closeSimEnvException": "Simulation environment close error: {error}", + "detectedSimRunning": "Detected simulation is running, stopping...", + "forceStopSimFailed": "Force stop simulation failed: {error}", + "forceStopSimException": "Force stop simulation error: {error}", + "simViewInit": "SimulationView initialized", + "errorMissingSimId": "Error: missing simulationId", + "simInstanceCreated": "Simulation instance created: {id}", + "preparingSimEnv": "Preparing simulation environment...", + "detectedExistingPrep": "Detected existing preparation, using it directly", + "prepareTaskStarted": "Preparation task started", + "prepareTaskId": " └─ Task ID: {taskId}", + "zepEntitiesFound": "Found {count} entities from Zep graph", + "entityTypes": " └─ Entity types: {types}", + "startPollingProgress": "Polling preparation progress...", + "prepareFailed": "Preparation failed: {error}", + "prepareException": "Preparation error: {error}", + "prepareComplete": "✓ Preparation complete", + "prepareFailedWithError": "✗ Preparation failed: {error}", + "startGeneratingConfig": "Generating dual-platform simulation config...", + "generatingAgentProfileConfig": "Generating agent persona config...", + "generatingLLMConfig": "Calling LLM to generate simulation config parameters...", + "configComplete": "✓ Simulation config generated", + "configSummaryAgents": " ├─ Agents: {count}", + "configSummaryHours": " ├─ Duration: {hours} hours", + "configSummaryPosts": " ├─ Initial posts: {count}", + "configSummaryTopics": " ├─ Hot topics: {count}", + "configSummaryPlatforms": " └─ Platforms: Twitter {twitter}, Reddit {reddit}", + "timeConfigDetail": "Time config: {minutes} min/round, {rounds} rounds total", + "narrativeDirection": "Narrative direction: {direction}", + "envSetupComplete": "✓ Environment setup complete, ready to simulate", + "startSimCustomRounds": "Starting simulation, custom rounds: {rounds}", + "startSimAutoRounds": "Starting simulation, auto-configured rounds: {rounds}", + "startGeneratingAgentProfiles": "Generating agent personas...", + "agentProfile": "→ Agent persona {current}/{total}: {name} ({profession})", + "allProfilesComplete": "✓ All {count} agent personas generated", + "loadingExistingConfig": "Loading existing config data...", + "loadedAgentProfiles": "Loaded {count} agent personas", + "configLoadSuccess": "✓ Simulation config loaded", + "configSummaryPostsAlt": " └─ Initial posts: {count}", + "configGenerating": "Config generating, polling...", + "loadConfigFailed": "Failed to load config: {error}", + "step2Init": "Step 2 environment setup initialized", + "step3Init": "Step 3 simulation run initialized", + "startingDualSim": "Starting dual-platform parallel simulation...", + "setMaxRounds": "Max simulation rounds set to: {rounds}", + "graphMemoryUpdateEnabled": "Dynamic graph memory update enabled", + "oldSimCleared": "✓ Old simulation logs cleared, restarting simulation", + "engineStarted": "✓ Simulation engine started successfully", + "startFailed": "✗ Start failed: {error}", + "startException": "✗ Start error: {error}", + "stoppingSim": "Stopping simulation...", + "simStoppedSuccess": "✓ Simulation stopped", + "stopFailed": "Stop failed: {error}", + "stopException": "Stop error: {error}", + "allPlatformsCompleted": "✓ All platform simulations have ended", + "simCompleted": "✓ Simulation completed", + "reportRequestSent": "Report generation request sent, please wait...", + "startingReportGen": "Starting report generation...", + "reportGenTaskStarted": "✓ Report generation task started: {reportId}", + "reportGenFailed": "✗ Failed to start report generation: {error}", + "reportGenException": "✗ Report generation error: {error}", + "step5Init": "Step 5 deep interaction initialized", + "selectChatTarget": "Selected chat target: {name}", + "sendFailed": "Send failed: {error}", + "sendToReportAgent": "Sent to Report Agent: {message}...", + "reportAgentReplied": "Report Agent replied", + "sendToAgent": "Sent to {name}: {message}...", + "agentReplied": "{name} replied", + "sendSurvey": "Sending survey to {count} targets...", + "receivedReplies": "Received {count} replies", + "surveySendFailed": "Survey send failed: {error}", + "loadReportData": "Loading report data: {id}", + "loadReportFailed": "Failed to load report: {error}", + "reportDataLoaded": "Report data loaded", + "loadReportLogFailed": "Failed to load report logs: {error}", + "loadedProfiles": "Loaded {count} simulated individuals", + "loadProfilesFailed": "Failed to load simulated individuals: {error}", + "interactionViewInit": "InteractionView initialized", + "reportViewInit": "ReportView initialized", + "getReportInfoFailed": "Failed to get report info: {error}", + "enterStep": "Entering Step {step}: {name}", + "returnToStep": "Returning to Step {step}: {name}", + "customSimRounds": "Custom simulation rounds: {rounds} rounds" + }, + "report": { + "taskStarted": "Report generation task started", + "planningStart": "Starting report outline planning", + "fetchSimContext": "Fetching simulation context", + "planningComplete": "Outline planning complete", + "sectionStart": "Starting section generation: {title}", + "reactThought": "ReACT round {iteration} thinking", + "toolCall": "Calling tool: {toolName}", + "toolResult": "Tool {toolName} returned result", + "llmResponse": "LLM response (tool calls: {hasToolCalls}, final answer: {hasFinalAnswer})", + "sectionContentDone": "Section {title} content generation complete", + "sectionComplete": "Section {title} generation complete", + "reportComplete": "Report generation complete", + "errorOccurred": "Error occurred: {error}", + "agentInitDone": "ReportAgent initialized: graph_id={graphId}, simulation_id={simulationId}", + "executingTool": "Executing tool: {toolName}, params: {params}", + "toolExecFailed": "Tool execution failed: {toolName}, error: {error}", + "startPlanningOutline": "Starting report outline planning...", + "outlinePlanDone": "Outline planning complete: {count} sections", + "outlinePlanFailed": "Outline planning failed: {error}", + "reactGenerateSection": "ReACT generating section: {title}", + "sectionIterNone": "Section {title} iteration {iteration}: LLM returned None", + "sectionConflict": "Section {title} round {iteration}: LLM output both tool call and Final Answer (conflict #{conflictCount})", + "sectionConflictDowngrade": "Section {title}: {conflictCount} consecutive conflicts, downgrading to truncate and execute first tool call", + "sectionGenDone": "Section {title} generation complete (tool calls: {count})", + "multiToolOnlyFirst": "LLM attempted {total} tool calls, executing only the first: {toolName}", + "sectionNoPrefix": "Section {title} missing 'Final Answer:' prefix, adopting LLM output as final content (tool calls: {count})", + "sectionMaxIter": "Section {title} reached max iterations, forcing generation", + "sectionForceFailed": "Section {title} force-finish LLM returned None, using default error message", + "sectionGenFailedContent": "(This section failed to generate: LLM returned empty response, please retry later)", + "outlineSavedToFile": "Outline saved to file: {reportId}/outline.json", + "sectionSaved": "Section saved: {reportId}/section_{sectionNum}.md", + "reportGenDone": "Report generation complete: {reportId}", + "reportGenFailed": "Report generation failed: {error}", + "agentChat": "Report Agent chat: {message}...", + "fetchReportFailed": "Failed to fetch report content: {error}", + "outlineSaved": "Outline saved: {reportId}", + "sectionFileSaved": "Section saved: {reportId}/{fileSuffix}", + "fullReportAssembled": "Full report assembled: {reportId}", + "reportSaved": "Report saved: {reportId}", + "reportFolderDeleted": "Report folder deleted: {reportId}", + "redirectToQuickSearch": "search_graph redirected to quick_search", + "redirectToInsightForge": "get_simulation_context redirected to insight_forge" + }, + "console": { + "zepToolsInitialized": "ZepToolsService initialized", + "zepRetryAttempt": "Zep {operation} attempt {attempt} failed: {error}, retrying in {delay}s...", + "zepAllRetriesFailed": "Zep {operation} failed after {retries} attempts: {error}", + "graphSearch": "Graph search: graph_id={graphId}, query={query}...", + "graphSearchOp": "Graph search (graph={graphId})", + "searchComplete": "Search complete: found {count} relevant facts", + "zepSearchApiFallback": "Zep Search API failed, falling back to local search: {error}", + "usingLocalSearch": "Using local search: query={query}...", + "localSearchComplete": "Local search complete: found {count} relevant facts", + "localSearchFailed": "Local search failed: {error}", + "fetchingAllNodes": "Fetching all nodes for graph {graphId}...", + "fetchedNodes": "Fetched {count} nodes", + "fetchingAllEdges": "Fetching all edges for graph {graphId}...", + "fetchedEdges": "Fetched {count} edges", + "fetchingNodeDetail": "Fetching node detail: {uuid}...", + "fetchNodeDetailOp": "Fetch node detail (uuid={uuid}...)", + "fetchNodeDetailFailed": "Failed to fetch node detail: {error}", + "fetchingNodeEdges": "Fetching edges for node {uuid}...", + "foundNodeEdges": "Found {count} edges related to node", + "fetchNodeEdgesFailed": "Failed to fetch node edges: {error}", + "fetchingEntitiesByType": "Fetching entities of type {type}...", + "foundEntitiesByType": "Found {count} entities of type {type}", + "fetchingEntitySummary": "Fetching relationship summary for entity {name}...", + "fetchingGraphStats": "Fetching statistics for graph {graphId}...", + "fetchingSimContext": "Fetching simulation context: {requirement}...", + "insightForgeStart": "InsightForge deep insight retrieval: {query}...", + "generatedSubQueries": "Generated {count} sub-queries", + "insightForgeComplete": "InsightForge complete: {facts} facts, {entities} entities, {relationships} relationships", + "generateSubQueriesFailed": "Failed to generate sub-queries: {error}, using defaults", + "panoramaSearchStart": "PanoramaSearch broad search: {query}...", + "panoramaSearchComplete": "PanoramaSearch complete: {active} active, {historical} historical", + "quickSearchStart": "QuickSearch simple search: {query}...", + "quickSearchComplete": "QuickSearch complete: {count} results", + "interviewAgentsStart": "InterviewAgents deep interview (real API): {requirement}...", + "profilesNotFound": "Profiles not found for simulation {simId}", + "loadedProfiles": "Loaded {count} agent profiles", + "selectedAgentsForInterview": "Selected {count} agents for interview: {indices}", + "generatedInterviewQuestions": "Generated {count} interview questions", + "callingBatchInterviewApi": "Calling batch interview API (dual platform): {count} agents", + "interviewApiReturned": "Interview API returned: {count} results, success={success}", + "interviewApiReturnedFailure": "Interview API returned failure: {error}", + "interviewApiCallFailed": "Interview API call failed (env not running?): {error}", + "interviewApiCallException": "Interview API call exception: {error}", + "interviewAgentsComplete": "InterviewAgents complete: interviewed {count} agents (dual platform)", + "loadedRedditProfiles": "Loaded {count} profiles from reddit_profiles.json", + "readRedditProfilesFailed": "Failed to read reddit_profiles.json: {error}", + "loadedTwitterProfiles": "Loaded {count} profiles from twitter_profiles.csv", + "readTwitterProfilesFailed": "Failed to read twitter_profiles.csv: {error}", + "llmSelectAgentFailed": "LLM agent selection failed, using default selection: {error}", + "generateInterviewQuestionsFailed": "Failed to generate interview questions: {error}", + "generateInterviewSummaryFailed": "Failed to generate interview summary: {error}" + } +} diff --git a/locales/languages.json b/locales/languages.json new file mode 100644 index 00000000..81732cec --- /dev/null +++ b/locales/languages.json @@ -0,0 +1,30 @@ +{ + "zh": { + "label": "中文", + "llmInstruction": "请使用中文回答。" + }, + "en": { + "label": "English", + "llmInstruction": "Please respond in English." + }, + "es": { + "label": "Español", + "llmInstruction": "Por favor, responde en español." + }, + "fr": { + "label": "Français", + "llmInstruction": "Veuillez répondre en français." + }, + "pt": { + "label": "Português", + "llmInstruction": "Por favor, responda em português." + }, + "ru": { + "label": "Русский", + "llmInstruction": "Пожалуйста, отвечайте на русском языке." + }, + "de": { + "label": "Deutsch", + "llmInstruction": "Bitte antworten Sie auf Deutsch." + } +} diff --git a/locales/zh.json b/locales/zh.json new file mode 100644 index 00000000..cd747e2f --- /dev/null +++ b/locales/zh.json @@ -0,0 +1,665 @@ +{ + "common": { + "confirm": "确认", + "cancel": "取消", + "loading": "加载中...", + "error": "错误", + "success": "成功", + "completed": "已完成", + "processing": "生成中", + "pending": "等待", + "ready": "就绪", + "running": "运行中", + "failed": "失败", + "unknown": "未知", + "unknownError": "未知错误", + "none": "无", + "close": "关闭", + "back": "返回", + "next": "下一步", + "retry": "重试", + "noData": "暂无数据", + "hours": "小时", + "minutes": "分钟", + "rounds": "轮", + "items": "个", + "files": "个文件" + }, + "meta": { + "title": "MiroFish - 预测万物", + "description": "MiroFish - 社交媒体舆论模拟系统" + }, + "nav": { + "visitGithub": "访问我们的Github主页" + }, + "home": { + "tagline": "简洁通用的群体智能引擎", + "version": "/ v0.1-预览版", + "heroTitle1": "上传任意报告", + "heroTitle2": "即刻推演未来", + "heroDesc": "即使只有一段文字,{brand} 也能基于其中的现实种子,全自动生成与之对应的至多{agentScale}构成的平行世界。通过上帝视角注入变量,在复杂的群体交互中寻找动态环境下的{optimalSolution}", + "heroDescBrand": "MiroFish", + "heroDescAgentScale": "百万级Agent", + "heroDescOptimalSolution": "\"局部最优解\"", + "slogan": "让未来在 Agent 群中预演,让决策在百战后胜出", + "systemStatus": "系统状态", + "systemReady": "准备就绪", + "systemReadyDesc": "预测引擎待命中,可上传多份非结构化数据以初始化模拟序列", + "metricLowCost": "低成本", + "metricLowCostDesc": "常规模拟平均5$/次", + "metricHighAvail": "高可用", + "metricHighAvailDesc": "最多百万级Agent模拟", + "workflowSequence": "工作流序列", + "step01Title": "图谱构建", + "step01Desc": "现实种子提取 & 个体与群体记忆注入 & GraphRAG构建", + "step02Title": "环境搭建", + "step02Desc": "实体关系抽取 & 人设生成 & 环境配置Agent注入仿真参数", + "step03Title": "开始模拟", + "step03Desc": "双平台并行模拟 & 自动解析预测需求 & 动态更新时序记忆", + "step04Title": "报告生成", + "step04Desc": "ReportAgent拥有丰富的工具集与模拟后环境进行深度交互", + "step05Title": "深度互动", + "step05Desc": "与模拟世界中的任意一位进行对话 & 与ReportAgent进行对话", + "realitySeed": "01 / 现实种子", + "supportedFormats": "支持格式: PDF, MD, TXT", + "dragToUpload": "拖拽文件上传", + "orBrowse": "或点击浏览文件系统", + "inputParams": "输入参数", + "simulationPrompt": ">_ 02 / 模拟提示词", + "promptPlaceholder": "// 用自然语言输入模拟或预测需求(例.武大若发布撤销肖某处分的公告,会引发什么舆情走向)", + "engineBadge": "引擎: MiroFish-V1.0", + "startEngine": "启动引擎", + "initializing": "初始化中..." + }, + "main": { + "layoutGraph": "图谱", + "layoutSplit": "双栏", + "layoutWorkbench": "工作台", + "stepNames": ["图谱构建", "环境搭建", "开始模拟", "报告生成", "深度互动"] + }, + "step1": { + "ontologyGeneration": "本体生成", + "ontologyCompleted": "已完成", + "ontologyGenerating": "生成中", + "ontologyPending": "等待", + "ontologyDesc": "LLM分析文档内容与模拟需求,提取出现实种子,自动生成合适的本体结构", + "analyzingDocs": "正在分析文档...", + "graphRagBuild": "GraphRAG构建", + "graphRagDesc": "基于生成的本体,将文档自动分块后调用 Zep 构建知识图谱,提取实体和关系,并形成时序记忆与社区摘要", + "entityNodes": "实体节点", + "relationEdges": "关系边", + "schemaTypes": "SCHEMA类型", + "buildComplete": "构建完成", + "buildCompleteDesc": "图谱构建已完成,请进入下一步进行模拟环境搭建", + "inProgress": "进行中", + "creating": "创建中...", + "enterEnvSetup": "进入环境搭建", + "createSimulationFailed": "创建模拟失败: {error}", + "createSimulationException": "创建模拟异常: {error}" + }, + "step2": { + "simInstanceInit": "模拟实例初始化", + "simInstanceDesc": "新建simulation实例,拉取模拟世界参数模版", + "asyncTaskDone": "异步任务已完成", + "generateAgentPersona": "生成 Agent 人设", + "generateAgentPersonaDesc": "结合上下文,自动调用工具从知识图谱梳理实体与关系,初始化模拟个体,并基于现实种子赋予他们独特的行为与记忆", + "currentAgentCount": "当前Agent数", + "expectedAgentTotal": "预期Agent总数", + "relatedTopicsCount": "现实种子当前关联话题数", + "generatedAgentPersonas": "已生成的 Agent 人设", + "unknownProfession": "未知职业", + "noBio": "暂无简介", + "dualPlatformConfig": "生成双平台模拟配置", + "dualPlatformConfigDesc": "LLM 根据模拟需求与现实种子,智能设置世界时间流速、推荐算法、每个个体的活跃时间段、发言频率、事件触发等参数", + "simulationDuration": "模拟时长", + "roundDuration": "每轮时长", + "totalRounds": "总轮次", + "activePerHour": "每小时活跃", + "peakHours": "高峰时段", + "workHours": "工作时段", + "morningHours": "早间时段", + "offPeakHours": "低谷时段", + "agentConfig": "Agent 配置", + "activeTimePeriod": "活跃时段", + "postsPerHour": "发帖/时", + "commentsPerHour": "评论/时", + "responseDelay": "响应延迟", + "activityLevel": "活跃度", + "sentimentBias": "情感倾向", + "influenceWeight": "影响力", + "recommendAlgoConfig": "推荐算法配置", + "platform1Name": "平台 1:广场 / 信息流", + "platform2Name": "平台 2:话题 / 社区", + "recencyWeight": "时效权重", + "popularityWeight": "热度权重", + "relevanceWeight": "相关性权重", + "viralThreshold": "病毒阈值", + "echoChamberStrength": "回音室强度", + "llmConfigReasoning": "LLM 配置推理", + "initialActivation": "初始激活编排", + "initialActivationDesc": "基于叙事方向,自动生成初始激活事件与热点话题,引导模拟世界的初始状态", + "orchestrating": "编排中", + "narrativeDirection": "叙事引导方向", + "initialHotTopics": "初始热点话题", + "initialActivationSeq": "初始激活序列 ({count})", + "setupComplete": "准备完成", + "setupCompleteDesc": "模拟环境已准备完成,可以开始运行模拟", + "roundsConfig": "模拟轮数设定", + "roundsConfigDesc": "MiroFish 自动规划推演现实 {hours} 小时,每轮代表现实 {minutesPerRound} 分钟时间流逝", + "customToggle": "自定义", + "roundsUnit": "轮", + "estimatedDuration": "若Agent规模为100:预计耗时约 {minutes} 分钟", + "estimatedDurationFull": "若Agent规模为100:预计耗时 {minutes} 分钟", + "recommendedRounds": "{rounds} (推荐)", + "customTip": "若首次运行,强烈建议切换至'自定义模式'减少模拟轮数,以便快速预览效果并降低报错风险", + "backToGraphBuild": "返回图谱构建", + "startDualWorldSim": "开始双世界并行模拟", + "profileModalAge": "事件外显年龄", + "profileModalGender": "事件外显性别", + "profileModalCountry": "国家/地区", + "profileModalMbti": "事件外显MBTI", + "profileModalBio": "人设简介", + "profileModalTopics": "现实种子关联话题", + "profileModalPersona": "详细人设背景", + "personaDimExperience": "事件全景经历", + "personaDimExperienceDesc": "在此事件中的完整行为轨迹", + "personaDimBehavior": "行为模式侧写", + "personaDimBehaviorDesc": "经验总结与行事风格偏好", + "personaDimMemory": "独特记忆印记", + "personaDimMemoryDesc": "基于现实种子形成的记忆", + "personaDimSocial": "社会关系网络", + "personaDimSocialDesc": "个体链接与交互图谱", + "genderMale": "男", + "genderFemale": "女", + "genderOther": "其他", + "yearsOld": "岁", + "initializing": "初始化", + "generating": "生成中" + }, + "step3": { + "startGenerateReport": "开始生成结果报告", + "generatingReport": "启动中...", + "waitingForActions": "Waiting for agent actions...", + "errorMissingSimId": "错误:缺少 simulationId", + "startingDualSim": "正在启动双平台并行模拟...", + "graphMemoryUpdateEnabled": "已开启动态图谱更新模式", + "setMaxRounds": "设置最大模拟轮数: {rounds}", + "oldSimCleared": "已清理旧的模拟日志,重新开始模拟", + "engineStarted": "模拟引擎启动成功", + "startFailed": "启动失败: {error}", + "startException": "启动异常: {error}", + "stoppingSim": "正在停止模拟...", + "simStopped": "模拟已停止", + "stopFailed": "停止失败: {error}", + "stopException": "停止异常: {error}", + "allPlatformsCompleted": "检测到所有平台模拟已结束", + "simCompleted": "模拟已完成", + "graphRealtimeRefresh": "开启图谱实时刷新 (30s)", + "graphRefreshStopped": "停止图谱实时刷新", + "preparingGoBack": "准备返回 Step 2,正在关闭模拟...", + "closingSimEnv": "正在关闭模拟环境...", + "simEnvClosed": "模拟环境已关闭", + "closeFailed": "关闭模拟环境失败,尝试强制停止...", + "stoppingProcess": "正在停止模拟进程...", + "checkStatusFailed": "检查模拟状态失败: {error}", + "forceStopSuccess": "模拟已强制停止", + "forceStopFailed": "强制停止失败: {error}", + "startGenerateReportBtn": "开始生成结果报告", + "generatingReportBtn": "启动中..." + }, + "step4": { + "generatingSection": "正在生成{title}...", + "goToInteraction": "进入深度互动", + "waitingForReportAgent": "Waiting for Report Agent...", + "collapse": "收起 ▲", + "expandAll": "展开全部 {count} 条 ▼", + "expandAllEntities": "展开全部 {count} 个 ▼", + "scenarioLabel": "预测场景: ", + "tabKeyFacts": "当前关键记忆 ({count})", + "tabCoreEntities": "核心实体 ({count})", + "tabRelationChains": "关系链 ({count})", + "tabSubQueries": "子问题 ({count})", + "panelKeyFacts": "时序记忆中所关联的最新关键事实", + "totalCount": "共 {count} 条", + "totalEntityCount": "共 {count} 个", + "panelCoreEntities": "核心实体", + "factCount": "{count}条", + "panelRelationChains": "关系链", + "panelSubQueries": "漂移查询生成分析子问题", + "emptyKeyFacts": "暂无当前关键记忆", + "emptyCoreEntities": "暂无核心实体", + "emptyRelationChains": "暂无关系链", + "tabActiveFacts": "当前有效记忆 ({count})", + "tabHistoricalFacts": "历史记忆 ({count})", + "tabEntities": "涉及实体 ({count})", + "panelActiveFacts": "当前有效记忆", + "emptyActiveFacts": "暂无当前有效记忆", + "panelHistoricalFacts": "历史记忆", + "emptyHistoricalFacts": "暂无历史记忆", + "panelEntities": "涉及实体", + "emptyEntities": "暂无涉及实体", + "searchLabel": "搜索: ", + "tabFacts": "事实 ({count})", + "tabEdges": "关系 ({count})", + "tabNodes": "节点 ({count})", + "panelSearchResults": "搜索结果", + "emptySearchResults": "未找到相关结果", + "panelRelatedEdges": "相关关系", + "panelRelatedNodes": "相关节点", + "world1": "世界1", + "world2": "世界2" + }, + "step5": { + "interactiveTools": "Interactive Tools", + "agentsAvailable": "{count} agents available", + "chatWithReportAgent": "与Report Agent对话", + "chatWithAgent": "与世界中任意个体对话", + "selectChatTarget": "选择对话对象", + "sendSurvey": "发送问卷调查到世界中", + "reportAgentChat": "Report Agent - Chat", + "reportAgentDesc": "报告生成智能体的快速对话版本,可调用 4 种专业工具,拥有MiroFish的完整记忆", + "toolInsightForge": "InsightForge 深度归因", + "toolInsightForgeDesc": "对齐现实世界种子数据与模拟环境状态,结合Global/Local Memory机制,提供跨时空的深度归因分析", + "toolPanoramaSearch": "PanoramaSearch 全景追踪", + "toolPanoramaSearchDesc": "基于图结构的广度遍历算法,重构事件传播路径,捕获全量信息流动的拓扑结构", + "toolQuickSearch": "QuickSearch 快速检索", + "toolQuickSearchDesc": "基于 GraphRAG 的即时查询接口,优化索引效率,用于快速提取具体的节点属性与离散事实", + "toolInterviewSubAgent": "InterviewSubAgent 虚拟访谈", + "toolInterviewSubAgentDesc": "自主式访谈,能够并行与模拟世界中个体进行多轮对话,采集非结构化的观点数据与心理状态", + "profileBio": "简介", + "chatEmptyReportAgent": "与 Report Agent 对话,深入了解报告内容", + "chatEmptyAgent": "与模拟个体对话,了解他们的观点", + "chatInputPlaceholder": "输入您的问题...", + "selectSurveyTarget": "选择调查对象", + "selectedCount": "已选 {selected} / {total}", + "surveyQuestions": "问卷问题", + "surveyInputPlaceholder": "输入您想问所有被选中对象的问题...", + "submitSurvey": "发送问卷", + "surveyResults": "调查结果", + "surveyResultsCount": "{count} 条回复", + "selectAll": "全选", + "clearSelection": "清空", + "errorOccurred": "抱歉,发生了错误: {error}", + "noResponse": "无响应", + "requestFailed": "请求失败", + "selectAgentFirst": "请先选择一个模拟个体" + }, + "graph": { + "panelTitle": "Graph Relationship Visualization", + "refreshGraph": "刷新图谱", + "graphMemoryRealtime": "GraphRAG长短期记忆实时更新中", + "realtimeUpdating": "实时更新中...", + "pendingContentHint": "还有少量内容处理中,建议稍后手动刷新图谱", + "nodeDetails": "Node Details", + "relationship": "Relationship", + "graphDataLoading": "图谱数据加载中...", + "waitingOntology": "等待本体生成...", + "toggleMaximize": "最大化/还原", + "closeHint": "关闭提示" + }, + "history": { + "title": "推演记录", + "graphBuild": "图谱构建", + "envSetup": "环境搭建", + "analysisReport": "分析报告", + "moreFiles": "+{count} 个文件", + "noFiles": "暂无文件", + "loadingText": "加载中...", + "simRequirement": "模拟需求", + "relatedFiles": "关联文件", + "noRelatedFiles": "暂无关联文件", + "replayTitle": "推演回放", + "step1Button": "图谱构建", + "step2Button": "环境搭建", + "step4Button": "分析报告", + "replayHint": "Step3「开始模拟」与 Step5「深度互动」需在运行中启动,不支持历史回放", + "notStarted": "未开始", + "roundsProgress": "{current}/{total} 轮", + "untitledSimulation": "未命名模拟", + "unknownFile": "未知文件" + }, + "api": { + "projectNotFound": "项目不存在: {id}", + "projectDeleteFailed": "项目不存在或删除失败: {id}", + "projectDeleted": "项目已删除: {id}", + "projectReset": "项目已重置: {id}", + "requireSimulationRequirement": "请提供模拟需求描述 (simulation_requirement)", + "requireFileUpload": "请至少上传一个文档文件", + "noDocProcessed": "没有成功处理任何文档,请检查文件格式", + "requireProjectId": "请提供 project_id", + "configError": "配置错误: {details}", + "zepApiKeyMissing": "ZEP_API_KEY未配置", + "ontologyNotGenerated": "项目尚未生成本体,请先调用 /ontology/generate", + "graphBuilding": "图谱正在构建中,请勿重复提交。如需强制重建,请添加 force: true", + "textNotFound": "未找到提取的文本内容", + "ontologyNotFound": "未找到本体定义", + "graphBuildStarted": "图谱构建任务已启动,请通过 /task/{taskId} 查询进度", + "graphBuildComplete": "图谱构建完成", + "buildFailed": "构建失败: {error}", + "taskNotFound": "任务不存在: {id}", + "graphDeleted": "图谱已删除: {id}", + "entityNotFound": "实体不存在: {id}", + "graphNotBuilt": "项目尚未构建图谱,请先调用 /api/graph/build", + "requireSimulationId": "请提供 simulation_id", + "simulationNotFound": "模拟不存在: {id}", + "projectMissingRequirement": "项目缺少模拟需求描述 (simulation_requirement)", + "prepareStarted": "准备任务已启动,请通过 /api/simulation/prepare/status 查询进度", + "alreadyPrepared": "已有完成的准备工作,无需重复生成", + "notStartedPrepare": "尚未开始准备,请调用 /api/simulation/prepare 开始", + "taskCompletedPrepared": "任务已完成(准备工作已存在)", + "requireTaskOrSimId": "请提供 task_id 或 simulation_id", + "configNotFound": "模拟配置不存在,请先调用 /prepare 接口", + "configFileNotFound": "配置文件不存在,请先调用 /prepare 接口", + "unknownScript": "未知脚本: {name},可选: {allowed}", + "scriptFileNotFound": "脚本文件不存在: {name}", + "requireGraphId": "请提供 graph_id", + "noMatchingEntities": "没有找到符合条件的实体", + "maxRoundsPositive": "max_rounds 必须是正整数", + "maxRoundsInvalid": "max_rounds 必须是有效的整数", + "invalidPlatform": "无效的平台类型: {platform},可选: twitter/reddit/parallel", + "simRunningForceHint": "模拟正在运行中,请先调用 /stop 接口停止,或使用 force=true 强制重新开始", + "simNotReady": "模拟未准备好,当前状态: {status},请先调用 /prepare 接口", + "graphIdRequiredForMemory": "启用图谱记忆更新需要有效的 graph_id,请确保项目已构建图谱", + "dbNotExist": "数据库不存在,模拟可能尚未运行", + "requireMessage": "请提供 message", + "missingGraphId": "缺少图谱ID", + "missingGraphIdEnsure": "缺少图谱ID,请确保已构建图谱", + "missingSimRequirement": "缺少模拟需求描述", + "reportAlreadyExists": "报告已存在", + "reportGenerateStarted": "报告生成任务已启动,请通过 /api/report/generate/status 查询进度", + "reportGenerated": "报告已生成", + "reportNotFound": "报告不存在: {id}", + "noReportForSim": "该模拟暂无报告: {id}", + "reportDeleted": "报告已删除: {id}", + "reportGenerateFailed": "报告生成失败", + "sectionNotFound": "章节不存在: section_{index}.md", + "reportProgressNotAvail": "报告不存在或进度信息不可用: {id}", + "requireAgentId": "请提供 agent_id", + "requirePrompt": "请提供 prompt(采访问题)", + "invalidInterviewPlatform": "platform 参数只能是 'twitter' 或 'reddit'", + "envNotRunning": "模拟环境未运行或已关闭。请确保模拟已完成并进入等待命令模式。", + "interviewTimeout": "等待Interview响应超时: {error}", + "requireInterviews": "请提供 interviews(采访列表)", + "interviewListMissingAgentId": "采访列表第{index}项缺少 agent_id", + "interviewListMissingPrompt": "采访列表第{index}项缺少 prompt", + "interviewListInvalidPlatform": "采访列表第{index}项的platform只能是 'twitter' 或 'reddit'", + "batchInterviewTimeout": "等待批量Interview响应超时: {error}", + "globalInterviewTimeout": "等待全局Interview响应超时: {error}", + "envRunning": "环境正在运行,可以接收Interview命令", + "envNotRunningShort": "环境未运行或已关闭", + "requireGraphIdAndQuery": "请提供 graph_id 和 query", + "initReportAgent": "初始化Report Agent..." + }, + "progress": { + "initGraphService": "初始化图谱构建服务...", + "textChunking": "文本分块中...", + "creatingZepGraph": "创建Zep图谱...", + "settingOntology": "设置本体定义...", + "addingChunks": "开始添加 {count} 个文本块...", + "waitingZepProcess": "等待Zep处理数据...", + "fetchingGraphData": "获取图谱数据...", + "graphBuildComplete": "图谱构建完成", + "buildFailed": "构建失败: {error}", + "startBuildingGraph": "开始构建图谱...", + "graphCreated": "图谱已创建: {graphId}", + "ontologySet": "本体已设置", + "textSplit": "文本已分割为 {count} 个块", + "fetchingGraphInfo": "获取图谱信息...", + "sendingBatch": "发送第 {current}/{total} 批数据 ({chunks} 块)...", + "batchFailed": "批次 {batch} 发送失败: {error}", + "noEpisodesWait": "无需等待(没有 episode)", + "waitingEpisodes": "开始等待 {count} 个文本块处理...", + "episodesTimeout": "部分文本块超时,已完成 {completed}/{total}", + "zepProcessing": "Zep处理中... {completed}/{total} 完成, {pending} 待处理 ({elapsed}秒)", + "processingComplete": "处理完成: {completed}/{total}", + "taskComplete": "任务完成", + "taskFailed": "任务失败", + "startPreparingEnv": "开始准备模拟环境...", + "connectingZepGraph": "正在连接Zep图谱...", + "readingNodeData": "正在读取节点数据...", + "readingComplete": "完成,共 {count} 个实体", + "startGenerating": "开始生成...", + "analyzingRequirements": "正在分析模拟需求...", + "generatingOutline": "正在生成报告大纲...", + "parsingOutline": "正在解析大纲结构...", + "outlinePlanComplete": "大纲规划完成", + "deepSearchAndWrite": "深度检索与撰写中 ({current}/{max})", + "initReport": "初始化报告...", + "startPlanningOutline": "开始规划报告大纲...", + "outlineDone": "大纲规划完成,共{count}个章节", + "generatingSection": "正在生成章节: {title} ({current}/{total})", + "sectionDone": "章节 {title} 已完成", + "assemblingReport": "正在组装完整报告...", + "reportComplete": "报告生成完成", + "reportFailed": "报告生成失败: {error}", + "savingProfiles": "保存Profile文件...", + "profilesComplete": "完成,共 {count} 个Profile", + "callingLLMConfig": "正在调用LLM生成配置...", + "savingConfigFiles": "正在保存配置文件...", + "configComplete": "配置生成完成", + "generatingTimeConfig": "生成时间配置...", + "generatingEventConfig": "生成事件配置和热点话题...", + "generatingAgentConfig": "生成Agent配置 ({start}-{end}/{total})...", + "generatingPlatformConfig": "生成平台配置...", + "zepSearchQuery": "关于{name}的所有信息、活动、事件、关系和背景", + "timeConfigLabel": "时间配置", + "eventConfigLabel": "事件配置", + "agentConfigResult": "Agent配置: 成功生成 {count} 个", + "postAssignResult": "初始帖子分配: {count} 个帖子已分配发布者", + "profileGenerated": "[已生成] {name} ({type})", + "readingGraphEntities": "读取图谱实体", + "generatingProfiles": "生成Agent人设", + "generatingSimConfig": "生成模拟配置", + "preparingScripts": "准备模拟脚本" + }, + "log": { + "preparingGoBack": "准备返回 Step 2,正在关闭模拟...", + "closingSimEnv": "正在关闭模拟环境...", + "simEnvClosed": "✓ 模拟环境已关闭", + "closeSimEnvFailed": "关闭模拟环境失败,尝试强制停止...", + "simForceStopSuccess": "✓ 模拟已强制停止", + "forceStopFailed": "强制停止失败: {error}", + "stoppingSimProcess": "正在停止模拟进程...", + "simStopped": "✓ 模拟已停止", + "stopSimFailed": "停止模拟失败: {error}", + "checkStatusFailed": "检查模拟状态失败: {error}", + "enterStep4": "进入 Step 4: 报告生成", + "loadingSimData": "加载模拟数据: {id}", + "timeConfig": "时间配置: 每轮 {minutes} 分钟", + "timeConfigFetchFailed": "获取时间配置失败,使用默认值: {minutes}分钟/轮", + "projectLoadSuccess": "项目加载成功: {id}", + "loadSimDataFailed": "加载模拟数据失败: {error}", + "loadException": "加载异常: {error}", + "graphDataLoadSuccess": "图谱数据加载成功", + "graphLoadFailed": "图谱加载失败: {error}", + "graphRealtimeRefreshStart": "开启图谱实时刷新 (30s)", + "graphRealtimeRefreshStop": "停止图谱实时刷新", + "simRunViewInit": "SimulationRunView 初始化", + "customRounds": "自定义模拟轮数: {rounds}", + "enterStep3": "进入 Step 3: 开始模拟", + "customRoundsConfig": "自定义模拟轮数: {rounds} 轮", + "useAutoRounds": "使用自动配置的模拟轮数", + "detectedSimEnvRunning": "检测到模拟环境正在运行,正在关闭...", + "closeSimEnvFailedWithError": "关闭模拟环境失败: {error}", + "closeSimEnvException": "关闭模拟环境异常: {error}", + "detectedSimRunning": "检测到模拟状态为运行中,正在停止...", + "forceStopSimFailed": "强制停止模拟失败: {error}", + "forceStopSimException": "强制停止模拟异常: {error}", + "simViewInit": "SimulationView 初始化", + "errorMissingSimId": "错误:缺少 simulationId", + "simInstanceCreated": "模拟实例已创建: {id}", + "preparingSimEnv": "正在准备模拟环境...", + "detectedExistingPrep": "检测到已有完成的准备工作,直接使用", + "prepareTaskStarted": "准备任务已启动", + "prepareTaskId": " └─ Task ID: {taskId}", + "zepEntitiesFound": "从Zep图谱读取到 {count} 个实体", + "entityTypes": " └─ 实体类型: {types}", + "startPollingProgress": "开始轮询准备进度...", + "prepareFailed": "准备失败: {error}", + "prepareException": "准备异常: {error}", + "prepareComplete": "✓ 准备工作已完成", + "prepareFailedWithError": "✗ 准备失败: {error}", + "startGeneratingConfig": "开始生成双平台模拟配置...", + "generatingAgentProfileConfig": "正在生成Agent人设配置...", + "generatingLLMConfig": "正在调用LLM生成模拟配置参数...", + "configComplete": "✓ 模拟配置生成完成", + "configSummaryAgents": " ├─ Agent数量: {count}个", + "configSummaryHours": " ├─ 模拟时长: {hours}小时", + "configSummaryPosts": " ├─ 初始帖子: {count}条", + "configSummaryTopics": " ├─ 热点话题: {count}个", + "configSummaryPlatforms": " └─ 平台配置: Twitter {twitter}, Reddit {reddit}", + "timeConfigDetail": "时间配置: 每轮{minutes}分钟, 共{rounds}轮", + "narrativeDirection": "叙事方向: {direction}", + "envSetupComplete": "✓ 环境搭建完成,可以开始模拟", + "startSimCustomRounds": "开始模拟,自定义轮数: {rounds} 轮", + "startSimAutoRounds": "开始模拟,使用自动配置轮数: {rounds} 轮", + "startGeneratingAgentProfiles": "开始生成Agent人设...", + "agentProfile": "→ Agent人设 {current}/{total}: {name} ({profession})", + "allProfilesComplete": "✓ 全部 {count} 个Agent人设生成完成", + "loadingExistingConfig": "正在加载已有配置数据...", + "loadedAgentProfiles": "已加载 {count} 个Agent人设", + "configLoadSuccess": "✓ 模拟配置加载成功", + "configSummaryPostsAlt": " └─ 初始帖子: {count}条", + "configGenerating": "配置生成中,开始轮询等待...", + "loadConfigFailed": "加载配置失败: {error}", + "step2Init": "Step2 环境搭建初始化", + "step3Init": "Step3 模拟运行初始化", + "startingDualSim": "正在启动双平台并行模拟...", + "setMaxRounds": "设置最大模拟轮数: {rounds}", + "graphMemoryUpdateEnabled": "已开启动态图谱更新模式", + "oldSimCleared": "✓ 已清理旧的模拟日志,重新开始模拟", + "engineStarted": "✓ 模拟引擎启动成功", + "startFailed": "✗ 启动失败: {error}", + "startException": "✗ 启动异常: {error}", + "stoppingSim": "正在停止模拟...", + "simStoppedSuccess": "✓ 模拟已停止", + "stopFailed": "停止失败: {error}", + "stopException": "停止异常: {error}", + "allPlatformsCompleted": "✓ 检测到所有平台模拟已结束", + "simCompleted": "✓ 模拟已完成", + "reportRequestSent": "报告生成请求已发送,请稍候...", + "startingReportGen": "正在启动报告生成...", + "reportGenTaskStarted": "✓ 报告生成任务已启动: {reportId}", + "reportGenFailed": "✗ 启动报告生成失败: {error}", + "reportGenException": "✗ 启动报告生成异常: {error}", + "step5Init": "Step5 深度互动初始化", + "selectChatTarget": "选择对话对象: {name}", + "sendFailed": "发送失败: {error}", + "sendToReportAgent": "向 Report Agent 发送: {message}...", + "reportAgentReplied": "Report Agent 已回复", + "sendToAgent": "向 {name} 发送: {message}...", + "agentReplied": "{name} 已回复", + "sendSurvey": "发送问卷给 {count} 个对象...", + "receivedReplies": "收到 {count} 条回复", + "surveySendFailed": "问卷发送失败: {error}", + "loadReportData": "加载报告数据: {id}", + "loadReportFailed": "加载报告失败: {error}", + "reportDataLoaded": "报告数据加载完成", + "loadReportLogFailed": "加载报告日志失败: {error}", + "loadedProfiles": "加载了 {count} 个模拟个体", + "loadProfilesFailed": "加载模拟个体失败: {error}", + "interactionViewInit": "InteractionView 初始化", + "reportViewInit": "ReportView 初始化", + "getReportInfoFailed": "获取报告信息失败: {error}", + "enterStep": "进入 Step {step}: {name}", + "returnToStep": "返回 Step {step}: {name}", + "customSimRounds": "自定义模拟轮数: {rounds} 轮" + }, + "report": { + "taskStarted": "报告生成任务开始", + "planningStart": "开始规划报告大纲", + "fetchSimContext": "获取模拟上下文信息", + "planningComplete": "大纲规划完成", + "sectionStart": "开始生成章节: {title}", + "reactThought": "ReACT 第{iteration}轮思考", + "toolCall": "调用工具: {toolName}", + "toolResult": "工具 {toolName} 返回结果", + "llmResponse": "LLM 响应 (工具调用: {hasToolCalls}, 最终答案: {hasFinalAnswer})", + "sectionContentDone": "章节 {title} 内容生成完成", + "sectionComplete": "章节 {title} 生成完成", + "reportComplete": "报告生成完成", + "errorOccurred": "发生错误: {error}", + "agentInitDone": "ReportAgent 初始化完成: graph_id={graphId}, simulation_id={simulationId}", + "executingTool": "执行工具: {toolName}, 参数: {params}", + "toolExecFailed": "工具执行失败: {toolName}, 错误: {error}", + "startPlanningOutline": "开始规划报告大纲...", + "outlinePlanDone": "大纲规划完成: {count} 个章节", + "outlinePlanFailed": "大纲规划失败: {error}", + "reactGenerateSection": "ReACT生成章节: {title}", + "sectionIterNone": "章节 {title} 第 {iteration} 次迭代: LLM 返回 None", + "sectionConflict": "章节 {title} 第 {iteration} 轮: LLM 同时输出工具调用和 Final Answer(第 {conflictCount} 次冲突)", + "sectionConflictDowngrade": "章节 {title}: 连续 {conflictCount} 次冲突,降级为截断执行第一个工具调用", + "sectionGenDone": "章节 {title} 生成完成(工具调用: {count}次)", + "multiToolOnlyFirst": "LLM 尝试调用 {total} 个工具,只执行第一个: {toolName}", + "sectionNoPrefix": "章节 {title} 未检测到 'Final Answer:' 前缀,直接采纳LLM输出作为最终内容(工具调用: {count}次)", + "sectionMaxIter": "章节 {title} 达到最大迭代次数,强制生成", + "sectionForceFailed": "章节 {title} 强制收尾时 LLM 返回 None,使用默认错误提示", + "sectionGenFailedContent": "(本章节生成失败:LLM 返回空响应,请稍后重试)", + "outlineSavedToFile": "大纲已保存到文件: {reportId}/outline.json", + "sectionSaved": "章节已保存: {reportId}/section_{sectionNum}.md", + "reportGenDone": "报告生成完成: {reportId}", + "reportGenFailed": "报告生成失败: {error}", + "agentChat": "Report Agent对话: {message}...", + "fetchReportFailed": "获取报告内容失败: {error}", + "outlineSaved": "大纲已保存: {reportId}", + "sectionFileSaved": "章节已保存: {reportId}/{fileSuffix}", + "fullReportAssembled": "完整报告已组装: {reportId}", + "reportSaved": "报告已保存: {reportId}", + "reportFolderDeleted": "报告文件夹已删除: {reportId}", + "redirectToQuickSearch": "search_graph 已重定向到 quick_search", + "redirectToInsightForge": "get_simulation_context 已重定向到 insight_forge" + }, + "console": { + "zepToolsInitialized": "ZepToolsService 初始化完成", + "zepRetryAttempt": "Zep {operation} 第 {attempt} 次尝试失败: {error}, {delay}秒后重试...", + "zepAllRetriesFailed": "Zep {operation} 在 {retries} 次尝试后仍失败: {error}", + "graphSearch": "图谱搜索: graph_id={graphId}, query={query}...", + "graphSearchOp": "图谱搜索(graph={graphId})", + "searchComplete": "搜索完成: 找到 {count} 条相关事实", + "zepSearchApiFallback": "Zep Search API失败,降级为本地搜索: {error}", + "usingLocalSearch": "使用本地搜索: query={query}...", + "localSearchComplete": "本地搜索完成: 找到 {count} 条相关事实", + "localSearchFailed": "本地搜索失败: {error}", + "fetchingAllNodes": "获取图谱 {graphId} 的所有节点...", + "fetchedNodes": "获取到 {count} 个节点", + "fetchingAllEdges": "获取图谱 {graphId} 的所有边...", + "fetchedEdges": "获取到 {count} 条边", + "fetchingNodeDetail": "获取节点详情: {uuid}...", + "fetchNodeDetailOp": "获取节点详情(uuid={uuid}...)", + "fetchNodeDetailFailed": "获取节点详情失败: {error}", + "fetchingNodeEdges": "获取节点 {uuid}... 的相关边", + "foundNodeEdges": "找到 {count} 条与节点相关的边", + "fetchNodeEdgesFailed": "获取节点边失败: {error}", + "fetchingEntitiesByType": "获取类型为 {type} 的实体...", + "foundEntitiesByType": "找到 {count} 个 {type} 类型的实体", + "fetchingEntitySummary": "获取实体 {name} 的关系摘要...", + "fetchingGraphStats": "获取图谱 {graphId} 的统计信息...", + "fetchingSimContext": "获取模拟上下文: {requirement}...", + "insightForgeStart": "InsightForge 深度洞察检索: {query}...", + "generatedSubQueries": "生成 {count} 个子问题", + "insightForgeComplete": "InsightForge完成: {facts}条事实, {entities}个实体, {relationships}条关系", + "generateSubQueriesFailed": "生成子问题失败: {error},使用默认子问题", + "panoramaSearchStart": "PanoramaSearch 广度搜索: {query}...", + "panoramaSearchComplete": "PanoramaSearch完成: {active}条有效, {historical}条历史", + "quickSearchStart": "QuickSearch 简单搜索: {query}...", + "quickSearchComplete": "QuickSearch完成: {count}条结果", + "interviewAgentsStart": "InterviewAgents 深度采访(真实API): {requirement}...", + "profilesNotFound": "未找到模拟 {simId} 的人设文件", + "loadedProfiles": "加载到 {count} 个Agent人设", + "selectedAgentsForInterview": "选择了 {count} 个Agent进行采访: {indices}", + "generatedInterviewQuestions": "生成了 {count} 个采访问题", + "callingBatchInterviewApi": "调用批量采访API(双平台): {count} 个Agent", + "interviewApiReturned": "采访API返回: {count} 个结果, success={success}", + "interviewApiReturnedFailure": "采访API返回失败: {error}", + "interviewApiCallFailed": "采访API调用失败(环境未运行?): {error}", + "interviewApiCallException": "采访API调用异常: {error}", + "interviewAgentsComplete": "InterviewAgents完成: 采访了 {count} 个Agent(双平台)", + "loadedRedditProfiles": "从 reddit_profiles.json 加载了 {count} 个人设", + "readRedditProfilesFailed": "读取 reddit_profiles.json 失败: {error}", + "loadedTwitterProfiles": "从 twitter_profiles.csv 加载了 {count} 个人设", + "readTwitterProfilesFailed": "读取 twitter_profiles.csv 失败: {error}", + "llmSelectAgentFailed": "LLM选择Agent失败,使用默认选择: {error}", + "generateInterviewQuestionsFailed": "生成采访问题失败: {error}", + "generateInterviewSummaryFailed": "生成采访摘要失败: {error}" + } +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..64b5f2fb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,333 @@ +{ + "name": "mirofish", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "mirofish", + "version": "0.1.0", + "license": "AGPL-3.0", + "devDependencies": { + "concurrently": "^9.1.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concurrently": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz", + "integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "4.1.2", + "rxjs": "7.8.2", + "shell-quote": "1.8.3", + "supports-color": "8.1.1", + "tree-kill": "1.2.2", + "yargs": "17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/shell-quote": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", + "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..63ace21a --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "mirofish", + "version": "0.1.0", + "description": "MiroFish - 简洁通用的群体智能引擎,预测万物", + "scripts": { + "setup": "npm install && cd frontend && npm install", + "setup:backend": "cd backend && uv sync", + "setup:all": "npm run setup && npm run setup:backend", + "dev": "concurrently --kill-others -n \"backend,frontend\" -c \"green,cyan\" \"npm run backend\" \"npm run frontend\"", + "backend": "cd backend && uv run python run.py", + "frontend": "cd frontend && npm run dev", + "build": "cd frontend && npm run build" + }, + "devDependencies": { + "concurrently": "^9.1.2" + }, + "engines": { + "node": ">=18.0.0" + }, + "license": "AGPL-3.0" +} diff --git a/static/image/MiroFish_logo.jpeg b/static/image/MiroFish_logo.jpeg new file mode 100644 index 00000000..edf1e2cb Binary files /dev/null and b/static/image/MiroFish_logo.jpeg differ diff --git a/static/image/MiroFish_logo_compressed.jpeg b/static/image/MiroFish_logo_compressed.jpeg new file mode 100644 index 00000000..eb7bd5af Binary files /dev/null and b/static/image/MiroFish_logo_compressed.jpeg differ diff --git a/static/image/QQ群.png b/static/image/QQ群.png new file mode 100644 index 00000000..8f3a54e8 Binary files /dev/null and b/static/image/QQ群.png differ diff --git a/static/image/Screenshot/运行截图1.png b/static/image/Screenshot/运行截图1.png new file mode 100644 index 00000000..46e9bedf Binary files /dev/null and b/static/image/Screenshot/运行截图1.png differ diff --git a/static/image/Screenshot/运行截图2.png b/static/image/Screenshot/运行截图2.png new file mode 100644 index 00000000..852aa456 Binary files /dev/null and b/static/image/Screenshot/运行截图2.png differ diff --git a/static/image/Screenshot/运行截图3.png b/static/image/Screenshot/运行截图3.png new file mode 100644 index 00000000..9911f66e Binary files /dev/null and b/static/image/Screenshot/运行截图3.png differ diff --git a/static/image/Screenshot/运行截图4.png b/static/image/Screenshot/运行截图4.png new file mode 100644 index 00000000..dcc6245b Binary files /dev/null and b/static/image/Screenshot/运行截图4.png differ diff --git a/static/image/Screenshot/运行截图5.png b/static/image/Screenshot/运行截图5.png new file mode 100644 index 00000000..ee1d5ea9 Binary files /dev/null and b/static/image/Screenshot/运行截图5.png differ diff --git a/static/image/Screenshot/运行截图6.png b/static/image/Screenshot/运行截图6.png new file mode 100644 index 00000000..6ef72ec1 Binary files /dev/null and b/static/image/Screenshot/运行截图6.png differ diff --git a/static/image/shanda_logo.png b/static/image/shanda_logo.png new file mode 100644 index 00000000..46582eb7 Binary files /dev/null and b/static/image/shanda_logo.png differ diff --git a/static/image/武大模拟演示封面.png b/static/image/武大模拟演示封面.png new file mode 100644 index 00000000..24126353 Binary files /dev/null and b/static/image/武大模拟演示封面.png differ diff --git a/static/image/红楼梦模拟推演封面.jpg b/static/image/红楼梦模拟推演封面.jpg new file mode 100644 index 00000000..2e5f49c8 Binary files /dev/null and b/static/image/红楼梦模拟推演封面.jpg differ