├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── Readme.md ├── images ├── shortgpt-win.PNG ├── shortgpt.png └── shortgpt_demo.PNG └── src ├── arg_parser.rs ├── completion_context.rs ├── gpt_chat_completion.rs ├── main.rs ├── models.rs ├── prompts.rs └── render.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anstream" 7 | version = "0.3.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" 10 | dependencies = [ 11 | "anstyle", 12 | "anstyle-parse", 13 | "anstyle-query", 14 | "anstyle-wincon", 15 | "colorchoice", 16 | "is-terminal", 17 | "utf8parse", 18 | ] 19 | 20 | [[package]] 21 | name = "anstyle" 22 | version = "1.0.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" 25 | 26 | [[package]] 27 | name = "anstyle-parse" 28 | version = "0.2.0" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" 31 | dependencies = [ 32 | "utf8parse", 33 | ] 34 | 35 | [[package]] 36 | name = "anstyle-query" 37 | version = "1.0.0" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 40 | dependencies = [ 41 | "windows-sys 0.48.0", 42 | ] 43 | 44 | [[package]] 45 | name = "anstyle-wincon" 46 | version = "1.0.1" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" 49 | dependencies = [ 50 | "anstyle", 51 | "windows-sys 0.48.0", 52 | ] 53 | 54 | [[package]] 55 | name = "atty" 56 | version = "0.2.14" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 59 | dependencies = [ 60 | "hermit-abi 0.1.19", 61 | "libc", 62 | "winapi", 63 | ] 64 | 65 | [[package]] 66 | name = "autocfg" 67 | version = "1.1.0" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 70 | 71 | [[package]] 72 | name = "base64" 73 | version = "0.21.0" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" 76 | 77 | [[package]] 78 | name = "bitflags" 79 | version = "1.3.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 82 | 83 | [[package]] 84 | name = "bumpalo" 85 | version = "3.12.1" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" 88 | 89 | [[package]] 90 | name = "bytes" 91 | version = "1.4.0" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" 94 | 95 | [[package]] 96 | name = "cc" 97 | version = "1.0.79" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 100 | 101 | [[package]] 102 | name = "cfg-if" 103 | version = "1.0.0" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 106 | 107 | [[package]] 108 | name = "clap" 109 | version = "4.2.5" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "8a1f23fa97e1d1641371b51f35535cb26959b8e27ab50d167a8b996b5bada819" 112 | dependencies = [ 113 | "clap_builder", 114 | "clap_derive", 115 | "once_cell", 116 | ] 117 | 118 | [[package]] 119 | name = "clap_builder" 120 | version = "4.2.5" 121 | source = "registry+https://github.com/rust-lang/crates.io-index" 122 | checksum = "0fdc5d93c358224b4d6867ef1356d740de2303e9892edc06c5340daeccd96bab" 123 | dependencies = [ 124 | "anstream", 125 | "anstyle", 126 | "bitflags", 127 | "clap_lex", 128 | "strsim", 129 | ] 130 | 131 | [[package]] 132 | name = "clap_derive" 133 | version = "4.2.0" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" 136 | dependencies = [ 137 | "heck", 138 | "proc-macro2", 139 | "quote", 140 | "syn 2.0.15", 141 | ] 142 | 143 | [[package]] 144 | name = "clap_lex" 145 | version = "0.4.1" 146 | source = "registry+https://github.com/rust-lang/crates.io-index" 147 | checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" 148 | 149 | [[package]] 150 | name = "colorchoice" 151 | version = "1.0.0" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 154 | 155 | [[package]] 156 | name = "colored" 157 | version = "2.0.0" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" 160 | dependencies = [ 161 | "atty", 162 | "lazy_static", 163 | "winapi", 164 | ] 165 | 166 | [[package]] 167 | name = "coolor" 168 | version = "0.5.0" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "af4d7a805ca0d92f8c61a31c809d4323fdaa939b0b440e544d21db7797c5aaad" 171 | dependencies = [ 172 | "crossterm", 173 | ] 174 | 175 | [[package]] 176 | name = "core-foundation" 177 | version = "0.9.3" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" 180 | dependencies = [ 181 | "core-foundation-sys", 182 | "libc", 183 | ] 184 | 185 | [[package]] 186 | name = "core-foundation-sys" 187 | version = "0.8.4" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" 190 | 191 | [[package]] 192 | name = "crossbeam" 193 | version = "0.8.2" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" 196 | dependencies = [ 197 | "cfg-if", 198 | "crossbeam-channel", 199 | "crossbeam-deque", 200 | "crossbeam-epoch", 201 | "crossbeam-queue", 202 | "crossbeam-utils", 203 | ] 204 | 205 | [[package]] 206 | name = "crossbeam-channel" 207 | version = "0.5.8" 208 | source = "registry+https://github.com/rust-lang/crates.io-index" 209 | checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" 210 | dependencies = [ 211 | "cfg-if", 212 | "crossbeam-utils", 213 | ] 214 | 215 | [[package]] 216 | name = "crossbeam-deque" 217 | version = "0.8.3" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" 220 | dependencies = [ 221 | "cfg-if", 222 | "crossbeam-epoch", 223 | "crossbeam-utils", 224 | ] 225 | 226 | [[package]] 227 | name = "crossbeam-epoch" 228 | version = "0.9.14" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" 231 | dependencies = [ 232 | "autocfg", 233 | "cfg-if", 234 | "crossbeam-utils", 235 | "memoffset", 236 | "scopeguard", 237 | ] 238 | 239 | [[package]] 240 | name = "crossbeam-queue" 241 | version = "0.3.8" 242 | source = "registry+https://github.com/rust-lang/crates.io-index" 243 | checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" 244 | dependencies = [ 245 | "cfg-if", 246 | "crossbeam-utils", 247 | ] 248 | 249 | [[package]] 250 | name = "crossbeam-utils" 251 | version = "0.8.15" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" 254 | dependencies = [ 255 | "cfg-if", 256 | ] 257 | 258 | [[package]] 259 | name = "crossterm" 260 | version = "0.23.2" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17" 263 | dependencies = [ 264 | "bitflags", 265 | "crossterm_winapi", 266 | "libc", 267 | "mio", 268 | "parking_lot", 269 | "signal-hook", 270 | "signal-hook-mio", 271 | "winapi", 272 | ] 273 | 274 | [[package]] 275 | name = "crossterm_winapi" 276 | version = "0.9.0" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" 279 | dependencies = [ 280 | "winapi", 281 | ] 282 | 283 | [[package]] 284 | name = "encoding_rs" 285 | version = "0.8.32" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" 288 | dependencies = [ 289 | "cfg-if", 290 | ] 291 | 292 | [[package]] 293 | name = "errno" 294 | version = "0.3.1" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" 297 | dependencies = [ 298 | "errno-dragonfly", 299 | "libc", 300 | "windows-sys 0.48.0", 301 | ] 302 | 303 | [[package]] 304 | name = "errno-dragonfly" 305 | version = "0.1.2" 306 | source = "registry+https://github.com/rust-lang/crates.io-index" 307 | checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" 308 | dependencies = [ 309 | "cc", 310 | "libc", 311 | ] 312 | 313 | [[package]] 314 | name = "fastrand" 315 | version = "1.9.0" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" 318 | dependencies = [ 319 | "instant", 320 | ] 321 | 322 | [[package]] 323 | name = "fnv" 324 | version = "1.0.7" 325 | source = "registry+https://github.com/rust-lang/crates.io-index" 326 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 327 | 328 | [[package]] 329 | name = "foreign-types" 330 | version = "0.3.2" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 333 | dependencies = [ 334 | "foreign-types-shared", 335 | ] 336 | 337 | [[package]] 338 | name = "foreign-types-shared" 339 | version = "0.1.1" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 342 | 343 | [[package]] 344 | name = "form_urlencoded" 345 | version = "1.1.0" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 348 | dependencies = [ 349 | "percent-encoding", 350 | ] 351 | 352 | [[package]] 353 | name = "futures-channel" 354 | version = "0.3.28" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" 357 | dependencies = [ 358 | "futures-core", 359 | ] 360 | 361 | [[package]] 362 | name = "futures-core" 363 | version = "0.3.28" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" 366 | 367 | [[package]] 368 | name = "futures-io" 369 | version = "0.3.28" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" 372 | 373 | [[package]] 374 | name = "futures-sink" 375 | version = "0.3.28" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" 378 | 379 | [[package]] 380 | name = "futures-task" 381 | version = "0.3.28" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" 384 | 385 | [[package]] 386 | name = "futures-util" 387 | version = "0.3.28" 388 | source = "registry+https://github.com/rust-lang/crates.io-index" 389 | checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" 390 | dependencies = [ 391 | "futures-core", 392 | "futures-io", 393 | "futures-task", 394 | "memchr", 395 | "pin-project-lite", 396 | "pin-utils", 397 | "slab", 398 | ] 399 | 400 | [[package]] 401 | name = "h2" 402 | version = "0.3.18" 403 | source = "registry+https://github.com/rust-lang/crates.io-index" 404 | checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" 405 | dependencies = [ 406 | "bytes", 407 | "fnv", 408 | "futures-core", 409 | "futures-sink", 410 | "futures-util", 411 | "http", 412 | "indexmap", 413 | "slab", 414 | "tokio", 415 | "tokio-util", 416 | "tracing", 417 | ] 418 | 419 | [[package]] 420 | name = "hashbrown" 421 | version = "0.12.3" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 424 | 425 | [[package]] 426 | name = "heck" 427 | version = "0.4.1" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 430 | 431 | [[package]] 432 | name = "hermit-abi" 433 | version = "0.1.19" 434 | source = "registry+https://github.com/rust-lang/crates.io-index" 435 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 436 | dependencies = [ 437 | "libc", 438 | ] 439 | 440 | [[package]] 441 | name = "hermit-abi" 442 | version = "0.2.6" 443 | source = "registry+https://github.com/rust-lang/crates.io-index" 444 | checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 445 | dependencies = [ 446 | "libc", 447 | ] 448 | 449 | [[package]] 450 | name = "hermit-abi" 451 | version = "0.3.1" 452 | source = "registry+https://github.com/rust-lang/crates.io-index" 453 | checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" 454 | 455 | [[package]] 456 | name = "http" 457 | version = "0.2.9" 458 | source = "registry+https://github.com/rust-lang/crates.io-index" 459 | checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" 460 | dependencies = [ 461 | "bytes", 462 | "fnv", 463 | "itoa", 464 | ] 465 | 466 | [[package]] 467 | name = "http-body" 468 | version = "0.4.5" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" 471 | dependencies = [ 472 | "bytes", 473 | "http", 474 | "pin-project-lite", 475 | ] 476 | 477 | [[package]] 478 | name = "httparse" 479 | version = "1.8.0" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" 482 | 483 | [[package]] 484 | name = "httpdate" 485 | version = "1.0.2" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" 488 | 489 | [[package]] 490 | name = "hyper" 491 | version = "0.14.26" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" 494 | dependencies = [ 495 | "bytes", 496 | "futures-channel", 497 | "futures-core", 498 | "futures-util", 499 | "h2", 500 | "http", 501 | "http-body", 502 | "httparse", 503 | "httpdate", 504 | "itoa", 505 | "pin-project-lite", 506 | "socket2", 507 | "tokio", 508 | "tower-service", 509 | "tracing", 510 | "want", 511 | ] 512 | 513 | [[package]] 514 | name = "hyper-tls" 515 | version = "0.5.0" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" 518 | dependencies = [ 519 | "bytes", 520 | "hyper", 521 | "native-tls", 522 | "tokio", 523 | "tokio-native-tls", 524 | ] 525 | 526 | [[package]] 527 | name = "idna" 528 | version = "0.3.0" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 531 | dependencies = [ 532 | "unicode-bidi", 533 | "unicode-normalization", 534 | ] 535 | 536 | [[package]] 537 | name = "indexmap" 538 | version = "1.9.3" 539 | source = "registry+https://github.com/rust-lang/crates.io-index" 540 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" 541 | dependencies = [ 542 | "autocfg", 543 | "hashbrown", 544 | ] 545 | 546 | [[package]] 547 | name = "instant" 548 | version = "0.1.12" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 551 | dependencies = [ 552 | "cfg-if", 553 | ] 554 | 555 | [[package]] 556 | name = "io-lifetimes" 557 | version = "1.0.10" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" 560 | dependencies = [ 561 | "hermit-abi 0.3.1", 562 | "libc", 563 | "windows-sys 0.48.0", 564 | ] 565 | 566 | [[package]] 567 | name = "ipnet" 568 | version = "2.7.2" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" 571 | 572 | [[package]] 573 | name = "is-terminal" 574 | version = "0.4.7" 575 | source = "registry+https://github.com/rust-lang/crates.io-index" 576 | checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" 577 | dependencies = [ 578 | "hermit-abi 0.3.1", 579 | "io-lifetimes", 580 | "rustix", 581 | "windows-sys 0.48.0", 582 | ] 583 | 584 | [[package]] 585 | name = "itoa" 586 | version = "1.0.6" 587 | source = "registry+https://github.com/rust-lang/crates.io-index" 588 | checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" 589 | 590 | [[package]] 591 | name = "js-sys" 592 | version = "0.3.61" 593 | source = "registry+https://github.com/rust-lang/crates.io-index" 594 | checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" 595 | dependencies = [ 596 | "wasm-bindgen", 597 | ] 598 | 599 | [[package]] 600 | name = "lazy_static" 601 | version = "1.4.0" 602 | source = "registry+https://github.com/rust-lang/crates.io-index" 603 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 604 | 605 | [[package]] 606 | name = "libc" 607 | version = "0.2.142" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" 610 | 611 | [[package]] 612 | name = "linux-raw-sys" 613 | version = "0.3.6" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "b64f40e5e03e0d54f03845c8197d0291253cdbedfb1cb46b13c2c117554a9f4c" 616 | 617 | [[package]] 618 | name = "lock_api" 619 | version = "0.4.9" 620 | source = "registry+https://github.com/rust-lang/crates.io-index" 621 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 622 | dependencies = [ 623 | "autocfg", 624 | "scopeguard", 625 | ] 626 | 627 | [[package]] 628 | name = "log" 629 | version = "0.4.17" 630 | source = "registry+https://github.com/rust-lang/crates.io-index" 631 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 632 | dependencies = [ 633 | "cfg-if", 634 | ] 635 | 636 | [[package]] 637 | name = "memchr" 638 | version = "2.5.0" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 641 | 642 | [[package]] 643 | name = "memoffset" 644 | version = "0.8.0" 645 | source = "registry+https://github.com/rust-lang/crates.io-index" 646 | checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" 647 | dependencies = [ 648 | "autocfg", 649 | ] 650 | 651 | [[package]] 652 | name = "mime" 653 | version = "0.3.17" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 656 | 657 | [[package]] 658 | name = "minimad" 659 | version = "0.12.0" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "38b136454924e4d020e55c4992e07c105b40d5c41b84662862f0e15bc0a2efef" 662 | dependencies = [ 663 | "once_cell", 664 | ] 665 | 666 | [[package]] 667 | name = "mio" 668 | version = "0.8.6" 669 | source = "registry+https://github.com/rust-lang/crates.io-index" 670 | checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" 671 | dependencies = [ 672 | "libc", 673 | "log", 674 | "wasi", 675 | "windows-sys 0.45.0", 676 | ] 677 | 678 | [[package]] 679 | name = "native-tls" 680 | version = "0.2.11" 681 | source = "registry+https://github.com/rust-lang/crates.io-index" 682 | checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" 683 | dependencies = [ 684 | "lazy_static", 685 | "libc", 686 | "log", 687 | "openssl", 688 | "openssl-probe", 689 | "openssl-sys", 690 | "schannel", 691 | "security-framework", 692 | "security-framework-sys", 693 | "tempfile", 694 | ] 695 | 696 | [[package]] 697 | name = "num_cpus" 698 | version = "1.15.0" 699 | source = "registry+https://github.com/rust-lang/crates.io-index" 700 | checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 701 | dependencies = [ 702 | "hermit-abi 0.2.6", 703 | "libc", 704 | ] 705 | 706 | [[package]] 707 | name = "once_cell" 708 | version = "1.17.1" 709 | source = "registry+https://github.com/rust-lang/crates.io-index" 710 | checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 711 | 712 | [[package]] 713 | name = "openssl" 714 | version = "0.10.52" 715 | source = "registry+https://github.com/rust-lang/crates.io-index" 716 | checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" 717 | dependencies = [ 718 | "bitflags", 719 | "cfg-if", 720 | "foreign-types", 721 | "libc", 722 | "once_cell", 723 | "openssl-macros", 724 | "openssl-sys", 725 | ] 726 | 727 | [[package]] 728 | name = "openssl-macros" 729 | version = "0.1.1" 730 | source = "registry+https://github.com/rust-lang/crates.io-index" 731 | checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" 732 | dependencies = [ 733 | "proc-macro2", 734 | "quote", 735 | "syn 2.0.15", 736 | ] 737 | 738 | [[package]] 739 | name = "openssl-probe" 740 | version = "0.1.5" 741 | source = "registry+https://github.com/rust-lang/crates.io-index" 742 | checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" 743 | 744 | [[package]] 745 | name = "openssl-sys" 746 | version = "0.9.87" 747 | source = "registry+https://github.com/rust-lang/crates.io-index" 748 | checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" 749 | dependencies = [ 750 | "cc", 751 | "libc", 752 | "pkg-config", 753 | "vcpkg", 754 | ] 755 | 756 | [[package]] 757 | name = "parking_lot" 758 | version = "0.12.1" 759 | source = "registry+https://github.com/rust-lang/crates.io-index" 760 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 761 | dependencies = [ 762 | "lock_api", 763 | "parking_lot_core", 764 | ] 765 | 766 | [[package]] 767 | name = "parking_lot_core" 768 | version = "0.9.7" 769 | source = "registry+https://github.com/rust-lang/crates.io-index" 770 | checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" 771 | dependencies = [ 772 | "cfg-if", 773 | "libc", 774 | "redox_syscall 0.2.16", 775 | "smallvec", 776 | "windows-sys 0.45.0", 777 | ] 778 | 779 | [[package]] 780 | name = "paste" 781 | version = "1.0.12" 782 | source = "registry+https://github.com/rust-lang/crates.io-index" 783 | checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" 784 | 785 | [[package]] 786 | name = "percent-encoding" 787 | version = "2.2.0" 788 | source = "registry+https://github.com/rust-lang/crates.io-index" 789 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 790 | 791 | [[package]] 792 | name = "pin-project-lite" 793 | version = "0.2.9" 794 | source = "registry+https://github.com/rust-lang/crates.io-index" 795 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 796 | 797 | [[package]] 798 | name = "pin-utils" 799 | version = "0.1.0" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 802 | 803 | [[package]] 804 | name = "pkg-config" 805 | version = "0.3.26" 806 | source = "registry+https://github.com/rust-lang/crates.io-index" 807 | checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" 808 | 809 | [[package]] 810 | name = "proc-macro2" 811 | version = "1.0.56" 812 | source = "registry+https://github.com/rust-lang/crates.io-index" 813 | checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" 814 | dependencies = [ 815 | "unicode-ident", 816 | ] 817 | 818 | [[package]] 819 | name = "quote" 820 | version = "1.0.26" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 823 | dependencies = [ 824 | "proc-macro2", 825 | ] 826 | 827 | [[package]] 828 | name = "redox_syscall" 829 | version = "0.2.16" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 832 | dependencies = [ 833 | "bitflags", 834 | ] 835 | 836 | [[package]] 837 | name = "redox_syscall" 838 | version = "0.3.5" 839 | source = "registry+https://github.com/rust-lang/crates.io-index" 840 | checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" 841 | dependencies = [ 842 | "bitflags", 843 | ] 844 | 845 | [[package]] 846 | name = "reqwest" 847 | version = "0.11.17" 848 | source = "registry+https://github.com/rust-lang/crates.io-index" 849 | checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" 850 | dependencies = [ 851 | "base64", 852 | "bytes", 853 | "encoding_rs", 854 | "futures-core", 855 | "futures-util", 856 | "h2", 857 | "http", 858 | "http-body", 859 | "hyper", 860 | "hyper-tls", 861 | "ipnet", 862 | "js-sys", 863 | "log", 864 | "mime", 865 | "native-tls", 866 | "once_cell", 867 | "percent-encoding", 868 | "pin-project-lite", 869 | "serde", 870 | "serde_json", 871 | "serde_urlencoded", 872 | "tokio", 873 | "tokio-native-tls", 874 | "tower-service", 875 | "url", 876 | "wasm-bindgen", 877 | "wasm-bindgen-futures", 878 | "web-sys", 879 | "winreg", 880 | ] 881 | 882 | [[package]] 883 | name = "rustix" 884 | version = "0.37.18" 885 | source = "registry+https://github.com/rust-lang/crates.io-index" 886 | checksum = "8bbfc1d1c7c40c01715f47d71444744a81669ca84e8b63e25a55e169b1f86433" 887 | dependencies = [ 888 | "bitflags", 889 | "errno", 890 | "io-lifetimes", 891 | "libc", 892 | "linux-raw-sys", 893 | "windows-sys 0.48.0", 894 | ] 895 | 896 | [[package]] 897 | name = "ryu" 898 | version = "1.0.13" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" 901 | 902 | [[package]] 903 | name = "schannel" 904 | version = "0.1.21" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" 907 | dependencies = [ 908 | "windows-sys 0.42.0", 909 | ] 910 | 911 | [[package]] 912 | name = "scopeguard" 913 | version = "1.1.0" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 916 | 917 | [[package]] 918 | name = "security-framework" 919 | version = "2.8.2" 920 | source = "registry+https://github.com/rust-lang/crates.io-index" 921 | checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" 922 | dependencies = [ 923 | "bitflags", 924 | "core-foundation", 925 | "core-foundation-sys", 926 | "libc", 927 | "security-framework-sys", 928 | ] 929 | 930 | [[package]] 931 | name = "security-framework-sys" 932 | version = "2.8.0" 933 | source = "registry+https://github.com/rust-lang/crates.io-index" 934 | checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" 935 | dependencies = [ 936 | "core-foundation-sys", 937 | "libc", 938 | ] 939 | 940 | [[package]] 941 | name = "serde" 942 | version = "1.0.160" 943 | source = "registry+https://github.com/rust-lang/crates.io-index" 944 | checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" 945 | dependencies = [ 946 | "serde_derive", 947 | ] 948 | 949 | [[package]] 950 | name = "serde_derive" 951 | version = "1.0.160" 952 | source = "registry+https://github.com/rust-lang/crates.io-index" 953 | checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" 954 | dependencies = [ 955 | "proc-macro2", 956 | "quote", 957 | "syn 2.0.15", 958 | ] 959 | 960 | [[package]] 961 | name = "serde_json" 962 | version = "1.0.96" 963 | source = "registry+https://github.com/rust-lang/crates.io-index" 964 | checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" 965 | dependencies = [ 966 | "itoa", 967 | "ryu", 968 | "serde", 969 | ] 970 | 971 | [[package]] 972 | name = "serde_urlencoded" 973 | version = "0.7.1" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 976 | dependencies = [ 977 | "form_urlencoded", 978 | "itoa", 979 | "ryu", 980 | "serde", 981 | ] 982 | 983 | [[package]] 984 | name = "shortgpt" 985 | version = "1.0.0" 986 | dependencies = [ 987 | "clap", 988 | "colored", 989 | "reqwest", 990 | "serde", 991 | "serde_json", 992 | "spinoff", 993 | "termimad", 994 | ] 995 | 996 | [[package]] 997 | name = "signal-hook" 998 | version = "0.3.15" 999 | source = "registry+https://github.com/rust-lang/crates.io-index" 1000 | checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" 1001 | dependencies = [ 1002 | "libc", 1003 | "signal-hook-registry", 1004 | ] 1005 | 1006 | [[package]] 1007 | name = "signal-hook-mio" 1008 | version = "0.2.3" 1009 | source = "registry+https://github.com/rust-lang/crates.io-index" 1010 | checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" 1011 | dependencies = [ 1012 | "libc", 1013 | "mio", 1014 | "signal-hook", 1015 | ] 1016 | 1017 | [[package]] 1018 | name = "signal-hook-registry" 1019 | version = "1.4.1" 1020 | source = "registry+https://github.com/rust-lang/crates.io-index" 1021 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 1022 | dependencies = [ 1023 | "libc", 1024 | ] 1025 | 1026 | [[package]] 1027 | name = "slab" 1028 | version = "0.4.8" 1029 | source = "registry+https://github.com/rust-lang/crates.io-index" 1030 | checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" 1031 | dependencies = [ 1032 | "autocfg", 1033 | ] 1034 | 1035 | [[package]] 1036 | name = "smallvec" 1037 | version = "1.10.0" 1038 | source = "registry+https://github.com/rust-lang/crates.io-index" 1039 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 1040 | 1041 | [[package]] 1042 | name = "socket2" 1043 | version = "0.4.9" 1044 | source = "registry+https://github.com/rust-lang/crates.io-index" 1045 | checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" 1046 | dependencies = [ 1047 | "libc", 1048 | "winapi", 1049 | ] 1050 | 1051 | [[package]] 1052 | name = "spinoff" 1053 | version = "0.7.0" 1054 | source = "registry+https://github.com/rust-lang/crates.io-index" 1055 | checksum = "fee259f96b31e7a18657d11741fe30d63f98e07de70e7a19d2b705ab9b331cdc" 1056 | dependencies = [ 1057 | "colored", 1058 | "once_cell", 1059 | "paste", 1060 | ] 1061 | 1062 | [[package]] 1063 | name = "strsim" 1064 | version = "0.10.0" 1065 | source = "registry+https://github.com/rust-lang/crates.io-index" 1066 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1067 | 1068 | [[package]] 1069 | name = "syn" 1070 | version = "1.0.109" 1071 | source = "registry+https://github.com/rust-lang/crates.io-index" 1072 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1073 | dependencies = [ 1074 | "proc-macro2", 1075 | "quote", 1076 | "unicode-ident", 1077 | ] 1078 | 1079 | [[package]] 1080 | name = "syn" 1081 | version = "2.0.15" 1082 | source = "registry+https://github.com/rust-lang/crates.io-index" 1083 | checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" 1084 | dependencies = [ 1085 | "proc-macro2", 1086 | "quote", 1087 | "unicode-ident", 1088 | ] 1089 | 1090 | [[package]] 1091 | name = "tempfile" 1092 | version = "3.5.0" 1093 | source = "registry+https://github.com/rust-lang/crates.io-index" 1094 | checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" 1095 | dependencies = [ 1096 | "cfg-if", 1097 | "fastrand", 1098 | "redox_syscall 0.3.5", 1099 | "rustix", 1100 | "windows-sys 0.45.0", 1101 | ] 1102 | 1103 | [[package]] 1104 | name = "termimad" 1105 | version = "0.23.0" 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" 1107 | checksum = "749b18b17745261a883ab334d931adffc8c5e07e71c73a861e77124557e7b41f" 1108 | dependencies = [ 1109 | "coolor", 1110 | "crossbeam", 1111 | "crossterm", 1112 | "minimad", 1113 | "thiserror", 1114 | "unicode-width", 1115 | ] 1116 | 1117 | [[package]] 1118 | name = "thiserror" 1119 | version = "1.0.40" 1120 | source = "registry+https://github.com/rust-lang/crates.io-index" 1121 | checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 1122 | dependencies = [ 1123 | "thiserror-impl", 1124 | ] 1125 | 1126 | [[package]] 1127 | name = "thiserror-impl" 1128 | version = "1.0.40" 1129 | source = "registry+https://github.com/rust-lang/crates.io-index" 1130 | checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 1131 | dependencies = [ 1132 | "proc-macro2", 1133 | "quote", 1134 | "syn 2.0.15", 1135 | ] 1136 | 1137 | [[package]] 1138 | name = "tinyvec" 1139 | version = "1.6.0" 1140 | source = "registry+https://github.com/rust-lang/crates.io-index" 1141 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 1142 | dependencies = [ 1143 | "tinyvec_macros", 1144 | ] 1145 | 1146 | [[package]] 1147 | name = "tinyvec_macros" 1148 | version = "0.1.1" 1149 | source = "registry+https://github.com/rust-lang/crates.io-index" 1150 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 1151 | 1152 | [[package]] 1153 | name = "tokio" 1154 | version = "1.28.0" 1155 | source = "registry+https://github.com/rust-lang/crates.io-index" 1156 | checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" 1157 | dependencies = [ 1158 | "autocfg", 1159 | "bytes", 1160 | "libc", 1161 | "mio", 1162 | "num_cpus", 1163 | "pin-project-lite", 1164 | "socket2", 1165 | "windows-sys 0.48.0", 1166 | ] 1167 | 1168 | [[package]] 1169 | name = "tokio-native-tls" 1170 | version = "0.3.1" 1171 | source = "registry+https://github.com/rust-lang/crates.io-index" 1172 | checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" 1173 | dependencies = [ 1174 | "native-tls", 1175 | "tokio", 1176 | ] 1177 | 1178 | [[package]] 1179 | name = "tokio-util" 1180 | version = "0.7.8" 1181 | source = "registry+https://github.com/rust-lang/crates.io-index" 1182 | checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" 1183 | dependencies = [ 1184 | "bytes", 1185 | "futures-core", 1186 | "futures-sink", 1187 | "pin-project-lite", 1188 | "tokio", 1189 | "tracing", 1190 | ] 1191 | 1192 | [[package]] 1193 | name = "tower-service" 1194 | version = "0.3.2" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" 1197 | 1198 | [[package]] 1199 | name = "tracing" 1200 | version = "0.1.37" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 1203 | dependencies = [ 1204 | "cfg-if", 1205 | "pin-project-lite", 1206 | "tracing-core", 1207 | ] 1208 | 1209 | [[package]] 1210 | name = "tracing-core" 1211 | version = "0.1.30" 1212 | source = "registry+https://github.com/rust-lang/crates.io-index" 1213 | checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" 1214 | dependencies = [ 1215 | "once_cell", 1216 | ] 1217 | 1218 | [[package]] 1219 | name = "try-lock" 1220 | version = "0.2.4" 1221 | source = "registry+https://github.com/rust-lang/crates.io-index" 1222 | checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" 1223 | 1224 | [[package]] 1225 | name = "unicode-bidi" 1226 | version = "0.3.13" 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" 1228 | checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" 1229 | 1230 | [[package]] 1231 | name = "unicode-ident" 1232 | version = "1.0.8" 1233 | source = "registry+https://github.com/rust-lang/crates.io-index" 1234 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 1235 | 1236 | [[package]] 1237 | name = "unicode-normalization" 1238 | version = "0.1.22" 1239 | source = "registry+https://github.com/rust-lang/crates.io-index" 1240 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1241 | dependencies = [ 1242 | "tinyvec", 1243 | ] 1244 | 1245 | [[package]] 1246 | name = "unicode-width" 1247 | version = "0.1.10" 1248 | source = "registry+https://github.com/rust-lang/crates.io-index" 1249 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 1250 | 1251 | [[package]] 1252 | name = "url" 1253 | version = "2.3.1" 1254 | source = "registry+https://github.com/rust-lang/crates.io-index" 1255 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 1256 | dependencies = [ 1257 | "form_urlencoded", 1258 | "idna", 1259 | "percent-encoding", 1260 | ] 1261 | 1262 | [[package]] 1263 | name = "utf8parse" 1264 | version = "0.2.1" 1265 | source = "registry+https://github.com/rust-lang/crates.io-index" 1266 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 1267 | 1268 | [[package]] 1269 | name = "vcpkg" 1270 | version = "0.2.15" 1271 | source = "registry+https://github.com/rust-lang/crates.io-index" 1272 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 1273 | 1274 | [[package]] 1275 | name = "want" 1276 | version = "0.3.0" 1277 | source = "registry+https://github.com/rust-lang/crates.io-index" 1278 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 1279 | dependencies = [ 1280 | "log", 1281 | "try-lock", 1282 | ] 1283 | 1284 | [[package]] 1285 | name = "wasi" 1286 | version = "0.11.0+wasi-snapshot-preview1" 1287 | source = "registry+https://github.com/rust-lang/crates.io-index" 1288 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1289 | 1290 | [[package]] 1291 | name = "wasm-bindgen" 1292 | version = "0.2.84" 1293 | source = "registry+https://github.com/rust-lang/crates.io-index" 1294 | checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" 1295 | dependencies = [ 1296 | "cfg-if", 1297 | "wasm-bindgen-macro", 1298 | ] 1299 | 1300 | [[package]] 1301 | name = "wasm-bindgen-backend" 1302 | version = "0.2.84" 1303 | source = "registry+https://github.com/rust-lang/crates.io-index" 1304 | checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" 1305 | dependencies = [ 1306 | "bumpalo", 1307 | "log", 1308 | "once_cell", 1309 | "proc-macro2", 1310 | "quote", 1311 | "syn 1.0.109", 1312 | "wasm-bindgen-shared", 1313 | ] 1314 | 1315 | [[package]] 1316 | name = "wasm-bindgen-futures" 1317 | version = "0.4.34" 1318 | source = "registry+https://github.com/rust-lang/crates.io-index" 1319 | checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" 1320 | dependencies = [ 1321 | "cfg-if", 1322 | "js-sys", 1323 | "wasm-bindgen", 1324 | "web-sys", 1325 | ] 1326 | 1327 | [[package]] 1328 | name = "wasm-bindgen-macro" 1329 | version = "0.2.84" 1330 | source = "registry+https://github.com/rust-lang/crates.io-index" 1331 | checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" 1332 | dependencies = [ 1333 | "quote", 1334 | "wasm-bindgen-macro-support", 1335 | ] 1336 | 1337 | [[package]] 1338 | name = "wasm-bindgen-macro-support" 1339 | version = "0.2.84" 1340 | source = "registry+https://github.com/rust-lang/crates.io-index" 1341 | checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" 1342 | dependencies = [ 1343 | "proc-macro2", 1344 | "quote", 1345 | "syn 1.0.109", 1346 | "wasm-bindgen-backend", 1347 | "wasm-bindgen-shared", 1348 | ] 1349 | 1350 | [[package]] 1351 | name = "wasm-bindgen-shared" 1352 | version = "0.2.84" 1353 | source = "registry+https://github.com/rust-lang/crates.io-index" 1354 | checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" 1355 | 1356 | [[package]] 1357 | name = "web-sys" 1358 | version = "0.3.61" 1359 | source = "registry+https://github.com/rust-lang/crates.io-index" 1360 | checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" 1361 | dependencies = [ 1362 | "js-sys", 1363 | "wasm-bindgen", 1364 | ] 1365 | 1366 | [[package]] 1367 | name = "winapi" 1368 | version = "0.3.9" 1369 | source = "registry+https://github.com/rust-lang/crates.io-index" 1370 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1371 | dependencies = [ 1372 | "winapi-i686-pc-windows-gnu", 1373 | "winapi-x86_64-pc-windows-gnu", 1374 | ] 1375 | 1376 | [[package]] 1377 | name = "winapi-i686-pc-windows-gnu" 1378 | version = "0.4.0" 1379 | source = "registry+https://github.com/rust-lang/crates.io-index" 1380 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1381 | 1382 | [[package]] 1383 | name = "winapi-x86_64-pc-windows-gnu" 1384 | version = "0.4.0" 1385 | source = "registry+https://github.com/rust-lang/crates.io-index" 1386 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1387 | 1388 | [[package]] 1389 | name = "windows-sys" 1390 | version = "0.42.0" 1391 | source = "registry+https://github.com/rust-lang/crates.io-index" 1392 | checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 1393 | dependencies = [ 1394 | "windows_aarch64_gnullvm 0.42.2", 1395 | "windows_aarch64_msvc 0.42.2", 1396 | "windows_i686_gnu 0.42.2", 1397 | "windows_i686_msvc 0.42.2", 1398 | "windows_x86_64_gnu 0.42.2", 1399 | "windows_x86_64_gnullvm 0.42.2", 1400 | "windows_x86_64_msvc 0.42.2", 1401 | ] 1402 | 1403 | [[package]] 1404 | name = "windows-sys" 1405 | version = "0.45.0" 1406 | source = "registry+https://github.com/rust-lang/crates.io-index" 1407 | checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 1408 | dependencies = [ 1409 | "windows-targets 0.42.2", 1410 | ] 1411 | 1412 | [[package]] 1413 | name = "windows-sys" 1414 | version = "0.48.0" 1415 | source = "registry+https://github.com/rust-lang/crates.io-index" 1416 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1417 | dependencies = [ 1418 | "windows-targets 0.48.0", 1419 | ] 1420 | 1421 | [[package]] 1422 | name = "windows-targets" 1423 | version = "0.42.2" 1424 | source = "registry+https://github.com/rust-lang/crates.io-index" 1425 | checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 1426 | dependencies = [ 1427 | "windows_aarch64_gnullvm 0.42.2", 1428 | "windows_aarch64_msvc 0.42.2", 1429 | "windows_i686_gnu 0.42.2", 1430 | "windows_i686_msvc 0.42.2", 1431 | "windows_x86_64_gnu 0.42.2", 1432 | "windows_x86_64_gnullvm 0.42.2", 1433 | "windows_x86_64_msvc 0.42.2", 1434 | ] 1435 | 1436 | [[package]] 1437 | name = "windows-targets" 1438 | version = "0.48.0" 1439 | source = "registry+https://github.com/rust-lang/crates.io-index" 1440 | checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" 1441 | dependencies = [ 1442 | "windows_aarch64_gnullvm 0.48.0", 1443 | "windows_aarch64_msvc 0.48.0", 1444 | "windows_i686_gnu 0.48.0", 1445 | "windows_i686_msvc 0.48.0", 1446 | "windows_x86_64_gnu 0.48.0", 1447 | "windows_x86_64_gnullvm 0.48.0", 1448 | "windows_x86_64_msvc 0.48.0", 1449 | ] 1450 | 1451 | [[package]] 1452 | name = "windows_aarch64_gnullvm" 1453 | version = "0.42.2" 1454 | source = "registry+https://github.com/rust-lang/crates.io-index" 1455 | checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 1456 | 1457 | [[package]] 1458 | name = "windows_aarch64_gnullvm" 1459 | version = "0.48.0" 1460 | source = "registry+https://github.com/rust-lang/crates.io-index" 1461 | checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" 1462 | 1463 | [[package]] 1464 | name = "windows_aarch64_msvc" 1465 | version = "0.42.2" 1466 | source = "registry+https://github.com/rust-lang/crates.io-index" 1467 | checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 1468 | 1469 | [[package]] 1470 | name = "windows_aarch64_msvc" 1471 | version = "0.48.0" 1472 | source = "registry+https://github.com/rust-lang/crates.io-index" 1473 | checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" 1474 | 1475 | [[package]] 1476 | name = "windows_i686_gnu" 1477 | version = "0.42.2" 1478 | source = "registry+https://github.com/rust-lang/crates.io-index" 1479 | checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 1480 | 1481 | [[package]] 1482 | name = "windows_i686_gnu" 1483 | version = "0.48.0" 1484 | source = "registry+https://github.com/rust-lang/crates.io-index" 1485 | checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" 1486 | 1487 | [[package]] 1488 | name = "windows_i686_msvc" 1489 | version = "0.42.2" 1490 | source = "registry+https://github.com/rust-lang/crates.io-index" 1491 | checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 1492 | 1493 | [[package]] 1494 | name = "windows_i686_msvc" 1495 | version = "0.48.0" 1496 | source = "registry+https://github.com/rust-lang/crates.io-index" 1497 | checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" 1498 | 1499 | [[package]] 1500 | name = "windows_x86_64_gnu" 1501 | version = "0.42.2" 1502 | source = "registry+https://github.com/rust-lang/crates.io-index" 1503 | checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 1504 | 1505 | [[package]] 1506 | name = "windows_x86_64_gnu" 1507 | version = "0.48.0" 1508 | source = "registry+https://github.com/rust-lang/crates.io-index" 1509 | checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" 1510 | 1511 | [[package]] 1512 | name = "windows_x86_64_gnullvm" 1513 | version = "0.42.2" 1514 | source = "registry+https://github.com/rust-lang/crates.io-index" 1515 | checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 1516 | 1517 | [[package]] 1518 | name = "windows_x86_64_gnullvm" 1519 | version = "0.48.0" 1520 | source = "registry+https://github.com/rust-lang/crates.io-index" 1521 | checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" 1522 | 1523 | [[package]] 1524 | name = "windows_x86_64_msvc" 1525 | version = "0.42.2" 1526 | source = "registry+https://github.com/rust-lang/crates.io-index" 1527 | checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 1528 | 1529 | [[package]] 1530 | name = "windows_x86_64_msvc" 1531 | version = "0.48.0" 1532 | source = "registry+https://github.com/rust-lang/crates.io-index" 1533 | checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" 1534 | 1535 | [[package]] 1536 | name = "winreg" 1537 | version = "0.10.1" 1538 | source = "registry+https://github.com/rust-lang/crates.io-index" 1539 | checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" 1540 | dependencies = [ 1541 | "winapi", 1542 | ] 1543 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shortgpt" 3 | version = "1.0.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | clap = { version = "4.2.5", features = ["derive"] } 10 | reqwest = { version = "0.11.17", features = ["blocking","json"] } 11 | serde = {version= "1.0.160",features = ["derive"]} 12 | serde_json = "1.0.96" 13 | termimad = "0.23.0" 14 | colored = "2" 15 | spinoff = "0.7.0" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Rupesh Sreeraman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # shortgpt 2 | 3 | shortgpt is an AI assistant console app for Windows/Linux/MacOS we can run it as command . It answers questions with less than 50 words,use GPT 3/4 from the terminal. 4 | 5 | ![shortgot](https://raw.githubusercontent.com/rupeshs/shortgpt/main/images/shortgpt.png) 6 | 7 | ## Features 8 | - Ask shortgpt for instant and concise answers 9 | - Add shortgpt to PATH environment and use it as command 10 | - You can use any one of the GPT model (gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301) 11 | - Default model is gpt-3.5-turbo 12 | - Cost effective 13 | - Use -l to enable long text mode 14 | 15 | ## Screenshots 16 | #### Windows 17 | ![shortgot windows](https://raw.githubusercontent.com/rupeshs/shortgpt/main/images/shortgpt-win.PNG) 18 | #### Linux 19 | 20 | ![shortgot linux](https://raw.githubusercontent.com/rupeshs/shortgpt/main/images/shortgpt_demo.PNG) 21 | 22 | ## Usage and Options 23 | ``` 24 | Usage: shortgpt.exe [OPTIONS] 25 | 26 | Arguments: 27 | 28 | 29 | Options: 30 | -m, --model GPT model (gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301) [default: gpt-3.5-turbo] 31 | -t, --temperature Sampling temperature to use, between 0 and 2 [default: 0.7] 32 | -l, --long Turn on long text mode (50 words output limit off) 33 | -h, --help Print help 34 | -V, --version Print version 35 | ``` 36 | 37 | ## Set OPENAI_API_KEY 38 | To set OpenAI API key run the following command. 39 | ### Windows 40 | To set OPENAI_API_KEY environment variable for the current `cmd` shell 41 | `set OPENAI_API_KEY=` 42 | 43 | To set OPENAI_API_KEY environment variable permanently 44 | 45 | `setx OPENAI_API_KEY “”` 46 | 47 | ## Linux / MacOS 48 | 49 | `export OPENAI_API_KEY=yourkey` 50 | 51 | Or set it permanently on .bashrc or .zshrc file 52 | ``` 53 | echo "export OPENAI_API_KEY='yourkey'" >> ~/.zshrc 54 | source ~/.zshrc 55 | echo $OPENAI_API_KEY 56 | ``` 57 | 58 | ## Development 59 | 60 | To run in the development mode run the following command : 61 | 62 | `cargo run -- "hello"` -------------------------------------------------------------------------------- /images/shortgpt-win.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupeshs/shortgpt/06aba4f9fab6a16d9feeaf66c0945e0c2c09f268/images/shortgpt-win.PNG -------------------------------------------------------------------------------- /images/shortgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupeshs/shortgpt/06aba4f9fab6a16d9feeaf66c0945e0c2c09f268/images/shortgpt.png -------------------------------------------------------------------------------- /images/shortgpt_demo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupeshs/shortgpt/06aba4f9fab6a16d9feeaf66c0945e0c2c09f268/images/shortgpt_demo.PNG -------------------------------------------------------------------------------- /src/arg_parser.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | use clap::{value_parser, Arg, ArgAction, Command}; 25 | 26 | pub fn parse_arguments() -> clap::ArgMatches { 27 | let version = env!("CARGO_PKG_VERSION"); 28 | let matches = Command::new("shortgpt") 29 | .version(version) 30 | .author("Rupesh Sreeraman. ") 31 | .about("Short and Sweet: Ask shortGPT for Instant and Concise Answers!") 32 | .arg(Arg::new("question").required(true)) 33 | .arg( 34 | Arg::new("model") 35 | .short('m') 36 | .long("model") 37 | .help("GPT model (gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301)") 38 | .default_value("gpt-3.5-turbo") 39 | ).arg( 40 | Arg::new("temperature") 41 | .short('t') 42 | .long("temperature") 43 | .value_parser(value_parser!(f32)) 44 | .help("Sampling temperature to use, between 0 and 2") 45 | .default_value("0.7") 46 | ).arg( 47 | Arg::new("long") 48 | .short('l') 49 | .long("long") 50 | .help("Turn on long text mode (50 words output limit off)") 51 | .action(ArgAction::SetTrue), 52 | ) 53 | .get_matches(); 54 | 55 | matches 56 | } 57 | -------------------------------------------------------------------------------- /src/completion_context.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | use crate::gpt_chat_completion; 26 | use crate::render; 27 | use colored::*; 28 | use spinoff::{spinners, Color, Spinner}; 29 | use std::time::Instant; 30 | 31 | pub fn do_completion( 32 | gpt_model: &str, 33 | openai_api_key: &str, 34 | query: &str, 35 | long_text: bool, 36 | temperature: f32, 37 | ) { 38 | let mut spinner = Spinner::new(spinners::Line, "Thinking...", Color::Green); 39 | let result = 40 | gpt_chat_completion::ask(gpt_model, &openai_api_key, query, long_text, temperature); 41 | let start_time = Instant::now(); 42 | match result { 43 | Ok(gpt_chat_output) => { 44 | spinner.update_text(""); 45 | spinner.stop(); 46 | let end_time = Instant::now(); 47 | let duration = end_time.duration_since(start_time); 48 | render::display(gpt_chat_output, duration.as_secs_f32()); 49 | } 50 | 51 | Err(error) => { 52 | spinner.update_text(""); 53 | spinner.stop(); 54 | println!("🛑 ERROR : {}", error.red()) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/gpt_chat_completion.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | use crate::models::{GptChatOutput, GptInput, Message}; 25 | use crate::prompts::{get_long_prompt, get_short_prompt}; 26 | use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, AUTHORIZATION, CONTENT_TYPE}; 27 | use reqwest::{blocking::Client, StatusCode}; 28 | 29 | const OPENAI_GPT_CHAT_API_URL: &str = "https://api.openai.com/v1/chat/completions"; 30 | 31 | fn get_authentication_bearer(api_key: &str) -> String { 32 | let auth_bearer = format!("Bearer {}", api_key); 33 | auth_bearer 34 | } 35 | 36 | fn get_gpt_input(model: &str, prompt: &str, temperature: f32) -> GptInput { 37 | let model = String::from(model); 38 | let messages = vec![Message { 39 | role: String::from("user"), 40 | content: String::from(prompt), 41 | }]; 42 | let gpt_input = GptInput { 43 | model, 44 | temperature, 45 | messages, 46 | }; 47 | gpt_input 48 | } 49 | 50 | fn get_headers(auth_bearer: &str) -> HeaderMap { 51 | let mut headers = HeaderMap::new(); 52 | headers.insert(ACCEPT, HeaderValue::from_static("*/*")); 53 | let api_key = HeaderValue::from_str(&auth_bearer).unwrap(); 54 | headers.insert(AUTHORIZATION, api_key); 55 | headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); 56 | headers 57 | } 58 | 59 | pub fn ask( 60 | model: &str, 61 | api_key: &str, 62 | query: &str, 63 | is_long: bool, 64 | temperature: f32, 65 | ) -> Result { 66 | let auth_bearer = get_authentication_bearer(api_key); 67 | let prompt; 68 | if is_long { 69 | prompt = get_long_prompt(query); 70 | } else { 71 | prompt = get_short_prompt(query); 72 | } 73 | 74 | let gpt_input = get_gpt_input(model, &prompt, temperature); 75 | let request_body = serde_json::to_string(&gpt_input).unwrap(); 76 | 77 | let headers = get_headers(&auth_bearer); 78 | let client = Client::new(); 79 | let response = client 80 | .post(OPENAI_GPT_CHAT_API_URL) 81 | .headers(headers) 82 | .body(request_body) 83 | .send(); 84 | 85 | match response { 86 | Ok(response) => match response.status() { 87 | StatusCode::OK => { 88 | let gpt_output: GptChatOutput = response.json().unwrap(); 89 | Ok(gpt_output) 90 | } 91 | status => { 92 | let description = status.canonical_reason().unwrap_or(""); 93 | let err = format!("Status code: {:?} - {}", status, description); 94 | Err(err) 95 | } 96 | }, 97 | Err(error) => { 98 | let err = format!("{}", error); 99 | Err(err) 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | https://platform.openai.com/docs/api-reference/completions/create 25 | https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety 26 | */ 27 | 28 | mod arg_parser; 29 | mod completion_context; 30 | mod gpt_chat_completion; 31 | mod models; 32 | mod render; 33 | mod prompts; 34 | 35 | use colored::*; 36 | 37 | #[cfg(target_os = "windows")] 38 | fn windows_term_color() { 39 | control::set_virtual_terminal(true).unwrap(); 40 | } 41 | fn main() { 42 | #[cfg(target_os = "windows")] 43 | windows_term_color(); 44 | 45 | let matches = arg_parser::parse_arguments(); 46 | let long_text = matches.get_flag("long"); 47 | let query = matches.get_one::("question").unwrap(); 48 | let gpt_model = matches.get_one::("model").unwrap(); 49 | let temperature: f32 = *matches.get_one("temperature").unwrap(); 50 | if long_text { 51 | println!("{}", "Running in long text mode!".yellow()); 52 | } 53 | println!("{}: {}", "Question".cyan(), query.bright_green()); 54 | let result = std::env::var("OPENAI_API_KEY"); 55 | match result { 56 | Ok(openai_api_key) => completion_context::do_completion( 57 | gpt_model, 58 | &openai_api_key, 59 | query, 60 | long_text, 61 | temperature, 62 | ), 63 | Err(_) => { 64 | let error_msg = "Error: Please set OPENAI_API_KEY environment variable!".red(); 65 | println!("🛑 {}", error_msg); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/models.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | use serde::{Deserialize, Serialize}; 26 | 27 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 28 | #[serde(rename_all = "camelCase")] 29 | pub struct GptChatOutput { 30 | pub id: String, 31 | pub model: String, 32 | pub usage: Usage, 33 | pub choices: Vec, 34 | } 35 | 36 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 37 | #[serde(rename_all = "camelCase")] 38 | pub struct Usage { 39 | #[serde(rename = "prompt_tokens")] 40 | pub prompt_tokens: i64, 41 | #[serde(rename = "completion_tokens")] 42 | pub completion_tokens: i64, 43 | #[serde(rename = "total_tokens")] 44 | pub total_tokens: i64, 45 | } 46 | 47 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 48 | #[serde(rename_all = "camelCase")] 49 | pub struct Choice { 50 | pub message: Message, 51 | #[serde(rename = "finish_reason")] 52 | pub finish_reason: String, 53 | pub index: i64, 54 | } 55 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 56 | #[serde(rename_all = "camelCase")] 57 | pub struct Message { 58 | pub role: String, 59 | pub content: String, 60 | } 61 | 62 | #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 63 | #[serde(rename_all = "camelCase")] 64 | pub struct GptInput { 65 | pub model: String, 66 | pub temperature: f32, 67 | pub messages: Vec, 68 | } 69 | -------------------------------------------------------------------------------- /src/prompts.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | const MAX_WORDS: u32 = 50; 26 | 27 | pub fn get_short_prompt(query: &str) -> String { 28 | let prompt = format!( 29 | r#" 30 | You are an expert assistant called shortgpt,your task is to give clear and correct answer to user's question. 31 | You can use maximum {} words.The generated text should be formatted with markdown. " 32 | {} 33 | "#, 34 | MAX_WORDS, query 35 | ); 36 | prompt 37 | } 38 | pub fn get_long_prompt(query: &str) -> String { 39 | let prompt = format!( 40 | r#" 41 | You are an expert assistant called shortgpt,your task is to give clear and correct answer to user's question. 42 | The generated text should be formatted with markdown. 43 | {} 44 | "#, 45 | query 46 | ); 47 | prompt 48 | } 49 | -------------------------------------------------------------------------------- /src/render.rs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2023 Rupesh Sreeraman 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | use crate::models::GptChatOutput; 25 | use termimad::crossterm::style::Stylize; 26 | 27 | pub fn display(gpt_chat_output: GptChatOutput, elapsed: f32) -> () { 28 | if gpt_chat_output.choices.len() > 0 { 29 | let usage = &gpt_chat_output.usage; 30 | let gpt_model = gpt_chat_output.model; 31 | let answer = &gpt_chat_output.choices[0].message.content; 32 | 33 | let status_msg = format!( 34 | "\n{} | Tokens -> sent: {}, received: {}, total: {} | {:.3}s", 35 | gpt_model, usage.prompt_tokens, usage.completion_tokens, usage.total_tokens, elapsed 36 | ); 37 | 38 | termimad::print_inline(answer); 39 | println!("\n {}", status_msg.dark_grey()); 40 | } 41 | } 42 | --------------------------------------------------------------------------------