├── .DS_Store ├── .gitignore ├── LICENSE ├── Project.toml ├── docs ├── .DS_Store ├── Manifest.toml ├── Project.toml ├── build │ ├── .DS_Store │ ├── .documenter-siteinfo.json │ ├── assets │ │ ├── documenter.js │ │ ├── themes │ │ │ ├── catppuccin-frappe.css │ │ │ ├── catppuccin-latte.css │ │ │ ├── catppuccin-macchiato.css │ │ │ ├── catppuccin-mocha.css │ │ │ ├── documenter-dark.css │ │ │ └── documenter-light.css │ │ ├── themeswap.js │ │ └── warner.js │ ├── index.html │ ├── objects.inv │ ├── overview.png │ ├── result1.png │ ├── result2.png │ ├── result3.png │ └── search_index.js ├── make.jl └── src │ ├── .DS_Store │ ├── index.md │ ├── overview.png │ ├── result1.png │ ├── result2.png │ └── result3.png ├── overview.png ├── readme.md └── src ├── .DS_Store ├── AskAI.jl ├── brain.jl └── models.jl /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | .Thumbs.db 5 | .Spotlight-V100 6 | .Trashes 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /Project.toml: -------------------------------------------------------------------------------- 1 | name = "AskAI" 2 | uuid = "588cbdfa-cf4b-4042-a2dc-5cbacb154fbb" 3 | authors = ["AIBioLab"] 4 | version = "0.1.2" 5 | 6 | [deps] 7 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 8 | JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" 9 | Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" 10 | ReplMaker = "b873ce64-0db9-51f5-a568-4457d8e49576" 11 | 12 | [compat] 13 | ReplMaker = "0.2.7" 14 | -------------------------------------------------------------------------------- /docs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/.DS_Store -------------------------------------------------------------------------------- /docs/Manifest.toml: -------------------------------------------------------------------------------- 1 | # This file is machine-generated - editing it directly is not advised 2 | 3 | julia_version = "1.10.2" 4 | manifest_format = "2.0" 5 | project_hash = "e0c77beb18dc1f6cce661ebd60658c0c1a77390f" 6 | 7 | [[deps.ANSIColoredPrinters]] 8 | git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c" 9 | uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" 10 | version = "0.0.1" 11 | 12 | [[deps.AbstractTrees]] 13 | git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177" 14 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 15 | version = "0.4.5" 16 | 17 | [[deps.ArgTools]] 18 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 19 | version = "1.1.1" 20 | 21 | [[deps.Artifacts]] 22 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 23 | 24 | [[deps.Base64]] 25 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 26 | 27 | [[deps.CodecZlib]] 28 | deps = ["TranscodingStreams", "Zlib_jll"] 29 | git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9" 30 | uuid = "944b1d66-785c-5afd-91f1-9de20f533193" 31 | version = "0.7.8" 32 | 33 | [[deps.Dates]] 34 | deps = ["Printf"] 35 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 36 | 37 | [[deps.DocStringExtensions]] 38 | git-tree-sha1 = "e7b7e6f178525d17c720ab9c081e4ef04429f860" 39 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 40 | version = "0.9.4" 41 | 42 | [[deps.Documenter]] 43 | deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "CodecZlib", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "TOML", "Test", "Unicode"] 44 | git-tree-sha1 = "9d733459cea04dcf1c41522ec25c31576387be8a" 45 | uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 46 | version = "1.10.1" 47 | 48 | [[deps.Downloads]] 49 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 50 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 51 | version = "1.6.0" 52 | 53 | [[deps.Expat_jll]] 54 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 55 | git-tree-sha1 = "d55dffd9ae73ff72f1c0482454dcf2ec6c6c4a63" 56 | uuid = "2e619515-83b5-522b-bb60-26c02a35a201" 57 | version = "2.6.5+0" 58 | 59 | [[deps.FileWatching]] 60 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 61 | 62 | [[deps.Git]] 63 | deps = ["Git_jll"] 64 | git-tree-sha1 = "04eff47b1354d702c3a85e8ab23d539bb7d5957e" 65 | uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2" 66 | version = "1.3.1" 67 | 68 | [[deps.Git_jll]] 69 | deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"] 70 | git-tree-sha1 = "2f6d6f7e6d6de361865d4394b802c02fc944fc7c" 71 | uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" 72 | version = "2.49.0+0" 73 | 74 | [[deps.IOCapture]] 75 | deps = ["Logging", "Random"] 76 | git-tree-sha1 = "b6d6bfdd7ce25b0f9b2f6b3dd56b2673a66c8770" 77 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 78 | version = "0.2.5" 79 | 80 | [[deps.InteractiveUtils]] 81 | deps = ["Markdown"] 82 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 83 | 84 | [[deps.JLLWrappers]] 85 | deps = ["Artifacts", "Preferences"] 86 | git-tree-sha1 = "a007feb38b422fbdab534406aeca1b86823cb4d6" 87 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" 88 | version = "1.7.0" 89 | 90 | [[deps.JSON]] 91 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 92 | git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" 93 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 94 | version = "0.21.4" 95 | 96 | [[deps.LazilyInitializedFields]] 97 | git-tree-sha1 = "0f2da712350b020bc3957f269c9caad516383ee0" 98 | uuid = "0e77f7df-68c5-4e49-93ce-4cd80f5598bf" 99 | version = "1.3.0" 100 | 101 | [[deps.LibCURL]] 102 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 103 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 104 | version = "0.6.4" 105 | 106 | [[deps.LibCURL_jll]] 107 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 108 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 109 | version = "8.4.0+0" 110 | 111 | [[deps.LibGit2]] 112 | deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] 113 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 114 | 115 | [[deps.LibGit2_jll]] 116 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] 117 | uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" 118 | version = "1.6.4+0" 119 | 120 | [[deps.LibSSH2_jll]] 121 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 122 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 123 | version = "1.11.0+1" 124 | 125 | [[deps.Libdl]] 126 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 127 | 128 | [[deps.Libiconv_jll]] 129 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 130 | git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809" 131 | uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" 132 | version = "1.18.0+0" 133 | 134 | [[deps.Logging]] 135 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 136 | 137 | [[deps.Markdown]] 138 | deps = ["Base64"] 139 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 140 | 141 | [[deps.MarkdownAST]] 142 | deps = ["AbstractTrees", "Markdown"] 143 | git-tree-sha1 = "465a70f0fc7d443a00dcdc3267a497397b8a3899" 144 | uuid = "d0879d2d-cac2-40c8-9cee-1863dc0c7391" 145 | version = "0.1.2" 146 | 147 | [[deps.MbedTLS_jll]] 148 | deps = ["Artifacts", "Libdl"] 149 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 150 | version = "2.28.2+1" 151 | 152 | [[deps.Mmap]] 153 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 154 | 155 | [[deps.MozillaCACerts_jll]] 156 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 157 | version = "2023.1.10" 158 | 159 | [[deps.NetworkOptions]] 160 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 161 | version = "1.2.0" 162 | 163 | [[deps.OpenSSL_jll]] 164 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 165 | git-tree-sha1 = "a9697f1d06cc3eb3fb3ad49cc67f2cfabaac31ea" 166 | uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" 167 | version = "3.0.16+0" 168 | 169 | [[deps.PCRE2_jll]] 170 | deps = ["Artifacts", "Libdl"] 171 | uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" 172 | version = "10.42.0+1" 173 | 174 | [[deps.Parsers]] 175 | deps = ["Dates", "PrecompileTools", "UUIDs"] 176 | git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" 177 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 178 | version = "2.8.1" 179 | 180 | [[deps.Pkg]] 181 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 182 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 183 | version = "1.10.0" 184 | 185 | [[deps.PrecompileTools]] 186 | deps = ["Preferences"] 187 | git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" 188 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" 189 | version = "1.2.1" 190 | 191 | [[deps.Preferences]] 192 | deps = ["TOML"] 193 | git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" 194 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 195 | version = "1.4.3" 196 | 197 | [[deps.Printf]] 198 | deps = ["Unicode"] 199 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 200 | 201 | [[deps.REPL]] 202 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 203 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 204 | 205 | [[deps.Random]] 206 | deps = ["SHA"] 207 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 208 | 209 | [[deps.RegistryInstances]] 210 | deps = ["LazilyInitializedFields", "Pkg", "TOML", "Tar"] 211 | git-tree-sha1 = "ffd19052caf598b8653b99404058fce14828be51" 212 | uuid = "2792f1a3-b283-48e8-9a74-f99dce5104f3" 213 | version = "0.1.0" 214 | 215 | [[deps.SHA]] 216 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 217 | version = "0.7.0" 218 | 219 | [[deps.Serialization]] 220 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 221 | 222 | [[deps.Sockets]] 223 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 224 | 225 | [[deps.TOML]] 226 | deps = ["Dates"] 227 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 228 | version = "1.0.3" 229 | 230 | [[deps.Tar]] 231 | deps = ["ArgTools", "SHA"] 232 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 233 | version = "1.10.0" 234 | 235 | [[deps.Test]] 236 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 237 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 238 | 239 | [[deps.TranscodingStreams]] 240 | git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742" 241 | uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" 242 | version = "0.11.3" 243 | 244 | [[deps.UUIDs]] 245 | deps = ["Random", "SHA"] 246 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 247 | 248 | [[deps.Unicode]] 249 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 250 | 251 | [[deps.Zlib_jll]] 252 | deps = ["Libdl"] 253 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 254 | version = "1.2.13+1" 255 | 256 | [[deps.nghttp2_jll]] 257 | deps = ["Artifacts", "Libdl"] 258 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 259 | version = "1.52.0+1" 260 | 261 | [[deps.p7zip_jll]] 262 | deps = ["Artifacts", "Libdl"] 263 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 264 | version = "17.4.0+2" 265 | -------------------------------------------------------------------------------- /docs/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 3 | -------------------------------------------------------------------------------- /docs/build/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/build/.DS_Store -------------------------------------------------------------------------------- /docs/build/.documenter-siteinfo.json: -------------------------------------------------------------------------------- 1 | {"documenter":{"julia_version":"1.10.2","generation_timestamp":"2025-04-14T16:07:02","documenter_version":"1.10.1"}} -------------------------------------------------------------------------------- /docs/build/assets/documenter.js: -------------------------------------------------------------------------------- 1 | // Generated by Documenter.jl 2 | requirejs.config({ 3 | paths: { 4 | 'highlight-julia': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/julia.min', 5 | 'headroom': 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.12.0/headroom.min', 6 | 'jqueryui': 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min', 7 | 'katex-auto-render': 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/contrib/auto-render.min', 8 | 'jquery': 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min', 9 | 'headroom-jquery': 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.12.0/jQuery.headroom.min', 10 | 'katex': 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min', 11 | 'highlight': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min', 12 | 'highlight-julia-repl': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/julia-repl.min', 13 | }, 14 | shim: { 15 | "highlight-julia": { 16 | "deps": [ 17 | "highlight" 18 | ] 19 | }, 20 | "katex-auto-render": { 21 | "deps": [ 22 | "katex" 23 | ] 24 | }, 25 | "headroom-jquery": { 26 | "deps": [ 27 | "jquery", 28 | "headroom" 29 | ] 30 | }, 31 | "highlight-julia-repl": { 32 | "deps": [ 33 | "highlight" 34 | ] 35 | } 36 | } 37 | }); 38 | //////////////////////////////////////////////////////////////////////////////// 39 | require(['jquery', 'katex', 'katex-auto-render'], function($, katex, renderMathInElement) { 40 | $(document).ready(function() { 41 | renderMathInElement( 42 | document.body, 43 | { 44 | "delimiters": [ 45 | { 46 | "left": "$", 47 | "right": "$", 48 | "display": false 49 | }, 50 | { 51 | "left": "$$", 52 | "right": "$$", 53 | "display": true 54 | }, 55 | { 56 | "left": "\\[", 57 | "right": "\\]", 58 | "display": true 59 | } 60 | ] 61 | } 62 | 63 | ); 64 | }) 65 | 66 | }) 67 | //////////////////////////////////////////////////////////////////////////////// 68 | require(['jquery', 'highlight', 'highlight-julia', 'highlight-julia-repl'], function($) { 69 | $(document).ready(function() { 70 | hljs.highlightAll(); 71 | }) 72 | 73 | }) 74 | //////////////////////////////////////////////////////////////////////////////// 75 | require(['jquery'], function($) { 76 | 77 | let timer = 0; 78 | var isExpanded = true; 79 | 80 | $(document).on( 81 | "click", 82 | ".docstring .docstring-article-toggle-button", 83 | function () { 84 | let articleToggleTitle = "Expand docstring"; 85 | const parent = $(this).parent(); 86 | 87 | debounce(() => { 88 | if (parent.siblings("section").is(":visible")) { 89 | parent 90 | .find("a.docstring-article-toggle-button") 91 | .removeClass("fa-chevron-down") 92 | .addClass("fa-chevron-right"); 93 | } else { 94 | parent 95 | .find("a.docstring-article-toggle-button") 96 | .removeClass("fa-chevron-right") 97 | .addClass("fa-chevron-down"); 98 | 99 | articleToggleTitle = "Collapse docstring"; 100 | } 101 | 102 | parent 103 | .children(".docstring-article-toggle-button") 104 | .prop("title", articleToggleTitle); 105 | parent.siblings("section").slideToggle(); 106 | }); 107 | } 108 | ); 109 | 110 | $(document).on("click", ".docs-article-toggle-button", function (event) { 111 | let articleToggleTitle = "Expand docstring"; 112 | let navArticleToggleTitle = "Expand all docstrings"; 113 | let animationSpeed = event.noToggleAnimation ? 0 : 400; 114 | 115 | debounce(() => { 116 | if (isExpanded) { 117 | $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); 118 | $("a.docstring-article-toggle-button") 119 | .removeClass("fa-chevron-down") 120 | .addClass("fa-chevron-right"); 121 | 122 | isExpanded = false; 123 | 124 | $(".docstring section").slideUp(animationSpeed); 125 | } else { 126 | $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); 127 | $("a.docstring-article-toggle-button") 128 | .removeClass("fa-chevron-right") 129 | .addClass("fa-chevron-down"); 130 | 131 | isExpanded = true; 132 | articleToggleTitle = "Collapse docstring"; 133 | navArticleToggleTitle = "Collapse all docstrings"; 134 | 135 | $(".docstring section").slideDown(animationSpeed); 136 | } 137 | 138 | $(this).prop("title", navArticleToggleTitle); 139 | $(".docstring-article-toggle-button").prop("title", articleToggleTitle); 140 | }); 141 | }); 142 | 143 | function debounce(callback, timeout = 300) { 144 | if (Date.now() - timer > timeout) { 145 | callback(); 146 | } 147 | 148 | clearTimeout(timer); 149 | 150 | timer = Date.now(); 151 | } 152 | 153 | }) 154 | //////////////////////////////////////////////////////////////////////////////// 155 | require([], function() { 156 | function addCopyButtonCallbacks() { 157 | for (const el of document.getElementsByTagName("pre")) { 158 | const button = document.createElement("button"); 159 | button.classList.add("copy-button", "fa-solid", "fa-copy"); 160 | button.setAttribute("aria-label", "Copy this code block"); 161 | button.setAttribute("title", "Copy"); 162 | 163 | el.appendChild(button); 164 | 165 | const success = function () { 166 | button.classList.add("success", "fa-check"); 167 | button.classList.remove("fa-copy"); 168 | }; 169 | 170 | const failure = function () { 171 | button.classList.add("error", "fa-xmark"); 172 | button.classList.remove("fa-copy"); 173 | }; 174 | 175 | button.addEventListener("click", function () { 176 | copyToClipboard(el.innerText).then(success, failure); 177 | 178 | setTimeout(function () { 179 | button.classList.add("fa-copy"); 180 | button.classList.remove("success", "fa-check", "fa-xmark"); 181 | }, 5000); 182 | }); 183 | } 184 | } 185 | 186 | function copyToClipboard(text) { 187 | // clipboard API is only available in secure contexts 188 | if (window.navigator && window.navigator.clipboard) { 189 | return window.navigator.clipboard.writeText(text); 190 | } else { 191 | return new Promise(function (resolve, reject) { 192 | try { 193 | const el = document.createElement("textarea"); 194 | el.textContent = text; 195 | el.style.position = "fixed"; 196 | el.style.opacity = 0; 197 | document.body.appendChild(el); 198 | el.select(); 199 | document.execCommand("copy"); 200 | 201 | resolve(); 202 | } catch (err) { 203 | reject(err); 204 | } finally { 205 | document.body.removeChild(el); 206 | } 207 | }); 208 | } 209 | } 210 | 211 | if (document.readyState === "loading") { 212 | document.addEventListener("DOMContentLoaded", addCopyButtonCallbacks); 213 | } else { 214 | addCopyButtonCallbacks(); 215 | } 216 | 217 | }) 218 | //////////////////////////////////////////////////////////////////////////////// 219 | require(['jquery', 'headroom', 'headroom-jquery'], function($, Headroom) { 220 | 221 | // Manages the top navigation bar (hides it when the user starts scrolling down on the 222 | // mobile). 223 | window.Headroom = Headroom; // work around buggy module loading? 224 | $(document).ready(function () { 225 | $("#documenter .docs-navbar").headroom({ 226 | tolerance: { up: 10, down: 10 }, 227 | }); 228 | }); 229 | 230 | }) 231 | //////////////////////////////////////////////////////////////////////////////// 232 | require(['jquery'], function($) { 233 | 234 | $(document).ready(function () { 235 | let meta = $("div[data-docstringscollapsed]").data(); 236 | 237 | if (meta?.docstringscollapsed) { 238 | $("#documenter-article-toggle-button").trigger({ 239 | type: "click", 240 | noToggleAnimation: true, 241 | }); 242 | 243 | setTimeout(function () { 244 | if (window.location.hash) { 245 | const targetId = window.location.hash.substring(1); 246 | const targetElement = document.getElementById(targetId); 247 | 248 | if (targetElement) { 249 | targetElement.scrollIntoView({ 250 | behavior: "smooth", 251 | block: "center", 252 | }); 253 | } 254 | } 255 | }, 100); 256 | } 257 | }); 258 | 259 | }) 260 | //////////////////////////////////////////////////////////////////////////////// 261 | require(['jquery'], function($) { 262 | 263 | /* 264 | To get an in-depth about the thought process you can refer: https://hetarth02.hashnode.dev/series/gsoc 265 | 266 | PSEUDOCODE: 267 | 268 | Searching happens automatically as the user types or adjusts the selected filters. 269 | To preserve responsiveness, as much as possible of the slow parts of the search are done 270 | in a web worker. Searching and result generation are done in the worker, and filtering and 271 | DOM updates are done in the main thread. The filters are in the main thread as they should 272 | be very quick to apply. This lets filters be changed without re-searching with minisearch 273 | (which is possible even if filtering is on the worker thread) and also lets filters be 274 | changed _while_ the worker is searching and without message passing (neither of which are 275 | possible if filtering is on the worker thread) 276 | 277 | SEARCH WORKER: 278 | 279 | Import minisearch 280 | 281 | Build index 282 | 283 | On message from main thread 284 | run search 285 | find the first 200 unique results from each category, and compute their divs for display 286 | note that this is necessary and sufficient information for the main thread to find the 287 | first 200 unique results from any given filter set 288 | post results to main thread 289 | 290 | MAIN: 291 | 292 | Launch worker 293 | 294 | Declare nonconstant globals (worker_is_running, last_search_text, unfiltered_results) 295 | 296 | On text update 297 | if worker is not running, launch_search() 298 | 299 | launch_search 300 | set worker_is_running to true, set last_search_text to the search text 301 | post the search query to worker 302 | 303 | on message from worker 304 | if last_search_text is not the same as the text in the search field, 305 | the latest search result is not reflective of the latest search query, so update again 306 | launch_search() 307 | otherwise 308 | set worker_is_running to false 309 | 310 | regardless, display the new search results to the user 311 | save the unfiltered_results as a global 312 | update_search() 313 | 314 | on filter click 315 | adjust the filter selection 316 | update_search() 317 | 318 | update_search 319 | apply search filters by looping through the unfiltered_results and finding the first 200 320 | unique results that match the filters 321 | 322 | Update the DOM 323 | */ 324 | 325 | /////// SEARCH WORKER /////// 326 | 327 | function worker_function(documenterSearchIndex, documenterBaseURL, filters) { 328 | importScripts( 329 | "https://cdn.jsdelivr.net/npm/minisearch@6.1.0/dist/umd/index.min.js" 330 | ); 331 | 332 | let data = documenterSearchIndex.map((x, key) => { 333 | x["id"] = key; // minisearch requires a unique for each object 334 | return x; 335 | }); 336 | 337 | // list below is the lunr 2.1.3 list minus the intersect with names(Base) 338 | // (all, any, get, in, is, only, which) and (do, else, for, let, where, while, with) 339 | // ideally we'd just filter the original list but it's not available as a variable 340 | const stopWords = new Set([ 341 | "a", 342 | "able", 343 | "about", 344 | "across", 345 | "after", 346 | "almost", 347 | "also", 348 | "am", 349 | "among", 350 | "an", 351 | "and", 352 | "are", 353 | "as", 354 | "at", 355 | "be", 356 | "because", 357 | "been", 358 | "but", 359 | "by", 360 | "can", 361 | "cannot", 362 | "could", 363 | "dear", 364 | "did", 365 | "does", 366 | "either", 367 | "ever", 368 | "every", 369 | "from", 370 | "got", 371 | "had", 372 | "has", 373 | "have", 374 | "he", 375 | "her", 376 | "hers", 377 | "him", 378 | "his", 379 | "how", 380 | "however", 381 | "i", 382 | "if", 383 | "into", 384 | "it", 385 | "its", 386 | "just", 387 | "least", 388 | "like", 389 | "likely", 390 | "may", 391 | "me", 392 | "might", 393 | "most", 394 | "must", 395 | "my", 396 | "neither", 397 | "no", 398 | "nor", 399 | "not", 400 | "of", 401 | "off", 402 | "often", 403 | "on", 404 | "or", 405 | "other", 406 | "our", 407 | "own", 408 | "rather", 409 | "said", 410 | "say", 411 | "says", 412 | "she", 413 | "should", 414 | "since", 415 | "so", 416 | "some", 417 | "than", 418 | "that", 419 | "the", 420 | "their", 421 | "them", 422 | "then", 423 | "there", 424 | "these", 425 | "they", 426 | "this", 427 | "tis", 428 | "to", 429 | "too", 430 | "twas", 431 | "us", 432 | "wants", 433 | "was", 434 | "we", 435 | "were", 436 | "what", 437 | "when", 438 | "who", 439 | "whom", 440 | "why", 441 | "will", 442 | "would", 443 | "yet", 444 | "you", 445 | "your", 446 | ]); 447 | 448 | let index = new MiniSearch({ 449 | fields: ["title", "text"], // fields to index for full-text search 450 | storeFields: ["location", "title", "text", "category", "page"], // fields to return with results 451 | processTerm: (term) => { 452 | let word = stopWords.has(term) ? null : term; 453 | if (word) { 454 | // custom trimmer that doesn't strip @ and !, which are used in julia macro and function names 455 | word = word 456 | .replace(/^[^a-zA-Z0-9@!]+/, "") 457 | .replace(/[^a-zA-Z0-9@!]+$/, ""); 458 | 459 | word = word.toLowerCase(); 460 | } 461 | 462 | return word ?? null; 463 | }, 464 | // add . as a separator, because otherwise "title": "Documenter.Anchors.add!", would not 465 | // find anything if searching for "add!", only for the entire qualification 466 | tokenize: (string) => string.split(/[\s\-\.]+/), 467 | // options which will be applied during the search 468 | searchOptions: { 469 | prefix: true, 470 | boost: { title: 100 }, 471 | fuzzy: 2, 472 | }, 473 | }); 474 | 475 | index.addAll(data); 476 | 477 | /** 478 | * Used to map characters to HTML entities. 479 | * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts 480 | */ 481 | const htmlEscapes = { 482 | "&": "&", 483 | "<": "<", 484 | ">": ">", 485 | '"': """, 486 | "'": "'", 487 | }; 488 | 489 | /** 490 | * Used to match HTML entities and HTML characters. 491 | * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts 492 | */ 493 | const reUnescapedHtml = /[&<>"']/g; 494 | const reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 495 | 496 | /** 497 | * Escape function from lodash 498 | * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts 499 | */ 500 | function escape(string) { 501 | return string && reHasUnescapedHtml.test(string) 502 | ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) 503 | : string || ""; 504 | } 505 | 506 | /** 507 | * RegX escape function from MDN 508 | * Refer: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping 509 | */ 510 | function escapeRegExp(string) { 511 | return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string 512 | } 513 | 514 | /** 515 | * Make the result component given a minisearch result data object and the value 516 | * of the search input as queryString. To view the result object structure, refer: 517 | * https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchresult 518 | * 519 | * @param {object} result 520 | * @param {string} querystring 521 | * @returns string 522 | */ 523 | function make_search_result(result, querystring) { 524 | let search_divider = `
`; 525 | let display_link = 526 | result.location.slice(Math.max(0), Math.min(50, result.location.length)) + 527 | (result.location.length > 30 ? "..." : ""); // To cut-off the link because it messes with the overflow of the whole div 528 | 529 | if (result.page !== "") { 530 | display_link += ` (${result.page})`; 531 | } 532 | searchstring = escapeRegExp(querystring); 533 | let textindex = new RegExp(`${searchstring}`, "i").exec(result.text); 534 | let text = 535 | textindex !== null 536 | ? result.text.slice( 537 | Math.max(textindex.index - 100, 0), 538 | Math.min( 539 | textindex.index + querystring.length + 100, 540 | result.text.length 541 | ) 542 | ) 543 | : ""; // cut-off text before and after from the match 544 | 545 | text = text.length ? escape(text) : ""; 546 | 547 | let display_result = text.length 548 | ? "..." + 549 | text.replace( 550 | new RegExp(`${escape(searchstring)}`, "i"), // For first occurrence 551 | '$&' 552 | ) + 553 | "..." 554 | : ""; // highlights the match 555 | 556 | let in_code = false; 557 | if (!["page", "section"].includes(result.category.toLowerCase())) { 558 | in_code = true; 559 | } 560 | 561 | // We encode the full url to escape some special characters which can lead to broken links 562 | let result_div = ` 563 | 566 |
567 |
${escape(result.title)}
570 |
${result.category}
571 |
572 |

