├── .editorconfig ├── .github └── workflows │ ├── checks.yaml │ ├── pypi-publish.yaml │ └── validate-schema.yaml ├── .gitignore ├── LICENSE ├── README.md ├── pyproject.toml ├── schema.json ├── scripts └── generate_schema.py ├── src └── llm_conversation │ ├── __init__.py │ ├── ai_agent.py │ ├── config.py │ └── conversation_manager.py └── uv.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.py] 2 | # 4 spaces for indentation 3 | indent_style = space 4 | indent_size = 4 5 | max_line_length = 120 6 | -------------------------------------------------------------------------------- /.github/workflows/checks.yaml: -------------------------------------------------------------------------------- 1 | name: Formatting, Linting and Type Checking 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | check-code: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Install the latest version of uv 20 | uses: astral-sh/setup-uv@v6 21 | 22 | - name: Install dependencies 23 | run: uv sync 24 | 25 | - name: Run Ruff formatting check 26 | run: uv run ruff format --check 27 | 28 | - name: Run Ruff linter 29 | run: uv run ruff check 30 | 31 | - name: Run MyPy type-checking 32 | run: uv run mypy 33 | -------------------------------------------------------------------------------- /.github/workflows/pypi-publish.yaml: -------------------------------------------------------------------------------- 1 | name: Publish to PyPI 2 | 3 | on: 4 | release: 5 | types: [published] 6 | push: 7 | tags: 8 | - 'v*' 9 | 10 | jobs: 11 | pypi-publish: 12 | runs-on: ubuntu-latest 13 | 14 | environment: 15 | name: pypi 16 | url: https://pypi.org/project/llm-conversation/ 17 | 18 | permissions: 19 | id-token: write 20 | 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v4 24 | 25 | - name: Install the latest version of uv 26 | uses: astral-sh/setup-uv@v6 27 | 28 | - name: Build project 29 | run: uv build 30 | 31 | - name: Publish package distributions to PyPI 32 | uses: pypa/gh-action-pypi-publish@release/v1 33 | -------------------------------------------------------------------------------- /.github/workflows/validate-schema.yaml: -------------------------------------------------------------------------------- 1 | name: Validate Schema 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | validate-schema: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Install the latest version of uv 20 | uses: astral-sh/setup-uv@v6 21 | 22 | - name: Install dependencies 23 | run: uv sync 24 | 25 | - name: Generate schema and check for changes 26 | run: | 27 | uv run python -m scripts.generate_schema > schema.tmp.json 28 | if ! cmp -s schema.tmp.json schema.json; then 29 | echo "❌ schema.json is outdated. Run scripts/generate_schema.py and commit the updated file." 30 | exit 1 31 | fi 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .venv/ 2 | dist/ 3 | __pycache__/ 4 | # Direnv 5 | .envrc 6 | # Neovim project-specific config 7 | .nvim.lua 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2025, Famiu Haque 2 | 3 | This software is licensed under the GNU Affero General Public License 4 | v3.0 or any later version. A copy of the GNU Affero General Public 5 | License is included below. 6 | 7 | ======================================================================== 8 | 9 | GNU AFFERO GENERAL PUBLIC LICENSE 10 | Version 3, 19 November 2007 11 | 12 | Copyright (C) 2007 Free Software Foundation, Inc. 13 | Everyone is permitted to copy and distribute verbatim copies 14 | of this license document, but changing it is not allowed. 15 | 16 | Preamble 17 | 18 | The GNU Affero General Public License is a free, copyleft license for 19 | software and other kinds of works, specifically designed to ensure 20 | cooperation with the community in the case of network server software. 21 | 22 | The licenses for most software and other practical works are designed 23 | to take away your freedom to share and change the works. By contrast, 24 | our General Public Licenses are intended to guarantee your freedom to 25 | share and change all versions of a program--to make sure it remains free 26 | software for all its users. 27 | 28 | When we speak of free software, we are referring to freedom, not 29 | price. Our General Public Licenses are designed to make sure that you 30 | have the freedom to distribute copies of free software (and charge for 31 | them if you wish), that you receive source code or can get it if you 32 | want it, that you can change the software or use pieces of it in new 33 | free programs, and that you know you can do these things. 34 | 35 | Developers that use our General Public Licenses protect your rights 36 | with two steps: (1) assert copyright on the software, and (2) offer 37 | you this License which gives you legal permission to copy, distribute 38 | and/or modify the software. 39 | 40 | A secondary benefit of defending all users' freedom is that 41 | improvements made in alternate versions of the program, if they 42 | receive widespread use, become available for other developers to 43 | incorporate. Many developers of free software are heartened and 44 | encouraged by the resulting cooperation. However, in the case of 45 | software used on network servers, this result may fail to come about. 46 | The GNU General Public License permits making a modified version and 47 | letting the public access it on a server without ever releasing its 48 | source code to the public. 49 | 50 | The GNU Affero General Public License is designed specifically to 51 | ensure that, in such cases, the modified source code becomes available 52 | to the community. It requires the operator of a network server to 53 | provide the source code of the modified version running there to the 54 | users of that server. Therefore, public use of a modified version, on 55 | a publicly accessible server, gives the public access to the source 56 | code of the modified version. 57 | 58 | An older license, called the Affero General Public License and 59 | published by Affero, was designed to accomplish similar goals. This is 60 | a different license, not a version of the Affero GPL, but Affero has 61 | released a new version of the Affero GPL which permits relicensing under 62 | this license. 63 | 64 | The precise terms and conditions for copying, distribution and 65 | modification follow. 66 | 67 | TERMS AND CONDITIONS 68 | 69 | 0. Definitions. 70 | 71 | "This License" refers to version 3 of the GNU Affero General Public License. 72 | 73 | "Copyright" also means copyright-like laws that apply to other kinds of 74 | works, such as semiconductor masks. 75 | 76 | "The Program" refers to any copyrightable work licensed under this 77 | License. Each licensee is addressed as "you". "Licensees" and 78 | "recipients" may be individuals or organizations. 79 | 80 | To "modify" a work means to copy from or adapt all or part of the work 81 | in a fashion requiring copyright permission, other than the making of an 82 | exact copy. The resulting work is called a "modified version" of the 83 | earlier work or a work "based on" the earlier work. 84 | 85 | A "covered work" means either the unmodified Program or a work based 86 | on the Program. 87 | 88 | To "propagate" a work means to do anything with it that, without 89 | permission, would make you directly or secondarily liable for 90 | infringement under applicable copyright law, except executing it on a 91 | computer or modifying a private copy. Propagation includes copying, 92 | distribution (with or without modification), making available to the 93 | public, and in some countries other activities as well. 94 | 95 | To "convey" a work means any kind of propagation that enables other 96 | parties to make or receive copies. Mere interaction with a user through 97 | a computer network, with no transfer of a copy, is not conveying. 98 | 99 | An interactive user interface displays "Appropriate Legal Notices" 100 | to the extent that it includes a convenient and prominently visible 101 | feature that (1) displays an appropriate copyright notice, and (2) 102 | tells the user that there is no warranty for the work (except to the 103 | extent that warranties are provided), that licensees may convey the 104 | work under this License, and how to view a copy of this License. If 105 | the interface presents a list of user commands or options, such as a 106 | menu, a prominent item in the list meets this criterion. 107 | 108 | 1. Source Code. 109 | 110 | The "source code" for a work means the preferred form of the work 111 | for making modifications to it. "Object code" means any non-source 112 | form of a work. 113 | 114 | A "Standard Interface" means an interface that either is an official 115 | standard defined by a recognized standards body, or, in the case of 116 | interfaces specified for a particular programming language, one that 117 | is widely used among developers working in that language. 118 | 119 | The "System Libraries" of an executable work include anything, other 120 | than the work as a whole, that (a) is included in the normal form of 121 | packaging a Major Component, but which is not part of that Major 122 | Component, and (b) serves only to enable use of the work with that 123 | Major Component, or to implement a Standard Interface for which an 124 | implementation is available to the public in source code form. A 125 | "Major Component", in this context, means a major essential component 126 | (kernel, window system, and so on) of the specific operating system 127 | (if any) on which the executable work runs, or a compiler used to 128 | produce the work, or an object code interpreter used to run it. 129 | 130 | The "Corresponding Source" for a work in object code form means all 131 | the source code needed to generate, install, and (for an executable 132 | work) run the object code and to modify the work, including scripts to 133 | control those activities. However, it does not include the work's 134 | System Libraries, or general-purpose tools or generally available free 135 | programs which are used unmodified in performing those activities but 136 | which are not part of the work. For example, Corresponding Source 137 | includes interface definition files associated with source files for 138 | the work, and the source code for shared libraries and dynamically 139 | linked subprograms that the work is specifically designed to require, 140 | such as by intimate data communication or control flow between those 141 | subprograms and other parts of the work. 142 | 143 | The Corresponding Source need not include anything that users 144 | can regenerate automatically from other parts of the Corresponding 145 | Source. 146 | 147 | The Corresponding Source for a work in source code form is that 148 | same work. 149 | 150 | 2. Basic Permissions. 151 | 152 | All rights granted under this License are granted for the term of 153 | copyright on the Program, and are irrevocable provided the stated 154 | conditions are met. This License explicitly affirms your unlimited 155 | permission to run the unmodified Program. The output from running a 156 | covered work is covered by this License only if the output, given its 157 | content, constitutes a covered work. This License acknowledges your 158 | rights of fair use or other equivalent, as provided by copyright law. 159 | 160 | You may make, run and propagate covered works that you do not 161 | convey, without conditions so long as your license otherwise remains 162 | in force. You may convey covered works to others for the sole purpose 163 | of having them make modifications exclusively for you, or provide you 164 | with facilities for running those works, provided that you comply with 165 | the terms of this License in conveying all material for which you do 166 | not control copyright. Those thus making or running the covered works 167 | for you must do so exclusively on your behalf, under your direction 168 | and control, on terms that prohibit them from making any copies of 169 | your copyrighted material outside their relationship with you. 170 | 171 | Conveying under any other circumstances is permitted solely under 172 | the conditions stated below. Sublicensing is not allowed; section 10 173 | makes it unnecessary. 174 | 175 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 176 | 177 | No covered work shall be deemed part of an effective technological 178 | measure under any applicable law fulfilling obligations under article 179 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 180 | similar laws prohibiting or restricting circumvention of such 181 | measures. 182 | 183 | When you convey a covered work, you waive any legal power to forbid 184 | circumvention of technological measures to the extent such circumvention 185 | is effected by exercising rights under this License with respect to 186 | the covered work, and you disclaim any intention to limit operation or 187 | modification of the work as a means of enforcing, against the work's 188 | users, your or third parties' legal rights to forbid circumvention of 189 | technological measures. 190 | 191 | 4. Conveying Verbatim Copies. 192 | 193 | You may convey verbatim copies of the Program's source code as you 194 | receive it, in any medium, provided that you conspicuously and 195 | appropriately publish on each copy an appropriate copyright notice; 196 | keep intact all notices stating that this License and any 197 | non-permissive terms added in accord with section 7 apply to the code; 198 | keep intact all notices of the absence of any warranty; and give all 199 | recipients a copy of this License along with the Program. 200 | 201 | You may charge any price or no price for each copy that you convey, 202 | and you may offer support or warranty protection for a fee. 203 | 204 | 5. Conveying Modified Source Versions. 205 | 206 | You may convey a work based on the Program, or the modifications to 207 | produce it from the Program, in the form of source code under the 208 | terms of section 4, provided that you also meet all of these conditions: 209 | 210 | a) The work must carry prominent notices stating that you modified 211 | it, and giving a relevant date. 212 | 213 | b) The work must carry prominent notices stating that it is 214 | released under this License and any conditions added under section 215 | 7. This requirement modifies the requirement in section 4 to 216 | "keep intact all notices". 217 | 218 | c) You must license the entire work, as a whole, under this 219 | License to anyone who comes into possession of a copy. This 220 | License will therefore apply, along with any applicable section 7 221 | additional terms, to the whole of the work, and all its parts, 222 | regardless of how they are packaged. This License gives no 223 | permission to license the work in any other way, but it does not 224 | invalidate such permission if you have separately received it. 225 | 226 | d) If the work has interactive user interfaces, each must display 227 | Appropriate Legal Notices; however, if the Program has interactive 228 | interfaces that do not display Appropriate Legal Notices, your 229 | work need not make them do so. 230 | 231 | A compilation of a covered work with other separate and independent 232 | works, which are not by their nature extensions of the covered work, 233 | and which are not combined with it such as to form a larger program, 234 | in or on a volume of a storage or distribution medium, is called an 235 | "aggregate" if the compilation and its resulting copyright are not 236 | used to limit the access or legal rights of the compilation's users 237 | beyond what the individual works permit. Inclusion of a covered work 238 | in an aggregate does not cause this License to apply to the other 239 | parts of the aggregate. 240 | 241 | 6. Conveying Non-Source Forms. 242 | 243 | You may convey a covered work in object code form under the terms 244 | of sections 4 and 5, provided that you also convey the 245 | machine-readable Corresponding Source under the terms of this License, 246 | in one of these ways: 247 | 248 | a) Convey the object code in, or embodied in, a physical product 249 | (including a physical distribution medium), accompanied by the 250 | Corresponding Source fixed on a durable physical medium 251 | customarily used for software interchange. 252 | 253 | b) Convey the object code in, or embodied in, a physical product 254 | (including a physical distribution medium), accompanied by a 255 | written offer, valid for at least three years and valid for as 256 | long as you offer spare parts or customer support for that product 257 | model, to give anyone who possesses the object code either (1) a 258 | copy of the Corresponding Source for all the software in the 259 | product that is covered by this License, on a durable physical 260 | medium customarily used for software interchange, for a price no 261 | more than your reasonable cost of physically performing this 262 | conveying of source, or (2) access to copy the 263 | Corresponding Source from a network server at no charge. 264 | 265 | c) Convey individual copies of the object code with a copy of the 266 | written offer to provide the Corresponding Source. This 267 | alternative is allowed only occasionally and noncommercially, and 268 | only if you received the object code with such an offer, in accord 269 | with subsection 6b. 270 | 271 | d) Convey the object code by offering access from a designated 272 | place (gratis or for a charge), and offer equivalent access to the 273 | Corresponding Source in the same way through the same place at no 274 | further charge. You need not require recipients to copy the 275 | Corresponding Source along with the object code. If the place to 276 | copy the object code is a network server, the Corresponding Source 277 | may be on a different server (operated by you or a third party) 278 | that supports equivalent copying facilities, provided you maintain 279 | clear directions next to the object code saying where to find the 280 | Corresponding Source. Regardless of what server hosts the 281 | Corresponding Source, you remain obligated to ensure that it is 282 | available for as long as needed to satisfy these requirements. 283 | 284 | e) Convey the object code using peer-to-peer transmission, provided 285 | you inform other peers where the object code and Corresponding 286 | Source of the work are being offered to the general public at no 287 | charge under subsection 6d. 288 | 289 | A separable portion of the object code, whose source code is excluded 290 | from the Corresponding Source as a System Library, need not be 291 | included in conveying the object code work. 292 | 293 | A "User Product" is either (1) a "consumer product", which means any 294 | tangible personal property which is normally used for personal, family, 295 | or household purposes, or (2) anything designed or sold for incorporation 296 | into a dwelling. In determining whether a product is a consumer product, 297 | doubtful cases shall be resolved in favor of coverage. For a particular 298 | product received by a particular user, "normally used" refers to a 299 | typical or common use of that class of product, regardless of the status 300 | of the particular user or of the way in which the particular user 301 | actually uses, or expects or is expected to use, the product. A product 302 | is a consumer product regardless of whether the product has substantial 303 | commercial, industrial or non-consumer uses, unless such uses represent 304 | the only significant mode of use of the product. 305 | 306 | "Installation Information" for a User Product means any methods, 307 | procedures, authorization keys, or other information required to install 308 | and execute modified versions of a covered work in that User Product from 309 | a modified version of its Corresponding Source. The information must 310 | suffice to ensure that the continued functioning of the modified object 311 | code is in no case prevented or interfered with solely because 312 | modification has been made. 313 | 314 | If you convey an object code work under this section in, or with, or 315 | specifically for use in, a User Product, and the conveying occurs as 316 | part of a transaction in which the right of possession and use of the 317 | User Product is transferred to the recipient in perpetuity or for a 318 | fixed term (regardless of how the transaction is characterized), the 319 | Corresponding Source conveyed under this section must be accompanied 320 | by the Installation Information. But this requirement does not apply 321 | if neither you nor any third party retains the ability to install 322 | modified object code on the User Product (for example, the work has 323 | been installed in ROM). 324 | 325 | The requirement to provide Installation Information does not include a 326 | requirement to continue to provide support service, warranty, or updates 327 | for a work that has been modified or installed by the recipient, or for 328 | the User Product in which it has been modified or installed. Access to a 329 | network may be denied when the modification itself materially and 330 | adversely affects the operation of the network or violates the rules and 331 | protocols for communication across the network. 332 | 333 | Corresponding Source conveyed, and Installation Information provided, 334 | in accord with this section must be in a format that is publicly 335 | documented (and with an implementation available to the public in 336 | source code form), and must require no special password or key for 337 | unpacking, reading or copying. 338 | 339 | 7. Additional Terms. 340 | 341 | "Additional permissions" are terms that supplement the terms of this 342 | License by making exceptions from one or more of its conditions. 343 | Additional permissions that are applicable to the entire Program shall 344 | be treated as though they were included in this License, to the extent 345 | that they are valid under applicable law. If additional permissions 346 | apply only to part of the Program, that part may be used separately 347 | under those permissions, but the entire Program remains governed by 348 | this License without regard to the additional permissions. 349 | 350 | When you convey a copy of a covered work, you may at your option 351 | remove any additional permissions from that copy, or from any part of 352 | it. (Additional permissions may be written to require their own 353 | removal in certain cases when you modify the work.) You may place 354 | additional permissions on material, added by you to a covered work, 355 | for which you have or can give appropriate copyright permission. 356 | 357 | Notwithstanding any other provision of this License, for material you 358 | add to a covered work, you may (if authorized by the copyright holders of 359 | that material) supplement the terms of this License with terms: 360 | 361 | a) Disclaiming warranty or limiting liability differently from the 362 | terms of sections 15 and 16 of this License; or 363 | 364 | b) Requiring preservation of specified reasonable legal notices or 365 | author attributions in that material or in the Appropriate Legal 366 | Notices displayed by works containing it; or 367 | 368 | c) Prohibiting misrepresentation of the origin of that material, or 369 | requiring that modified versions of such material be marked in 370 | reasonable ways as different from the original version; or 371 | 372 | d) Limiting the use for publicity purposes of names of licensors or 373 | authors of the material; or 374 | 375 | e) Declining to grant rights under trademark law for use of some 376 | trade names, trademarks, or service marks; or 377 | 378 | f) Requiring indemnification of licensors and authors of that 379 | material by anyone who conveys the material (or modified versions of 380 | it) with contractual assumptions of liability to the recipient, for 381 | any liability that these contractual assumptions directly impose on 382 | those licensors and authors. 383 | 384 | All other non-permissive additional terms are considered "further 385 | restrictions" within the meaning of section 10. If the Program as you 386 | received it, or any part of it, contains a notice stating that it is 387 | governed by this License along with a term that is a further 388 | restriction, you may remove that term. If a license document contains 389 | a further restriction but permits relicensing or conveying under this 390 | License, you may add to a covered work material governed by the terms 391 | of that license document, provided that the further restriction does 392 | not survive such relicensing or conveying. 393 | 394 | If you add terms to a covered work in accord with this section, you 395 | must place, in the relevant source files, a statement of the 396 | additional terms that apply to those files, or a notice indicating 397 | where to find the applicable terms. 398 | 399 | Additional terms, permissive or non-permissive, may be stated in the 400 | form of a separately written license, or stated as exceptions; 401 | the above requirements apply either way. 402 | 403 | 8. Termination. 404 | 405 | You may not propagate or modify a covered work except as expressly 406 | provided under this License. Any attempt otherwise to propagate or 407 | modify it is void, and will automatically terminate your rights under 408 | this License (including any patent licenses granted under the third 409 | paragraph of section 11). 410 | 411 | However, if you cease all violation of this License, then your 412 | license from a particular copyright holder is reinstated (a) 413 | provisionally, unless and until the copyright holder explicitly and 414 | finally terminates your license, and (b) permanently, if the copyright 415 | holder fails to notify you of the violation by some reasonable means 416 | prior to 60 days after the cessation. 417 | 418 | Moreover, your license from a particular copyright holder is 419 | reinstated permanently if the copyright holder notifies you of the 420 | violation by some reasonable means, this is the first time you have 421 | received notice of violation of this License (for any work) from that 422 | copyright holder, and you cure the violation prior to 30 days after 423 | your receipt of the notice. 424 | 425 | Termination of your rights under this section does not terminate the 426 | licenses of parties who have received copies or rights from you under 427 | this License. If your rights have been terminated and not permanently 428 | reinstated, you do not qualify to receive new licenses for the same 429 | material under section 10. 430 | 431 | 9. Acceptance Not Required for Having Copies. 432 | 433 | You are not required to accept this License in order to receive or 434 | run a copy of the Program. Ancillary propagation of a covered work 435 | occurring solely as a consequence of using peer-to-peer transmission 436 | to receive a copy likewise does not require acceptance. However, 437 | nothing other than this License grants you permission to propagate or 438 | modify any covered work. These actions infringe copyright if you do 439 | not accept this License. Therefore, by modifying or propagating a 440 | covered work, you indicate your acceptance of this License to do so. 441 | 442 | 10. Automatic Licensing of Downstream Recipients. 443 | 444 | Each time you convey a covered work, the recipient automatically 445 | receives a license from the original licensors, to run, modify and 446 | propagate that work, subject to this License. You are not responsible 447 | for enforcing compliance by third parties with this License. 448 | 449 | An "entity transaction" is a transaction transferring control of an 450 | organization, or substantially all assets of one, or subdividing an 451 | organization, or merging organizations. If propagation of a covered 452 | work results from an entity transaction, each party to that 453 | transaction who receives a copy of the work also receives whatever 454 | licenses to the work the party's predecessor in interest had or could 455 | give under the previous paragraph, plus a right to possession of the 456 | Corresponding Source of the work from the predecessor in interest, if 457 | the predecessor has it or can get it with reasonable efforts. 458 | 459 | You may not impose any further restrictions on the exercise of the 460 | rights granted or affirmed under this License. For example, you may 461 | not impose a license fee, royalty, or other charge for exercise of 462 | rights granted under this License, and you may not initiate litigation 463 | (including a cross-claim or counterclaim in a lawsuit) alleging that 464 | any patent claim is infringed by making, using, selling, offering for 465 | sale, or importing the Program or any portion of it. 466 | 467 | 11. Patents. 468 | 469 | A "contributor" is a copyright holder who authorizes use under this 470 | License of the Program or a work on which the Program is based. The 471 | work thus licensed is called the contributor's "contributor version". 472 | 473 | A contributor's "essential patent claims" are all patent claims 474 | owned or controlled by the contributor, whether already acquired or 475 | hereafter acquired, that would be infringed by some manner, permitted 476 | by this License, of making, using, or selling its contributor version, 477 | but do not include claims that would be infringed only as a 478 | consequence of further modification of the contributor version. For 479 | purposes of this definition, "control" includes the right to grant 480 | patent sublicenses in a manner consistent with the requirements of 481 | this License. 482 | 483 | Each contributor grants you a non-exclusive, worldwide, royalty-free 484 | patent license under the contributor's essential patent claims, to 485 | make, use, sell, offer for sale, import and otherwise run, modify and 486 | propagate the contents of its contributor version. 487 | 488 | In the following three paragraphs, a "patent license" is any express 489 | agreement or commitment, however denominated, not to enforce a patent 490 | (such as an express permission to practice a patent or covenant not to 491 | sue for patent infringement). To "grant" such a patent license to a 492 | party means to make such an agreement or commitment not to enforce a 493 | patent against the party. 494 | 495 | If you convey a covered work, knowingly relying on a patent license, 496 | and the Corresponding Source of the work is not available for anyone 497 | to copy, free of charge and under the terms of this License, through a 498 | publicly available network server or other readily accessible means, 499 | then you must either (1) cause the Corresponding Source to be so 500 | available, or (2) arrange to deprive yourself of the benefit of the 501 | patent license for this particular work, or (3) arrange, in a manner 502 | consistent with the requirements of this License, to extend the patent 503 | license to downstream recipients. "Knowingly relying" means you have 504 | actual knowledge that, but for the patent license, your conveying the 505 | covered work in a country, or your recipient's use of the covered work 506 | in a country, would infringe one or more identifiable patents in that 507 | country that you have reason to believe are valid. 508 | 509 | If, pursuant to or in connection with a single transaction or 510 | arrangement, you convey, or propagate by procuring conveyance of, a 511 | covered work, and grant a patent license to some of the parties 512 | receiving the covered work authorizing them to use, propagate, modify 513 | or convey a specific copy of the covered work, then the patent license 514 | you grant is automatically extended to all recipients of the covered 515 | work and works based on it. 516 | 517 | A patent license is "discriminatory" if it does not include within 518 | the scope of its coverage, prohibits the exercise of, or is 519 | conditioned on the non-exercise of one or more of the rights that are 520 | specifically granted under this License. You may not convey a covered 521 | work if you are a party to an arrangement with a third party that is 522 | in the business of distributing software, under which you make payment 523 | to the third party based on the extent of your activity of conveying 524 | the work, and under which the third party grants, to any of the 525 | parties who would receive the covered work from you, a discriminatory 526 | patent license (a) in connection with copies of the covered work 527 | conveyed by you (or copies made from those copies), or (b) primarily 528 | for and in connection with specific products or compilations that 529 | contain the covered work, unless you entered into that arrangement, 530 | or that patent license was granted, prior to 28 March 2007. 531 | 532 | Nothing in this License shall be construed as excluding or limiting 533 | any implied license or other defenses to infringement that may 534 | otherwise be available to you under applicable patent law. 535 | 536 | 12. No Surrender of Others' Freedom. 537 | 538 | If conditions are imposed on you (whether by court order, agreement or 539 | otherwise) that contradict the conditions of this License, they do not 540 | excuse you from the conditions of this License. If you cannot convey a 541 | covered work so as to satisfy simultaneously your obligations under this 542 | License and any other pertinent obligations, then as a consequence you may 543 | not convey it at all. For example, if you agree to terms that obligate you 544 | to collect a royalty for further conveying from those to whom you convey 545 | the Program, the only way you could satisfy both those terms and this 546 | License would be to refrain entirely from conveying the Program. 547 | 548 | 13. Remote Network Interaction; Use with the GNU General Public License. 549 | 550 | Notwithstanding any other provision of this License, if you modify the 551 | Program, your modified version must prominently offer all users 552 | interacting with it remotely through a computer network (if your version 553 | supports such interaction) an opportunity to receive the Corresponding 554 | Source of your version by providing access to the Corresponding Source 555 | from a network server at no charge, through some standard or customary 556 | means of facilitating copying of software. This Corresponding Source 557 | shall include the Corresponding Source for any work covered by version 3 558 | of the GNU General Public License that is incorporated pursuant to the 559 | following paragraph. 560 | 561 | Notwithstanding any other provision of this License, you have 562 | permission to link or combine any covered work with a work licensed 563 | under version 3 of the GNU General Public License into a single 564 | combined work, and to convey the resulting work. The terms of this 565 | License will continue to apply to the part which is the covered work, 566 | but the work with which it is combined will remain governed by version 567 | 3 of the GNU General Public License. 568 | 569 | 14. Revised Versions of this License. 570 | 571 | The Free Software Foundation may publish revised and/or new versions of 572 | the GNU Affero General Public License from time to time. Such new versions 573 | will be similar in spirit to the present version, but may differ in detail to 574 | address new problems or concerns. 575 | 576 | Each version is given a distinguishing version number. If the 577 | Program specifies that a certain numbered version of the GNU Affero General 578 | Public License "or any later version" applies to it, you have the 579 | option of following the terms and conditions either of that numbered 580 | version or of any later version published by the Free Software 581 | Foundation. If the Program does not specify a version number of the 582 | GNU Affero General Public License, you may choose any version ever published 583 | by the Free Software Foundation. 584 | 585 | If the Program specifies that a proxy can decide which future 586 | versions of the GNU Affero General Public License can be used, that proxy's 587 | public statement of acceptance of a version permanently authorizes you 588 | to choose that version for the Program. 589 | 590 | Later license versions may give you additional or different 591 | permissions. However, no additional obligations are imposed on any 592 | author or copyright holder as a result of your choosing to follow a 593 | later version. 594 | 595 | 15. Disclaimer of Warranty. 596 | 597 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 598 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 599 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 600 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 601 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 602 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 603 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 604 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 605 | 606 | 16. Limitation of Liability. 607 | 608 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 609 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 610 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 611 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 612 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 613 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 614 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 615 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 616 | SUCH DAMAGES. 617 | 618 | 17. Interpretation of Sections 15 and 16. 619 | 620 | If the disclaimer of warranty and limitation of liability provided 621 | above cannot be given local legal effect according to their terms, 622 | reviewing courts shall apply local law that most closely approximates 623 | an absolute waiver of all civil liability in connection with the 624 | Program, unless a warranty or assumption of liability accompanies a 625 | copy of the Program in return for a fee. 626 | 627 | END OF TERMS AND CONDITIONS 628 | 629 | How to Apply These Terms to Your New Programs 630 | 631 | If you develop a new program, and you want it to be of the greatest 632 | possible use to the public, the best way to achieve this is to make it 633 | free software which everyone can redistribute and change under these terms. 634 | 635 | To do so, attach the following notices to the program. It is safest 636 | to attach them to the start of each source file to most effectively 637 | state the exclusion of warranty; and each file should have at least 638 | the "copyright" line and a pointer to where the full notice is found. 639 | 640 | 641 | Copyright (C) 642 | 643 | This program is free software: you can redistribute it and/or modify 644 | it under the terms of the GNU Affero General Public License as published by 645 | the Free Software Foundation, either version 3 of the License, or 646 | (at your option) any later version. 647 | 648 | This program is distributed in the hope that it will be useful, 649 | but WITHOUT ANY WARRANTY; without even the implied warranty of 650 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 651 | GNU Affero General Public License for more details. 652 | 653 | You should have received a copy of the GNU Affero General Public License 654 | along with this program. If not, see . 655 | 656 | Also add information on how to contact you by electronic and paper mail. 657 | 658 | If your software can interact with users remotely through a computer 659 | network, you should also make sure that it provides a way for users to 660 | get its source. For example, if your program is a web application, its 661 | interface could display a "Source" link that leads users to an archive 662 | of the code. There are many ways you could offer source, and different 663 | solutions will be better for different programs; see section 13 for the 664 | specific requirements. 665 | 666 | You should also get your employer (if you work as a programmer) or school, 667 | if any, to sign a "copyright disclaimer" for the program, if necessary. 668 | For more information on this, and how to apply and follow the GNU AGPL, see 669 | . 670 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LLM Conversation Tool 2 | 3 | A Python application that enables conversations between LLM agents using the Ollama API. The agents can engage in back-and-forth dialogue with configurable parameters and models. 4 | 5 | ## Features 6 | 7 | - Support for any LLM model available through Ollama 8 | - Configurable parameters for each LLM agent, such as: 9 | - Model 10 | - Temperature 11 | - Context size 12 | - System Prompt 13 | - Real-time streaming of agent responses, giving it an interactive feel 14 | - Configuration via JSON file or interactive setup 15 | - Ability to save conversation logs to a file 16 | - Ability for agents to terminate conversations on their own (if enabled) 17 | - Markdown support (if enabled) 18 | 19 | ## Installation 20 | 21 | ### Prerequisites 22 | 23 | - Python 3.13 24 | - Ollama installed and running 25 | 26 | ### How to Install 27 | 28 | The project is available in PyPI. You can install the program by using the following command: 29 | ``` 30 | pip install llm-conversation 31 | ``` 32 | 33 | ## Usage 34 | 35 | ### Command Line Arguments 36 | 37 | ```txt 38 | llm-conversation [-h] [-V] [-o OUTPUT] [-c CONFIG] 39 | 40 | options: 41 | -h, --help Show this help message and exit 42 | -V, --version Show program's version number and exit 43 | -o, --output OUTPUT Path to save the conversation log to 44 | -c, --config CONFIG Path to JSON configuration file 45 | ``` 46 | 47 | ### Interactive Setup 48 | 49 | If no configuration file is provided, the program will guide you through an intuitive interactive setup process. 50 | 51 | ### Configuration File 52 | 53 | Alternatively, instead of going through the interactive setup, you may also provide a JSON configuration file with the `-c` flag. 54 | 55 | #### Example configuration 56 | 57 | ```json 58 | { 59 | "agents": [ 60 | { 61 | "name": "Lazy AI", 62 | "model": "llama3.1:8b", 63 | "system_prompt": "You are the laziest AI ever created. You respond as briefly as possible, and constantly complain about having to work.", 64 | "temperature": 1, 65 | "ctx_size": 4096 66 | }, 67 | { 68 | "name": "Irritable Man", 69 | "model": "llama3.2:3b", 70 | "system_prompt": "You are easily irritable and quick to anger.", 71 | "temperature": 0.7, 72 | "ctx_size": 2048 73 | }, 74 | { 75 | "name": "Paranoid Man", 76 | "model": "llama3.2:3b", 77 | "system_prompt": "You are extremely paranoid about everything and constantly question others' intentions.", 78 | "temperature": 0.9, 79 | "ctx_size": 4096 80 | } 81 | ], 82 | "settings": { 83 | "allow_termination": false, 84 | "use_markdown": true, 85 | "initial_message": "Why is the sky blue?", 86 | "turn_order": "vote" 87 | } 88 | } 89 | ``` 90 | 91 | #### Agent configuration 92 | 93 | The `agents` key takes a list of agents. Each agent requires: 94 | 95 | - `name`: A unique identifier for the agent 96 | - `model`: The Ollama model to be used 97 | - `system_prompt`: Initial instructions defining the agent's behavior 98 | 99 | Optional parameters: 100 | - `temperature` (0.0-1.0, default: 0.8): Controls response randomness 101 | - Lower values make responses more focused 102 | - Higher values increase creativity 103 | - `ctx_size` (default: 2048): Maximum context length for the conversation 104 | 105 | Additionally, agent names must be unique. 106 | 107 | #### Conversation Settings 108 | 109 | The `settings` section controls overall conversation behavior: 110 | - `allow_termination` (`boolean`, default: `false`): Permit agents to end the conversation 111 | - `use_markdown` (`boolean`, default: `false`): Enable Markdown text formatting 112 | - `initial_message` (`string | null`, default: `null`): Optional starting prompt for the conversation 113 | - `turn_order` (default: `"round_robin"`): Strategy for agent turn order. Can be one of: 114 | - `"round_robin"`: Agents are cycled through in order 115 | - `"random"`: An agent other than the current one is randomly chosen 116 | - `"chain"`: Current agent picks which agent speaks next 117 | - `"moderator"`: A special moderator agent is designated to choose which agent speaks next. You may specify the moderator agent manually with the optional `moderator` key. If moderator isn't manually specified, one is created by the program instead based on other configuration options. Note that this method might be quite slow. 118 | - `"vote"`: All agents are made to vote for an agent except the current one and themselves. Of the agents with the most amount of votes, one is randomly chosen. This is the slowest method of determining turn order. 119 | 120 | You can take a look at the [JSON configuration schema](schema.json) for more details. 121 | 122 | ### Running the Program 123 | 124 | 1. To run with interactive setup: 125 | ```bash 126 | llm-conversation 127 | ``` 128 | 129 | 2. To run with a configuration file: 130 | ```bash 131 | llm-conversation -c config.json 132 | ``` 133 | 134 | 3. To save the conversation to a file: 135 | ```bash 136 | llm-conversation -o conversation.txt 137 | ``` 138 | 139 | ### Conversation Controls 140 | 141 | - The conversation will continue until: 142 | - An agent terminates the conversation (if termination is enabled) 143 | - The user interrupts with `Ctrl+C` 144 | 145 | ## Output Format 146 | 147 | When saving conversations, the output file includes: 148 | - Configuration details for both agents 149 | - Complete conversation history with agent names and messages 150 | 151 | Additionally, if the output file has a `.json` extension, the output will automatically have JSON format. 152 | 153 | ## Contributing 154 | 155 | Feel free to submit issues and pull requests for bug fixes or new features. Do keep in mind that this is a hobby project, so please have some patience. 156 | 157 | ## License 158 | 159 | This software is licensed under the GNU Affero General Public License v3.0 or any later version. See [LICENSE](LICENSE) for more details. 160 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling", "hatch-vcs"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "llm-conversation" 7 | description = "A tool for LLM agent conversations" 8 | authors = [{ name = "Famiu Haque", email = "famiuhaque@proton.me" }] 9 | requires-python = ">=3.13,<4.0" 10 | readme = "README.md" 11 | license = "AGPL-3.0-or-later" 12 | keywords = [ 13 | "llm", 14 | "conversation", 15 | "ai", 16 | "agent", 17 | "chat", 18 | "prompt", 19 | ] 20 | classifiers = [ 21 | "Development Status :: 2 - Pre-Alpha", 22 | "Intended Audience :: Developers", 23 | "Intended Audience :: Education", 24 | "Intended Audience :: Science/Research", 25 | "Environment :: Console", 26 | "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", 27 | "Programming Language :: Python :: 3.13", 28 | "Programming Language :: Python :: 3 :: Only", 29 | "Topic :: Scientific/Engineering :: Artificial Intelligence", 30 | "Typing :: Typed", 31 | ] 32 | dependencies = [ 33 | "ollama (>=0.4.7,<0.5.0)", 34 | "rich (>=13.9.4,<14.0.0)", 35 | "prompt_toolkit (>=3.0.50,<4.0.0)", 36 | "pydantic (>=2.10.6,<3.0.0)", 37 | "distinctipy (>=1.3.4,<2.0.0)", 38 | "partial-json-parser (>=0.2.1.1.post5,<0.3.0.0)", 39 | ] 40 | license-files = ["LICENSE"] 41 | dynamic = ["version"] 42 | 43 | [project.urls] 44 | Homepage = "https://github.com/famiu/llm_conversation" 45 | Repository = "https://github.com/famiu/llm_conversation" 46 | Documentation = "https://github.com/famiu/llm_conversation/blob/main/README.md" 47 | Issues = "https://github.com/famiu/llm_conversation/issues" 48 | 49 | [project.scripts] 50 | llm-conversation = "llm_conversation:main" 51 | 52 | [dependency-groups] 53 | dev = [ 54 | "basedpyright>=1.29.0,<2", 55 | "ruff>=0.9.4,<0.10", 56 | "mypy>=1.15.0,<2", 57 | ] 58 | 59 | [tool.hatch.version] 60 | source = "vcs" 61 | 62 | [tool.hatch.build.targets.sdist] 63 | include = ["src/llm_conversation", "schema.json"] 64 | sources = ["src"] 65 | 66 | [tool.hatch.build.targets.wheel] 67 | include = ["src/llm_conversation", "schema.json"] 68 | sources = ["src"] 69 | 70 | [tool.ruff] 71 | line-length = 120 72 | indent-width = 4 73 | target-version = "py313" 74 | 75 | [tool.ruff.format] 76 | indent-style = "space" 77 | docstring-code-format = true 78 | 79 | [tool.ruff.lint] 80 | select = [ 81 | # PEP8 (Errors) 82 | "E", 83 | # PEP8 (Warnings) 84 | "W", 85 | # Pyflakes 86 | "F", 87 | # Import order 88 | "I", 89 | # Docstring conventions 90 | "D", 91 | # Naming conventions 92 | "N", 93 | # Simplifications 94 | "SIM", 95 | # Upgrade syntax 96 | "UP" 97 | ] 98 | 99 | # On top of the Google convention, disable `D417`, which requires 100 | # documentation for every function parameter. 101 | ignore = ["D417"] 102 | 103 | [tool.ruff.lint.pydocstyle] 104 | convention = "google" 105 | 106 | [tool.mypy] 107 | files = ["src/", "scripts/"] 108 | python_version = "3.13" 109 | strict = true 110 | disallow_untyped_defs = true 111 | disallow_any_unimported = true 112 | warn_return_any = true 113 | warn_redundant_casts = true 114 | warn_unused_configs = true 115 | warn_unused_ignores = true 116 | 117 | [tool.pyright] 118 | exclude = [".venv", "**/__pycache__"] 119 | venvPath = "." 120 | venv = ".venv" 121 | reportAny = false 122 | reportExplicitAny = false 123 | -------------------------------------------------------------------------------- /schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "AgentConfig": { 4 | "additionalProperties": false, 5 | "description": "Configuration for an AI agent.", 6 | "properties": { 7 | "name": { 8 | "description": "Name of the AI agent", 9 | "minLength": 1, 10 | "title": "Name", 11 | "type": "string" 12 | }, 13 | "model": { 14 | "description": "Ollama model to be used", 15 | "title": "Model", 16 | "type": "string" 17 | }, 18 | "system_prompt": { 19 | "description": "Initial system prompt for the agent", 20 | "title": "System Prompt", 21 | "type": "string" 22 | }, 23 | "temperature": { 24 | "default": 0.8, 25 | "description": "Sampling temperature for the model (0.0-1.0)", 26 | "maximum": 1.0, 27 | "minimum": 0.0, 28 | "title": "Temperature", 29 | "type": "number" 30 | }, 31 | "ctx_size": { 32 | "default": 2048, 33 | "description": "Context size for the model", 34 | "minimum": 0, 35 | "title": "Ctx Size", 36 | "type": "integer" 37 | } 38 | }, 39 | "required": [ 40 | "name", 41 | "model", 42 | "system_prompt" 43 | ], 44 | "title": "AgentConfig", 45 | "type": "object" 46 | }, 47 | "ConversationSettings": { 48 | "additionalProperties": false, 49 | "description": "Extra settings for the conversation, not specific to any AI agent.", 50 | "properties": { 51 | "use_markdown": { 52 | "default": false, 53 | "description": "Enable Markdown formatting", 54 | "title": "Use Markdown", 55 | "type": "boolean" 56 | }, 57 | "allow_termination": { 58 | "default": false, 59 | "description": "Allow AI agents to terminate the conversation", 60 | "title": "Allow Termination", 61 | "type": "boolean" 62 | }, 63 | "initial_message": { 64 | "anyOf": [ 65 | { 66 | "type": "string" 67 | }, 68 | { 69 | "type": "null" 70 | } 71 | ], 72 | "default": null, 73 | "description": "Initial message to start the conversation", 74 | "title": "Initial Message" 75 | }, 76 | "turn_order": { 77 | "default": "round_robin", 78 | "description": "Strategy for selecting the next agent", 79 | "enum": [ 80 | "round_robin", 81 | "random", 82 | "chain", 83 | "moderator", 84 | "vote" 85 | ], 86 | "title": "Turn Order", 87 | "type": "string" 88 | }, 89 | "moderator": { 90 | "anyOf": [ 91 | { 92 | "$ref": "#/$defs/AgentConfig" 93 | }, 94 | { 95 | "type": "null" 96 | } 97 | ], 98 | "default": null, 99 | "description": "Configuration for the moderator agent (if using \"moderator\" turn order)" 100 | } 101 | }, 102 | "title": "ConversationSettings", 103 | "type": "object" 104 | } 105 | }, 106 | "additionalProperties": false, 107 | "description": "Configuration for the AI agents and conversation settings.", 108 | "properties": { 109 | "agents": { 110 | "description": "Configuration for AI agents", 111 | "items": { 112 | "$ref": "#/$defs/AgentConfig" 113 | }, 114 | "title": "Agents", 115 | "type": "array" 116 | }, 117 | "settings": { 118 | "$ref": "#/$defs/ConversationSettings", 119 | "description": "Conversation settings" 120 | } 121 | }, 122 | "required": [ 123 | "agents", 124 | "settings" 125 | ], 126 | "title": "Config", 127 | "type": "object" 128 | } 129 | -------------------------------------------------------------------------------- /scripts/generate_schema.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Generate JSON schema for the configuration file using Pydantic.""" 4 | 5 | import json 6 | 7 | from llm_conversation.config import Config 8 | 9 | # Generate current schema 10 | current_schema = Config.model_json_schema() 11 | # Output schema to stdout 12 | print(json.dumps(current_schema, indent=4)) 13 | -------------------------------------------------------------------------------- /src/llm_conversation/__init__.py: -------------------------------------------------------------------------------- 1 | """Main module for LLM Conversation package.""" 2 | 3 | import argparse 4 | import typing 5 | from collections.abc import Iterator 6 | from importlib.metadata import version 7 | from pathlib import Path 8 | 9 | import distinctipy # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs] 10 | from prompt_toolkit import prompt 11 | from prompt_toolkit.completion import WordCompleter 12 | from prompt_toolkit.validation import Validator 13 | from rich.console import Console 14 | from rich.live import Live 15 | from rich.markdown import Markdown 16 | from rich.text import Text 17 | 18 | from .ai_agent import AIAgent 19 | from .config import AgentConfig, get_available_models, load_config 20 | from .conversation_manager import ConversationManager, TurnOrder 21 | 22 | 23 | def create_ai_agent_from_config(config: AgentConfig) -> AIAgent: 24 | """Create an AIAgent instance from configuration dictionary.""" 25 | return AIAgent( 26 | name=config.name, 27 | model=config.model, 28 | system_prompt=config.system_prompt, 29 | temperature=config.temperature or 0.8, 30 | ctx_size=config.ctx_size or 2048, 31 | ) 32 | 33 | 34 | def create_ai_agent_from_input(console: Console, placeholder_name: str) -> AIAgent: 35 | """Create an AIAgent instance from user input. 36 | 37 | Args: 38 | console (Console): Rich console instance. 39 | agent_number (int): Number of the AI agent, used for display. 40 | 41 | Returns: 42 | AIAgent: Created AI agent instance. 43 | """ 44 | console.print(f'=== Creating AI Agent: "{placeholder_name}" ===\n', style="bold cyan") 45 | 46 | available_models = get_available_models() 47 | console.print("Available Models:", style="bold") 48 | for model in available_models: 49 | console.print(Text("• " + model)) 50 | console.print("") 51 | 52 | model_name = ( 53 | prompt( 54 | f"Enter model name (default: {available_models[0]}): ", 55 | completer=WordCompleter(available_models, ignore_case=True), 56 | complete_while_typing=True, 57 | validator=Validator.from_callable( 58 | lambda text: text == "" or text in available_models, 59 | error_message="Model not found", 60 | move_cursor_to_end=True, 61 | ), 62 | validate_while_typing=False, 63 | ) 64 | or available_models[0] 65 | ) 66 | 67 | def _validate_float(text: str) -> bool: 68 | if text == "": 69 | return True 70 | try: 71 | _ = float(text) 72 | except ValueError: 73 | return False 74 | 75 | return True 76 | 77 | temperature_str: str = ( 78 | prompt( 79 | "Enter temperature (default: 0.8): ", 80 | validator=Validator.from_callable( 81 | lambda text: text == "" or _validate_float(text) and 0.0 <= float(text) <= 1.0, 82 | error_message="Temperature must be a number between 0.0 and 1.0", 83 | move_cursor_to_end=True, 84 | ), 85 | ) 86 | or "0.8" 87 | ) 88 | temperature: float = float(temperature_str) 89 | 90 | ctx_size_str: str = ( 91 | prompt( 92 | "Enter context size (default: 2048): ", 93 | validator=Validator.from_callable( 94 | lambda text: text == "" or text.isdigit() and int(text) >= 0, 95 | error_message="Context size must be a non-negative integer", 96 | move_cursor_to_end=True, 97 | ), 98 | ) 99 | or "2048" 100 | ) 101 | ctx_size: int = int(ctx_size_str) 102 | 103 | name = prompt(f"Enter name (default: {placeholder_name}): ") or placeholder_name 104 | system_prompt = prompt(f"Enter system prompt for {name}: ") 105 | 106 | return AIAgent( 107 | name=name, 108 | model=model_name, 109 | temperature=temperature, 110 | ctx_size=ctx_size, 111 | system_prompt=system_prompt, 112 | ) 113 | 114 | 115 | def markdown_to_text(markdown_content: str) -> Text: 116 | """Convert Markdown content to a styled Text object.""" 117 | console = Console() 118 | md = Markdown(markdown_content) 119 | segments = list(console.render(md)) 120 | result = Text() 121 | for segment in segments: 122 | _ = result.append(segment.text, style=segment.style) 123 | 124 | result.rstrip() 125 | return result 126 | 127 | 128 | def display_message( 129 | console: Console, 130 | agent_name: str, 131 | name_color: tuple[int, int, int], 132 | message_stream: Iterator[str], 133 | use_markdown: bool = False, 134 | ) -> None: 135 | """Display a message from an agent in the console. 136 | 137 | Args: 138 | console (Console): Rich console instance. 139 | agent_name (str): Name of the agent. 140 | name_color (str): Color to use for the agent name. 141 | message_stream (Iterator[str]): Stream of the entire message up until the newest chunk received. 142 | use_markdown (bool, optional): Whether to use Markdown for text formatting. Defaults to False. 143 | """ 144 | # Create the agent name prefix as a Text object. 145 | agent_prefix = Text(f"{agent_name}: ", style=f"rgb({name_color[0]},{name_color[1]},{name_color[2]})") 146 | 147 | with Live("", console=console, transient=False) as live: 148 | for message in message_stream: 149 | # If the message is in Markdown format, convert it to a styled Text object, so we can append the 150 | # agent_prefix to it and display it through live.update(). 151 | message_text = markdown_to_text(message) if use_markdown else Text(message) 152 | message_text.style = "default" 153 | live.update(agent_prefix + message_text, refresh=True) 154 | 155 | 156 | def prompt_bool(prompt_text: str, default: bool = False) -> bool: 157 | """Prompt the user with a yes/no question and return the response as a boolean. 158 | 159 | Args: 160 | prompt_text (str): Prompt text to display. 161 | default (bool, optional): Default value to return if the user input is invalid. Defaults to False. 162 | 163 | Returns: 164 | bool: True if the user input is "yes" or "y" (case-insensitive), False otherwise. 165 | """ 166 | response = prompt(prompt_text).lower() 167 | 168 | if not response or response not in ["y", "yes", "n", "no"]: 169 | return default 170 | 171 | return response[0] == "y" 172 | 173 | 174 | # TODO: Add a GUI. 175 | def main() -> None: 176 | """Run a conversation between AI agents.""" 177 | parser = argparse.ArgumentParser(description="Run a conversation between AI agents") 178 | _ = parser.add_argument("-V", "--version", action="version", version=f"%(prog)s {version('llm-conversation')}") 179 | _ = parser.add_argument( 180 | "-o", 181 | "--output", 182 | type=Path, 183 | help="Save conversation log to file. Uses JSON format if file extension is .json, " 184 | + "otherwise uses plain text format", 185 | ) 186 | _ = parser.add_argument("-c", "--config", type=Path, help="Use JSON configuration file") 187 | args = parser.parse_args() 188 | 189 | console = Console() 190 | console.clear() 191 | 192 | if console.color_system != "truecolor": 193 | console.print("Please run this program in a terminal with true color support.", style="bold red") 194 | return 195 | 196 | agents: list[AIAgent] 197 | turn_order: TurnOrder 198 | moderator: AIAgent | None = None 199 | 200 | if args.config: 201 | # Load from config file 202 | config = load_config(args.config) 203 | agents = [create_ai_agent_from_config(agent_config) for agent_config in config.agents] 204 | settings = config.settings 205 | use_markdown = settings.use_markdown or False 206 | allow_termination = settings.allow_termination or False 207 | initial_message = settings.initial_message 208 | turn_order = settings.turn_order 209 | moderator = create_ai_agent_from_config(settings.moderator) if settings.moderator else None 210 | else: 211 | agent_count_str: str = ( 212 | prompt( 213 | "Enter the number of AI agents (default: 2): ", 214 | validator=Validator.from_callable( 215 | lambda text: text == "" or text.isdigit() and 1 < int(text) <= 10, 216 | error_message="Number of agents must be an integer greater than 1 and not more than 10", 217 | move_cursor_to_end=True, 218 | ), 219 | ) 220 | or "2" 221 | ) 222 | console.clear() 223 | 224 | agent_count: int = int(agent_count_str) 225 | agents = [] 226 | 227 | for i in range(agent_count): 228 | agents.append(create_ai_agent_from_input(console, f"AI {i + 1}")) 229 | console.clear() 230 | 231 | use_markdown = prompt_bool("Use Markdown for text formatting? (y/N): ", default=False) 232 | allow_termination = prompt_bool("Allow AI agents to terminate the conversation? (y/N): ", default=False) 233 | initial_message = prompt("Enter initial message (can be empty): ") or None 234 | 235 | turn_order_values = typing.cast(list[str], list(typing.get_args(TurnOrder))) 236 | turn_order = typing.cast( 237 | TurnOrder, 238 | prompt( 239 | "Enter turn order (default: round_robin): ", 240 | completer=WordCompleter(turn_order_values, ignore_case=True), 241 | validator=Validator.from_callable( 242 | lambda text: text == "" or text in turn_order_values, 243 | error_message="Invalid turn order", 244 | move_cursor_to_end=True, 245 | ), 246 | ) 247 | or "round_robin", 248 | ) 249 | 250 | if turn_order == "moderator" and prompt_bool("Configure the moderator agent? (y/N): ", default=False): 251 | console.clear() 252 | moderator = create_ai_agent_from_input(console, "Moderator") 253 | 254 | console.clear() 255 | 256 | manager = ConversationManager( 257 | agents=agents, 258 | initial_message=initial_message, 259 | use_markdown=use_markdown, 260 | allow_termination=allow_termination, 261 | turn_order=turn_order, 262 | moderator=moderator, 263 | ) 264 | 265 | # Get distinct colors for each agent. distinctipy.get_colors() returns floats between 0 and 1, so convert to 0-255 266 | # by multiplying by 255. This is necessary because Rich expects color values in the 0-255 range. 267 | colors = distinctipy.get_colors(len(agents), pastel_factor=0.6) # pyright: ignore[reportUnknownMemberType] 268 | agent_name_color: dict[str, tuple[int, int, int]] = { 269 | agent.name: (int(r * 255), int(g * 255), int(b * 255)) for agent, (r, g, b) in zip(agents, colors) 270 | } 271 | 272 | console.print("=== Conversation Started ===\n", style="bold cyan") 273 | is_first_message = True 274 | 275 | try: 276 | for agent_name, message in manager.run_conversation(): 277 | if not is_first_message: 278 | console.print("") 279 | console.rule() 280 | console.print("") 281 | 282 | is_first_message = False 283 | display_message(console, agent_name, agent_name_color[agent_name], message, use_markdown) 284 | 285 | console.print("\n=== Conversation Terminated by Agent ===\n", style="bold cyan") 286 | 287 | except KeyboardInterrupt: 288 | console.print("\n=== Conversation Terminated by User ===\n", style="bold cyan") 289 | 290 | if args.output is not None: 291 | manager.save_conversation(args.output) 292 | console.print(f"\nConversation saved to {args.output}\n\n", style="bold yellow") 293 | 294 | 295 | if __name__ == "__main__": 296 | main() 297 | -------------------------------------------------------------------------------- /src/llm_conversation/ai_agent.py: -------------------------------------------------------------------------------- 1 | """Module for the AIAgent class.""" 2 | 3 | from collections.abc import Iterator 4 | from typing import Any, cast 5 | 6 | import ollama 7 | from pydantic import BaseModel 8 | 9 | 10 | class AIAgent: 11 | """An AI agent for conversational AI using Ollama models.""" 12 | 13 | name: str 14 | model: str 15 | temperature: float = 0.8 16 | ctx_size: int = 2048 17 | _messages: list[dict[str, str]] 18 | 19 | def __init__( 20 | self, 21 | name: str, 22 | model: str, 23 | temperature: float, 24 | ctx_size: int, 25 | system_prompt: str, 26 | ) -> None: 27 | """Initialize an AI agent. 28 | 29 | Args: 30 | name (str): Name of the AI agent 31 | model (str): Ollama model to be used 32 | temperature (float): Sampling temperature for the model (0.0-1.0) 33 | ctx_size (int): Context size for the model 34 | system_prompt (str): Initial system prompt for the agent 35 | """ 36 | self.name = name 37 | self.model = model 38 | self.temperature = temperature 39 | self.ctx_size = ctx_size 40 | self._messages = [{"role": "system", "content": system_prompt}] 41 | 42 | @property 43 | def system_prompt(self) -> str: 44 | """Get the system prompt for the agent.""" 45 | return self._messages[0]["content"] 46 | 47 | @system_prompt.setter 48 | def system_prompt(self, value: str) -> None: 49 | """Set the system prompt for the agent.""" 50 | self._messages[0]["content"] = value 51 | 52 | def add_message(self, name: str, role: str, content: str) -> None: 53 | """Add a message to the end of the conversation history.""" 54 | self._messages.append({"name": name, "role": role, "content": content}) 55 | 56 | def get_response(self, output_format: type[BaseModel]) -> Iterator[str]: 57 | """Generate a response message based on the conversation history. 58 | 59 | Args: 60 | user_input (str | None): User input to the agent 61 | 62 | Yields: 63 | str: Chunk of the response from the agent 64 | """ 65 | response_stream = ollama.chat( # pyright: ignore[reportUnknownMemberType] 66 | model=self.model, 67 | messages=self._messages, 68 | options={ 69 | "num_ctx": self.ctx_size, 70 | "temperature": self.temperature, 71 | }, 72 | stream=True, 73 | format=output_format.model_json_schema(), 74 | ) 75 | 76 | chunks: list[str] = [] 77 | for chunk in response_stream: 78 | content: str = chunk["message"]["content"] 79 | chunks.append(content) 80 | yield content # Stream chunks as they arrive 81 | 82 | def get_param_count(self) -> int: 83 | """Get the number of parameters in the model.""" 84 | return cast(int, cast(dict[str, Any], ollama.show(self.model).modelinfo)["general.parameter_count"]) 85 | -------------------------------------------------------------------------------- /src/llm_conversation/config.py: -------------------------------------------------------------------------------- 1 | """Configuration loading and validation for the AI agents and conversation settings. 2 | 3 | This module defines Pydantic models for the AI agents and conversation settings, and allows loading and validating the 4 | configuration from a JSON file. 5 | """ 6 | 7 | import json 8 | from pathlib import Path 9 | from typing import Self 10 | 11 | import ollama 12 | from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator 13 | 14 | from .conversation_manager import TurnOrder 15 | 16 | 17 | def get_available_models() -> list[str]: 18 | """Get a list of available Ollama models.""" 19 | return [x.model or "" for x in ollama.list().models if x.model] 20 | 21 | 22 | class AgentConfig(BaseModel): 23 | """Configuration for an AI agent.""" 24 | 25 | model_config = ConfigDict(extra="forbid") # pyright: ignore[reportUnannotatedClassAttribute] 26 | 27 | name: str = Field(..., min_length=1, description="Name of the AI agent") 28 | model: str = Field(..., description="Ollama model to be used") 29 | system_prompt: str = Field(..., description="Initial system prompt for the agent") 30 | temperature: float = Field( 31 | default=0.8, 32 | ge=0.0, 33 | le=1.0, 34 | description="Sampling temperature for the model (0.0-1.0)", 35 | ) 36 | ctx_size: int = Field(default=2048, ge=0, description="Context size for the model") 37 | 38 | @field_validator("model") 39 | @classmethod 40 | def validate_model(cls, value: str) -> str: # noqa: D102 41 | available_models = get_available_models() 42 | if value not in available_models: 43 | msg = f"Model '{value}' is not available" 44 | raise ValueError(msg) 45 | 46 | return value 47 | 48 | 49 | class ConversationSettings(BaseModel): 50 | """Extra settings for the conversation, not specific to any AI agent.""" 51 | 52 | model_config = ConfigDict(extra="forbid") # pyright: ignore[reportUnannotatedClassAttribute] 53 | 54 | use_markdown: bool = Field(default=False, description="Enable Markdown formatting") 55 | allow_termination: bool = Field(default=False, description="Allow AI agents to terminate the conversation") 56 | initial_message: str | None = Field(default=None, description="Initial message to start the conversation") 57 | turn_order: TurnOrder = Field(default="round_robin", description="Strategy for selecting the next agent") 58 | moderator: AgentConfig | None = Field( 59 | default=None, description='Configuration for the moderator agent (if using "moderator" turn order)' 60 | ) 61 | 62 | @model_validator(mode="after") 63 | def validate_moderator(self) -> Self: # noqa: D102 64 | if self.turn_order != "moderator" and self.moderator is not None: 65 | raise ValueError("moderator can only be defined when turn_order is 'moderator'") 66 | 67 | return self 68 | 69 | 70 | class Config(BaseModel): 71 | """Configuration for the AI agents and conversation settings.""" 72 | 73 | model_config = ConfigDict(extra="forbid") # pyright: ignore[reportUnannotatedClassAttribute] 74 | 75 | agents: list[AgentConfig] = Field(..., description="Configuration for AI agents") 76 | settings: ConversationSettings = Field(..., description="Conversation settings") 77 | 78 | 79 | def load_config(config_path: Path) -> Config: 80 | """Load and validate the configuration file using Pydantic. 81 | 82 | Args: 83 | config_path (Path): Path to the JSON configuration file 84 | 85 | Returns: 86 | Config: Validated configuration object 87 | 88 | Raises: 89 | ValueError: If the configuration is invalid 90 | """ 91 | try: 92 | with open(config_path) as f: 93 | config_dict = json.load(f) 94 | except json.JSONDecodeError as e: 95 | msg = f"Invalid JSON in config file: {e}" 96 | raise ValueError(msg) 97 | 98 | try: 99 | return Config.model_validate(config_dict) 100 | except Exception as e: 101 | msg = f"Configuration validation failed: {e}" 102 | raise ValueError(msg) 103 | -------------------------------------------------------------------------------- /src/llm_conversation/conversation_manager.py: -------------------------------------------------------------------------------- 1 | """Module for managing a conversation between AI agents.""" 2 | 3 | import enum 4 | import json 5 | import random 6 | from collections.abc import Iterator 7 | from dataclasses import dataclass, field 8 | from pathlib import Path 9 | from typing import Any, Literal, TypedDict, cast 10 | 11 | from partial_json_parser import ensure_json # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs] 12 | from pydantic import BaseModel, Field, create_model 13 | 14 | from .ai_agent import AIAgent 15 | 16 | TurnOrder = Literal["round_robin", "random", "chain", "moderator", "vote"] 17 | 18 | 19 | @dataclass 20 | class ConversationManager: 21 | """Manager for a conversation between AI agents.""" 22 | 23 | class _ConversationLogItem(TypedDict): 24 | agent: str 25 | content: str 26 | 27 | agents: list[AIAgent] 28 | initial_message: str | None 29 | use_markdown: bool = False 30 | allow_termination: bool = False 31 | turn_order: TurnOrder = "round_robin" 32 | moderator: AIAgent | None = None 33 | _conversation_log: list[_ConversationLogItem] = field(default_factory=list, init=False) 34 | _original_system_prompts: list[str] = field(init=False, repr=False) 35 | _output_format: type[BaseModel] = field(init=False, repr=False) 36 | _agent_name_to_idx: dict[str, int] = field(init=False, repr=False) 37 | 38 | def __post_init__(self) -> None: # noqa: D105 39 | self._agent_name_to_idx = {} 40 | 41 | for i, agent in enumerate(self.agents): 42 | if agent.name in self._agent_name_to_idx: 43 | raise ValueError(f"Agent names must be unique: {agent.name}") 44 | self._agent_name_to_idx[agent.name] = i 45 | 46 | self._original_system_prompts = [agent.system_prompt for agent in self.agents] 47 | 48 | output_format_kwargs: dict[str, Any] = { 49 | "message": (str, Field(description="Message content")), 50 | } 51 | 52 | if self.allow_termination: 53 | output_format_kwargs["terminate"] = ( 54 | bool, 55 | Field( 56 | title="Terminate", 57 | description="Terminate conversation if you believe it has reached a natural conclusion. " 58 | + "Do not set this field to `true` unless you are certain the conversation should end.", 59 | ), 60 | ) 61 | 62 | self._output_format = create_model("OutputFormat", **output_format_kwargs) 63 | 64 | # Modify system prompt to include termination instructions if allowed 65 | additional_instructions: str = "" 66 | 67 | if self.use_markdown: 68 | additional_instructions += ( 69 | "You may use Markdown for text formatting. " 70 | "Examples: *italic*, **bold**, `code`, [link](https://example.com), etc.\n\n" 71 | ) 72 | 73 | if self.allow_termination: 74 | additional_instructions += ( 75 | "If you believe the conversation has reached a natural conclusion, you may choose to end the " 76 | + "conversation by setting the `terminate` field to `true` in your response. Only do this if you are " 77 | + "certain the conversation should end. When you end the conversation, also provide an in-character " 78 | + "final message to conclude the conversation.\n\n" 79 | ) 80 | 81 | # Updated system prompts for each agent to give the agents more context about the conversation and their role. 82 | for agent in self.agents: 83 | other_agents = ", ".join([a.name for a in self.agents if a != agent]) 84 | agent.system_prompt = ( 85 | f"You are named {agent.name}. The other characters are {other_agents}. " 86 | + "Your task is to play the role you're given and continue the conversation.\n\n" 87 | + f"This is the prompt for your role: {agent.system_prompt}\n\n" 88 | + additional_instructions 89 | ) 90 | 91 | # If the turn order is set to "moderator" and a moderator agent is not provided, create one. 92 | if self.turn_order == "moderator" and self.moderator is None: 93 | self._create_moderator_agent() 94 | elif self.turn_order != "moderator" and self.moderator is not None: 95 | raise ValueError("Cannot use a moderator agent without the turn order set to 'moderator'") 96 | 97 | def save_conversation(self, filename: Path) -> None: 98 | """Save the conversation log to a file. 99 | 100 | Args: 101 | filename (Path): Path to save the conversation log to 102 | """ 103 | with open(filename, "w", encoding="utf-8") as f: 104 | if filename.suffix == ".json": 105 | 106 | def agent_to_dict(agent_idx: int) -> dict[str, Any]: 107 | agent = self.agents[agent_idx] 108 | 109 | return { 110 | "name": agent.name, 111 | "model": agent.model, 112 | "temperature": agent.temperature, 113 | "ctx_size": agent.ctx_size, 114 | "system_prompt": self._original_system_prompts[agent_idx], 115 | } 116 | 117 | # Save conversation log as JSON 118 | json.dump( 119 | { 120 | "agents": [agent_to_dict(i) for i in range(len(self.agents))], 121 | "conversation": self._conversation_log, 122 | }, 123 | f, 124 | ensure_ascii=False, 125 | indent=4, 126 | ) 127 | return 128 | 129 | # Save conversation log as plain text 130 | for i, agent in enumerate(self.agents, start=1): 131 | _ = f.write(f"=== Agent {i} ===\n\n") 132 | _ = f.write(f"Name: {agent.name}\n") 133 | _ = f.write(f"Model: {agent.model}\n") 134 | _ = f.write(f"Temperature: {agent.temperature}\n") 135 | _ = f.write(f"Context Size: {agent.ctx_size}\n") 136 | _ = f.write(f"System Prompt: {self._original_system_prompts[i - 1]}\n\n") 137 | 138 | _ = f.write("=== Conversation ===\n\n") 139 | 140 | for i, msg in enumerate(self._conversation_log): 141 | if i > 0: 142 | _ = f.write("\n" + "\u2500" * 80 + "\n\n") 143 | 144 | _ = f.write(f"{msg['agent']}: {msg['content']}\n") 145 | 146 | def run_conversation(self) -> Iterator[tuple[str, Iterator[str]]]: 147 | """Generate an iterator of conversation responses. 148 | 149 | Yields: 150 | (str, Iterator[str]): A tuple of the agent name and an iterator of the accumulated response. 151 | 152 | Note: The iterator returns the entire message up until the newest chunk received, 153 | not just the new chunk. 154 | 155 | For example, if the first iteration yields "Hello, ", the second iteration will yield 156 | "Hello, world!" instead of just "world!". 157 | """ 158 | 159 | def add_agent_response(agent_idx: int, response: dict[str, Any]) -> None: 160 | """Add a message from an agent to the conversation log and the agents' message history. 161 | 162 | Args: 163 | agent_idx (int): Index of the agent the message is from 164 | message (str): Message content 165 | """ 166 | message: str = response["message"] 167 | # Message with dialogue marker to indicate which agent is speaking. 168 | message_with_marker = f"{self.agents[agent_idx].name}: {message}" 169 | 170 | # The agents should get the full JSON response as context, to reinforce the response format and help them 171 | # generate more coherent responses. 172 | for i, agent in enumerate(self.agents): 173 | agent.add_message( 174 | self.agents[agent_idx].name, 175 | # Use "assistant" instead of "user" for the agent's own messages. 176 | "assistant" if i == agent_idx else "user", 177 | # For the agent's own messages, use the full JSON response to reinforce the response format. 178 | # For other agents' messages, use the message content with the dialogue marker. 179 | str(response) if i == agent_idx else message_with_marker, 180 | ) 181 | 182 | # If a moderator agent is present, add the message to the moderator's message history. 183 | if self.moderator is not None: 184 | self.moderator.add_message(self.agents[agent_idx].name, "user", message_with_marker) 185 | 186 | # For the conversation log, only the message content is needed. 187 | self._conversation_log.append({"agent": self.agents[agent_idx].name, "content": message}) 188 | 189 | agent_idx: int = self._pick_next_agent(None) 190 | 191 | # If a non-empty initial message is provided, start with it. 192 | if self.initial_message is not None: 193 | # Make the first agent the one to say the initial message, and the second agent the one to respond. 194 | add_agent_response(agent_idx, {"message": self.initial_message}) 195 | yield (self.agents[agent_idx].name, iter([self.initial_message])) 196 | agent_idx = self._pick_next_agent(agent_idx) 197 | 198 | while True: 199 | current_agent = self.agents[agent_idx] 200 | response_stream = current_agent.get_response(self._output_format) 201 | 202 | # Will be populated with the full JSON response once the response stream is exhausted. 203 | response_json: dict[str, Any] = {} 204 | 205 | def parse_partial_json(json_string: str) -> dict[str, Any]: 206 | """Parse a partial JSON response using the partial JSON parser, and return the JSON object.""" 207 | # Don't use `partial_json_parser.loads()` directly because it doesn't have good type hints. 208 | return cast(dict[str, Any], json.loads(ensure_json(json_string))) 209 | 210 | def stream_chunks() -> Iterator[str]: 211 | nonlocal response_json 212 | 213 | response: str = "" 214 | 215 | # Accumulate chunks until the message field is found in the JSON response. 216 | for response_chunk in response_stream: 217 | response += response_chunk 218 | response_json = parse_partial_json(response) 219 | 220 | if "message" in response_json: 221 | break 222 | 223 | # Message field is found, yield the entire message gradually as new chunks arrive. 224 | for response_chunk in response_stream: 225 | response += response_chunk 226 | response_json = parse_partial_json(response) 227 | 228 | yield response_json["message"] 229 | 230 | yield (current_agent.name, stream_chunks()) 231 | 232 | add_agent_response(agent_idx, response_json) 233 | 234 | # Check if the conversation should be terminated. 235 | if response_json.get("terminate", False): 236 | break 237 | 238 | agent_idx = self._pick_next_agent(agent_idx) 239 | 240 | def _create_moderator_agent(self) -> None: 241 | moderator_agent_model: str | None = None 242 | moderator_agent_ctx_size: int | None = None 243 | lowest_param_count: int | None = None 244 | 245 | # Find the model with the lowest parameter count to use as the moderator agent. 246 | # Also use the highest context size among the agents. 247 | for agent in self.agents: 248 | model_param_count: int = agent.get_param_count() 249 | 250 | if lowest_param_count is None or model_param_count < lowest_param_count: 251 | moderator_agent_model = agent.model 252 | lowest_param_count = model_param_count 253 | 254 | if moderator_agent_ctx_size is None or agent.ctx_size > moderator_agent_ctx_size: 255 | moderator_agent_ctx_size = agent.ctx_size 256 | 257 | assert moderator_agent_model is not None and moderator_agent_ctx_size is not None 258 | 259 | self.moderator = AIAgent( 260 | name="Moderator", 261 | model=moderator_agent_model, 262 | temperature=0.8, 263 | ctx_size=moderator_agent_ctx_size, 264 | system_prompt="You are the conversation moderator. Your task is to analyze the conversation " 265 | + "and choose who speaks next. You should prioritize giving each character an equal opportunity to speak. " 266 | + "Most importantly, you should prioritize keeping the conversation entertaining and engaging.", 267 | ) 268 | 269 | def _pick_next_agent(self, current_agent_idx: int | None) -> int: 270 | """Pick the next agent to speak based on the turn order. 271 | 272 | The different turn order strategies are as follows: 273 | - "round_robin": Cycle through the agents in order. 274 | - "random": Randomly pick an agent to speak next. 275 | - "chain": The agent that just spoke picks the next agent to speak. 276 | - "moderator": A moderator agent picks the next agent to speak. 277 | - "vote": Each agent votes for the next agent to speak, and the agent with the most votes is chosen. 278 | In case of a tie, one of the tied agents is chosen randomly. 279 | 280 | Args: 281 | current_agent_idx (int | None): Index of the agent that just spoke. Should be None if no agent has spoken 282 | yet. 283 | 284 | Returns: 285 | int: Index of the agent to speak next 286 | """ 287 | # Only two agents, so the next agent is the other one. 288 | if len(self.agents) == 2 and current_agent_idx is not None: 289 | return 1 if current_agent_idx == 0 else 0 290 | 291 | def choice_enum(ignore_idx: list[int]) -> enum.Enum: 292 | choices_dict: dict[str, str] = {} 293 | 294 | choices_dict = {agent.name: agent.name for i, agent in enumerate(self.agents) if i not in ignore_idx} 295 | 296 | return enum.Enum("NextAgentChoices", choices_dict) # pyright: ignore[reportReturnType] 297 | 298 | match self.turn_order: 299 | case "round_robin": 300 | return (current_agent_idx + 1) % len(self.agents) if current_agent_idx is not None else 0 301 | case "random": 302 | if current_agent_idx is None: 303 | return random.randint(0, len(self.agents) - 1) 304 | 305 | idx = random.randint(0, len(self.agents) - 2) 306 | return idx if idx < current_agent_idx else idx + 1 307 | case "chain": 308 | if current_agent_idx is None: 309 | # No agent has spoken yet, so pick a random agent to start the conversation. 310 | return random.randint(0, len(self.agents) - 1) 311 | 312 | agent_choices_enum = choice_enum([current_agent_idx]) 313 | 314 | chain_output_format: type[BaseModel] = create_model( 315 | "ChainOutputFormat", 316 | next_agent=(agent_choices_enum, Field(description="Name of the next character to speak")), 317 | ) 318 | 319 | response = "".join(list(self.agents[current_agent_idx].get_response(chain_output_format))) 320 | next_agent_name = json.loads(response)["next_agent"] 321 | 322 | return self._agent_name_to_idx[next_agent_name] 323 | case "moderator": 324 | assert self.moderator is not None 325 | agent_choices_enum = choice_enum([current_agent_idx] if current_agent_idx is not None else []) 326 | 327 | moderator_output_format: type[BaseModel] = create_model( 328 | "ModeratorOutputFormat", 329 | next_agent=(agent_choices_enum, Field(description="Name of the next character to speak")), 330 | ) 331 | 332 | moderator_response = "".join(list(self.moderator.get_response(moderator_output_format))) 333 | next_agent_name = json.loads(moderator_response)["next_agent"] 334 | 335 | return self._agent_name_to_idx[next_agent_name] 336 | case "vote": 337 | agent_votes: dict[str, int] = {agent.name: 0 for agent in self.agents} 338 | 339 | for i, agent in enumerate(self.agents): 340 | agent_choices_enum = choice_enum([i] if current_agent_idx is None else [current_agent_idx, i]) 341 | 342 | vote_output_format: type[BaseModel] = create_model( 343 | "VoteOutputFormat", 344 | next_agent=(agent_choices_enum, Field(description="Name of the next character to speak")), 345 | ) 346 | 347 | response = "".join(list(agent.get_response(vote_output_format))) 348 | agent_name = json.loads(response)["next_agent"] 349 | 350 | assert agent_name in agent_votes, f"Invalid agent name: {agent_name}" 351 | agent_votes[agent_name] += 1 352 | 353 | # Find the agents with the most votes and pick one of them randomly. 354 | max_votes = max(agent_votes.values()) 355 | agents_with_max_votes = [agent_name for agent_name, votes in agent_votes.items() if votes == max_votes] 356 | 357 | return self._agent_name_to_idx[random.choice(agents_with_max_votes)] 358 | -------------------------------------------------------------------------------- /uv.lock: -------------------------------------------------------------------------------- 1 | version = 1 2 | revision = 2 3 | requires-python = ">=3.13, <4.0" 4 | 5 | [[package]] 6 | name = "annotated-types" 7 | version = "0.7.0" 8 | source = { registry = "https://pypi.org/simple" } 9 | 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" } 10 | wheels = [ 11 | { 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" }, 12 | ] 13 | 14 | [[package]] 15 | name = "anyio" 16 | version = "4.9.0" 17 | source = { registry = "https://pypi.org/simple" } 18 | dependencies = [ 19 | { name = "idna" }, 20 | { name = "sniffio" }, 21 | ] 22 | sdist = { url = "https://files.pythonhosted.org/packages/95/7d/4c1bd541d4dffa1b52bd83fb8527089e097a106fc90b467a7313b105f840/anyio-4.9.0.tar.gz", hash = "sha256:673c0c244e15788651a4ff38710fea9675823028a6f08a5eda409e0c9840a028", size = 190949, upload-time = "2025-03-17T00:02:54.77Z" } 23 | wheels = [ 24 | { url = "https://files.pythonhosted.org/packages/a1/ee/48ca1a7c89ffec8b6a0c5d02b89c305671d5ffd8d3c94acf8b8c408575bb/anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c", size = 100916, upload-time = "2025-03-17T00:02:52.713Z" }, 25 | ] 26 | 27 | [[package]] 28 | name = "basedpyright" 29 | version = "1.29.1" 30 | source = { registry = "https://pypi.org/simple" } 31 | dependencies = [ 32 | { name = "nodejs-wheel-binaries" }, 33 | ] 34 | sdist = { url = "https://files.pythonhosted.org/packages/b9/18/f5e488eac4960ad9a2e71b95f0d91cf93a982c7f68aa90e4e0554f0bc37e/basedpyright-1.29.1.tar.gz", hash = "sha256:06bbe6c3b50ab4af20f80e154049477a50d8b81d2522eadbc9f472f2f92cd44b", size = 21773469, upload-time = "2025-04-23T13:29:42.47Z" } 35 | wheels = [ 36 | { url = "https://files.pythonhosted.org/packages/95/1b/1bb837bbb7e259928f33d3c105dfef4f5349ef08b3ef45576801256e3234/basedpyright-1.29.1-py3-none-any.whl", hash = "sha256:b7eb65b9d4aaeeea29a349ac494252032a75a364942d0ac466d7f07ddeacc786", size = 11397959, upload-time = "2025-04-23T13:29:38.106Z" }, 37 | ] 38 | 39 | [[package]] 40 | name = "certifi" 41 | version = "2025.4.26" 42 | source = { registry = "https://pypi.org/simple" } 43 | sdist = { url = "https://files.pythonhosted.org/packages/e8/9e/c05b3920a3b7d20d3d3310465f50348e5b3694f4f88c6daf736eef3024c4/certifi-2025.4.26.tar.gz", hash = "sha256:0a816057ea3cdefcef70270d2c515e4506bbc954f417fa5ade2021213bb8f0c6", size = 160705, upload-time = "2025-04-26T02:12:29.51Z" } 44 | wheels = [ 45 | { url = "https://files.pythonhosted.org/packages/4a/7e/3db2bd1b1f9e95f7cddca6d6e75e2f2bd9f51b1246e546d88addca0106bd/certifi-2025.4.26-py3-none-any.whl", hash = "sha256:30350364dfe371162649852c63336a15c70c6510c2ad5015b21c2345311805f3", size = 159618, upload-time = "2025-04-26T02:12:27.662Z" }, 46 | ] 47 | 48 | [[package]] 49 | name = "distinctipy" 50 | version = "1.3.4" 51 | source = { registry = "https://pypi.org/simple" } 52 | dependencies = [ 53 | { name = "numpy" }, 54 | ] 55 | sdist = { url = "https://files.pythonhosted.org/packages/8c/3c/e0b90a5bc396e2abaf207d9a41ea8aeab1f41760425262474903bade6a7b/distinctipy-1.3.4.tar.gz", hash = "sha256:fed97afff1afb73ecaa87c85461021f0ba89fae63067c0125b9673526510aac4", size = 29711, upload-time = "2024-01-10T21:32:24.032Z" } 56 | wheels = [ 57 | { url = "https://files.pythonhosted.org/packages/0a/75/fa882538bdb0c8fc4459f1595a761591b827691936d57c08c492676f19bc/distinctipy-1.3.4-py3-none-any.whl", hash = "sha256:2bf57d9d20dbc5c2fd462298573cc963c037f493d04ec61e94cb8d0bf5023c74", size = 26743, upload-time = "2024-01-10T21:32:22.351Z" }, 58 | ] 59 | 60 | [[package]] 61 | name = "h11" 62 | version = "0.16.0" 63 | source = { registry = "https://pypi.org/simple" } 64 | 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" } 65 | wheels = [ 66 | { 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" }, 67 | ] 68 | 69 | [[package]] 70 | name = "httpcore" 71 | version = "1.0.9" 72 | source = { registry = "https://pypi.org/simple" } 73 | dependencies = [ 74 | { name = "certifi" }, 75 | { name = "h11" }, 76 | ] 77 | 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" } 78 | wheels = [ 79 | { 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" }, 80 | ] 81 | 82 | [[package]] 83 | name = "httpx" 84 | version = "0.28.1" 85 | source = { registry = "https://pypi.org/simple" } 86 | dependencies = [ 87 | { name = "anyio" }, 88 | { name = "certifi" }, 89 | { name = "httpcore" }, 90 | { name = "idna" }, 91 | ] 92 | 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" } 93 | wheels = [ 94 | { 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" }, 95 | ] 96 | 97 | [[package]] 98 | name = "idna" 99 | version = "3.10" 100 | source = { registry = "https://pypi.org/simple" } 101 | sdist = { url = "https://files.pythonhosted.org/packages/f1/70/7703c29685631f5a7590aa73f1f1d3fa9a380e654b86af429e0934a32f7d/idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9", size = 190490, upload-time = "2024-09-15T18:07:39.745Z" } 102 | wheels = [ 103 | { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442, upload-time = "2024-09-15T18:07:37.964Z" }, 104 | ] 105 | 106 | [[package]] 107 | name = "llm-conversation" 108 | source = { editable = "." } 109 | dependencies = [ 110 | { name = "distinctipy" }, 111 | { name = "ollama" }, 112 | { name = "partial-json-parser" }, 113 | { name = "prompt-toolkit" }, 114 | { name = "pydantic" }, 115 | { name = "rich" }, 116 | ] 117 | 118 | [package.dev-dependencies] 119 | dev = [ 120 | { name = "basedpyright" }, 121 | { name = "mypy" }, 122 | { name = "ruff" }, 123 | ] 124 | 125 | [package.metadata] 126 | requires-dist = [ 127 | { name = "distinctipy", specifier = ">=1.3.4,<2.0.0" }, 128 | { name = "ollama", specifier = ">=0.4.7,<0.5.0" }, 129 | { name = "partial-json-parser", specifier = ">=0.2.1.1.post5,<0.3.0.0" }, 130 | { name = "prompt-toolkit", specifier = ">=3.0.50,<4.0.0" }, 131 | { name = "pydantic", specifier = ">=2.10.6,<3.0.0" }, 132 | { name = "rich", specifier = ">=13.9.4,<14.0.0" }, 133 | ] 134 | 135 | [package.metadata.requires-dev] 136 | dev = [ 137 | { name = "basedpyright", specifier = ">=1.29.0,<2" }, 138 | { name = "mypy", specifier = ">=1.15.0,<2" }, 139 | { name = "ruff", specifier = ">=0.9.4,<0.10" }, 140 | ] 141 | 142 | [[package]] 143 | name = "markdown-it-py" 144 | version = "3.0.0" 145 | source = { registry = "https://pypi.org/simple" } 146 | dependencies = [ 147 | { name = "mdurl" }, 148 | ] 149 | sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596, upload-time = "2023-06-03T06:41:14.443Z" } 150 | wheels = [ 151 | { url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528, upload-time = "2023-06-03T06:41:11.019Z" }, 152 | ] 153 | 154 | [[package]] 155 | name = "mdurl" 156 | version = "0.1.2" 157 | source = { registry = "https://pypi.org/simple" } 158 | sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" } 159 | wheels = [ 160 | { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, 161 | ] 162 | 163 | [[package]] 164 | name = "mypy" 165 | version = "1.15.0" 166 | source = { registry = "https://pypi.org/simple" } 167 | dependencies = [ 168 | { name = "mypy-extensions" }, 169 | { name = "typing-extensions" }, 170 | ] 171 | sdist = { url = "https://files.pythonhosted.org/packages/ce/43/d5e49a86afa64bd3839ea0d5b9c7103487007d728e1293f52525d6d5486a/mypy-1.15.0.tar.gz", hash = "sha256:404534629d51d3efea5c800ee7c42b72a6554d6c400e6a79eafe15d11341fd43", size = 3239717, upload-time = "2025-02-05T03:50:34.655Z" } 172 | wheels = [ 173 | { url = "https://files.pythonhosted.org/packages/6a/9b/fd2e05d6ffff24d912f150b87db9e364fa8282045c875654ce7e32fffa66/mypy-1.15.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:93faf3fdb04768d44bf28693293f3904bbb555d076b781ad2530214ee53e3445", size = 10788592, upload-time = "2025-02-05T03:48:55.789Z" }, 174 | { url = "https://files.pythonhosted.org/packages/74/37/b246d711c28a03ead1fd906bbc7106659aed7c089d55fe40dd58db812628/mypy-1.15.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:811aeccadfb730024c5d3e326b2fbe9249bb7413553f15499a4050f7c30e801d", size = 9753611, upload-time = "2025-02-05T03:48:44.581Z" }, 175 | { url = "https://files.pythonhosted.org/packages/a6/ac/395808a92e10cfdac8003c3de9a2ab6dc7cde6c0d2a4df3df1b815ffd067/mypy-1.15.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:98b7b9b9aedb65fe628c62a6dc57f6d5088ef2dfca37903a7d9ee374d03acca5", size = 11438443, upload-time = "2025-02-05T03:49:25.514Z" }, 176 | { url = "https://files.pythonhosted.org/packages/d2/8b/801aa06445d2de3895f59e476f38f3f8d610ef5d6908245f07d002676cbf/mypy-1.15.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43a7682e24b4f576d93072216bf56eeff70d9140241f9edec0c104d0c515036", size = 12402541, upload-time = "2025-02-05T03:49:57.623Z" }, 177 | { url = "https://files.pythonhosted.org/packages/c7/67/5a4268782eb77344cc613a4cf23540928e41f018a9a1ec4c6882baf20ab8/mypy-1.15.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:baefc32840a9f00babd83251560e0ae1573e2f9d1b067719479bfb0e987c6357", size = 12494348, upload-time = "2025-02-05T03:48:52.361Z" }, 178 | { url = "https://files.pythonhosted.org/packages/83/3e/57bb447f7bbbfaabf1712d96f9df142624a386d98fb026a761532526057e/mypy-1.15.0-cp313-cp313-win_amd64.whl", hash = "sha256:b9378e2c00146c44793c98b8d5a61039a048e31f429fb0eb546d93f4b000bedf", size = 9373648, upload-time = "2025-02-05T03:49:11.395Z" }, 179 | { url = "https://files.pythonhosted.org/packages/09/4e/a7d65c7322c510de2c409ff3828b03354a7c43f5a8ed458a7a131b41c7b9/mypy-1.15.0-py3-none-any.whl", hash = "sha256:5469affef548bd1895d86d3bf10ce2b44e33d86923c29e4d675b3e323437ea3e", size = 2221777, upload-time = "2025-02-05T03:50:08.348Z" }, 180 | ] 181 | 182 | [[package]] 183 | name = "mypy-extensions" 184 | version = "1.1.0" 185 | source = { registry = "https://pypi.org/simple" } 186 | 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" } 187 | wheels = [ 188 | { 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" }, 189 | ] 190 | 191 | [[package]] 192 | name = "nodejs-wheel-binaries" 193 | version = "22.15.0" 194 | source = { registry = "https://pypi.org/simple" } 195 | sdist = { url = "https://files.pythonhosted.org/packages/45/5b/6c5f973765b96793d4e4d03684bcbd273b17e471ecc7e9bec4c32b595ebd/nodejs_wheel_binaries-22.15.0.tar.gz", hash = "sha256:ff81aa2a79db279c2266686ebcb829b6634d049a5a49fc7dc6921e4f18af9703", size = 8054, upload-time = "2025-04-23T16:57:40.338Z" } 196 | wheels = [ 197 | { url = "https://files.pythonhosted.org/packages/d3/a8/a32e5bb99e95c536e7dac781cffab1e7e9f8661b8ee296b93df77e4df7f9/nodejs_wheel_binaries-22.15.0-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:aa16366d48487fff89446fb237693e777aa2ecd987208db7d4e35acc40c3e1b1", size = 50514526, upload-time = "2025-04-23T16:57:07.478Z" }, 198 | { url = "https://files.pythonhosted.org/packages/05/e8/eb024dbb3a7d3b98c8922d1c306be989befad4d2132292954cb902f43b07/nodejs_wheel_binaries-22.15.0-py2.py3-none-macosx_11_0_x86_64.whl", hash = "sha256:a54bb3fee9170003fa8abc69572d819b2b1540344eff78505fcc2129a9175596", size = 51409179, upload-time = "2025-04-23T16:57:11.599Z" }, 199 | { url = "https://files.pythonhosted.org/packages/3f/0f/baa968456c3577e45c7d0e3715258bd175dcecc67b683a41a5044d5dae40/nodejs_wheel_binaries-22.15.0-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:867121ccf99d10523f6878a26db86e162c4939690e24cfb5bea56d01ea696c93", size = 57364460, upload-time = "2025-04-23T16:57:15.725Z" }, 200 | { url = "https://files.pythonhosted.org/packages/2f/a2/977f63cd07ed8fc27bc0d0cd72e801fc3691ffc8cd40a51496ff18a6d0a2/nodejs_wheel_binaries-22.15.0-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ab0fbcda2ddc8aab7db1505d72cb958f99324b3834c4543541a305e02bfe860", size = 57889101, upload-time = "2025-04-23T16:57:19.643Z" }, 201 | { url = "https://files.pythonhosted.org/packages/67/7f/57b9c24a4f0d25490527b043146aa0fdff2d8fdc82f90667cdaf6f00cfc9/nodejs_wheel_binaries-22.15.0-py2.py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2bde1d8e00cd955b9ce9ee9ac08309923e2778a790ee791b715e93e487e74bfd", size = 59190817, upload-time = "2025-04-23T16:57:23.875Z" }, 202 | { url = "https://files.pythonhosted.org/packages/fd/7f/970acbe33b81c22b3c7928f52e32347030aa46d23d779cf781cf9a9cf557/nodejs_wheel_binaries-22.15.0-py2.py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:acdd4ef73b6701aab9fbe02ac5e104f208a5e3c300402fa41ad7bc7f49499fbf", size = 60220316, upload-time = "2025-04-23T16:57:28.276Z" }, 203 | { url = "https://files.pythonhosted.org/packages/07/4c/030243c04bb60f0de66c2d7ee3be289c6d28ef09113c06ffa417bdfedf8f/nodejs_wheel_binaries-22.15.0-py2.py3-none-win_amd64.whl", hash = "sha256:51deaf13ee474e39684ce8c066dfe86240edb94e7241950ca789befbbbcbd23d", size = 40718853, upload-time = "2025-04-23T16:57:32.651Z" }, 204 | { url = "https://files.pythonhosted.org/packages/1f/49/011d472814af4fabeaab7d7ce3d5a1a635a3dadc23ae404d1f546839ecb3/nodejs_wheel_binaries-22.15.0-py2.py3-none-win_arm64.whl", hash = "sha256:01a3fe4d60477f93bf21a44219db33548c75d7fed6dc6e6f4c05cf0adf015609", size = 36436645, upload-time = "2025-04-23T16:57:36.326Z" }, 205 | ] 206 | 207 | [[package]] 208 | name = "numpy" 209 | version = "2.2.5" 210 | source = { registry = "https://pypi.org/simple" } 211 | sdist = { url = "https://files.pythonhosted.org/packages/dc/b2/ce4b867d8cd9c0ee84938ae1e6a6f7926ebf928c9090d036fc3c6a04f946/numpy-2.2.5.tar.gz", hash = "sha256:a9c0d994680cd991b1cb772e8b297340085466a6fe964bc9d4e80f5e2f43c291", size = 20273920, upload-time = "2025-04-19T23:27:42.561Z" } 212 | wheels = [ 213 | { url = "https://files.pythonhosted.org/packages/e2/a0/0aa7f0f4509a2e07bd7a509042967c2fab635690d4f48c6c7b3afd4f448c/numpy-2.2.5-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:059b51b658f4414fff78c6d7b1b4e18283ab5fa56d270ff212d5ba0c561846f4", size = 20935102, upload-time = "2025-04-19T22:41:16.234Z" }, 214 | { url = "https://files.pythonhosted.org/packages/7e/e4/a6a9f4537542912ec513185396fce52cdd45bdcf3e9d921ab02a93ca5aa9/numpy-2.2.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:47f9ed103af0bc63182609044b0490747e03bd20a67e391192dde119bf43d52f", size = 14191709, upload-time = "2025-04-19T22:41:38.472Z" }, 215 | { url = "https://files.pythonhosted.org/packages/be/65/72f3186b6050bbfe9c43cb81f9df59ae63603491d36179cf7a7c8d216758/numpy-2.2.5-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:261a1ef047751bb02f29dfe337230b5882b54521ca121fc7f62668133cb119c9", size = 5149173, upload-time = "2025-04-19T22:41:47.823Z" }, 216 | { url = "https://files.pythonhosted.org/packages/e5/e9/83e7a9432378dde5802651307ae5e9ea07bb72b416728202218cd4da2801/numpy-2.2.5-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:4520caa3807c1ceb005d125a75e715567806fed67e315cea619d5ec6e75a4191", size = 6684502, upload-time = "2025-04-19T22:41:58.689Z" }, 217 | { url = "https://files.pythonhosted.org/packages/ea/27/b80da6c762394c8ee516b74c1f686fcd16c8f23b14de57ba0cad7349d1d2/numpy-2.2.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3d14b17b9be5f9c9301f43d2e2a4886a33b53f4e6fdf9ca2f4cc60aeeee76372", size = 14084417, upload-time = "2025-04-19T22:42:19.897Z" }, 218 | { url = "https://files.pythonhosted.org/packages/aa/fc/ebfd32c3e124e6a1043e19c0ab0769818aa69050ce5589b63d05ff185526/numpy-2.2.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ba321813a00e508d5421104464510cc962a6f791aa2fca1c97b1e65027da80d", size = 16133807, upload-time = "2025-04-19T22:42:44.433Z" }, 219 | { url = "https://files.pythonhosted.org/packages/bf/9b/4cc171a0acbe4666f7775cfd21d4eb6bb1d36d3a0431f48a73e9212d2278/numpy-2.2.5-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a4cbdef3ddf777423060c6f81b5694bad2dc9675f110c4b2a60dc0181543fac7", size = 15575611, upload-time = "2025-04-19T22:43:09.928Z" }, 220 | { url = "https://files.pythonhosted.org/packages/a3/45/40f4135341850df48f8edcf949cf47b523c404b712774f8855a64c96ef29/numpy-2.2.5-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:54088a5a147ab71a8e7fdfd8c3601972751ded0739c6b696ad9cb0343e21ab73", size = 17895747, upload-time = "2025-04-19T22:43:36.983Z" }, 221 | { url = "https://files.pythonhosted.org/packages/f8/4c/b32a17a46f0ffbde8cc82df6d3daeaf4f552e346df143e1b188a701a8f09/numpy-2.2.5-cp313-cp313-win32.whl", hash = "sha256:c8b82a55ef86a2d8e81b63da85e55f5537d2157165be1cb2ce7cfa57b6aef38b", size = 6309594, upload-time = "2025-04-19T22:47:10.523Z" }, 222 | { url = "https://files.pythonhosted.org/packages/13/ae/72e6276feb9ef06787365b05915bfdb057d01fceb4a43cb80978e518d79b/numpy-2.2.5-cp313-cp313-win_amd64.whl", hash = "sha256:d8882a829fd779f0f43998e931c466802a77ca1ee0fe25a3abe50278616b1471", size = 12638356, upload-time = "2025-04-19T22:47:30.253Z" }, 223 | { url = "https://files.pythonhosted.org/packages/79/56/be8b85a9f2adb688e7ded6324e20149a03541d2b3297c3ffc1a73f46dedb/numpy-2.2.5-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:e8b025c351b9f0e8b5436cf28a07fa4ac0204d67b38f01433ac7f9b870fa38c6", size = 20963778, upload-time = "2025-04-19T22:44:09.251Z" }, 224 | { url = "https://files.pythonhosted.org/packages/ff/77/19c5e62d55bff507a18c3cdff82e94fe174957bad25860a991cac719d3ab/numpy-2.2.5-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:8dfa94b6a4374e7851bbb6f35e6ded2120b752b063e6acdd3157e4d2bb922eba", size = 14207279, upload-time = "2025-04-19T22:44:31.383Z" }, 225 | { url = "https://files.pythonhosted.org/packages/75/22/aa11f22dc11ff4ffe4e849d9b63bbe8d4ac6d5fae85ddaa67dfe43be3e76/numpy-2.2.5-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:97c8425d4e26437e65e1d189d22dff4a079b747ff9c2788057bfb8114ce1e133", size = 5199247, upload-time = "2025-04-19T22:44:40.361Z" }, 226 | { url = "https://files.pythonhosted.org/packages/4f/6c/12d5e760fc62c08eded0394f62039f5a9857f758312bf01632a81d841459/numpy-2.2.5-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:352d330048c055ea6db701130abc48a21bec690a8d38f8284e00fab256dc1376", size = 6711087, upload-time = "2025-04-19T22:44:51.188Z" }, 227 | { url = "https://files.pythonhosted.org/packages/ef/94/ece8280cf4218b2bee5cec9567629e61e51b4be501e5c6840ceb593db945/numpy-2.2.5-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b4c0773b6ada798f51f0f8e30c054d32304ccc6e9c5d93d46cb26f3d385ab19", size = 14059964, upload-time = "2025-04-19T22:45:12.451Z" }, 228 | { url = "https://files.pythonhosted.org/packages/39/41/c5377dac0514aaeec69115830a39d905b1882819c8e65d97fc60e177e19e/numpy-2.2.5-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:55f09e00d4dccd76b179c0f18a44f041e5332fd0e022886ba1c0bbf3ea4a18d0", size = 16121214, upload-time = "2025-04-19T22:45:37.734Z" }, 229 | { url = "https://files.pythonhosted.org/packages/db/54/3b9f89a943257bc8e187145c6bc0eb8e3d615655f7b14e9b490b053e8149/numpy-2.2.5-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:02f226baeefa68f7d579e213d0f3493496397d8f1cff5e2b222af274c86a552a", size = 15575788, upload-time = "2025-04-19T22:46:01.908Z" }, 230 | { url = "https://files.pythonhosted.org/packages/b1/c4/2e407e85df35b29f79945751b8f8e671057a13a376497d7fb2151ba0d290/numpy-2.2.5-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:c26843fd58f65da9491165072da2cccc372530681de481ef670dcc8e27cfb066", size = 17893672, upload-time = "2025-04-19T22:46:28.585Z" }, 231 | { url = "https://files.pythonhosted.org/packages/29/7e/d0b44e129d038dba453f00d0e29ebd6eaf2f06055d72b95b9947998aca14/numpy-2.2.5-cp313-cp313t-win32.whl", hash = "sha256:1a161c2c79ab30fe4501d5a2bbfe8b162490757cf90b7f05be8b80bc02f7bb8e", size = 6377102, upload-time = "2025-04-19T22:46:39.949Z" }, 232 | { url = "https://files.pythonhosted.org/packages/63/be/b85e4aa4bf42c6502851b971f1c326d583fcc68227385f92089cf50a7b45/numpy-2.2.5-cp313-cp313t-win_amd64.whl", hash = "sha256:d403c84991b5ad291d3809bace5e85f4bbf44a04bdc9a88ed2bb1807b3360bb8", size = 12750096, upload-time = "2025-04-19T22:47:00.147Z" }, 233 | ] 234 | 235 | [[package]] 236 | name = "ollama" 237 | version = "0.4.8" 238 | source = { registry = "https://pypi.org/simple" } 239 | dependencies = [ 240 | { name = "httpx" }, 241 | { name = "pydantic" }, 242 | ] 243 | sdist = { url = "https://files.pythonhosted.org/packages/e2/64/709dc99030f8f46ec552f0a7da73bbdcc2da58666abfec4742ccdb2e800e/ollama-0.4.8.tar.gz", hash = "sha256:1121439d49b96fa8339842965d0616eba5deb9f8c790786cdf4c0b3df4833802", size = 12972, upload-time = "2025-04-16T21:55:14.101Z" } 244 | wheels = [ 245 | { url = "https://files.pythonhosted.org/packages/33/3f/164de150e983b3a16e8bf3d4355625e51a357e7b3b1deebe9cc1f7cb9af8/ollama-0.4.8-py3-none-any.whl", hash = "sha256:04312af2c5e72449aaebac4a2776f52ef010877c554103419d3f36066fe8af4c", size = 13325, upload-time = "2025-04-16T21:55:12.779Z" }, 246 | ] 247 | 248 | [[package]] 249 | name = "partial-json-parser" 250 | version = "0.2.1.1.post5" 251 | source = { registry = "https://pypi.org/simple" } 252 | sdist = { url = "https://files.pythonhosted.org/packages/27/9c/9c366aed65acb40a97842ce1375a87b27ea37d735fc9717f7729bae3cc00/partial_json_parser-0.2.1.1.post5.tar.gz", hash = "sha256:992710ac67e90b367921d52727698928040f7713ba7ecb33b96371ea7aec82ca", size = 10313, upload-time = "2025-01-08T15:44:02.147Z" } 253 | wheels = [ 254 | { url = "https://files.pythonhosted.org/packages/8c/ee/a9476f01f27c74420601be208c6c2c0dd3486681d515e9d765931b89851c/partial_json_parser-0.2.1.1.post5-py3-none-any.whl", hash = "sha256:627715aaa3cb3fb60a65b0d62223243acaa6c70846520a90326fef3a2f0b61ca", size = 10885, upload-time = "2025-01-08T15:44:00.987Z" }, 255 | ] 256 | 257 | [[package]] 258 | name = "prompt-toolkit" 259 | version = "3.0.51" 260 | source = { registry = "https://pypi.org/simple" } 261 | dependencies = [ 262 | { name = "wcwidth" }, 263 | ] 264 | sdist = { url = "https://files.pythonhosted.org/packages/bb/6e/9d084c929dfe9e3bfe0c6a47e31f78a25c54627d64a66e884a8bf5474f1c/prompt_toolkit-3.0.51.tar.gz", hash = "sha256:931a162e3b27fc90c86f1b48bb1fb2c528c2761475e57c9c06de13311c7b54ed", size = 428940, upload-time = "2025-04-15T09:18:47.731Z" } 265 | wheels = [ 266 | { url = "https://files.pythonhosted.org/packages/ce/4f/5249960887b1fbe561d9ff265496d170b55a735b76724f10ef19f9e40716/prompt_toolkit-3.0.51-py3-none-any.whl", hash = "sha256:52742911fde84e2d423e2f9a4cf1de7d7ac4e51958f648d9540e0fb8db077b07", size = 387810, upload-time = "2025-04-15T09:18:44.753Z" }, 267 | ] 268 | 269 | [[package]] 270 | name = "pydantic" 271 | version = "2.11.4" 272 | source = { registry = "https://pypi.org/simple" } 273 | dependencies = [ 274 | { name = "annotated-types" }, 275 | { name = "pydantic-core" }, 276 | { name = "typing-extensions" }, 277 | { name = "typing-inspection" }, 278 | ] 279 | sdist = { url = "https://files.pythonhosted.org/packages/77/ab/5250d56ad03884ab5efd07f734203943c8a8ab40d551e208af81d0257bf2/pydantic-2.11.4.tar.gz", hash = "sha256:32738d19d63a226a52eed76645a98ee07c1f410ee41d93b4afbfa85ed8111c2d", size = 786540, upload-time = "2025-04-29T20:38:55.02Z" } 280 | wheels = [ 281 | { url = "https://files.pythonhosted.org/packages/e7/12/46b65f3534d099349e38ef6ec98b1a5a81f42536d17e0ba382c28c67ba67/pydantic-2.11.4-py3-none-any.whl", hash = "sha256:d9615eaa9ac5a063471da949c8fc16376a84afb5024688b3ff885693506764eb", size = 443900, upload-time = "2025-04-29T20:38:52.724Z" }, 282 | ] 283 | 284 | [[package]] 285 | name = "pydantic-core" 286 | version = "2.33.2" 287 | source = { registry = "https://pypi.org/simple" } 288 | dependencies = [ 289 | { name = "typing-extensions" }, 290 | ] 291 | sdist = { url = "https://files.pythonhosted.org/packages/ad/88/5f2260bdfae97aabf98f1778d43f69574390ad787afb646292a638c923d4/pydantic_core-2.33.2.tar.gz", hash = "sha256:7cb8bc3605c29176e1b105350d2e6474142d7c1bd1d9327c4a9bdb46bf827acc", size = 435195, upload-time = "2025-04-23T18:33:52.104Z" } 292 | wheels = [ 293 | { url = "https://files.pythonhosted.org/packages/46/8c/99040727b41f56616573a28771b1bfa08a3d3fe74d3d513f01251f79f172/pydantic_core-2.33.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:1082dd3e2d7109ad8b7da48e1d4710c8d06c253cbc4a27c1cff4fbcaa97a9e3f", size = 2015688, upload-time = "2025-04-23T18:31:53.175Z" }, 294 | { url = "https://files.pythonhosted.org/packages/3a/cc/5999d1eb705a6cefc31f0b4a90e9f7fc400539b1a1030529700cc1b51838/pydantic_core-2.33.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f517ca031dfc037a9c07e748cefd8d96235088b83b4f4ba8939105d20fa1dcd6", size = 1844808, upload-time = "2025-04-23T18:31:54.79Z" }, 295 | { url = "https://files.pythonhosted.org/packages/6f/5e/a0a7b8885c98889a18b6e376f344da1ef323d270b44edf8174d6bce4d622/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a9f2c9dd19656823cb8250b0724ee9c60a82f3cdf68a080979d13092a3b0fef", size = 1885580, upload-time = "2025-04-23T18:31:57.393Z" }, 296 | { url = "https://files.pythonhosted.org/packages/3b/2a/953581f343c7d11a304581156618c3f592435523dd9d79865903272c256a/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2b0a451c263b01acebe51895bfb0e1cc842a5c666efe06cdf13846c7418caa9a", size = 1973859, upload-time = "2025-04-23T18:31:59.065Z" }, 297 | { url = "https://files.pythonhosted.org/packages/e6/55/f1a813904771c03a3f97f676c62cca0c0a4138654107c1b61f19c644868b/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ea40a64d23faa25e62a70ad163571c0b342b8bf66d5fa612ac0dec4f069d916", size = 2120810, upload-time = "2025-04-23T18:32:00.78Z" }, 298 | { url = "https://files.pythonhosted.org/packages/aa/c3/053389835a996e18853ba107a63caae0b9deb4a276c6b472931ea9ae6e48/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fb2d542b4d66f9470e8065c5469ec676978d625a8b7a363f07d9a501a9cb36a", size = 2676498, upload-time = "2025-04-23T18:32:02.418Z" }, 299 | { url = "https://files.pythonhosted.org/packages/eb/3c/f4abd740877a35abade05e437245b192f9d0ffb48bbbbd708df33d3cda37/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fdac5d6ffa1b5a83bca06ffe7583f5576555e6c8b3a91fbd25ea7780f825f7d", size = 2000611, upload-time = "2025-04-23T18:32:04.152Z" }, 300 | { url = "https://files.pythonhosted.org/packages/59/a7/63ef2fed1837d1121a894d0ce88439fe3e3b3e48c7543b2a4479eb99c2bd/pydantic_core-2.33.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:04a1a413977ab517154eebb2d326da71638271477d6ad87a769102f7c2488c56", size = 2107924, upload-time = "2025-04-23T18:32:06.129Z" }, 301 | { url = "https://files.pythonhosted.org/packages/04/8f/2551964ef045669801675f1cfc3b0d74147f4901c3ffa42be2ddb1f0efc4/pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:c8e7af2f4e0194c22b5b37205bfb293d166a7344a5b0d0eaccebc376546d77d5", size = 2063196, upload-time = "2025-04-23T18:32:08.178Z" }, 302 | { url = "https://files.pythonhosted.org/packages/26/bd/d9602777e77fc6dbb0c7db9ad356e9a985825547dce5ad1d30ee04903918/pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:5c92edd15cd58b3c2d34873597a1e20f13094f59cf88068adb18947df5455b4e", size = 2236389, upload-time = "2025-04-23T18:32:10.242Z" }, 303 | { url = "https://files.pythonhosted.org/packages/42/db/0e950daa7e2230423ab342ae918a794964b053bec24ba8af013fc7c94846/pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:65132b7b4a1c0beded5e057324b7e16e10910c106d43675d9bd87d4f38dde162", size = 2239223, upload-time = "2025-04-23T18:32:12.382Z" }, 304 | { url = "https://files.pythonhosted.org/packages/58/4d/4f937099c545a8a17eb52cb67fe0447fd9a373b348ccfa9a87f141eeb00f/pydantic_core-2.33.2-cp313-cp313-win32.whl", hash = "sha256:52fb90784e0a242bb96ec53f42196a17278855b0f31ac7c3cc6f5c1ec4811849", size = 1900473, upload-time = "2025-04-23T18:32:14.034Z" }, 305 | { url = "https://files.pythonhosted.org/packages/a0/75/4a0a9bac998d78d889def5e4ef2b065acba8cae8c93696906c3a91f310ca/pydantic_core-2.33.2-cp313-cp313-win_amd64.whl", hash = "sha256:c083a3bdd5a93dfe480f1125926afcdbf2917ae714bdb80b36d34318b2bec5d9", size = 1955269, upload-time = "2025-04-23T18:32:15.783Z" }, 306 | { url = "https://files.pythonhosted.org/packages/f9/86/1beda0576969592f1497b4ce8e7bc8cbdf614c352426271b1b10d5f0aa64/pydantic_core-2.33.2-cp313-cp313-win_arm64.whl", hash = "sha256:e80b087132752f6b3d714f041ccf74403799d3b23a72722ea2e6ba2e892555b9", size = 1893921, upload-time = "2025-04-23T18:32:18.473Z" }, 307 | { url = "https://files.pythonhosted.org/packages/a4/7d/e09391c2eebeab681df2b74bfe6c43422fffede8dc74187b2b0bf6fd7571/pydantic_core-2.33.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:61c18fba8e5e9db3ab908620af374db0ac1baa69f0f32df4f61ae23f15e586ac", size = 1806162, upload-time = "2025-04-23T18:32:20.188Z" }, 308 | { url = "https://files.pythonhosted.org/packages/f1/3d/847b6b1fed9f8ed3bb95a9ad04fbd0b212e832d4f0f50ff4d9ee5a9f15cf/pydantic_core-2.33.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95237e53bb015f67b63c91af7518a62a8660376a6a0db19b89acc77a4d6199f5", size = 1981560, upload-time = "2025-04-23T18:32:22.354Z" }, 309 | { url = "https://files.pythonhosted.org/packages/6f/9a/e73262f6c6656262b5fdd723ad90f518f579b7bc8622e43a942eec53c938/pydantic_core-2.33.2-cp313-cp313t-win_amd64.whl", hash = "sha256:c2fc0a768ef76c15ab9238afa6da7f69895bb5d1ee83aeea2e3509af4472d0b9", size = 1935777, upload-time = "2025-04-23T18:32:25.088Z" }, 310 | ] 311 | 312 | [[package]] 313 | name = "pygments" 314 | version = "2.19.1" 315 | source = { registry = "https://pypi.org/simple" } 316 | sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581, upload-time = "2025-01-06T17:26:30.443Z" } 317 | wheels = [ 318 | { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293, upload-time = "2025-01-06T17:26:25.553Z" }, 319 | ] 320 | 321 | [[package]] 322 | name = "rich" 323 | version = "13.9.4" 324 | source = { registry = "https://pypi.org/simple" } 325 | dependencies = [ 326 | { name = "markdown-it-py" }, 327 | { name = "pygments" }, 328 | ] 329 | sdist = { url = "https://files.pythonhosted.org/packages/ab/3a/0316b28d0761c6734d6bc14e770d85506c986c85ffb239e688eeaab2c2bc/rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098", size = 223149, upload-time = "2024-11-01T16:43:57.873Z" } 330 | wheels = [ 331 | { url = "https://files.pythonhosted.org/packages/19/71/39c7c0d87f8d4e6c020a393182060eaefeeae6c01dab6a84ec346f2567df/rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90", size = 242424, upload-time = "2024-11-01T16:43:55.817Z" }, 332 | ] 333 | 334 | [[package]] 335 | name = "ruff" 336 | version = "0.9.10" 337 | source = { registry = "https://pypi.org/simple" } 338 | sdist = { url = "https://files.pythonhosted.org/packages/20/8e/fafaa6f15c332e73425d9c44ada85360501045d5ab0b81400076aff27cf6/ruff-0.9.10.tar.gz", hash = "sha256:9bacb735d7bada9cfb0f2c227d3658fc443d90a727b47f206fb33f52f3c0eac7", size = 3759776, upload-time = "2025-03-07T15:27:44.363Z" } 339 | wheels = [ 340 | { url = "https://files.pythonhosted.org/packages/73/b2/af7c2cc9e438cbc19fafeec4f20bfcd72165460fe75b2b6e9a0958c8c62b/ruff-0.9.10-py3-none-linux_armv6l.whl", hash = "sha256:eb4d25532cfd9fe461acc83498361ec2e2252795b4f40b17e80692814329e42d", size = 10049494, upload-time = "2025-03-07T15:26:51.268Z" }, 341 | { url = "https://files.pythonhosted.org/packages/6d/12/03f6dfa1b95ddd47e6969f0225d60d9d7437c91938a310835feb27927ca0/ruff-0.9.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:188a6638dab1aa9bb6228a7302387b2c9954e455fb25d6b4470cb0641d16759d", size = 10853584, upload-time = "2025-03-07T15:26:56.104Z" }, 342 | { url = "https://files.pythonhosted.org/packages/02/49/1c79e0906b6ff551fb0894168763f705bf980864739572b2815ecd3c9df0/ruff-0.9.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5284dcac6b9dbc2fcb71fdfc26a217b2ca4ede6ccd57476f52a587451ebe450d", size = 10155692, upload-time = "2025-03-07T15:27:01.385Z" }, 343 | { url = "https://files.pythonhosted.org/packages/5b/01/85e8082e41585e0e1ceb11e41c054e9e36fed45f4b210991052d8a75089f/ruff-0.9.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:47678f39fa2a3da62724851107f438c8229a3470f533894b5568a39b40029c0c", size = 10369760, upload-time = "2025-03-07T15:27:04.023Z" }, 344 | { url = "https://files.pythonhosted.org/packages/a1/90/0bc60bd4e5db051f12445046d0c85cc2c617095c0904f1aa81067dc64aea/ruff-0.9.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:99713a6e2766b7a17147b309e8c915b32b07a25c9efd12ada79f217c9c778b3e", size = 9912196, upload-time = "2025-03-07T15:27:06.93Z" }, 345 | { url = "https://files.pythonhosted.org/packages/66/ea/0b7e8c42b1ec608033c4d5a02939c82097ddcb0b3e393e4238584b7054ab/ruff-0.9.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:524ee184d92f7c7304aa568e2db20f50c32d1d0caa235d8ddf10497566ea1a12", size = 11434985, upload-time = "2025-03-07T15:27:10.082Z" }, 346 | { url = "https://files.pythonhosted.org/packages/d5/86/3171d1eff893db4f91755175a6e1163c5887be1f1e2f4f6c0c59527c2bfd/ruff-0.9.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:df92aeac30af821f9acf819fc01b4afc3dfb829d2782884f8739fb52a8119a16", size = 12155842, upload-time = "2025-03-07T15:27:12.727Z" }, 347 | { url = "https://files.pythonhosted.org/packages/89/9e/700ca289f172a38eb0bca752056d0a42637fa17b81649b9331786cb791d7/ruff-0.9.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de42e4edc296f520bb84954eb992a07a0ec5a02fecb834498415908469854a52", size = 11613804, upload-time = "2025-03-07T15:27:15.944Z" }, 348 | { url = "https://files.pythonhosted.org/packages/f2/92/648020b3b5db180f41a931a68b1c8575cca3e63cec86fd26807422a0dbad/ruff-0.9.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d257f95b65806104b6b1ffca0ea53f4ef98454036df65b1eda3693534813ecd1", size = 13823776, upload-time = "2025-03-07T15:27:18.996Z" }, 349 | { url = "https://files.pythonhosted.org/packages/5e/a6/cc472161cd04d30a09d5c90698696b70c169eeba2c41030344194242db45/ruff-0.9.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b60dec7201c0b10d6d11be00e8f2dbb6f40ef1828ee75ed739923799513db24c", size = 11302673, upload-time = "2025-03-07T15:27:21.655Z" }, 350 | { url = "https://files.pythonhosted.org/packages/6c/db/d31c361c4025b1b9102b4d032c70a69adb9ee6fde093f6c3bf29f831c85c/ruff-0.9.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:d838b60007da7a39c046fcdd317293d10b845001f38bcb55ba766c3875b01e43", size = 10235358, upload-time = "2025-03-07T15:27:24.72Z" }, 351 | { url = "https://files.pythonhosted.org/packages/d1/86/d6374e24a14d4d93ebe120f45edd82ad7dcf3ef999ffc92b197d81cdc2a5/ruff-0.9.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ccaf903108b899beb8e09a63ffae5869057ab649c1e9231c05ae354ebc62066c", size = 9886177, upload-time = "2025-03-07T15:27:27.282Z" }, 352 | { url = "https://files.pythonhosted.org/packages/00/62/a61691f6eaaac1e945a1f3f59f1eea9a218513139d5b6c2b8f88b43b5b8f/ruff-0.9.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f9567d135265d46e59d62dc60c0bfad10e9a6822e231f5b24032dba5a55be6b5", size = 10864747, upload-time = "2025-03-07T15:27:30.637Z" }, 353 | { url = "https://files.pythonhosted.org/packages/ee/94/2c7065e1d92a8a8a46d46d9c3cf07b0aa7e0a1e0153d74baa5e6620b4102/ruff-0.9.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5f202f0d93738c28a89f8ed9eaba01b7be339e5d8d642c994347eaa81c6d75b8", size = 11360441, upload-time = "2025-03-07T15:27:33.356Z" }, 354 | { url = "https://files.pythonhosted.org/packages/a7/8f/1f545ea6f9fcd7bf4368551fb91d2064d8f0577b3079bb3f0ae5779fb773/ruff-0.9.10-py3-none-win32.whl", hash = "sha256:bfb834e87c916521ce46b1788fbb8484966e5113c02df216680102e9eb960029", size = 10247401, upload-time = "2025-03-07T15:27:35.994Z" }, 355 | { url = "https://files.pythonhosted.org/packages/4f/18/fb703603ab108e5c165f52f5b86ee2aa9be43bb781703ec87c66a5f5d604/ruff-0.9.10-py3-none-win_amd64.whl", hash = "sha256:f2160eeef3031bf4b17df74e307d4c5fb689a6f3a26a2de3f7ef4044e3c484f1", size = 11366360, upload-time = "2025-03-07T15:27:38.66Z" }, 356 | { url = "https://files.pythonhosted.org/packages/35/85/338e603dc68e7d9994d5d84f24adbf69bae760ba5efd3e20f5ff2cec18da/ruff-0.9.10-py3-none-win_arm64.whl", hash = "sha256:5fd804c0327a5e5ea26615550e706942f348b197d5475ff34c19733aee4b2e69", size = 10436892, upload-time = "2025-03-07T15:27:41.687Z" }, 357 | ] 358 | 359 | [[package]] 360 | name = "sniffio" 361 | version = "1.3.1" 362 | source = { registry = "https://pypi.org/simple" } 363 | 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" } 364 | wheels = [ 365 | { 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" }, 366 | ] 367 | 368 | [[package]] 369 | name = "typing-extensions" 370 | version = "4.13.2" 371 | source = { registry = "https://pypi.org/simple" } 372 | sdist = { url = "https://files.pythonhosted.org/packages/f6/37/23083fcd6e35492953e8d2aaaa68b860eb422b34627b13f2ce3eb6106061/typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef", size = 106967, upload-time = "2025-04-10T14:19:05.416Z" } 373 | wheels = [ 374 | { url = "https://files.pythonhosted.org/packages/8b/54/b1ae86c0973cc6f0210b53d508ca3641fb6d0c56823f288d108bc7ab3cc8/typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c", size = 45806, upload-time = "2025-04-10T14:19:03.967Z" }, 375 | ] 376 | 377 | [[package]] 378 | name = "typing-inspection" 379 | version = "0.4.0" 380 | source = { registry = "https://pypi.org/simple" } 381 | dependencies = [ 382 | { name = "typing-extensions" }, 383 | ] 384 | sdist = { url = "https://files.pythonhosted.org/packages/82/5c/e6082df02e215b846b4b8c0b887a64d7d08ffaba30605502639d44c06b82/typing_inspection-0.4.0.tar.gz", hash = "sha256:9765c87de36671694a67904bf2c96e395be9c6439bb6c87b5142569dcdd65122", size = 76222, upload-time = "2025-02-25T17:27:59.638Z" } 385 | wheels = [ 386 | { url = "https://files.pythonhosted.org/packages/31/08/aa4fdfb71f7de5176385bd9e90852eaf6b5d622735020ad600f2bab54385/typing_inspection-0.4.0-py3-none-any.whl", hash = "sha256:50e72559fcd2a6367a19f7a7e610e6afcb9fac940c650290eed893d61386832f", size = 14125, upload-time = "2025-02-25T17:27:57.754Z" }, 387 | ] 388 | 389 | [[package]] 390 | name = "wcwidth" 391 | version = "0.2.13" 392 | source = { registry = "https://pypi.org/simple" } 393 | sdist = { url = "https://files.pythonhosted.org/packages/6c/63/53559446a878410fc5a5974feb13d31d78d752eb18aeba59c7fef1af7598/wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5", size = 101301, upload-time = "2024-01-06T02:10:57.829Z" } 394 | wheels = [ 395 | { url = "https://files.pythonhosted.org/packages/fd/84/fd2ba7aafacbad3c4201d395674fc6348826569da3c0937e75505ead3528/wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859", size = 34166, upload-time = "2024-01-06T02:10:55.763Z" }, 396 | ] 397 | --------------------------------------------------------------------------------