573 | ${display_result} 574 |

575 |
580 | ${display_link} 581 |
582 |
583 | ${search_divider} 584 | `; 585 | 586 | return result_div; 587 | } 588 | 589 | self.onmessage = function (e) { 590 | let query = e.data; 591 | let results = index.search(query, { 592 | filter: (result) => { 593 | // Only return relevant results 594 | return result.score >= 1; 595 | }, 596 | combineWith: "AND", 597 | }); 598 | 599 | // Pre-filter to deduplicate and limit to 200 per category to the extent 600 | // possible without knowing what the filters are. 601 | let filtered_results = []; 602 | let counts = {}; 603 | for (let filter of filters) { 604 | counts[filter] = 0; 605 | } 606 | let present = {}; 607 | 608 | for (let result of results) { 609 | cat = result.category; 610 | cnt = counts[cat]; 611 | if (cnt < 200) { 612 | id = cat + "---" + result.location; 613 | if (present[id]) { 614 | continue; 615 | } 616 | present[id] = true; 617 | filtered_results.push({ 618 | location: result.location, 619 | category: cat, 620 | div: make_search_result(result, query), 621 | }); 622 | } 623 | } 624 | 625 | postMessage(filtered_results); 626 | }; 627 | } 628 | 629 | /////// SEARCH MAIN /////// 630 | 631 | function runSearchMainCode() { 632 | // `worker = Threads.@spawn worker_function(documenterSearchIndex)`, but in JavaScript! 633 | const filters = [ 634 | ...new Set(documenterSearchIndex["docs"].map((x) => x.category)), 635 | ]; 636 | const worker_str = 637 | "(" + 638 | worker_function.toString() + 639 | ")(" + 640 | JSON.stringify(documenterSearchIndex["docs"]) + 641 | "," + 642 | JSON.stringify(documenterBaseURL) + 643 | "," + 644 | JSON.stringify(filters) + 645 | ")"; 646 | const worker_blob = new Blob([worker_str], { type: "text/javascript" }); 647 | const worker = new Worker(URL.createObjectURL(worker_blob)); 648 | 649 | // Whether the worker is currently handling a search. This is a boolean 650 | // as the worker only ever handles 1 or 0 searches at a time. 651 | var worker_is_running = false; 652 | 653 | // The last search text that was sent to the worker. This is used to determine 654 | // if the worker should be launched again when it reports back results. 655 | var last_search_text = ""; 656 | 657 | // The results of the last search. This, in combination with the state of the filters 658 | // in the DOM, is used compute the results to display on calls to update_search. 659 | var unfiltered_results = []; 660 | 661 | // Which filter is currently selected 662 | var selected_filter = ""; 663 | 664 | document.addEventListener("reset-filter", function () { 665 | selected_filter = ""; 666 | update_search(); 667 | }); 668 | 669 | //update the url with search query 670 | function updateSearchURL(query) { 671 | const url = new URL(window.location); 672 | 673 | if (query && query.trim() !== "") { 674 | url.searchParams.set("q", query); 675 | } else { 676 | // remove the 'q' param if it exists 677 | if (url.searchParams.has("q")) { 678 | url.searchParams.delete("q"); 679 | } 680 | } 681 | 682 | // Add or remove the filter parameter based on selected_filter 683 | if (selected_filter && selected_filter.trim() !== "") { 684 | url.searchParams.set("filter", selected_filter); 685 | } else { 686 | // remove the 'filter' param if it exists 687 | if (url.searchParams.has("filter")) { 688 | url.searchParams.delete("filter"); 689 | } 690 | } 691 | 692 | // Only update history if there are parameters, otherwise use the base URL 693 | if (url.search) { 694 | window.history.replaceState({}, "", url); 695 | } else { 696 | window.history.replaceState({}, "", url.pathname + url.hash); 697 | } 698 | } 699 | 700 | $(document).on("input", ".documenter-search-input", function (event) { 701 | if (!worker_is_running) { 702 | launch_search(); 703 | } 704 | }); 705 | 706 | function launch_search() { 707 | worker_is_running = true; 708 | last_search_text = $(".documenter-search-input").val(); 709 | updateSearchURL(last_search_text); 710 | worker.postMessage(last_search_text); 711 | } 712 | 713 | worker.onmessage = function (e) { 714 | if (last_search_text !== $(".documenter-search-input").val()) { 715 | launch_search(); 716 | } else { 717 | worker_is_running = false; 718 | } 719 | 720 | unfiltered_results = e.data; 721 | update_search(); 722 | }; 723 | 724 | $(document).on("click", ".search-filter", function () { 725 | let search_input = $(".documenter-search-input"); 726 | let cursor_position = search_input[0].selectionStart; 727 | 728 | if ($(this).hasClass("search-filter-selected")) { 729 | selected_filter = ""; 730 | } else { 731 | selected_filter = $(this).text().toLowerCase(); 732 | } 733 | 734 | // This updates search results and toggles classes for UI: 735 | update_search(); 736 | 737 | search_input.focus(); 738 | search_input.setSelectionRange(cursor_position, cursor_position); 739 | }); 740 | 741 | /** 742 | * Make/Update the search component 743 | */ 744 | function update_search() { 745 | let querystring = $(".documenter-search-input").val(); 746 | updateSearchURL(querystring); 747 | 748 | if (querystring.trim()) { 749 | if (selected_filter == "") { 750 | results = unfiltered_results; 751 | } else { 752 | results = unfiltered_results.filter((result) => { 753 | return selected_filter == result.category.toLowerCase(); 754 | }); 755 | } 756 | 757 | let search_result_container = ``; 758 | let modal_filters = make_modal_body_filters(); 759 | let search_divider = `
`; 760 | 761 | if (results.length) { 762 | let links = []; 763 | let count = 0; 764 | let search_results = ""; 765 | 766 | for (var i = 0, n = results.length; i < n && count < 200; ++i) { 767 | let result = results[i]; 768 | if (result.location && !links.includes(result.location)) { 769 | search_results += result.div; 770 | count++; 771 | links.push(result.location); 772 | } 773 | } 774 | 775 | if (count == 1) { 776 | count_str = "1 result"; 777 | } else if (count == 200) { 778 | count_str = "200+ results"; 779 | } else { 780 | count_str = count + " results"; 781 | } 782 | let result_count = `
${count_str}
`; 783 | 784 | search_result_container = ` 785 |
786 | ${modal_filters} 787 | ${search_divider} 788 | ${result_count} 789 |
790 | ${search_results} 791 |
792 |
793 | `; 794 | } else { 795 | search_result_container = ` 796 |
797 | ${modal_filters} 798 | ${search_divider} 799 |
0 result(s)
800 |
801 |
No result found!
802 | `; 803 | } 804 | 805 | if ($(".search-modal-card-body").hasClass("is-justify-content-center")) { 806 | $(".search-modal-card-body").removeClass("is-justify-content-center"); 807 | } 808 | 809 | $(".search-modal-card-body").html(search_result_container); 810 | } else { 811 | if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { 812 | $(".search-modal-card-body").addClass("is-justify-content-center"); 813 | } 814 | 815 | $(".search-modal-card-body").html(` 816 |
Type something to get started!
817 | `); 818 | } 819 | } 820 | 821 | //url param checking 822 | function checkURLForSearch() { 823 | const urlParams = new URLSearchParams(window.location.search); 824 | const searchQuery = urlParams.get("q"); 825 | const filterParam = urlParams.get("filter"); 826 | 827 | // Set the selected filter if present in URL 828 | if (filterParam) { 829 | selected_filter = filterParam.toLowerCase(); 830 | } 831 | 832 | // Trigger input event if there's a search query to perform the search 833 | if (searchQuery) { 834 | $(".documenter-search-input").val(searchQuery).trigger("input"); 835 | } 836 | } 837 | setTimeout(checkURLForSearch, 100); 838 | 839 | /** 840 | * Make the modal filter html 841 | * 842 | * @returns string 843 | */ 844 | function make_modal_body_filters() { 845 | let str = filters 846 | .map((val) => { 847 | if (selected_filter == val.toLowerCase()) { 848 | return `${val}`; 849 | } else { 850 | return `${val}`; 851 | } 852 | }) 853 | .join(""); 854 | 855 | return ` 856 |
857 | Filters: 858 | ${str} 859 |
`; 860 | } 861 | } 862 | 863 | function waitUntilSearchIndexAvailable() { 864 | // It is possible that the documenter.js script runs before the page 865 | // has finished loading and documenterSearchIndex gets defined. 866 | // So we need to wait until the search index actually loads before setting 867 | // up all the search-related stuff. 868 | if (typeof documenterSearchIndex !== "undefined") { 869 | runSearchMainCode(); 870 | } else { 871 | console.warn("Search Index not available, waiting"); 872 | setTimeout(waitUntilSearchIndexAvailable, 1000); 873 | } 874 | } 875 | 876 | // The actual entry point to the search code 877 | waitUntilSearchIndexAvailable(); 878 | 879 | }) 880 | //////////////////////////////////////////////////////////////////////////////// 881 | require(['jquery'], function($) { 882 | 883 | // Modal settings dialog 884 | $(document).ready(function () { 885 | var settings = $("#documenter-settings"); 886 | $("#documenter-settings-button").click(function () { 887 | settings.toggleClass("is-active"); 888 | }); 889 | // Close the dialog if X is clicked 890 | $("#documenter-settings button.delete").click(function () { 891 | settings.removeClass("is-active"); 892 | }); 893 | // Close dialog if ESC is pressed 894 | $(document).keyup(function (e) { 895 | if (e.keyCode == 27) settings.removeClass("is-active"); 896 | }); 897 | }); 898 | 899 | }) 900 | //////////////////////////////////////////////////////////////////////////////// 901 | require(['jquery'], function($) { 902 | 903 | $(document).ready(function () { 904 | let search_modal_header = ` 905 | 919 | `; 920 | 921 | let initial_search_body = ` 922 |
Type something to get started!
923 | `; 924 | 925 | let search_modal_footer = ` 926 |
927 | 928 | Ctrl + 929 | / to search 930 | 931 | esc to close 932 |
933 | `; 934 | 935 | $(document.body).append( 936 | ` 937 | 947 | ` 948 | ); 949 | 950 | function checkURLForSearch() { 951 | const urlParams = new URLSearchParams(window.location.search); 952 | const searchQuery = urlParams.get("q"); 953 | 954 | if (searchQuery) { 955 | //only if there is a search query, open the modal 956 | openModal(); 957 | } 958 | } 959 | 960 | //this function will be called whenever the page will load 961 | checkURLForSearch(); 962 | 963 | document.querySelector(".docs-search-query").addEventListener("click", () => { 964 | openModal(); 965 | }); 966 | 967 | document 968 | .querySelector(".close-search-modal") 969 | .addEventListener("click", () => { 970 | closeModal(); 971 | }); 972 | 973 | $(document).on("click", ".search-result-link", function () { 974 | closeModal(); 975 | }); 976 | 977 | document.addEventListener("keydown", (event) => { 978 | if ((event.ctrlKey || event.metaKey) && event.key === "/") { 979 | openModal(); 980 | } else if (event.key === "Escape") { 981 | closeModal(); 982 | } 983 | 984 | return false; 985 | }); 986 | 987 | //event listener for the link icon to copy the URL 988 | $(document).on("click", ".link-icon", function () { 989 | const currentUrl = window.location.href; 990 | 991 | navigator.clipboard 992 | .writeText(currentUrl) 993 | .then(() => { 994 | const $linkIcon = $(this); 995 | $linkIcon.removeClass("fa-link").addClass("fa-check"); 996 | 997 | setTimeout(() => { 998 | $linkIcon.removeClass("fa-check").addClass("fa-link"); 999 | }, 1000); 1000 | }) 1001 | .catch((err) => { 1002 | console.error("Failed to copy URL: ", err); 1003 | }); 1004 | }); 1005 | 1006 | // Functions to open and close a modal 1007 | function openModal() { 1008 | let searchModal = document.querySelector("#search-modal"); 1009 | 1010 | searchModal.classList.add("is-active"); 1011 | document.querySelector(".documenter-search-input").focus(); 1012 | } 1013 | 1014 | function closeModal() { 1015 | let searchModal = document.querySelector("#search-modal"); 1016 | let initial_search_body = ` 1017 |
Type something to get started!
1018 | `; 1019 | 1020 | $(".documenter-search-input").val(""); 1021 | $(".search-modal-card-body").html(initial_search_body); 1022 | 1023 | document.dispatchEvent(new CustomEvent("reset-filter")); 1024 | 1025 | searchModal.classList.remove("is-active"); 1026 | document.querySelector(".documenter-search-input").blur(); 1027 | 1028 | if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { 1029 | $(".search-modal-card-body").addClass("is-justify-content-center"); 1030 | } 1031 | } 1032 | 1033 | document 1034 | .querySelector("#search-modal .modal-background") 1035 | .addEventListener("click", () => { 1036 | closeModal(); 1037 | }); 1038 | }); 1039 | 1040 | }) 1041 | //////////////////////////////////////////////////////////////////////////////// 1042 | require(['jquery'], function($) { 1043 | 1044 | // Manages the showing and hiding of the sidebar. 1045 | $(document).ready(function () { 1046 | var sidebar = $("#documenter > .docs-sidebar"); 1047 | var sidebar_button = $("#documenter-sidebar-button"); 1048 | sidebar_button.click(function (ev) { 1049 | ev.preventDefault(); 1050 | sidebar.toggleClass("visible"); 1051 | if (sidebar.hasClass("visible")) { 1052 | // Makes sure that the current menu item is visible in the sidebar. 1053 | $("#documenter .docs-menu a.is-active").focus(); 1054 | } 1055 | }); 1056 | $("#documenter > .docs-main").bind("click", function (ev) { 1057 | if ($(ev.target).is(sidebar_button)) { 1058 | return; 1059 | } 1060 | if (sidebar.hasClass("visible")) { 1061 | sidebar.removeClass("visible"); 1062 | } 1063 | }); 1064 | }); 1065 | 1066 | // Resizes the package name / sitename in the sidebar if it is too wide. 1067 | // Inspired by: https://github.com/davatron5000/FitText.js 1068 | $(document).ready(function () { 1069 | e = $("#documenter .docs-autofit"); 1070 | function resize() { 1071 | var L = parseInt(e.css("max-width"), 10); 1072 | var L0 = e.width(); 1073 | if (L0 > L) { 1074 | var h0 = parseInt(e.css("font-size"), 10); 1075 | e.css("font-size", (L * h0) / L0); 1076 | // TODO: make sure it survives resizes? 1077 | } 1078 | } 1079 | // call once and then register events 1080 | resize(); 1081 | $(window).resize(resize); 1082 | $(window).on("orientationchange", resize); 1083 | }); 1084 | 1085 | // Scroll the navigation bar to the currently selected menu item 1086 | $(document).ready(function () { 1087 | var sidebar = $("#documenter .docs-menu").get(0); 1088 | var active = $("#documenter .docs-menu .is-active").get(0); 1089 | if (typeof active !== "undefined") { 1090 | sidebar.scrollTop = active.offsetTop - sidebar.offsetTop - 15; 1091 | } 1092 | }); 1093 | 1094 | }) 1095 | //////////////////////////////////////////////////////////////////////////////// 1096 | require(['jquery'], function($) { 1097 | 1098 | // Theme picker setup 1099 | $(document).ready(function () { 1100 | // onchange callback 1101 | $("#documenter-themepicker").change(function themepick_callback(ev) { 1102 | var themename = $("#documenter-themepicker option:selected").attr("value"); 1103 | if (themename === "auto") { 1104 | // set_theme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); 1105 | window.localStorage.removeItem("documenter-theme"); 1106 | } else { 1107 | // set_theme(themename); 1108 | window.localStorage.setItem("documenter-theme", themename); 1109 | } 1110 | // We re-use the global function from themeswap.js to actually do the swapping. 1111 | set_theme_from_local_storage(); 1112 | }); 1113 | 1114 | // Make sure that the themepicker displays the correct theme when the theme is retrieved 1115 | // from localStorage 1116 | if (typeof window.localStorage !== "undefined") { 1117 | var theme = window.localStorage.getItem("documenter-theme"); 1118 | if (theme !== null) { 1119 | $("#documenter-themepicker option").each(function (i, e) { 1120 | e.selected = e.value === theme; 1121 | }); 1122 | } 1123 | } 1124 | }); 1125 | 1126 | }) 1127 | //////////////////////////////////////////////////////////////////////////////// 1128 | require(['jquery'], function($) { 1129 | 1130 | // update the version selector with info from the siteinfo.js and ../versions.js files 1131 | $(document).ready(function () { 1132 | // If the version selector is disabled with DOCUMENTER_VERSION_SELECTOR_DISABLED in the 1133 | // siteinfo.js file, we just return immediately and not display the version selector. 1134 | if ( 1135 | typeof DOCUMENTER_VERSION_SELECTOR_DISABLED === "boolean" && 1136 | DOCUMENTER_VERSION_SELECTOR_DISABLED 1137 | ) { 1138 | return; 1139 | } 1140 | 1141 | var version_selector = $("#documenter .docs-version-selector"); 1142 | var version_selector_select = $("#documenter .docs-version-selector select"); 1143 | 1144 | version_selector_select.change(function (x) { 1145 | target_href = version_selector_select 1146 | .children("option:selected") 1147 | .get(0).value; 1148 | window.location.href = target_href; 1149 | }); 1150 | 1151 | // add the current version to the selector based on siteinfo.js, but only if the selector is empty 1152 | if ( 1153 | typeof DOCUMENTER_CURRENT_VERSION !== "undefined" && 1154 | $("#version-selector > option").length == 0 1155 | ) { 1156 | var option = $( 1157 | "" 1160 | ); 1161 | version_selector_select.append(option); 1162 | } 1163 | 1164 | if (typeof DOC_VERSIONS !== "undefined") { 1165 | var existing_versions = version_selector_select.children("option"); 1166 | var existing_versions_texts = existing_versions.map(function (i, x) { 1167 | return x.text; 1168 | }); 1169 | DOC_VERSIONS.forEach(function (each) { 1170 | var version_url = documenterBaseURL + "/../" + each + "/"; 1171 | var existing_id = $.inArray(each, existing_versions_texts); 1172 | // if not already in the version selector, add it as a new option, 1173 | // otherwise update the old option with the URL and enable it 1174 | if (existing_id == -1) { 1175 | var option = $( 1176 | "" 1177 | ); 1178 | version_selector_select.append(option); 1179 | } else { 1180 | var option = existing_versions[existing_id]; 1181 | option.value = version_url; 1182 | option.disabled = false; 1183 | } 1184 | }); 1185 | } 1186 | 1187 | // only show the version selector if the selector has been populated 1188 | if (version_selector_select.children("option").length > 0) { 1189 | version_selector.toggleClass("visible"); 1190 | } 1191 | }); 1192 | 1193 | }) 1194 | -------------------------------------------------------------------------------- /docs/build/assets/themeswap.js: -------------------------------------------------------------------------------- 1 | // Small function to quickly swap out themes. Gets put into the tag.. 2 | function set_theme_from_local_storage() { 3 | // Initialize the theme to null, which means default 4 | var theme = null; 5 | // If the browser supports the localstorage and is not disabled then try to get the 6 | // documenter theme 7 | if (window.localStorage != null) { 8 | // Get the user-picked theme from localStorage. May be `null`, which means the default 9 | // theme. 10 | theme = window.localStorage.getItem("documenter-theme"); 11 | } 12 | // Check if the users preference is for dark color scheme 13 | var darkPreference = 14 | window.matchMedia("(prefers-color-scheme: dark)").matches === true; 15 | // Initialize a few variables for the loop: 16 | // 17 | // - active: will contain the index of the theme that should be active. Note that there 18 | // is no guarantee that localStorage contains sane values. If `active` stays `null` 19 | // we either could not find the theme or it is the default (primary) theme anyway. 20 | // Either way, we then need to stick to the primary theme. 21 | // 22 | // - disabled: style sheets that should be disabled (i.e. all the theme style sheets 23 | // that are not the currently active theme) 24 | var active = null; 25 | var disabled = []; 26 | var primaryLightTheme = null; 27 | var primaryDarkTheme = null; 28 | for (var i = 0; i < document.styleSheets.length; i++) { 29 | var ss = document.styleSheets[i]; 30 | // The tag of each style sheet is expected to have a data-theme-name attribute 31 | // which must contain the name of the theme. The names in localStorage much match this. 32 | var themename = ss.ownerNode.getAttribute("data-theme-name"); 33 | // attribute not set => non-theme stylesheet => ignore 34 | if (themename === null) continue; 35 | // To distinguish the default (primary) theme, it needs to have the data-theme-primary 36 | // attribute set. 37 | if (ss.ownerNode.getAttribute("data-theme-primary") !== null) { 38 | primaryLightTheme = themename; 39 | } 40 | // Check if the theme is primary dark theme so that we could store its name in darkTheme 41 | if (ss.ownerNode.getAttribute("data-theme-primary-dark") !== null) { 42 | primaryDarkTheme = themename; 43 | } 44 | // If we find a matching theme (and it's not the default), we'll set active to non-null 45 | if (themename === theme) active = i; 46 | // Store the style sheets of inactive themes so that we could disable them 47 | if (themename !== theme) disabled.push(ss); 48 | } 49 | var activeTheme = null; 50 | if (active !== null) { 51 | // If we did find an active theme, we'll (1) add the theme--$(theme) class to 52 | document.getElementsByTagName("html")[0].className = "theme--" + theme; 53 | activeTheme = theme; 54 | } else { 55 | // If we did _not_ find an active theme, then we need to fall back to the primary theme 56 | // which can either be dark or light, depending on the user's OS preference. 57 | var activeTheme = darkPreference ? primaryDarkTheme : primaryLightTheme; 58 | // In case it somehow happens that the relevant primary theme was not found in the 59 | // preceding loop, we abort without doing anything. 60 | if (activeTheme === null) { 61 | console.error("Unable to determine primary theme."); 62 | return; 63 | } 64 | // When switching to the primary light theme, then we must not have a class name 65 | // for the tag. That's only for non-primary or the primary dark theme. 66 | if (darkPreference) { 67 | document.getElementsByTagName("html")[0].className = 68 | "theme--" + activeTheme; 69 | } else { 70 | document.getElementsByTagName("html")[0].className = ""; 71 | } 72 | } 73 | for (var i = 0; i < document.styleSheets.length; i++) { 74 | var ss = document.styleSheets[i]; 75 | // The tag of each style sheet is expected to have a data-theme-name attribute 76 | // which must contain the name of the theme. The names in localStorage much match this. 77 | var themename = ss.ownerNode.getAttribute("data-theme-name"); 78 | // attribute not set => non-theme stylesheet => ignore 79 | if (themename === null) continue; 80 | // we'll disable all the stylesheets, except for the active one 81 | ss.disabled = !(themename == activeTheme); 82 | } 83 | } 84 | set_theme_from_local_storage(); 85 | -------------------------------------------------------------------------------- /docs/build/assets/warner.js: -------------------------------------------------------------------------------- 1 | function maybeAddWarning() { 2 | // DOCUMENTER_NEWEST is defined in versions.js, DOCUMENTER_CURRENT_VERSION and DOCUMENTER_STABLE 3 | // in siteinfo.js. 4 | // If either of these are undefined something went horribly wrong, so we abort. 5 | if ( 6 | window.DOCUMENTER_NEWEST === undefined || 7 | window.DOCUMENTER_CURRENT_VERSION === undefined || 8 | window.DOCUMENTER_STABLE === undefined 9 | ) { 10 | return; 11 | } 12 | 13 | // Current version is not a version number, so we can't tell if it's the newest version. Abort. 14 | if (!/v(\d+\.)*\d+/.test(window.DOCUMENTER_CURRENT_VERSION)) { 15 | return; 16 | } 17 | 18 | // Current version is newest version, so no need to add a warning. 19 | if (window.DOCUMENTER_NEWEST === window.DOCUMENTER_CURRENT_VERSION) { 20 | return; 21 | } 22 | 23 | // Add a noindex meta tag (unless one exists) so that search engines don't index this version of the docs. 24 | if (document.body.querySelector('meta[name="robots"]') === null) { 25 | const meta = document.createElement("meta"); 26 | meta.name = "robots"; 27 | meta.content = "noindex"; 28 | 29 | document.getElementsByTagName("head")[0].appendChild(meta); 30 | } 31 | 32 | const div = document.createElement("div"); 33 | div.classList.add("outdated-warning-overlay"); 34 | const closer = document.createElement("button"); 35 | closer.classList.add("outdated-warning-closer", "delete"); 36 | closer.addEventListener("click", function () { 37 | document.body.removeChild(div); 38 | }); 39 | const href = window.documenterBaseURL + "/../" + window.DOCUMENTER_STABLE; 40 | div.innerHTML = 41 | 'This documentation is not for the latest stable release, but for either the development version or an older release.
Click here to go to the documentation for the latest stable release.'; 44 | div.appendChild(closer); 45 | document.body.appendChild(div); 46 | } 47 | 48 | if (document.readyState === "loading") { 49 | document.addEventListener("DOMContentLoaded", maybeAddWarning); 50 | } else { 51 | maybeAddWarning(); 52 | } 53 | -------------------------------------------------------------------------------- /docs/build/index.html: -------------------------------------------------------------------------------- 1 | 2 | Overview · AskAI.jl

Overview

AskAI.jl, as its name suggests, is a straightforward tool for querying Large Language Models. Currently supporting only Google's Gemini model due to its free, though rate-limited, API, it's designed to be simple and direct: send prompts and questions to Gemini, and optionally execute the included code within a sandboxed "playground" to avoid affecting the main scope.

The main macro, @ai, retrieves results from a large language model (current the Gemini, more model supported soon), while @AI executes the code within the "playground" scope and displays the output(or any errors.)

a REPL mode was also support. Press } to enter and backspace to exit

AskAI

Note

as most of the AI tool, it needs the api key, for the Gemini key you can apply from Google Gemini. and the set it in the ENV["AI_API_KEY"] or use AskAI.setapi() to replace new key. please also add a module called playground: module playground end in your main scope for the code execute.

Note

A convenient way is to put below code in your Julia startup.jl configuration file.

ENV["AI_API_KEY"] = "your_key_for_Google_Gemini"
 3 | module playground end
 4 | using AskAI

then you can use the AskAI in every session by default

it starts as my persional AI tool in julia REP and only support the Gemini model currently. have fun with it and I welcome your suggestions and input for AskAI.jl!!!

quickly example

Here's an example of using AskAI to generate scatter and histogram plots and perform basic statistical calculations.

@AI "tell me the current date, use the pacakge when in need"
 5 | @AI "create a new project in /tmp, name it as demo + date, activate it"
 6 | @AI "load my data as df, the data file is in /tmp/celldata.csv"
 7 | @AI "tell me the data size"
 8 | @AI "does the data contain columns named geneX and  geneY??"
 9 | @AI "install the package to support figure display in the terminal"
10 | @AI "plot a scatter plot of geneX and geneY, I want the geneX on axis Y"
11 | @AI "please also label the axis"
12 | @AI "calculate the correlation of geneX and geneY"
13 | @AI "keep only 3 digits"
14 | @AI "generate a histogram to show the distribution of geneX "
15 | @AI "do the same to geneY"
16 | @AI "fit a linear model to predict value of geneY from geneX,using GLM"
17 | @AI "give me the coef of geneX in this model,keep 5 digits"

Output Results are here

Details

result1 result2 result3

Note

some time you may get the wrong result from the LLM, LLM results aren't always perfect, so please double-check. You can use @ai instead of @AI for code checks. then use exe() to perform the code. Often the case I met is the necessary packages aren't installed.

@ai "tell me the current date,install the package if it needs"
18 | AskAI.exe(ans)

to review the conversation history

AskAI.Brain.history["ask"] 
19 | AskAI.Brain.history["ans"] 
20 | 
21 | # review the last response 
22 | AskAI.Brain.history["ans"][end] |> AskAI.MD

you can also try the stream mode under terminal

AskAI.Brain.stream = true
23 | @ai "why the sky is blue"

function and macro

AskAI.exeMethod

execute the string as code

"1 + 1" |> AskAI.exe
24 | 
25 | (@ai "1 + 1") |> AskAI.exe
AskAI.resetMethod

Reset the AskAI, it will remove the conversation history, memory, prompt... and everything as default defined

AskAI.reset()
AskAI.setapiMethod

set the API_KEY

setapi("1234567890abcdef1234567890abcdef")
AskAI.@AIMacro

similar to @ai,

send the question to AI but @AI perform the code directly and only return the result, or error :(

the conversation history will stored in the AskAI.Brain.history

example:

@AI "tell me the current time, used the package you need"
AskAI.@aiMacro

get the answer from the AI

example

@ai "fit a linear model"
26 | # or you can concatenate your question
27 | @ai "fit a" + "linear model"
AskAI.checkMemory!Function

optimalize the memory text, when the memory words length exceeds 3000 words, summary it into 300 words

AskAI.showStreamStringFromChannelMethod

for stream mode, displays a streaming response from the channel, updating the display in terminal with each chunk of text received.

AskAI.streamToMemoryMethod

for stream mode, take string from the channel, convert to markdown, and save as memory context

28 | -------------------------------------------------------------------------------- /docs/build/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/build/objects.inv -------------------------------------------------------------------------------- /docs/build/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/build/overview.png -------------------------------------------------------------------------------- /docs/build/result1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/build/result1.png -------------------------------------------------------------------------------- /docs/build/result2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/build/result2.png -------------------------------------------------------------------------------- /docs/build/result3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/build/result3.png -------------------------------------------------------------------------------- /docs/build/search_index.js: -------------------------------------------------------------------------------- 1 | var documenterSearchIndex = {"docs": 2 | [{"location":"#Overview","page":"Overview","title":"Overview","text":"","category":"section"},{"location":"","page":"Overview","title":"Overview","text":"AskAI.jl, as its name suggests, is a straightforward tool for querying Large Language Models. Currently supporting only Google's Gemini model due to its free, though rate-limited, API, it's designed to be simple and direct: send prompts and questions to Gemini, and optionally execute the included code within a sandboxed \"playground\" to avoid affecting the main scope.","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"The main macro, @ai, retrieves results from a large language model (current the Gemini, more model supported soon), while @AI executes the code within the \"playground\" scope and displays the output(or any errors.)","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"a REPL mode was also support. Press } to enter and backspace to exit","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"(Image: AskAI)","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"note: Note\nas most of the AI tool, it needs the api key, for the Gemini key you can apply from Google Gemini. and the set it in the ENV[\"AI_API_KEY\"] or use AskAI.setapi() to replace new key. please also add a module called playground: module playground end in your main scope for the code execute. ","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"note: Note\nA convenient way is to put below code in your Julia startup.jl configuration file.ENV[\"AI_API_KEY\"] = \"your_key_for_Google_Gemini\"\nmodule playground end\nusing AskAIthen you can use the AskAI in every session by default","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"it starts as my persional AI tool in julia REP and only support the Gemini model currently. have fun with it and I welcome your suggestions and input for AskAI.jl!!!","category":"page"},{"location":"#quickly-example","page":"Overview","title":"quickly example","text":"","category":"section"},{"location":"","page":"Overview","title":"Overview","text":"Here's an example of using AskAI to generate scatter and histogram plots and perform basic statistical calculations.","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"@AI \"tell me the current date, use the pacakge when in need\"\n@AI \"create a new project in /tmp, name it as demo + date, activate it\"\n@AI \"load my data as df, the data file is in /tmp/celldata.csv\"\n@AI \"tell me the data size\"\n@AI \"does the data contain columns named geneX and geneY??\"\n@AI \"install the package to support figure display in the terminal\"\n@AI \"plot a scatter plot of geneX and geneY, I want the geneX on axis Y\"\n@AI \"please also label the axis\"\n@AI \"calculate the correlation of geneX and geneY\"\n@AI \"keep only 3 digits\"\n@AI \"generate a histogram to show the distribution of geneX \"\n@AI \"do the same to geneY\"\n@AI \"fit a linear model to predict value of geneY from geneX,using GLM\"\n@AI \"give me the coef of geneX in this model,keep 5 digits\"","category":"page"},{"location":"#Output-Results-are-here","page":"Overview","title":"Output Results are here","text":"","category":"section"},{"location":"","page":"Overview","title":"Overview","text":"details: Details\n(Image: result1) (Image: result2) (Image: result3)","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"note: Note\nsome time you may get the wrong result from the LLM, LLM results aren't always perfect, so please double-check. You can use @ai instead of @AI for code checks. then use exe() to perform the code. Often the case I met is the necessary packages aren't installed.@ai \"tell me the current date,install the package if it needs\"\nAskAI.exe(ans)","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"to review the conversation history","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"AskAI.Brain.history[\"ask\"] \nAskAI.Brain.history[\"ans\"] \n\n# review the last response \nAskAI.Brain.history[\"ans\"][end] |> AskAI.MD","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"you can also try the stream mode under terminal","category":"page"},{"location":"","page":"Overview","title":"Overview","text":"AskAI.Brain.stream = true\n@ai \"why the sky is blue\"","category":"page"},{"location":"#function-and-macro","page":"Overview","title":"function and macro","text":"","category":"section"},{"location":"","page":"Overview","title":"Overview","text":"Modules = [AskAI]\nPages = [\"AskAI.jl\", \"brain.jl\"]","category":"page"},{"location":"#AskAI.exe-Tuple{Any}","page":"Overview","title":"AskAI.exe","text":"execute the string as code\n\n\"1 + 1\" |> AskAI.exe\n\n(@ai \"1 + 1\") |> AskAI.exe\n\n\n\n\n\n","category":"method"},{"location":"#AskAI.reset-Tuple{}","page":"Overview","title":"AskAI.reset","text":"Reset the AskAI, it will remove the conversation history, memory, prompt... and everything as default defined\n\nAskAI.reset()\n\n\n\n\n\n","category":"method"},{"location":"#AskAI.setapi-Tuple{AbstractString}","page":"Overview","title":"AskAI.setapi","text":"set the API_KEY\n\nsetapi(\"1234567890abcdef1234567890abcdef\")\n\n\n\n\n\n","category":"method"},{"location":"#AskAI.@AI-Tuple{Any}","page":"Overview","title":"AskAI.@AI","text":"similar to @ai,\n\nsend the question to AI but @AI perform the code directly and only return the result, or error :(\n\nthe conversation history will stored in the AskAI.Brain.history\n\nexample:\n\n@AI \"tell me the current time, used the package you need\"\n\n\n\n\n\n","category":"macro"},{"location":"#AskAI.@ai-Tuple{Any}","page":"Overview","title":"AskAI.@ai","text":"get the answer from the AI\n\nexample\n\n@ai \"fit a linear model\"\n# or you can concatenate your question\n@ai \"fit a\" + \"linear model\"\n\n\n\n\n\n","category":"macro"},{"location":"#AskAI.checkMemory!","page":"Overview","title":"AskAI.checkMemory!","text":"optimalize the memory text, when the memory words length exceeds 3000 words, summary it into 300 words\n\n\n\n\n\n","category":"function"},{"location":"#AskAI.showStreamStringFromChannel-Tuple{Channel}","page":"Overview","title":"AskAI.showStreamStringFromChannel","text":"for stream mode, displays a streaming response from the channel, updating the display in terminal with each chunk of text received.\n\n\n\n\n\n","category":"method"},{"location":"#AskAI.streamToMemory-Tuple{AskAI.AIBrain, Channel}","page":"Overview","title":"AskAI.streamToMemory","text":"for stream mode, take string from the channel, convert to markdown, and save as memory context\n\n\n\n\n\n","category":"method"}] 3 | } 4 | -------------------------------------------------------------------------------- /docs/make.jl: -------------------------------------------------------------------------------- 1 | push!(LOAD_PATH,"../src/") 2 | using Documenter, AskAI 3 | 4 | makedocs(sitename="AskAI.jl",remotes=nothing) 5 | 6 | -------------------------------------------------------------------------------- /docs/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/src/.DS_Store -------------------------------------------------------------------------------- /docs/src/index.md: -------------------------------------------------------------------------------- 1 | 2 | # Overview 3 | 4 | AskAI.jl, as its name suggests, is a straightforward tool for querying Large Language Models. 5 | Currently supporting ollama and Google's Gemini model API. it's designed to be simple and direct: send prompts and questions to AI provider, and optionally execute the included code within a sandboxed "playground" to avoid affecting the main scope. 6 | 7 | The main macro, `@ai`, retrieves results from a large language model, while `@AI` executes the code within the "playground" scope and displays the output(or any errors.) 8 | 9 | a REPL mode was also support. Press `}` to enter and backspace to exit 10 | 11 | 12 | ![AskAI](./overview.png) 13 | 14 | 15 | !!! note 16 | as most of the AI tool, it needs the api key or similar configure, in AskAI it follow the rule: "providerg|model|api". eg, For the Gemini it would be "Gemini|gemini-2.0-flash|1234567890abcdef1234567890abcdef" and for ollama it would be something likes "ollama|qwen2.5:72b|http://localhost:11434". you can put it in the `ENV["AskAI_config"]` or use `AskAI.setapi("providerg|model|api")` to apply your setting. Please also add a module called playground: `module playground end` in your main scope for the code execute just in case you want to use the `@AI` macro. 17 | 18 | !!! note 19 | A convenient way is to put below code in your Julia `startup.jl` configuration file. 20 | ``` 21 | ENV["AskAI_config"] = "provider|model|api or URL" 22 | module playground end 23 | using AskAI 24 | ``` 25 | then you can use the AskAI in every session by default 26 | 27 | 28 | it starts as my persional AI tool in julia REP and only support the Gemini model currently. have fun with it and I welcome your suggestions and input for AskAI.jl!!! 29 | 30 | # installation 31 | 32 | ```julia 33 | (@v1.10) pkg> add https://github.com/AIBioLab/AskAI 34 | julia> using AskAI 35 | # now you can configure it with your AI model provider; eg ollama 36 | julia> AskAI.setapi("ollama|glm4:latest|http://localhost:11434") 37 | # or Gemini 38 | julia> AskAI.setapi("Gemini|modelName|your API key") 39 | ``` 40 | 41 | !!! note 42 | by default the response mode is stream, it should work well, however you can always change it by set `AskAI.Brain.stream = false`. 43 | 44 | # quickly example 45 | Here's an example of using AskAI to generate scatter and histogram plots and perform basic statistical calculations. 46 | ```julia 47 | @AI "tell me the current date, use the pacakge when in need" 48 | @AI "create a new project in /tmp, name it as demo + date, activate it" 49 | @AI "load my data as df, the data file is in /tmp/celldata.csv" 50 | @AI "tell me the data size" 51 | @AI "does the data contain columns named geneX and geneY??" 52 | @AI "install the package to support figure display in the terminal" 53 | @AI "plot a scatter plot of geneX and geneY, I want the geneX on axis Y" 54 | @AI "please also label the axis" 55 | @AI "calculate the correlation of geneX and geneY" 56 | @AI "keep only 3 digits" 57 | @AI "generate a histogram to show the distribution of geneX " 58 | @AI "do the same to geneY" 59 | @AI "fit a linear model to predict value of geneY from geneX,using GLM" 60 | @AI "give me the coef of geneX in this model,keep 5 digits" 61 | ``` 62 | 63 | 64 | ## Output Results are here 65 | 66 | !!! details 67 | ![result1](./result1.png) 68 | ![result2](./result2.png) 69 | ![result3](./result3.png) 70 | 71 | !!! note 72 | some time you may get the wrong result from the LLM, LLM results aren't always perfect, so please double-check. You can use `@ai` instead of `@AI` for code checks. then use `exe()` to perform the code. Often the case I met is the necessary packages aren't installed. 73 | ```julia 74 | @ai "tell me the current date,install the package if it needs" 75 | AskAI.exe(ans) 76 | ``` 77 | 78 | to review the conversation history 79 | ```julia 80 | AskAI.Brain.history["ask"] 81 | AskAI.Brain.history["ans"] 82 | 83 | # review the last response 84 | AskAI.Brain.history["ans"][end] |> AskAI.MD 85 | ``` 86 | 87 | 88 | you can also try the stream mode under terminal 89 | ```julia 90 | AskAI.Brain.stream = true 91 | @ai "why the sky is blue" 92 | ``` 93 | 94 | 95 | # function and macro 96 | ```@autodocs 97 | Modules = [AskAI] 98 | Pages = ["AskAI.jl", "brain.jl"] 99 | ``` 100 | 101 | -------------------------------------------------------------------------------- /docs/src/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/src/overview.png -------------------------------------------------------------------------------- /docs/src/result1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/src/result1.png -------------------------------------------------------------------------------- /docs/src/result2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/src/result2.png -------------------------------------------------------------------------------- /docs/src/result3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/docs/src/result3.png -------------------------------------------------------------------------------- /overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/overview.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Static Badge 4 | 5 | 6 | AskAI.jl, as its name suggests, is a straightforward tool for querying Large Language Models. 7 | Currently supporting ollama and Google's Gemini model API. it's designed to be simple and direct: send prompts and questions to AI provider, and optionally execute the included code within a sandboxed "playground" to avoid affecting the main scope. 8 | 9 | The main macro, `@ai`, retrieves results from a large language model, while `@AI` executes the code within the "playground" scope and displays the output(or any errors.) 10 | 11 | a REPL mode was also support. Press `}` to enter and backspace to exit 12 | 13 | ## Overview 14 | ![AskAI](./overview.png) 15 | 16 | ## Screenshot 17 | ![screenshot](./docs/src/result3.png) 18 | -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIBioLab/AskAI/524cd85b6675b07a1a12c119e8cc5f4e894eb686/src/.DS_Store -------------------------------------------------------------------------------- /src/AskAI.jl: -------------------------------------------------------------------------------- 1 | module AskAI 2 | using HTTP, JSON3, Markdown 3 | using ReplMaker: initrepl 4 | 5 | include("models.jl") 6 | include("brain.jl") 7 | 8 | prompt_to_get_code = "if the answer contains code, only output the raw code in julia" 9 | 10 | AskAI_config="provider|model|apiOrURL" 11 | 12 | # AI_API_KEY = "API key not set" 13 | 14 | function __init__() 15 | global AI_Provider,AI_Model,AI_URL_Or_API 16 | 17 | ###################################### 18 | # check for the required AI_API_KEY # 19 | ###################################### 20 | if haskey(ENV, "AskAI_config") 21 | setapi(ENV["AskAI_config"]) 22 | else 23 | msg = """ 24 | AskAI_config is needed. please set it as an environment variable, follow the rule: "provider|model|api" : 25 | ```julia 26 | # for Gemini 27 | ENV["AskAI_config"]="Gemini|gemini-2.0-flash|1234567890abcdef1234567890abcdef" 28 | 29 | # for ollama 30 | ENV["AskAI_config"]="ollama|qwen2.5:72b|http://localhost:11434" 31 | 32 | ``` 33 | 34 | or set it through function `setapi()` 35 | ```julia 36 | $(@__MODULE__).setapi("Gemini|gemini-2.0-flash|1234567890abcdef1234567890abcdef") 37 | # or 38 | $(@__MODULE__).setapi("ollama|qwen2.5:72b|http://localhost:11434") 39 | ``` 40 | """ 41 | setapi("Gemini|noModel|noAPI|") 42 | display(Markdown.parse(msg)) 43 | end 44 | 45 | isinteractive() || return 46 | initrepl(s -> Main.eval(Meta.parse("AskAI.@ai \"$s\"")); 47 | prompt_text="ask ai> ", 48 | prompt_color=104, 49 | start_key='}', 50 | mode_name=:askai, 51 | ) 52 | 53 | end 54 | 55 | 56 | """ 57 | ```julia 58 | setapi("ollama|modelName|URL") 59 | setapi("gemini|modelName|api") 60 | ``` 61 | """ 62 | function setapi( api::String ) 63 | provider, model, apiOrURL = split(api,"|") 64 | provider = lowercase(provider) 65 | @assert lowercase(provider) in ["gemini", "ollama"] 66 | if provider == "gemini" 67 | global Brain = AIBrain( model = Gemini(model,apiOrURL), prompt = prompt_to_get_code ) 68 | else 69 | global Brain = AIBrain( model = ollama(model,apiOrURL), prompt = prompt_to_get_code ) 70 | end 71 | end 72 | 73 | 74 | """ 75 | Reset the AskAI, it will remove the conversation history, memory, prompt... and everything as default defined 76 | ```julia 77 | AskAI.reset() 78 | ``` 79 | """ 80 | function reset() 81 | global Brain = AIBrain(model = Brain.model,prompt = Brain.prompt) 82 | 83 | end 84 | 85 | 86 | """ 87 | get the answer from the AI 88 | ## example 89 | ```julia 90 | @ai "fit a linear model" 91 | # or you can concatenate your question 92 | @ai "fit a" + "linear model" 93 | ``` 94 | """ 95 | macro ai(expr) 96 | if isa(expr,String) 97 | return :(Brain($expr)) 98 | end 99 | 100 | # Create a list to hold the concatenated parts 101 | parts = [] 102 | 103 | # Iterate over the arguments of the expression 104 | for arg in expr.args 105 | # Push each argument to the parts list 106 | push!(parts, esc(arg)) 107 | end 108 | 109 | # Create the expression to call f with the concatenated string 110 | return :(Brain(string($(Expr(:call, Symbol("string"), parts...))))) 111 | end 112 | 113 | 114 | """ 115 | execute the string as code 116 | 117 | ```julia 118 | "1 + 1" |> AskAI.exe 119 | 120 | (@ai "1 + 1") |> AskAI.exe 121 | ``` 122 | """ 123 | exe(x) = include_string(Main.playground,replace(string(x), "```julia" => "", "```" => "")) 124 | 125 | 126 | """ 127 | similar to `@ai`, 128 | 129 | send the question to AI but @AI perform the code directly and only return the result, or error :( 130 | 131 | 132 | the conversation history will stored in the `AskAI.Brain.history` 133 | ## example: 134 | ```julia 135 | @AI "tell me the current time, used the package you need" 136 | ``` 137 | """ 138 | macro AI(expr) 139 | if !isdefined(Main, :playground) 140 | msg = """ 141 | please run 142 | ```julia 143 | module playground end 144 | ``` 145 | to add the module to the Main scope, which will be used by @AI to call julia code 146 | """ 147 | Markdown.parse(msg) |> display 148 | else 149 | # does not support stream mode 150 | # tmp = Brain.stream 151 | Brain.stream = false 152 | :( exe($(@ai($(expr))))) 153 | # Brain.stream = tmp; # recover the stream setting 154 | # res 155 | end 156 | end 157 | 158 | export setAPI, @ai, @AI, avaliableModels, changeModels! 159 | end 160 | -------------------------------------------------------------------------------- /src/brain.jl: -------------------------------------------------------------------------------- 1 | Base.@kwdef mutable struct AIBrain 2 | memory::AbstractString = "" # summary of the past query 3 | history::Dict = Dict("ask" => [], "ans" => []) # conversation history 4 | prompt::AbstractString = "" 5 | stream::Bool=true # if the model returns the stream response 6 | timeout::Int = 10 # set the timeout for the http request 7 | model::modelProvider # = "gemini-2.0-flash" # the model 8 | RAG::AbstractString = "" # to store RAG result 9 | end 10 | 11 | 12 | """ 13 | changeModels!(AskAI.Brain, "qwen2.5:72b") 14 | """ 15 | function changeModels!(m::AIBrain, model::String) 16 | m.model.model = model 17 | end 18 | 19 | 20 | (m::AIBrain)( question::AbstractString ) = begin 21 | headers = Dict("Content-Type" => "application/json") 22 | url = getRESTURL(m.model) 23 | body = question2JSONString(m.model,question) 24 | if !m.stream 25 | try 26 | resp = HTTP.post(url,body=body, headers=headers, timeout=m.timeout) 27 | if resp.status == 200 28 | # text = JSON3.read(resp.body)[:candidates][1][:content][:parts][1]["text"] 29 | text = getAnswer(m.model, resp) 30 | m.memory *= "ask: $(question) \n ans: $(text) \n" 31 | push!(m.history["ask"], question) 32 | push!(m.history["ans"], text) 33 | @async checkMemory!(m) 34 | return text |> Markdown.parse # show in the terminal 35 | else 36 | return "respond code: $(resp.status)🔗🚫" 37 | end 38 | catch error 39 | @error "Unexpected response,Please check the model" 40 | Brain 41 | end 42 | else 43 | ########################## 44 | # for streaming response # 45 | ########################## 46 | 47 | m.memory *= "ask: $(question) \n" 48 | push!(m.history["ask"], question) 49 | 50 | channel = Channel{String}(3000) 51 | channel2 = Channel{String}(3000) 52 | 53 | @async HTTP.open(:POST, url, headers=headers, timeout=m.timeout) do io 54 | write(io, body) 55 | HTTP.closewrite(io) 56 | r = HTTP.startread(io) 57 | EOF_signal = 0 58 | last_str="EOF" 59 | while (EOF_signal > 10) || !eof(io) 60 | chunk = String(readavailable(io)) 61 | lines = String.(filter(!isempty, split(chunk, "\n"))) 62 | for line in lines 63 | currentText = getAnswer(m.model,line) 64 | # If the model falls into a repetitive loop, I should stop it 65 | if last_str === currentText 66 | EOF_signal += 1 67 | end 68 | last_str = currentText 69 | push!(channel,currentText) 70 | push!(channel2,currentText) 71 | end 72 | end 73 | HTTP.closeread(io) 74 | isopen(channel) && close(channel); 75 | isopen(channel2) && close(channel2); 76 | end 77 | showStreamStringFromChannel(channel) # show in the terminal 78 | streamToMemory(m,channel2) 79 | @async checkMemory!(m) 80 | # final reflash and print output 81 | print("\033c") 82 | replace(Brain.history["ans"][end], r"^ans: " => "# Final Output \n\n" ) |> MD 83 | 84 | end; 85 | end 86 | 87 | """ 88 | for stream mode, displays a streaming response from the channel, updating the display in terminal with each chunk of text received. 89 | """ 90 | function showStreamStringFromChannel(channel::Channel) 91 | first_text = take!(channel) 92 | response = first_text 93 | println() 94 | print("\e[32m¬ \e[0m") 95 | print("\033[s") 96 | print(first_text) 97 | for chunk in channel 98 | print("\033[u\033[s") 99 | response *= chunk 100 | sleep(0.01) 101 | display(Markdown.parse(response)) 102 | end 103 | end 104 | 105 | 106 | """ 107 | for stream mode, take string from the channel, convert to markdown, and save as `memory` context 108 | """ 109 | function streamToMemory(m::AIBrain,channel::Channel) 110 | first_text = take!(channel) 111 | response = first_text 112 | 113 | m.memory *= "ans: $(response)" 114 | cache = "ans: $(response)" 115 | 116 | for chunk in channel 117 | m.memory *= "$(chunk)" 118 | cache *= "$(chunk)" 119 | end 120 | push!(m.history["ans"], cache) 121 | end 122 | 123 | """ 124 | optimalize the `memory text`, when the memory words length exceeds 3000 words, summary it into 300 words 125 | """ 126 | function checkMemory!(m::AIBrain,L = 3000) 127 | if length(m.memory) > L 128 | tmpBrain = AIBrain(api=AI_API_KEY,prompt = "summary below into 300 words:") 129 | m.memory = tmpBrain( m.memory) |> string; 130 | end 131 | return nothing 132 | end; 133 | 134 | MD = Markdown.parse 135 | Base.show(io::IO, ::MIME"text/plain", m::AIBrain) = begin 136 | MD(""" 137 | $(m.model.model) 138 | 139 | \n for more \n 140 | - memory: $(length(m.memory)) words 141 | - history: $(length(m.history["ans"])) conversation 142 | - prompt: $(m.prompt) 143 | 144 | """) |> show 145 | end 146 | 147 | -------------------------------------------------------------------------------- /src/models.jl: -------------------------------------------------------------------------------- 1 | abstract type modelProvider end 2 | 3 | """ 4 | model::String: name of the model provided in Google Gemini, like 'gemini-2.0-flash' 5 | api::String: your google gemini api key 6 | """ 7 | Base.@kwdef mutable struct Gemini <: modelProvider 8 | model::String 9 | api::String 10 | end 11 | 12 | """ 13 | model::String: name of the model provided in local ollama 14 | url::String: the url of ollama model, IP:port is needed 15 | """ 16 | Base.@kwdef mutable struct ollama <: modelProvider 17 | model::String 18 | url::String 19 | end 20 | 21 | """ 22 | list avaliabel models in currrent provider 23 | 24 | ```julia 25 | AskAI.setapi("Gemini|gemini-2.0-flash|AIzaSyBqwIWyterU29hkdUNkSHYoBRSi4AN4fgU") 26 | AskAI.avaliableModels(pretty=true) # pretty = false to return raw string vector 27 | ``` 28 | avalibale models: 29 | 30 | • glm4:latest 31 | 32 | • deepseek-r1:70b 33 | """ 34 | function avaliableModels end 35 | function avaliableModels(m::modelProvider; pretty::Bool = true ) 36 | if typeof(m) == Gemini 37 | url = "https://generativelanguage.googleapis.com/v1beta/models?key=$(m.api)" 38 | try 39 | resp = HTTP.get(url) 40 | if resp.status == 200 41 | res = JSON3.read(resp.body)[:models] 42 | models = [replace(i["name"],"models/" => "") for i in res if "generateContent" in i["supportedGenerationMethods"]] 43 | if pretty 44 | join( vcat(["avalibale models:"],models), "\n - ") |> MD 45 | else 46 | models 47 | end 48 | 49 | end 50 | catch error 51 | return "error code $(resp.status)" 52 | end 53 | 54 | elseif typeof(m) == ollama 55 | url = m.url * "/api/tags" 56 | try 57 | resp = HTTP.get(url) 58 | if resp.status == 200 59 | models = [i["name"] for i in JSON3.read(resp.body)[:models]] 60 | if pretty 61 | join( vcat(["avalibale models:"],models), "\n - ") |> MD 62 | else 63 | models 64 | end 65 | end 66 | catch error 67 | return "error code $(resp.status)" 68 | end 69 | 70 | end 71 | end 72 | avaliableModels(;kws...) = avaliableModels(Brain.model;kws...) 73 | 74 | """ 75 | warp question into json data 76 | """ 77 | function question2JSONString(m::modelProvider, question::AbstractString) 78 | question = Brain.RAG * "\n" * Brain.memory * "\n" * Brain.prompt * "\n" * question 79 | if typeof(m) == Gemini 80 | return JSON3.write(Dict("contents" => Dict("parts" => [Dict("text" => question)]))) 81 | 82 | elseif typeof(m) == ollama 83 | return JSON3.write(Dict("model" => m.model, 84 | "prompt" => question, 85 | "stream" => Brain.stream)) 86 | end 87 | 88 | @error "Error in converting question into json string" 89 | end 90 | 91 | """ 92 | construct the URL for HTTP request, based on model provider 93 | """ 94 | function getRESTURL(m::modelProvider) 95 | if typeof(m) == Gemini 96 | if !Brain.stream 97 | return "https://generativelanguage.googleapis.com/v1beta/models/$(m.model):generateContent?key=$(m.api)" 98 | else 99 | return "https://generativelanguage.googleapis.com/v1beta/models/$(m.model):streamGenerateContent?alt=sse&key=$(m.api)" 100 | end 101 | elseif typeof(m) == ollama 102 | strip(m.url, '/') 103 | return "$(m.url)/api/generate" 104 | end 105 | end 106 | 107 | """ 108 | retrieve answer from AI response 109 | """ 110 | function getAnswer end 111 | function getAnswer(m::Gemini, resp) 112 | if !AskAI.Brain.stream 113 | return JSON3.read(resp.body)[:candidates][1][:content][:parts][1]["text"] 114 | else 115 | if startswith(resp, "data: ") 116 | data = JSON3.read(replace(resp, r"^data: " => "")) 117 | return data[:candidates][1][:content][:parts][1]["text"] 118 | else 119 | return "" 120 | end 121 | end 122 | end 123 | 124 | function getAnswer(m::ollama, resp) 125 | try 126 | resp = !AskAI.Brain.stream ? JSON3.read(resp.body)["response"] : JSON3.read(resp)["response"] 127 | catch error 128 | resp = "" 129 | end 130 | return resp 131 | end 132 | --------------------------------------------------------------------------------