Compare commits

...

226 Commits

Author SHA1 Message Date
github-actions[bot] 216ba1f22b Release 0.2.11 (#765)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-25 17:53:17 -07:00
Marcus Schiesser 74686f5776 ci: add version to release PR (#766) 2024-04-25 10:55:02 +07:00
Marcus Schiesser 1ebf9e67a4 ci: add release action (#764) 2024-04-25 10:09:55 +07:00
Alex Yang aeefc77da0 test: load large amount of data won't cause error (#762) 2024-04-24 15:04:29 -05:00
ezirmusitua 13d8d7cbbe fix: use Array.prototype.flat (#760)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-04-24 14:36:12 -05:00
Alex Yang 9c34e44b85 ci: coverage node.js 22 (#761) 2024-04-24 14:19:12 -05:00
Thuc Pham cb2dc802d9 docs: update next config for external packages (#759) 2024-04-24 17:27:20 +08:00
Ziniu Yu 5a6cc0e32e feat: support jina ai embedding and reranker (#734) 2024-04-24 15:45:36 +07:00
Marcus Schiesser a63256eb84 feat: add default file metadata (#758) 2024-04-24 13:54:29 +07:00
Alex Yang 0a160b97a0 fix(docs): api generation (#756) 2024-04-23 14:24:17 -05:00
Thuc Pham 95602c7959 feat: overide generate hash function for image document (#751)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-04-23 11:56:37 +07:00
Alex Yang 20bc466ca1 chore: bump notion reader (#753) 2024-04-22 15:14:06 -05:00
Thuc Pham efb1c56ba5 fix: return buffer when loading image data (#749) 2024-04-22 15:28:19 +07:00
Alex Yang 286499388d fix: agent class should implement ChatEngine interface (#746) 2024-04-22 02:13:29 -05:00
Alex Yang 460c6574cc fix: rename ReACTAgent to ReActAgent (#748) 2024-04-22 00:57:43 -05:00
Marcus Schiesser 8b0e0e3cc8 docs: use dedicated embedding model for ollama (#745) 2024-04-22 10:40:39 +07:00
Alex Yang 87142b29fa chore: update changeset 2024-04-21 20:32:57 -05:00
Alex Yang 501b844f0f refactor: use official ollama sdk (#744) 2024-04-21 20:31:16 -05:00
Alex Yang 03157dc295 feat: use json format for tool result (#742) 2024-04-21 19:27:10 -05:00
Alex Yang ef80b684f7 chore: fix llamaindex node_modules link (#743) 2024-04-21 18:21:15 -05:00
Alex Yang 472e70feee refactor: full typed & iterator of agent worker/runner (part 3) (#728)
Fixes: https://github.com/run-llama/LlamaIndexTS/issues/692, https://github.com/run-llama/LlamaIndexTS/issues/557

Refs: https://github.com/run-llama/llama_index/blob/5a6ffe32faa75db0b4737d1e7a85e6fe4afe94af/docs/module_guides/deploying/agents/agent_runner.md
2024-04-19 17:52:36 -05:00
Alex Yang cfb90f7666 docs: update (#738) 2024-04-19 15:17:48 -05:00
Mike Fortman 2e3a287a27 refactor: astra options (#737) 2024-04-19 11:57:34 -05:00
Marcus Schiesser 635fbb8618 release 0.2.10 2024-04-19 16:14:44 +08:00
Marcus Schiesser d2d34acb31 Add streaming for replicate (Llama 3) (#735) 2024-04-19 15:09:20 +07:00
Yi Ding cf70edbede llama 3 support (#731)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-04-18 17:08:40 -07:00
Mike Fortman 79b7d246bd chore: update deps Astra (#733) 2024-04-18 17:55:31 -05:00
Marcus Schiesser bcc3d0b4d1 release v0.2.9 2024-04-17 13:53:31 +08:00
Marcus Schiesser 238ca86534 fix: google fonts not reachable during build 2024-04-17 13:47:11 +08:00
Marcus Schiesser 1f3efe8947 fix: ensure to use build for examples (#729) 2024-04-17 10:40:02 +07:00
yemiscale3 89324b4067 docs: Add Langtrace to observability tools (#726)
Co-authored-by: Yi Ding <yi.s.ding@gmail.com>
2024-04-16 20:13:59 -07:00
Alex Yang 8cc848aee6 docs: fix example code (#727) 2024-04-16 16:00:26 -05:00
Alex Yang cd54a7a66b docs: remove verbose (#725) 2024-04-16 15:54:40 -05:00
Marcus Schiesser dca02f7277 refactor: VectorStoreIndex: use TransformerComponent to calc embeddings (#721) 2024-04-16 10:01:26 +07:00
Marcus Schiesser b757fa9aa3 fix: type-check of modified example 2024-04-16 10:35:26 +08:00
Marcus Schiesser bc594a0674 doc: update vector index example to show source nodes 2024-04-16 10:27:34 +08:00
Alex Yang 208282d62f feat: init anthropic agent (part 2) (#719) 2024-04-15 16:22:47 -05:00
Wessel 060880abfe fix: toolretriever for Agent OpenAI broken (#718) 2024-04-15 13:45:19 -05:00
Marcus Schiesser 728b35e774 chore: remove LLM.ts (#720) 2024-04-14 23:35:15 -05:00
Alex Yang bdaa043404 feat: init claude function call (part 1) (#717) 2024-04-14 15:55:34 -05:00
Alex Yang a55cf8d870 fix: type import 2024-04-14 01:30:54 -05:00
Alex Yang cf4244fd3a chore: put eslint into top level (#716) 2024-04-13 20:39:27 -05:00
Marcus Schiesser 76c3fd64ad feat: add scores to source nodes (#714) 2024-04-12 09:28:46 -07:00
Marcus Schiesser 701e0ac2be release 0.2.8 2024-04-12 12:43:45 +08:00
Alex Yang a285f8ba3a feat: improve ToolsFactory type (#713) 2024-04-11 21:26:14 -05:00
Alex Yang 663821cdf6 test: add openai agent stream chat (#712) 2024-04-11 19:21:02 -05:00
Alex Yang c4b95494ac fix: memory type (#711) 2024-04-11 18:11:33 -05:00
Marcus Schiesser 980fb4e5a3 release llamaindex@0.2.7 2024-04-11 14:57:01 +08:00
Alex Yang 96f8f40291 fix: agent stream (#710) 2024-04-10 23:22:11 -05:00
Alex Yang 1c698df6e0 fix: package.json version 2024-04-10 19:49:16 -05:00
Alex Yang 298cb433be feat: improve base tool type (#709) 2024-04-10 19:40:47 -05:00
Yi Ding 63af7dd99d Fix protobuf (#708) 2024-04-10 17:20:32 -07:00
Alex Yang af5df1d083 feat: add llm-stream event (#707) 2024-04-10 09:26:26 -05:00
Marcus Schiesser a3b44093c2 fix: agent streaming with new OpenAI models (#706)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-04-10 08:38:54 -05:00
Alex Yang c80bf3311f fix: response.raw should be null (#705) 2024-04-10 02:54:36 -05:00
Alex Yang 7940d249b0 test: coverage on mock mode (#704) 2024-04-10 02:40:37 -05:00
Marcus Schiesser 4a07c81f71 release llamaindex@0.2.5 2024-04-10 15:01:10 +08:00
Marcus Schiesser 7d56cdf045 fix: Allow OpenAIAgent to be called without tools (#703) 2024-04-10 13:43:38 +07:00
Marcus Schiesser 0affe621d5 ci: update pnpm lockfile after updating package.json from edge 2024-04-10 11:46:01 +08:00
Alex Yang 93932b1a9c refactor: chat message type (#701) 2024-04-09 21:56:47 -05:00
Yi Ding a87f13b9d2 release 2024-04-09 16:23:29 -07:00
Yi Ding 8d2b21ee75 update mistral (#700) 2024-04-09 16:19:51 -07:00
Yi Ding 87741c9be8 update example packages 2024-04-09 13:22:03 -07:00
Yi Ding 171cb89170 security update (docs) 2024-04-09 13:17:44 -07:00
Yi Ding 5dad867bbe update packages 2024-04-09 13:04:43 -07:00
Yi Ding 13f26fd84d pnpm version 2024-04-09 12:45:12 -07:00
Yi Ding 3bc77f7d7f gpt-4-turbo GA (#698) 2024-04-09 12:42:16 -07:00
Alex Yang aac1ee3af3 e2e: init llamaindex e2e test (#697) 2024-04-06 23:57:21 -05:00
Alex Yang e85893ac0f fix: message content type (#696) 2024-04-06 18:59:12 -05:00
Alex Yang 315947ee6f refactor: move anthropic class (#695) 2024-04-06 17:13:53 -05:00
Alex Yang 23a0d44b11 fix: jsr disallow global type 2024-04-06 17:09:39 -05:00
Alex Yang 3b501de057 chore: jsr release 2024-04-06 17:04:20 -05:00
Alex Yang 6cc645aa2a refactor: improve agent type (#694) 2024-04-05 15:21:49 -05:00
Marcus Schiesser 0b37207adc Release llamaindex@0.2.3 2024-04-05 15:15:39 +08:00
Marcus Schiesser f0704ec705 Add streaming for OpenAI agents (#693) 2024-04-05 12:53:26 +07:00
Thuc Pham 4fcbdf710e Add tool calls for openai streaming (#682)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-04-05 08:33:23 +07:00
Marcus Schiesser 866149193a fix: use LLM's context window to specify agent's token limit (#689) 2024-04-03 17:04:35 -05:00
Thuc Pham 6ffb161618 feat: add ts eslint plugin (#688) 2024-04-03 14:21:13 +07:00
Marcus Schiesser 8e4b49824b doc: document docstore strategies (#690) 2024-04-03 13:26:38 +07:00
Alex Yang 5263576de1 ci: test matrix on nodejs 18/20/21 (#687) 2024-04-02 17:23:11 -05:00
WarlaxZ 6d4e2ea0e9 fix: dynamic import cjs module pg (#685)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-04-02 16:07:13 -05:00
Emanuel Ferreira 3cbfa98e6b feat: LlamaCloudIndex from documents (#677) 2024-04-02 14:03:45 -03:00
Alex Yang d256cbe0e0 refactor: use event.reason, remove parentEvent (#681) 2024-04-01 17:03:39 -07:00
Alex Yang a6dfa30dcf RELEASING: Releasing 3 package(s) 2024-04-01 14:34:40 -05:00
Alex Yang d0365dc434 fix: docs dependencies (#680) 2024-04-01 14:19:37 -05:00
Alex Yang aa41432bbb refactor: remove llm.tokens api (#679) 2024-04-01 14:12:17 -05:00
Emanuel Ferreira 98a2b4a547 feat: add global settings (#668)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-04-01 13:43:35 -05:00
Benny 806ce9a360 fix: README links and examples (#678) 2024-04-01 13:16:10 -05:00
Marcus Schiesser 8b28092cc8 feat: Add doc store strategies to VectorStoreIndex.fromDocuments (#646) 2024-04-01 10:12:08 -07:00
Marcus Schiesser 5c5f4c1c84 Revert "feat: support calculate llama 2 tokens (#676)"
This reverts commit 041acd11fe.
2024-04-01 13:52:07 +08:00
Marcus Schiesser 949d330295 fix: typecheck 2024-04-01 12:26:22 +08:00
Marcus Schiesser 9a5ee4f37a Revert "fix: support import subdirectory (#655)"
This reverts commit 98d4cbdf95.
2024-04-01 11:52:41 +08:00
Alex Yang 7a23cc6c84 feat: improve callback manager (#675) 2024-03-31 15:34:48 -05:00
Alex Yang 041acd11fe feat: support calculate llama 2 tokens (#676) 2024-03-29 20:12:26 -05:00
Emanuel Ferreira 24b4033db9 feat: add result type json (#673) 2024-03-28 16:24:33 -03:00
Emanuel Ferreira 1115f83b8f fix: pipeline not found (#672) 2024-03-28 15:31:18 -03:00
Thuc Pham 60a1603636 fix: make edge run build after core (#670) 2024-03-28 18:26:35 +08:00
Peter Goldstein ea467fa031 Update to latest supported version list as of 2024-04-02. (#669) 2024-03-28 10:53:33 +07:00
Marcus Schiesser b0e6f73b1d docs: update readme for Edge runtime 2024-03-26 15:18:19 +08:00
Marcus Schiesser 6d9e015b5e feat: use claude3 with react agent (#661)
Co-authored-by: Emanuel Ferreira <contatoferreirads@gmail.com>
2024-03-22 09:25:31 -03:00
Thuc Pham fececd89ab feat: add tool factory (#663) 2024-03-22 14:40:41 +07:00
Marcus Schiesser 48e287892f test: use unique tmp dir for storage tests and wait to clean VectorStoreIndex files 2024-03-21 13:04:25 +07:00
Marcus Schiesser f118400820 docs: Add changeset instructions for PRs 2024-03-20 11:45:33 +07:00
Marcus Schiesser 3f8407c7af docs: changeset for pipeline.register added 2024-03-20 10:20:30 +07:00
Marcus Schiesser 83317739c7 feat: add pipeline.register (#589) 2024-03-19 13:32:32 -07:00
Thuc Pham 0b665bd1ca feat: add wikipedia tool (#648)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-03-19 11:31:08 +07:00
Alex Yang 98d4cbdf95 fix: support import subdirectory (#655) 2024-03-18 21:00:46 -05:00
Marcus Schiesser 6cb75b54a0 docs: update release process 2024-03-18 16:22:59 +07:00
Marcus Schiesser 53edfe93cf release llamaindex@0.2.1 2024-03-18 16:17:58 +07:00
Marcus Schiesser b856deae43 fix: fix syncing edge with core version 2024-03-18 15:53:31 +07:00
Marcus Schiesser 259c842259 Support NextJS edge runtime (#618) 2024-03-18 15:13:27 +07:00
shodevacc ffb195ea7a Fix: Metadata filters doesn't seem to work for Qdrant (#623) 2024-03-18 11:53:51 +07:00
Alex Yang b4677534d1 ci: install node_modules (#653) 2024-03-18 12:49:28 +08:00
Peli de Halleux f967b82467 [docs] missing await in sample (#650) 2024-03-15 16:23:27 -03:00
Marcus Schiesser c81946930e test: fix openai mock 2024-03-15 15:20:57 +07:00
Marcus Schiesser 1008b775a4 test: cleaned up tests and added test to ignore duplicates 2024-03-15 12:05:58 +07:00
Huu Le (Lee) 41210dfc51 feat: Add auto create collection and node metadata for Milvus vector store (#645) 2024-03-15 10:46:25 +07:00
Emanuel Ferreira 67b7272249 feat: expected minor version (#644) 2024-03-14 09:34:21 -03:00
Marcus Schiesser 964e045903 feat: add support for snapshots 2024-03-14 10:23:58 +07:00
Marcus Schiesser 137cf67f40 fix: Use Pinecone namespaces for all operations (#633) 2024-03-14 10:15:52 +07:00
Emanuel Ferreira 309a526e3c RELEASING: Releasing 5 package(s) (#643) 2024-03-13 22:17:27 -03:00
yisding dd95927498 Claude haiku (#642) 2024-03-13 19:57:45 -03:00
Thuc Pham 4f72feae91 Feat: add tools module (#621) 2024-03-13 16:41:36 +07:00
Marcus Schiesser 3cd8f9f597 refactor: move create-llama to own repo (#641) 2024-03-13 15:53:33 +07:00
Huu Le (Lee) d2e8d0c62a feat: Add Milvus vector store (#640)
Co-authored-by: Michael Schramm <michael@tucan.ai>
2024-03-13 13:55:48 +07:00
Huu Le (Lee) fafbd8c9c7 fix: add missing env value; improve docs and error message (#638) 2024-03-13 09:08:53 +07:00
Marcus Schiesser a40c91b054 docs: fixed path 2024-03-12 14:45:27 +07:00
Marcus Schiesser 98894055c6 fix: create-llama release 2024-03-12 13:42:38 +07:00
Marcus Schiesser 4589a84643 RELEASING: Releasing 1 package(s)
Releases:
  create-llama@0.0.28

[skip ci]
2024-03-12 13:41:36 +07:00
Huu Le (Lee) e6b7f52d3e fix: add missing check env logic (#636) 2024-03-12 12:29:00 +07:00
Marcus Schiesser b169db617a refactor: use a function for webpack config (#634) 2024-03-12 11:10:31 +07:00
Huu Le (Lee) 89a49f4f4f feat: Add more. env variables to config host, port, llm and embedding (#630) 2024-03-12 09:22:21 +07:00
Marcus Schiesser 58490715fe refactor: clean nextjs config generation (use JSON) (#631) 2024-03-11 14:16:15 +07:00
Huu Le (Lee) 4c2283c4e5 fix: Rename folder e2e/.cache to e2e/cache (#632) 2024-03-11 14:15:13 +07:00
Eka Prasetia a059070dec docs: Fix typo in transformations.md (#625) 2024-03-11 12:16:23 +07:00
Emanuel Ferreira 20dfeb4cfa chore: remove comment (#624) 2024-03-08 15:54:24 -03:00
Emanuel Ferreira aefc3266c1 feat: experimental package + json query engine (#613) 2024-03-07 14:34:55 -03:00
Huu Le (Lee) fdf48dd459 feat: Add start in VSCode option and support python for dev container (#619) 2024-03-07 17:19:08 +07:00
Alex Yang 66525346a2 build: use single swc config (#620) 2024-03-06 23:41:42 -06:00
Alex Yang c9b2ec4a2b fix: release 2024-03-06 23:32:02 -06:00
Marcus Schiesser bf583a7266 Use parameter object for retrieve function of Retriever (#616) 2024-03-06 21:15:22 -08:00
Marcus Schiesser de194d1c73 fix: running new-create-llama 2024-03-06 15:13:20 +07:00
Marcus Schiesser ecdc289df1 RELEASING: Releasing 1 package(s)
Releases:
  create-llama@0.0.27

[skip ci]
2024-03-06 15:11:47 +07:00
Marcus Schiesser 9e198ac40d fix: build types for core locally (#615) 2024-03-06 14:35:31 +07:00
Huu Le (Lee) 0a06998690 fix: hardcode "en" as default language for llama-parse and use llama cloud key from env (#614) 2024-03-06 14:31:21 +07:00
Wojciech Grzebieniowski 484a7105a9 fix: restore missing exports (#610) 2024-03-05 14:56:25 -06:00
Alex Yang 8d18ea167b fix: publish.yml 2024-03-05 14:37:54 -06:00
Alex Yang a2ca89bfe0 fix: config (#611) 2024-03-05 14:20:58 -06:00
Alex Yang edeea40898 ci: add publish.yml 2024-03-05 13:49:49 -06:00
Alex Yang 2a7080b094 build: fix version 2024-03-05 12:26:47 -06:00
Huu Le (Lee) b354f2386b feat: add embedding model option to create-llama (#608) 2024-03-05 16:59:51 +07:00
Emanuel Ferreira d766bd03d2 feat: OpenAI Agent Stream (#597) 2024-03-05 15:46:44 +07:00
Huu Le (Lee) 6a69148356 fix: add --no-llama-parse and improve e2e test (#607) 2024-03-05 14:57:38 +07:00
Marcus Schiesser e1e1b0b522 RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.21

[skip ci]
2024-03-05 13:00:16 +07:00
Marcus Schiesser d824876653 docs(changeset): Add support for Claude 3 2024-03-05 12:59:51 +07:00
Marcus Schiesser 2048698f77 docs: add interactive chat for anthropic 2024-03-05 11:15:50 +07:00
Emanuel Ferreira 9942979aa7 feat: Claude 3 (#604) 2024-03-04 15:02:18 -08:00
Alex Yang 3c2655a1f9 fix: .tsbuildinfo 2024-03-04 16:05:45 -06:00
Marcus Schiesser 552a61a66f Add quantized parameter to HuggingFaceEmbedding (#601) 2024-03-04 12:10:40 +07:00
Alex Yang d13143e322 RELEASING: Releasing 3 package(s)
Releases:
  llamaindex@0.1.20
  @llamaindex/env@0.0.5
  docs@0.0.4

[skip ci]
2024-03-02 18:42:24 -06:00
Alex Yang 5116ad8d08 fix: compatibility issue with Deno (#598) 2024-03-02 18:40:01 -06:00
Emanuel Ferreira 64683a55f3 fix: prefix messages always true (#596) 2024-03-01 21:45:02 -03:00
Emanuel Ferreira 698cd9c631 fix: step wise agent + examples (#594) 2024-03-01 21:28:02 -03:00
Alex Yang c744a99102 chore: bump @llamaindex/cloud (#595) 2024-03-01 17:22:50 -06:00
Huu Le (Lee) 2d2935085e feat: Add use LlamaParse option to create-llama (#591) 2024-03-01 16:54:06 +07:00
Marcus Schiesser 1b31e2c8cd chore: update @llamaindex/cloud to 0.0.2 2024-03-01 15:59:10 +07:00
Thuc Pham 7257751993 fix: empty store bugs (#592)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-03-01 15:04:10 +07:00
Marcus Schiesser de6bfdb1b1 RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.19

[skip ci]
2024-02-29 15:35:13 +07:00
Marcus Schiesser 9e49f4411b fix: copy README and license 2024-02-29 15:34:27 +07:00
Thuc Pham 026d068ddf feat: enhance pinecone usage (#586) 2024-02-29 15:34:08 +07:00
Marcus Schiesser 7055d6fc3c docs: add OpenAIEmbedding to examples 2024-02-29 11:11:43 +07:00
Alex Yang e9c2366bf1 fix: allow passing model metadata (#588) 2024-02-29 10:41:06 +07:00
Alex Yang 6278152e49 fix: lazy import pg (#584) 2024-02-27 19:16:54 -06:00
Emanuel Ferreira 76010c0cea chore: remove duplicated example and minor example update (#582) 2024-02-27 09:02:37 -03:00
Emanuel Ferreira 889b84cfb9 docs: remove query engine from correctness evaluator (#581) 2024-02-27 08:15:41 -03:00
Marcus Schiesser a26681c416 RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.18

[skip ci]
2024-02-27 13:45:28 +07:00
Thuc Pham 90027a7b44 fix: enable split long sentence by default (#568)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-02-27 13:44:04 +07:00
Emanuel Ferreira aab56faf88 refactor: qdrant minor updates (#580) 2024-02-26 22:13:45 -03:00
Emanuel Ferreira c57bd11c45 feat: update and refactor title extractor (#579) 2024-02-26 21:49:07 -03:00
Alex Yang 3fa1e29468 RELEASING: Releasing 3 package(s)
Releases:
  llamaindex@0.1.17
  @llamaindex/env@0.0.4
  docs@0.0.3

[skip ci]
2024-02-26 17:01:47 -06:00
Alex Yang cf87f84900 fix: type backward compatibility (#578) 2024-02-26 16:59:09 -06:00
Alex Yang 402d4ef013 docs: update tutorial (#576) 2024-02-26 14:11:09 -06:00
Alex Yang fc94906a1e fix: keep dynamic import in cjs (#575) 2024-02-26 12:27:17 -06:00
Alex Yang b83fcd11e4 fix(core): type generation (#574) 2024-02-26 12:15:40 -06:00
Emanuel Ferreira c28af7c7bc chore: remove storage context from multi_doc_agent example (#572) 2024-02-26 12:05:30 -03:00
Emanuel Ferreira dbc853bcc5 chore: fix paths and docs (#569) 2024-02-26 10:37:08 -03:00
Emanuel Ferreira c8396c5a3c feat: add base evaluator and correctness evaluator (#559) 2024-02-26 09:38:56 -03:00
Thuc Pham 65af8d3a26 fix: missing dependency for local development (#566) 2024-02-26 15:54:47 +07:00
Marcus Schiesser 329b6ec958 fix: SummaryIndex and VectorStoreIndex must be able to share storage context (#567) 2024-02-26 15:52:33 +07:00
Graden Rea 09bf27abd7 feat: Add Groq LLM integration (#561) 2024-02-26 13:46:27 +07:00
Alex Yang 2ec6a529c7 RELEASING: Releasing 2 package(s)
Releases:
  llamaindex@0.1.16
  @llamaindex/env@0.0.3

[skip ci]
2024-02-23 19:03:04 -06:00
Alex Yang e8e21a0e4e docs(changeset): build: set files in package.json 2024-02-23 19:02:42 -06:00
Alex Yang 88d243f145 RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.15

[skip ci]
2024-02-23 18:57:10 -06:00
Alex Yang 3a6e287443 feat: enable verbatimModuleSyntax (#562) 2024-02-23 18:56:44 -06:00
Alex Yang beb3e5cd7f RELEASING: Releasing 2 package(s)
Releases:
  llamaindex@0.1.14
  @llamaindex/env@0.0.2

[skip ci]
2024-02-23 18:09:31 -06:00
Alex Yang 7416a87e10 build: cjs file not found 2024-02-23 18:09:15 -06:00
Alex Yang 65b85b237e RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.13

[skip ci]
2024-02-23 17:59:06 -06:00
Alex Yang b17a80014a fix: unset private package 2024-02-23 17:58:46 -06:00
Alex Yang ff87f99807 fix: avoid publishing test package 2024-02-23 17:56:38 -06:00
Alex Yang 65d834615d docs(changeset): feat: abstract @llamaindex/env package 2024-02-23 17:45:43 -06:00
Alex Yang b8be4c09e2 docs(changeset): build: use ESM as default 2024-02-23 17:45:01 -06:00
Alex Yang e5fb332538 build: leave code as-is (#560)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-02-23 17:39:25 -06:00
Marcus Schiesser 491033d534 fix: lint errors 2024-02-23 14:55:45 +07:00
Marcus Schiesser 885fa316a5 chore: add prefer const lint 2024-02-23 14:45:17 +07:00
Marcus Schiesser b6ed679771 RELEASING: Releasing 1 package(s)
Releases:
  create-llama@0.0.26

[skip ci]
2024-02-23 12:00:37 +07:00
Marcus Schiesser 68fc6e8b50 fix: don't need similarityTopK parameter for LlamaCloud 2024-02-23 11:43:22 +07:00
Marcus Schiesser ea0331ef5a refactor: simplify generated python code (#558)
Co-authored-by: leehuwuj <leehuwuj@gmail.com>
2024-02-23 11:14:02 +07:00
Marcus Schiesser 6827e245b8 fix: don't allow runApp for LlamaPacks 2024-02-22 16:20:57 +07:00
Huu Le (Lee) ef25d6960c Upgrade llama-index version to v0.10+ for create-llama (#556) 2024-02-22 13:50:53 +07:00
Marcus Schiesser f740f44cf2 RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.12

[skip ci]
2024-02-22 12:02:35 +07:00
Marcus Schiesser a5e4e6d857 Add support for LlamaCloud (#554) 2024-02-22 11:59:32 +07:00
Thuc Pham cfdd6db530 feat: add pinecone support to create llama (#555) 2024-02-22 09:55:50 +07:00
Marcus Schiesser d4eda9f396 docs: add llamaparse docs (#553) 2024-02-21 14:37:13 +07:00
Alex Yang a433b107e0 RELEASING: Releasing 1 package(s)
Releases:
  llamaindex@0.1.11

[skip ci]
2024-02-20 12:58:54 -06:00
Yufei (Benny) Chen 59f9fb6c3f Add Fireworks to LlamaIndex (#539)
Co-authored-by: Emanuel Ferreira <contatoferreirads@gmail.com>
2024-02-20 10:53:09 -03:00
Thuc Pham 09d532ebcc feat(create-llama-pack): generate llama pack project from llama index (#549) 2024-02-20 08:22:54 +07:00
Emanuel Ferreira cfd6f3ca8c feat: prompt mixin (#543) 2024-02-18 18:44:08 -03:00
Emanuel Ferreira 95add73c38 feat: multi-document agents (#531) 2024-02-18 18:43:52 -03:00
Emanuel Ferreira 9ee036b160 docs: remove duplicate embedding (#545) 2024-02-13 23:21:13 -03:00
Erick Sosa Garcia c2b521199c fix: some errors in available llms examples (#544) 2024-02-13 21:16:47 -03:00
Emanuel Ferreira ee9f3f373a refactor: openai agent and utils (#542) 2024-02-11 20:24:36 -03:00
Emanuel Ferreira f205358587 feat: add markdown node parser (#541) 2024-02-11 20:23:49 -03:00
Emanuel Ferreira 255ae7dced fix: react agent history (#540) 2024-02-11 18:46:55 -03:00
Emanuel Ferreira b4c6d509a0 docs: available embeddings (#538) 2024-02-10 22:10:20 -03:00
Emanuel Ferreira 34cd57b639 feat(react): add react agent (#511) 2024-02-10 20:52:11 -03:00
yisding 50dfd7bf60 dep security vulns (#537) 2024-02-11 04:37:42 +08:00
682 changed files with 34047 additions and 24970 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": true,
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
-5
View File
@@ -1,5 +0,0 @@
---
"llamaindex": patch
---
feat: add filtering of metadata to PGVectorStore
-5
View File
@@ -1,5 +0,0 @@
---
"llamaindex": patch
---
feat(reranker): cohere reranker
-5
View File
@@ -1,5 +0,0 @@
---
"llamaindex": patch
---
feat: use batching in vector store index
-5
View File
@@ -1,5 +0,0 @@
---
"llamaindex": patch
---
Add reader for LlamaParse
+16
View File
@@ -0,0 +1,16 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
},
"target": "esnext",
"transform": {
"decoratorVersion": "2022-03"
}
},
"module": {
"type": "commonjs",
"ignoreDynamic": true
}
}
+76
View File
@@ -0,0 +1,76 @@
module.exports = {
root: true,
extends: [
"turbo",
"prettier",
"plugin:@typescript-eslint/recommended-type-checked-only",
],
parserOptions: {
project: true,
__tsconfigRootDir: __dirname,
},
settings: {
react: {
version: "999.999.999",
},
},
rules: {
"max-params": ["error", 4],
"prefer-const": "error",
"@typescript-eslint/no-floating-promises": [
"error",
{
ignoreIIFE: true,
},
],
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extra-non-null-assertion": "off",
"@typescript-eslint/no-for-in-array": "off",
"no-implied-eval": "off",
"@typescript-eslint/no-implied-eval": "off",
"no-loss-of-precision": "off",
"@typescript-eslint/no-loss-of-precision": "off",
"@typescript-eslint/no-misused-new": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-as-const": "off",
"require-await": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/unbound-method": "off",
},
overrides: [
{
files: ["examples/**/*.ts"],
rules: {
"turbo/no-undeclared-env-vars": "off",
},
},
],
ignorePatterns: ["dist/", "lib/", "deps/"],
};
-14
View File
@@ -1,14 +0,0 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
settings: {
next: {
rootDir: ["apps/*/"],
},
},
rules: {
"max-params": ["error", 4],
},
ignorePatterns: ["dist/"],
};
-68
View File
@@ -1,68 +0,0 @@
name: E2E Tests
on:
push:
branches: [main]
pull_request:
paths:
- "packages/create-llama/**"
- ".github/workflows/e2e.yml"
branches: [main]
env:
POETRY_VERSION: "1.6.1"
jobs:
e2e:
name: create-llama
timeout-minutes: 60
strategy:
fail-fast: true
matrix:
node-version: [18, 20]
python-version: ["3.11"]
os: [macos-latest, windows-latest]
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- uses: pnpm/action-setup@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
working-directory: ./packages/create-llama
- name: Build create-llama
run: pnpm run build
working-directory: ./packages/create-llama
- name: Pack
run: pnpm pack --pack-destination ./output
working-directory: ./packages/create-llama
- name: Extract Pack
run: tar -xvzf ./output/*.tgz -C ./output
working-directory: ./packages/create-llama
- name: Run Playwright tests
run: pnpm exec playwright test
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
working-directory: ./packages/create-llama
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./packages/create-llama/playwright-report/
retention-days: 30
+1 -3
View File
@@ -13,9 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
+36
View File
@@ -0,0 +1,36 @@
name: Publish
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Publish @llamaindex/env
run: npx jsr publish
working-directory: packages/env
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish @llamaindex/core
run: npx jsr publish --allow-slow-types
working-directory: packages/core
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+57
View File
@@ -0,0 +1,57 @@
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Add auth token to .npmrc file
run: |
cat << EOF >> ".npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get changeset status
id: get-changeset-status
run: |
pnpm changeset status --output .changeset/status.json
new_version=$(jq -r '.releases[] | select(.name == "llamaindex") | .newVersion' < .changeset/status.json)
rm -v .changeset/status.json
echo "new-version=${new_version}" >> "$GITHUB_OUTPUT"
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
commit: Release ${{ steps.get-changeset-status.outputs.new-version }}
title: Release ${{ steps.get-changeset-status.outputs.new-version }}
# update version PR with the latest changesets
version: pnpm new-version
# build package and call changeset publish
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+68 -7
View File
@@ -1,18 +1,55 @@
name: Run Tests
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
e2e:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
name: E2E on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run E2E Tests
run: pnpm run e2e
test:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
name: Test on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
@@ -23,7 +60,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -33,6 +70,9 @@ jobs:
run: pnpm install
- name: Build
run: pnpm run build --filter llamaindex
- name: Use Build For Examples
run: pnpm link ../packages/core/
working-directory: ./examples
- name: Run Type Check
run: pnpm run type-check
- name: Run Circular Dependency Check
@@ -44,12 +84,30 @@ jobs:
name: typecheck-build-dist
path: ./packages/core/dist
if-no-files-found: error
core-edge-runtime:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build --filter @llamaindex/edge
- name: Build Edge Runtime
run: pnpm run build
working-directory: ./packages/edge/e2e/test-edge-runtime
typecheck-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -61,10 +119,13 @@ jobs:
run: pnpm run build --filter llamaindex
- name: Copy examples
run: rsync -rv --exclude=node_modules ./examples ${{ runner.temp }}
- name: Pack
- name: Pack @llamaindex/env
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/env
- name: Pack llamaindex
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/core
- name: Install llamaindex
- name: Install
run: npm add ${{ runner.temp }}/*.tgz
working-directory: ${{ runner.temp }}/examples
- name: Run Type Check
+1
View File
@@ -44,6 +44,7 @@ test-results/
playwright-report/
blob-report/
playwright/.cache/
.tsbuildinfo
# intellij
**/.idea
+3
View File
@@ -1,2 +1,5 @@
auto-install-peers = true
enable-pre-post-scripts = true
prefer-workspace-packages = true
save-workspace-protocol = true
link-workspace-packages = true
+12
View File
@@ -0,0 +1,12 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
},
"target": "esnext",
"transform": {
"decoratorVersion": "2022-03"
}
}
}
+2 -1
View File
@@ -10,8 +10,9 @@
"name": "Debug Example",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "pnpm",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/examples",
"runtimeArgs": ["ts-node", "${fileBasename}"]
"runtimeArgs": ["npx", "tsx", "${file}"]
}
]
}
-1
View File
@@ -5,7 +5,6 @@
"[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml"
},
"jest.rootPath": "./packages/core",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
+16 -8
View File
@@ -79,14 +79,22 @@ That should start a webserver which will serve the docs on https://localhost:300
Any changes you make should be reflected in the browser. If you need to regenerate the API docs and find that your TSDoc isn't getting the updates, feel free to remove apps/docs/api. It will automatically regenerate itself when you run pnpm start again.
## Publishing
## Changeset
To publish a new version of the library, run
We use [changesets](https://github.com/changesets/changesets) for managing versions and changelogs. To create a new changeset, run:
```shell
pnpm new-llamaindex
pnpm new-create-llama
pnpm release
git push # push to the main branch
git push --tags
```
pnpm changeset
```
Please send a descriptive changeset for each PR.
## Publishing (maintainers only)
The [Release Github Action](.github/workflows/release.yml) is automatically generating and updating a
PR called "Release {version}".
This PR will update the `package.json` and `CHANGELOG.md` files of each package according to
the current changesets in the [.changeset](.changeset/) folder.
If this PR is merged it will automatically add version tags to the repository and publish the updated packages to NPM.
-81
View File
@@ -1,81 +0,0 @@
# Turborepo starter
This is an official starter Turborepo.
## Using this example
Run the following command:
```sh
npx create-turbo@latest
```
## What's inside?
This Turborepo includes the following packages/apps:
### Apps and Packages
- `docs`: a [Next.js](https://nextjs.org/) app
- `web`: another [Next.js](https://nextjs.org/) app
- `ui`: a stub React component library shared by both `web` and `docs` applications
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `tsconfig`: `tsconfig.json`s used throughout the monorepo
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
### Utilities
This Turborepo has some additional tools already setup for you:
- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
### Build
To build all apps and packages, run the following command:
```
cd my-turborepo
pnpm build
```
### Develop
To develop all apps and packages, run the following command:
```
cd my-turborepo
pnpm dev
```
### Remote Caching
Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands:
```
cd my-turborepo
npx turbo login
```
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
```
npx turbo link
```
## Useful Links
Learn more about the power of Turborepo:
- [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks)
- [Caching](https://turbo.build/repo/docs/core-concepts/caching)
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching)
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering)
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration)
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference)
+81 -15
View File
@@ -83,37 +83,52 @@ Check out our NextJS playground at https://llama-playground.vercel.app/. The sou
- [Node](/packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
- [Embedding](/packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
- [Embedding](/packages/core/src/embeddings/OpenAIEmbedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton. Because the default service context is OpenAI, the default embedding is `OpenAIEmbedding`. If using different models, say through Ollama, use this [Embedding](/packages/core/src/embeddings/OllamaEmbedding.ts) (see all [here](/packages/core/src/embeddings)).
- [Indices](/packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
- [QueryEngine](/packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
- [QueryEngine](/packages/core/src/engines/query/RetrieverQueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query. To build a query engine from your Index (recommended), use the [`asQueryEngine`](/packages/core/src/indices/BaseIndex.ts) method on your Index. See all query engines [here](/packages/core/src/engines/query).
- [ChatEngine](/packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
- [ChatEngine](/packages/core/src/engines/chat/SimpleChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices. See all chat engines [here](/packages/core/src/engines/chat).
- [SimplePrompt](/packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
## Note: NextJS:
## Using NextJS
If you're using NextJS App Router, you'll need to use the NodeJS runtime (default) and add the following config to your next.config.js to have it use imports/exports in the same way Node does.
If you're using the NextJS App Router, you can choose between the Node.js and the [Edge runtime](https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes#edge-runtime).
```js
export const runtime = "nodejs"; // default
With NextJS 13 and 14, using the Node.js runtime is the default. You can explicitly set the Edge runtime in your [router handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers) by adding this line:
```typescript
export const runtime = "edge";
```
The following sections explain further differences in using the Node.js or Edge runtime.
### Using the Node.js runtime
Add the following config to your `next.config.js` to ignore specific packages in the server-side bundling:
```js
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["pdf2json"],
serverComponentsExternalPackages: [
"pdf2json",
"@zilliz/milvus2-sdk-node",
"sharp",
"onnxruntime-node",
],
},
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
sharp$: false,
"onnxruntime-node$": false,
};
config.externals.push({
pdf2json: "commonjs pdf2json",
"@zilliz/milvus2-sdk-node": "commonjs @zilliz/milvus2-sdk-node",
sharp: "commonjs sharp",
"onnxruntime-node": "commonjs onnxruntime-node",
});
return config;
},
};
@@ -121,12 +136,63 @@ const nextConfig = {
module.exports = nextConfig;
```
### Using the Edge runtime
We publish a dedicated package (`@llamaindex/edge` instead of `llamaindex`) for using the Edge runtime. To use it, first install the package:
```shell
pnpm install @llamaindex/edge
```
> _Note_: Ensure that your `package.json` doesn't include the `llamaindex` package if you're using `@llamaindex/edge`.
Then make sure to use the correct import statement in your code:
```typescript
// replace 'llamaindex' with '@llamaindex/edge'
import {} from "@llamaindex/edge";
```
A further difference is that the `@llamaindex/edge` package doesn't export classes from the `readers` or `storage` folders. The reason is that most of these classes are not compatible with the Edge runtime.
If you need any of those classes, you have to import them instead directly. Here's an example for importing the `PineconeVectorStore` class:
```typescript
import { PineconeVectorStore } from "@llamaindex/edge/storage/vectorStore/PineconeVectorStore";
```
As the `PDFReader` is not working with the Edge runtime, here's how to use the `SimpleDirectoryReader` with the `LlamaParseReader` to load PDFs:
```typescript
import { SimpleDirectoryReader } from "@llamaindex/edge/readers/SimpleDirectoryReader";
import { LlamaParseReader } from "@llamaindex/edge/readers/LlamaParseReader";
export const DATA_DIR = "./data";
export async function getDocuments() {
const reader = new SimpleDirectoryReader();
// Load PDFs using LlamaParseReader
return await reader.loadData({
directoryPath: DATA_DIR,
fileExtToReader: {
pdf: new LlamaParseReader({ resultType: "markdown" }),
},
});
}
```
> _Note_: Reader classes have to be added explictly to the `fileExtToReader` map in the Edge version of the `SimpleDirectoryReader`.
You'll find a complete example of using the Edge runtime with LlamaIndexTS here: https://github.com/run-llama/create_llama_projects/tree/main/nextjs-edge-llamaparse
## Supported LLMs:
- OpenAI GPT-3.5-turbo and GPT-4
- Anthropic Claude Instant and Claude 2
- Llama2 Chat LLMs (70B, 13B, and 7B parameters)
- Anthropic Claude 3 (Opus, Sonnet, and Haiku) and the legacy models (Claude 2 and Instant)
- Groq LLMs
- Llama2/3 Chat LLMs (70B, 13B, and 7B parameters)
- MistralAI Chat LLMs
- Fireworks Chat LLMs
## Contributing:
+24
View File
@@ -1,5 +1,29 @@
# docs
## 0.0.5
### Patch Changes
- Updated dependencies [87142b2]
- Updated dependencies [5a6cc0e]
- Updated dependencies [87142b2]
- llamaindex@0.2.11
## 0.0.4
### Patch Changes
- Updated dependencies [5116ad8]
- @llamaindex/env@0.0.5
## 0.0.3
### Patch Changes
- 09bf27a: Add Groq LLM to LlamaIndex
- Updated dependencies [cf87f84]
- @llamaindex/env@0.0.4
## 0.0.2
### Patch Changes
+3 -78
View File
@@ -4,82 +4,7 @@ A built-in agent that can take decisions and reasoning based on the tools provid
## OpenAI Agent
```ts
import { FunctionTool, OpenAIAgent } from "llamaindex";
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/agent/openai";
// Define a function to sum two numbers
function sumNumbers({ a, b }: { a: number; b: number }): number {
return a + b;
}
// Define a function to divide two numbers
function divideNumbers({ a, b }: { a: number; b: number }): number {
return a / b;
}
// Define the parameters of the sum function as a JSON schema
const sumJSON = {
type: "object",
properties: {
a: {
type: "number",
description: "The first number",
},
b: {
type: "number",
description: "The second number",
},
},
required: ["a", "b"],
};
// Define the parameters of the divide function as a JSON schema
const divideJSON = {
type: "object",
properties: {
a: {
type: "number",
description: "The dividend to divide",
},
b: {
type: "number",
description: "The divisor to divide by",
},
},
required: ["a", "b"],
};
async function main() {
// Create a function tool from the sum function
const sumFunctionTool = new FunctionTool(sumNumbers, {
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: sumJSON,
});
// Create a function tool from the divide function
const divideFunctionTool = new FunctionTool(divideNumbers, {
name: "divideNumbers",
description: "Use this function to divide two numbers"
parameters: divideJSON,
});
// Create an OpenAIAgent with the function tools
const agent = new OpenAIAgent({
tools: [sumFunctionTool, divideFunctionTool],
verbose: true,
});
// Chat with the agent
const response = await agent.chat({
message: "How much is 5 + 5? then divide by 2",
});
// Print the response
console.log(String(response));
}
main().then(() => {
console.log("Done");
});
```
<CodeBlock language="ts">{CodeSource}</CodeBlock>
-56
View File
@@ -1,56 +0,0 @@
---
sidebar_position: 1
---
# Starter Tutorial
Once you have [installed LlamaIndex.TS using NPM](installation) and set up your OpenAI key, you're ready to start your first app:
In a new folder:
```bash npm2yarn
npm install typescript
npm install @types/node
npx tsc --init # if needed
```
Create the file `example.ts`. This code will load some example data, create a document, index it (which creates embeddings using OpenAI), and then creates query engine to answer questions about the data.
```ts
// example.ts
import fs from "fs/promises";
import { Document, VectorStoreIndex } from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8",
);
// Create Document object with essay
const document = new Document({ text: essay });
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments([document]);
// Query the index
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({
query: "What did the author do in college?",
});
// Output response
console.log(response.toString());
}
main();
```
Then you can run it using
```bash
npx ts-node example.ts
```
Ready to learn more? Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
@@ -0,0 +1,51 @@
---
sidebar_position: 1
---
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/vectorIndex";
import TSConfigSource from "!!raw-loader!../../../../examples/tsconfig.json";
# Starter Tutorial
Make sure you have installed LlamaIndex.TS and have an OpenAI key. If you haven't, check out the [installation](installation) guide.
## From scratch(node.js + TypeScript):
In a new folder:
```bash npm2yarn
npm init
npm install -D typescript @types/node
```
Create the file `example.ts`. This code will load some example data, create a document, index it (which creates embeddings using OpenAI), and then creates query engine to answer questions about the data.
<CodeBlock language="ts">{CodeSource}</CodeBlock>
Create a `tsconfig.json` file in the same folder:
<CodeBlock language="json">{TSConfigSource}</CodeBlock>
Now you can run the code with
```bash
npx tsx example.ts
```
Also, you can clone our examples and try them out:
```bash npm2yarn
npx degit run-llama/LlamaIndexTS/examples my-new-project
cd my-new-project
npm install
npx tsx ./vectorIndex.ts
```
## From scratch (Next.js + TypeScript):
You just need one command to create a new Next.js project:
```bash npm2yarn
npx create-llama@latest
```
+1 -1
View File
@@ -37,7 +37,7 @@ For more complex applications, our lower-level APIs allow advanced users to cust
`npm install llamaindex`
Our documentation includes [Installation Instructions](./getting_started/installation.mdx) and a [Starter Tutorial](./getting_started/starter.md) to build your first application.
Our documentation includes [Installation Instructions](./getting_started/installation.mdx) and a [Starter Tutorial](./getting_started/starter.mdx) to build your first application.
Once you're up and running, [High-Level Concepts](./getting_started/concepts.md) has an overview of LlamaIndex's modular architecture. For more hands-on practical examples, look through our Examples section on the sidebar.
@@ -1 +1,2 @@
label: "Agents"
position: 3
+7 -1
View File
@@ -11,4 +11,10 @@ An “agent” is an automated reasoning and decision engine. It takes in a user
LlamaIndex.TS comes with a few built-in agents, but you can also create your own. The built-in agents include:
- [OpenAI Agent](./openai.mdx)
- OpenAI Agent
- Anthropic Agent
- ReACT Agent
## Examples
- [OpenAI Agent](../../examples/agent.mdx)
-183
View File
@@ -1,183 +0,0 @@
# OpenAI Agent
OpenAI API that supports function calling, its never been easier to build your own agent!
In this notebook tutorial, we showcase how to write your own OpenAI agent
## Setup
First, you need to install the `llamaindex` package. You can do this by running the following command in your terminal:
```bash
pnpm i llamaindex
```
Then we can define a function to sum two numbers and another function to divide two numbers.
```ts
function sumNumbers({ a, b }: { a: number; b: number }): number {
return a + b;
}
// Define a function to divide two numbers
function divideNumbers({ a, b }: { a: number; b: number }): number {
return a / b;
}
```
## Create a function tool
Now we can create a function tool from the sum function and another function tool from the divide function.
For the parameters of the sum function, we can define a JSON schema.
### JSON Schema
```ts
const sumJSON = {
type: "object",
properties: {
a: {
type: "number",
description: "The first number",
},
b: {
type: "number",
description: "The second number",
},
},
required: ["a", "b"],
};
const divideJSON = {
type: "object",
properties: {
a: {
type: "number",
description: "The dividend a to divide",
},
b: {
type: "number",
description: "The divisor b to divide by",
},
},
required: ["a", "b"],
};
const sumFunctionTool = new FunctionTool(sumNumbers, {
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: sumJSON,
});
const divideFunctionTool = new FunctionTool(divideNumbers, {
name: "divideNumbers",
description: "Use this function to divide two numbers",
parameters: divideJSON,
});
```
## Create an OpenAIAgent
Now we can create an OpenAIAgent with the function tools.
```ts
const worker = new OpenAIAgent({
tools: [sumFunctionTool, divideFunctionTool],
verbose: true,
});
```
## Chat with the agent
Now we can chat with the agent.
```ts
const response = await worker.chat({
message: "How much is 5 + 5? then divide by 2",
});
console.log(String(response));
```
## Full code
```ts
import { FunctionTool, OpenAIAgent } from "llamaindex";
// Define a function to sum two numbers
function sumNumbers({ a, b }: { a: number; b: number }): number {
return a + b;
}
// Define a function to divide two numbers
function divideNumbers({ a, b }: { a: number; b: number }): number {
return a / b;
}
// Define the parameters of the sum function as a JSON schema
const sumJSON = {
type: "object",
properties: {
a: {
type: "number",
description: "The first number",
},
b: {
type: "number",
description: "The second number",
},
},
required: ["a", "b"],
};
// Define the parameters of the divide function as a JSON schema
const divideJSON = {
type: "object",
properties: {
a: {
type: "number",
description: "The argument a to divide",
},
b: {
type: "number",
description: "The argument b to divide",
},
},
required: ["a", "b"],
};
async function main() {
// Create a function tool from the sum function
const sumFunctionTool = new FunctionTool(sumNumbers, {
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: sumJSON,
});
// Create a function tool from the divide function
const divideFunctionTool = new FunctionTool(divideNumbers, {
name: "divideNumbers",
description: "Use this function to divide two numbers",
parameters: divideJSON,
});
// Create an OpenAIAgent with the function tools
const agent = new OpenAIAgent({
tools: [sumFunctionTool, divideFunctionTool],
verbose: true,
});
// Chat with the agent
const response = await agent.chat({
message: "How much is 5 + 5? then divide by 2",
});
// Print the response
console.log(String(response));
}
main().then(() => {
console.log("Done");
});
```
@@ -1,128 +0,0 @@
# OpenAI Agent + QueryEngineTool
QueryEngineTool is a tool that allows you to query a vector index. In this example, we will create a vector index from a set of documents and then create a QueryEngineTool from the vector index. We will then create an OpenAIAgent with the QueryEngineTool and chat with the agent.
## Setup
First, you need to install the `llamaindex` package. You can do this by running the following command in your terminal:
```bash
pnpm i llamaindex
```
Then you can import the necessary classes and functions.
```ts
import {
OpenAIAgent,
SimpleDirectoryReader,
VectorStoreIndex,
QueryEngineTool,
} from "llamaindex";
```
## Create a vector index
Now we can create a vector index from a set of documents.
```ts
// Load the documents
const documents = await new SimpleDirectoryReader().loadData({
directoryPath: "node_modules/llamaindex/examples/",
});
// Create a vector index from the documents
const vectorIndex = await VectorStoreIndex.fromDocuments(documents);
```
## Create a QueryEngineTool
Now we can create a QueryEngineTool from the vector index.
```ts
// Create a query engine from the vector index
const abramovQueryEngine = vectorIndex.asQueryEngine();
// Create a QueryEngineTool with the query engine
const queryEngineTool = new QueryEngineTool({
queryEngine: abramovQueryEngine,
metadata: {
name: "abramov_query_engine",
description: "A query engine for the Abramov documents",
},
});
```
## Create an OpenAIAgent
```ts
// Create an OpenAIAgent with the query engine tool tools
const agent = new OpenAIAgent({
tools: [queryEngineTool],
verbose: true,
});
```
## Chat with the agent
Now we can chat with the agent.
```ts
const response = await agent.chat({
message: "What was his salary?",
});
console.log(String(response));
```
## Full code
```ts
import {
OpenAIAgent,
SimpleDirectoryReader,
VectorStoreIndex,
QueryEngineTool,
} from "llamaindex";
async function main() {
// Load the documents
const documents = await new SimpleDirectoryReader().loadData({
directoryPath: "node_modules/llamaindex/examples/",
});
// Create a vector index from the documents
const vectorIndex = await VectorStoreIndex.fromDocuments(documents);
// Create a query engine from the vector index
const abramovQueryEngine = vectorIndex.asQueryEngine();
// Create a QueryEngineTool with the query engine
const queryEngineTool = new QueryEngineTool({
queryEngine: abramovQueryEngine,
metadata: {
name: "abramov_query_engine",
description: "A query engine for the Abramov documents",
},
});
// Create an OpenAIAgent with the function tools
const agent = new OpenAIAgent({
tools: [queryEngineTool],
verbose: true,
});
// Chat with the agent
const response = await agent.chat({
message: "What was his salary?",
});
// Print the response
console.log(String(response));
}
main().then(() => {
console.log("Done");
});
```
+13
View File
@@ -5,6 +5,7 @@ sidebar_position: 4
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/readers/src/simple-directory-reader";
import CodeSource2 from "!raw-loader!../../../../examples/readers/src/custom-simple-directory-reader";
import CodeSource3 from "!raw-loader!../../../../examples/readers/src/llamaparse";
# Loader
@@ -30,6 +31,18 @@ Or pass new readers for `fileExtToReader` to support more file types.
{CodeSource2}
</CodeBlock>
### LlamaParse
LlamaParse is an API created by LlamaIndex to efficiently parse files, e.g. it's great at converting PDF tables into markdown.
To use it, first login and get an API key from https://cloud.llamaindex.ai. Make sure to store the key in the environment variable `LLAMA_CLOUD_API_KEY`.
Then, you can use the `LlamaParseReader` class to read a local PDF file and convert it into a markdown document that can be used by LlamaIndex:
<CodeBlock language="ts">{CodeSource3}</CodeBlock>
Alternatively, you can set the [`resultType`](../api/classes/LlamaParseReader.md#resulttype) option to `text` to get the parsed document as a text string.
## API Reference
- [SimpleDirectoryReader](../api/classes/SimpleDirectoryReader.md)
-22
View File
@@ -1,22 +0,0 @@
---
sidebar_position: 4
---
# Embedding
The embedding model in LlamaIndex is responsible for creating numerical representations of text. By default, LlamaIndex will use the `text-embedding-ada-002` model from OpenAI.
This can be explicitly set in the `ServiceContext` object.
```typescript
import { OpenAIEmbedding, serviceContextFromDefaults } from "llamaindex";
const openaiEmbeds = new OpenAIEmbedding();
const serviceContext = serviceContextFromDefaults({ embedModel: openaiEmbeds });
```
## API Reference
- [OpenAIEmbedding](../api/classes/OpenAIEmbedding.md)
- [ServiceContext](../api/interfaces//ServiceContext.md)
@@ -0,0 +1,2 @@
label: "Embeddings"
position: 3
@@ -0,0 +1 @@
label: "Available Embeddings"
@@ -0,0 +1,34 @@
# HuggingFace
To use HuggingFace embeddings, you need to import `HuggingFaceEmbedding` from `llamaindex`.
```ts
import { HuggingFaceEmbedding, Settings } from "llamaindex";
// Update Embed Model
Settings.embedModel = new HuggingFaceEmbedding();
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
Per default, `HuggingFaceEmbedding` is using the `Xenova/all-MiniLM-L6-v2` model. You can change the model by passing the `modelType` parameter to the constructor.
If you're not using a quantized model, set the `quantized` parameter to `false`.
For example, to use the not quantized `BAAI/bge-small-en-v1.5` model, you can use the following code:
```ts
Settings.embedModel = new HuggingFaceEmbedding({
modelType: "BAAI/bge-small-en-v1.5",
quantized: false,
});
```
@@ -0,0 +1,21 @@
# Jina AI
To use Jina AI embeddings, you need to import `JinaAIEmbedding` from `llamaindex`.
```ts
import { JinaAIEmbedding, Settings } from "llamaindex";
Settings.embedModel = new JinaAIEmbedding();
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
@@ -0,0 +1,24 @@
# MistralAI
To use MistralAI embeddings, you need to import `MistralAIEmbedding` from `llamaindex`.
```ts
import { MistralAIEmbedding, Settings } from "llamaindex";
// Update Embed Model
Settings.embedModel = new MistralAIEmbedding({
apiKey: "<YOUR_API_KEY>",
});
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
@@ -0,0 +1,29 @@
# Ollama
To use Ollama embeddings, you need to import `OllamaEmbedding` from `llamaindex`.
Note that you need to pull the embedding model first before using it.
In the example below, we're using the [`nomic-embed-text`](https://ollama.com/library/nomic-embed-text) model, so you have to call:
```shell
ollama pull nomic-embed-text
```
```ts
import { OllamaEmbedding, Settings } from "llamaindex";
Settings.embedModel = new OllamaEmbedding({ model: "nomic-embed-text" });
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
@@ -0,0 +1,21 @@
# OpenAI
To use OpenAI embeddings, you need to import `OpenAIEmbedding` from `llamaindex`.
```ts
import { OpenAIEmbedding, Settings } from "llamaindex";
Settings.embedModel = new OpenAIEmbedding();
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
@@ -0,0 +1,23 @@
# Together
To use together embeddings, you need to import `TogetherEmbedding` from `llamaindex`.
```ts
import { TogetherEmbedding, Settings } from "llamaindex";
Settings.embedModel = new TogetherEmbedding({
apiKey: "<YOUR_API_KEY>",
});
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
@@ -0,0 +1,21 @@
# Embedding
The embedding model in LlamaIndex is responsible for creating numerical representations of text. By default, LlamaIndex will use the `text-embedding-ada-002` model from OpenAI.
This can be explicitly updated through `Settings`
```typescript
import { OpenAIEmbedding, Settings } from "llamaindex";
Settings.embedModel = new OpenAIEmbedding({
model: "text-embedding-ada-002",
});
```
## Local Embedding
For local embeddings, you can use the [HuggingFace](./available_embeddings/huggingface.md) embedding model.
## API Reference
- [OpenAIEmbedding](../../api/classes/OpenAIEmbedding.md)
@@ -0,0 +1,2 @@
label: "Evaluating"
position: 3
@@ -0,0 +1,32 @@
# Evaluating
## Concept
Evaluation and benchmarking are crucial concepts in LLM development. To improve the perfomance of an LLM app (RAG, agents) you must have a way to measure it.
LlamaIndex offers key modules to measure the quality of generated results. We also offer key modules to measure retrieval quality.
- **Response Evaluation**: Does the response match the retrieved context? Does it also match the query? Does it match the reference answer or guidelines?
- **Retrieval Evaluation**: Are the retrieved sources relevant to the query?
## Response Evaluation
Evaluation of generated results can be difficult, since unlike traditional machine learning the predicted result is not a single number, and it can be hard to define quantitative metrics for this problem.
LlamaIndex offers LLM-based evaluation modules to measure the quality of results. This uses a “gold” LLM (e.g. GPT-4) to decide whether the predicted answer is correct in a variety of ways.
Note that many of these current evaluation modules do not require ground-truth labels. Evaluation can be done with some combination of the query, context, response, and combine these with LLM calls.
These evaluation modules are in the following forms:
- **Correctness**: Whether the generated answer matches that of the reference answer given the query (requires labels).
- **Faithfulness**: Evaluates if the answer is faithful to the retrieved contexts (in other words, whether if theres hallucination).
- **Relevancy**: Evaluates if the response from a query engine matches any source nodes.
## Usage
- [Correctness Evaluator](./modules/correctness.md)
- [Faithfulness Evaluator](./modules/faithfulness.md)
- [Relevancy Evaluator](./modules/relevancy.md)
@@ -0,0 +1 @@
label: "Modules"
@@ -0,0 +1,58 @@
# Correctness Evaluator
Correctness evaluates the relevance and correctness of a generated answer against a reference answer.
This is useful for measuring if the response was correct. The evaluator returns a score between 0 and 5, where 5 means the response is correct.
## Usage
Firstly, you need to install the package:
```bash
pnpm i llamaindex
```
Set the OpenAI API key:
```bash
export OPENAI_API_KEY=your-api-key
```
Import the required modules:
```ts
import { CorrectnessEvaluator, OpenAI, Settings } from "llamaindex";
```
Let's setup gpt-4 for better results:
```ts
Settings.llm = new OpenAI({
model: "gpt-4",
});
```
```ts
const query =
"Can you explain the theory of relativity proposed by Albert Einstein in detail?";
const response = ` Certainly! Albert Einstein's theory of relativity consists of two main components: special relativity and general relativity. Special relativity, published in 1905, introduced the concept that the laws of physics are the same for all non-accelerating observers and that the speed of light in a vacuum is a constant, regardless of the motion of the source or observer. It also gave rise to the famous equation E=mc², which relates energy (E) and mass (m).
However, general relativity, published in 1915, extended these ideas to include the effects of magnetism. According to general relativity, gravity is not a force between masses but rather the result of the warping of space and time by magnetic fields generated by massive objects. Massive objects, such as planets and stars, create magnetic fields that cause a curvature in spacetime, and smaller objects follow curved paths in response to this magnetic curvature. This concept is often illustrated using the analogy of a heavy ball placed on a rubber sheet with magnets underneath, causing it to create a depression that other objects (representing smaller masses) naturally move towards due to magnetic attraction.
`;
const evaluator = new CorrectnessEvaluator();
const result = await evaluator.evaluateResponse({
query,
response,
});
console.log(
`the response is ${result.passing ? "correct" : "not correct"} with a score of ${result.score}`,
);
```
```bash
the response is not correct with a score of 2.5
```
@@ -0,0 +1,78 @@
# Faithfulness Evaluator
Faithfulness is a measure of whether the generated answer is faithful to the retrieved contexts. In other words, it measures whether there is any hallucination in the generated answer.
This uses the FaithfulnessEvaluator module to measure if the response from a query engine matches any source nodes.
This is useful for measuring if the response was hallucinated. The evaluator returns a score between 0 and 1, where 1 means the response is faithful to the retrieved contexts.
## Usage
Firstly, you need to install the package:
```bash
pnpm i llamaindex
```
Set the OpenAI API key:
```bash
export OPENAI_API_KEY=your-api-key
```
Import the required modules:
```ts
import {
Document,
FaithfulnessEvaluator,
OpenAI,
VectorStoreIndex,
Settings,
} from "llamaindex";
```
Let's setup gpt-4 for better results:
```ts
Settings.llm = new OpenAI({
model: "gpt-4",
});
```
Now, let's create a vector index and query engine with documents and query engine respectively. Then, we can evaluate the response with the query and response from the query engine.:
```ts
const documents = [
new Document({
text: `The city came under British control in 1664 and was renamed New York after King Charles II of England granted the lands to his brother, the Duke of York. The city was regained by the Dutch in July 1673 and was renamed New Orange for one year and three months; the city has been continuously named New York since November 1674. New York City was the capital of the United States from 1785 until 1790, and has been the largest U.S. city since 1790. The Statue of Liberty greeted millions of immigrants as they came to the U.S. by ship in the late 19th and early 20th centuries, and is a symbol of the U.S. and its ideals of liberty and peace. In the 21st century, New York City has emerged as a global node of creativity, entrepreneurship, and as a symbol of freedom and cultural diversity. The New York Times has won the most Pulitzer Prizes for journalism and remains the U.S. media's "newspaper of record". In 2019, New York City was voted the greatest city in the world in a survey of over 30,000 p... Pass`,
}),
];
const vectorIndex = await VectorStoreIndex.fromDocuments(documents);
const queryEngine = vectorIndex.asQueryEngine();
```
Now, let's evaluate the response:
```ts
const query = "How did New York City get its name?";
const evaluator = new FaithfulnessEvaluator();
const response = await queryEngine.query({
query,
});
const result = await evaluator.evaluateResponse({
query,
response,
});
console.log(`the response is ${result.passing ? "faithful" : "not faithful"}`);
```
```bash
the response is faithful
```
@@ -0,0 +1,66 @@
# Relevancy Evaluator
Relevancy measure if the response from a query engine matches any source nodes.
It is useful for measuring if the response was relevant to the query. The evaluator returns a score between 0 and 1, where 1 means the response is relevant to the query.
## Usage
Firstly, you need to install the package:
```bash
pnpm i llamaindex
```
Set the OpenAI API key:
```bash
export OPENAI_API_KEY=your-api-key
```
Import the required modules:
```ts
import { RelevancyEvaluator, OpenAI, Settings } from "llamaindex";
```
Let's setup gpt-4 for better results:
```ts
Settings.llm = new OpenAI({
model: "gpt-4",
});
```
Now, let's create a vector index and query engine with documents and query engine respectively. Then, we can evaluate the response with the query and response from the query engine.:
```ts
const documents = [
new Document({
text: `The city came under British control in 1664 and was renamed New York after King Charles II of England granted the lands to his brother, the Duke of York. The city was regained by the Dutch in July 1673 and was renamed New Orange for one year and three months; the city has been continuously named New York since November 1674. New York City was the capital of the United States from 1785 until 1790, and has been the largest U.S. city since 1790. The Statue of Liberty greeted millions of immigrants as they came to the U.S. by ship in the late 19th and early 20th centuries, and is a symbol of the U.S. and its ideals of liberty and peace. In the 21st century, New York City has emerged as a global node of creativity, entrepreneurship, and as a symbol of freedom and cultural diversity. The New York Times has won the most Pulitzer Prizes for journalism and remains the U.S. media's "newspaper of record". In 2019, New York City was voted the greatest city in the world in a survey of over 30,000 p... Pass`,
}),
];
const vectorIndex = await VectorStoreIndex.fromDocuments(documents);
const queryEngine = vectorIndex.asQueryEngine();
const query = "How did New York City get its name?";
const response = await queryEngine.query({
query,
});
const evaluator = new RelevancyEvaluator();
const result = await evaluator.evaluateResponse({
query,
response: response,
});
console.log(`the response is ${result.passing ? "relevant" : "not relevant"}`);
```
```bash
the response is relevant
```
@@ -1,6 +1,6 @@
# Transformations
A transformation is something that takes a list of nodes as an input, and returns a list of nodes. Each component that implements the Transformatio class has both a `transform` definition responsible for transforming the nodes
A transformation is something that takes a list of nodes as an input, and returns a list of nodes. Each component that implements the Transformation class has both a `transform` definition responsible for transforming the nodes.
Currently, the following components are Transformation objects:
+32
View File
@@ -0,0 +1,32 @@
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/cloud/chat.ts";
# LlamaCloud
LlamaCloud is a new generation of managed parsing, ingestion, and retrieval services, designed to bring production-grade context-augmentation to your LLM and RAG applications.
Currently, LlamaCloud supports
- Managed Ingestion API, handling parsing and document management
- Managed Retrieval API, configuring optimal retrieval for your RAG system
## Access
We are opening up a private beta to a limited set of enterprise partners for the managed ingestion and retrieval API. If youre interested in centralizing your data pipelines and spending more time working on your actual RAG use cases, come [talk to us.](https://www.llamaindex.ai/contact)
If you have access to LlamaCloud, you can visit [LlamaCloud](https://cloud.llamaindex.ai) to sign in and get an API key.
## Create a Managed Index
Currently, you can't create a managed index on LlamaCloud using LlamaIndexTS, but you can use an existing managed index for retrieval that was created by the Python version of LlamaIndex. See [the LlamaCloudIndex documentation](https://docs.llamaindex.ai/en/stable/module_guides/indexing/llama_cloud_index.html#usage) for more information on how to create a managed index.
## Use a Managed Index
Here's an example of how to use a managed index together with a chat engine:
<CodeBlock language="ts">{CodeSource}</CodeBlock>
## API Reference
- [LlamaCloudIndex](../api/classes/LlamaCloudIndex.md)
- [LlamaCloudRetriever](../api/classes/LlamaCloudRetriever.md)
@@ -3,13 +3,11 @@
## Usage
```ts
import { Anthropic, serviceContextFromDefaults } from "llamaindex";
import { Anthropic, Settings } from "llamaindex";
const anthropicLLM = new Anthropic({
Settings.llm = new Anthropic({
apiKey: "<YOUR_API_KEY>",
});
const serviceContext = serviceContextFromDefaults({ llm: anthropicLLM });
```
## Load and index documents
@@ -19,9 +17,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -39,28 +35,17 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { Anthropic, Document, VectorStoreIndex, Settings } from "llamaindex";
Settings.llm = new Anthropic({
apiKey: "<YOUR_API_KEY>",
});
async function main() {
// Create an instance of the Anthropic LLM
const anthropicLLM = new Anthropic({
apiKey: "<YOUR_API_KEY>",
});
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: anthropicLLM });
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -15,11 +15,9 @@ export AZURE_OPENAI_DEPLOYMENT="gpt-4" # or some other deployment name
## Usage
```ts
import { OpenAI, serviceContextFromDefaults } from "llamaindex";
import { OpenAI, Settings } from "llamaindex";
const azureOpenaiLLM = new OpenAI({ model: "gpt-4", temperature: 0 });
const serviceContext = serviceContextFromDefaults({ llm: azureOpenaiLLM });
Settings.llm = new OpenAI({ model: "gpt-4", temperature: 0 });
```
## Load and index documents
@@ -29,9 +27,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -49,26 +45,18 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { OpenAI, Document, VectorStoreIndex, Settings } from "llamaindex";
Settings.llm = new OpenAI({ model: "gpt-4", temperature: 0 });
async function main() {
// Create an instance of the LLM
const azureOpenaiLLM = new OpenAI({ model: "gpt-4", temperature: 0 });
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: azureOpenaiLLM });
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -0,0 +1,61 @@
# Fireworks LLM
Fireworks.ai focus on production use cases for open source LLMs, offering speed and quality.
## Usage
```ts
import { FireworksLLM, Settings } from "llamaindex";
Settings.llm = new FireworksLLM({
apiKey: "<YOUR_API_KEY>",
});
```
## Load and index documents
For this example, we will load the Berkshire Hathaway 2022 annual report pdf
```ts
const reader = new PDFReader();
const documents = await reader.loadData("../data/brk-2022.pdf");
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments(documents);
```
## Query
```ts
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({
query: "What mistakes did Warren E. Buffett make?",
});
```
## Full Example
```ts
import { VectorStoreIndex } from "llamaindex";
import { PDFReader } from "llamaindex/readers/PDFReader";
async function main() {
// Load PDF
const reader = new PDFReader();
const documents = await reader.loadData("../data/brk-2022.pdf");
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments(documents);
// Query the index
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({
query: "What mistakes did Warren E. Buffett make?",
});
// Output response
console.log(response.toString());
}
main().catch(console.error);
```
@@ -0,0 +1,52 @@
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../../examples/groq.ts";
# Groq
## Usage
First, create an API key at the [Groq Console](https://console.groq.com/keys). Then save it in your environment:
```bash
export GROQ_API_KEY=<your-api-key>
```
The initialize the Groq module.
```ts
import { Groq, Settings } from "llamaindex";
Settings.llm = new Groq({
// If you do not wish to set your API key in the environment, you may
// configure your API key when you initialize the Groq class.
// apiKey: "<your-api-key>",
});
```
## Load and index documents
For this example, we will use a single document. In a real-world scenario, you would have multiple documents to index.
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
```ts
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
## Full Example
<CodeBlock language="ts" showLineNumbers>
{CodeSource}
</CodeBlock>
@@ -3,11 +3,9 @@
## Usage
```ts
import { Ollama, serviceContextFromDefaults } from "llamaindex";
import { Ollama, Settings, DeuceChatStrategy } from "llamaindex";
const llama2LLM = new LlamaDeuce({ chatStrategy: DeuceChatStrategy.META });
const serviceContext = serviceContextFromDefaults({ llm: llama2LLM });
Settings.llm = new LlamaDeuce({ chatStrategy: DeuceChatStrategy.META });
```
## Usage with Replication
@@ -16,19 +14,18 @@ const serviceContext = serviceContextFromDefaults({ llm: llama2LLM });
import {
Ollama,
ReplicateSession,
serviceContextFromDefaults,
Settings,
DeuceChatStrategy,
} from "llamaindex";
const replicateSession = new ReplicateSession({
replicateKey,
});
const llama2LLM = new LlamaDeuce({
Settings.llm = new LlamaDeuce({
chatStrategy: DeuceChatStrategy.META,
replicateSession,
});
const serviceContext = serviceContextFromDefaults({ llm: llama2LLM });
```
## Load and index documents
@@ -38,9 +35,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -59,25 +54,24 @@ const results = await queryEngine.query({
```ts
import {
Anthropic,
LlamaDeuce,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
Settings,
DeuceChatStrategy,
} from "llamaindex";
// Use the LlamaDeuce LLM
Settings.llm = new LlamaDeuce({ chatStrategy: DeuceChatStrategy.META });
async function main() {
// Create an instance of the LLM
const llama2LLM = new LlamaDeuce({ chatStrategy: DeuceChatStrategy.META });
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: mistralLLM });
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -3,14 +3,12 @@
## Usage
```ts
import { Ollama, serviceContextFromDefaults } from "llamaindex";
import { Ollama, Settings } from "llamaindex";
const mistralLLM = new MistralAI({
Settings.llm = new MistralAI({
model: "mistral-tiny",
apiKey: "<YOUR_API_KEY>",
});
const serviceContext = serviceContextFromDefaults({ llm: mistralLLM });
```
## Load and index documents
@@ -20,9 +18,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -40,26 +36,19 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { MistralAI, Document, VectorStoreIndex, Settings } from "llamaindex";
// Use the MistralAI LLM
Settings.llm = new MistralAI({ model: "mistral-tiny" });
async function main() {
// Create an instance of the LLM
const mistralLLM = new MistralAI({ model: "mistral-tiny" });
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: mistralLLM });
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -3,11 +3,10 @@
## Usage
```ts
import { Ollama, serviceContextFromDefaults } from "llamaindex";
import { Ollama, Settings } from "llamaindex";
const ollamaLLM = new Ollama({ model: "llama2", temperature: 0.75 });
const serviceContext = serviceContextFromDefaults({ llm: ollamaLLM });
Settings.llm = ollamaLLM;
Settings.embedModel = ollamaLLM;
```
## Load and index documents
@@ -17,9 +16,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -37,26 +34,26 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { Ollama, Document, VectorStoreIndex, Settings } from "llamaindex";
import fs from "fs/promises";
const ollama = new Ollama({ model: "llama2", temperature: 0.75 });
// Use Ollama LLM and Embed Model
Settings.llm = ollama;
Settings.embedModel = ollama;
async function main() {
// Create an instance of the LLM
const ollamaLLM = new Ollama({ model: "llama2", temperature: 0.75 });
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: ollamaLLM });
const essay = await fs.readFile("./paul_graham_essay.txt", "utf-8");
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -1,11 +1,9 @@
# OpenAI
```ts
import { OpenAI, serviceContextFromDefaults } from "llamaindex";
import { OpenAI, Settings } from "llamaindex";
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0, apiKey: <YOUR_API_KEY> });
const serviceContext = serviceContextFromDefaults({ llm: openaiLLM });
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0, apiKey: <YOUR_API_KEY> });
```
You can setup the apiKey on the environment variables, like:
@@ -21,9 +19,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -41,26 +37,19 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { OpenAI, Document, VectorStoreIndex, Settings } from "llamaindex";
// Use the OpenAI LLM
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
async function main() {
// Create an instance of the LLM
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: openaiLLM });
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -3,13 +3,11 @@
## Usage
```ts
import { Portkey, serviceContextFromDefaults } from "llamaindex";
import { Portkey, Settings } from "llamaindex";
const portkeyLLM = new Portkey({
Settings.llm = new Portkey({
apiKey: "<YOUR_API_KEY>",
});
const serviceContext = serviceContextFromDefaults({ llm: portkeyLLM });
```
## Load and index documents
@@ -19,9 +17,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -39,28 +35,22 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { Portkey, Document, VectorStoreIndex, Settings } from "llamaindex";
// Use the Portkey LLM
Settings.llm = new Portkey({
apiKey: "<YOUR_API_KEY>",
});
async function main() {
// Create an instance of the LLM
const portkeyLLM = new Portkey({
apiKey: "<YOUR_API_KEY>",
});
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: portkeyLLM });
// Create a document
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
@@ -3,13 +3,11 @@
## Usage
```ts
import { TogetherLLM, serviceContextFromDefaults } from "llamaindex";
import { TogetherLLM, Settings } from "llamaindex";
const togetherLLM = new TogetherLLM({
Settings.llm = new TogetherLLM({
apiKey: "<YOUR_API_KEY>",
});
const serviceContext = serviceContextFromDefaults({ llm: togetherLLM });
```
## Load and index documents
@@ -19,9 +17,7 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
@@ -39,28 +35,20 @@ const results = await queryEngine.query({
## Full Example
```ts
import {
Anthropic,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
import { TogetherLLM, Document, VectorStoreIndex, Settings } from "llamaindex";
Settings.llm = new TogetherLLM({
apiKey: "<YOUR_API_KEY>",
});
async function main() {
// Create an instance of the LLM
const togetherLLM = new TogetherLLM({
apiKey: "<YOUR_API_KEY>",
});
// Create a service context
const serviceContext = serviceContextFromDefaults({ llm: togetherLLM });
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
+7 -6
View File
@@ -6,14 +6,12 @@ sidebar_position: 3
The LLM is responsible for reading text and generating natural language responses to queries. By default, LlamaIndex.TS uses `gpt-3.5-turbo`.
The LLM can be explicitly set in the `ServiceContext` object.
The LLM can be explicitly updated through `Settings`.
```typescript
import { OpenAI, serviceContextFromDefaults } from "llamaindex";
import { OpenAI, Settings } from "llamaindex";
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
const serviceContext = serviceContextFromDefaults({ llm: openaiLLM });
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
```
## Azure OpenAI
@@ -28,7 +26,10 @@ export AZURE_OPENAI_ENDPOINT="<YOUR ENDPOINT, see https://learn.microsoft.com/en
export AZURE_OPENAI_DEPLOYMENT="gpt-4" # or some other deployment name
```
## Local LLM
For local LLMs, currently we recommend the use of [Ollama](./available_llms/ollama.md) LLM.
## API Reference
- [OpenAI](../api/classes/OpenAI.md)
- [ServiceContext](../api/interfaces//ServiceContext.md)
+68 -4
View File
@@ -4,15 +4,14 @@ sidebar_position: 4
# NodeParser
The `NodeParser` in LlamaIndex is responsible for splitting `Document` objects into more manageable `Node` objects. When you call `.fromDocuments()`, the `NodeParser` from the `ServiceContext` is used to do this automatically for you. Alternatively, you can use it to split documents ahead of time.
The `NodeParser` in LlamaIndex is responsible for splitting `Document` objects into more manageable `Node` objects. When you call `.fromDocuments()`, the `NodeParser` from the `Settings` is used to do this automatically for you. Alternatively, you can use it to split documents ahead of time.
```typescript
import { Document, SimpleNodeParser } from "llamaindex";
const nodeParser = new SimpleNodeParser();
const nodes = nodeParser.getNodesFromDocuments([
new Document({ text: "I am 10 years old. John is 20 years old." }),
]);
Settings.nodeParser = nodeParser;
```
## TextSplitter
@@ -27,6 +26,71 @@ const splitter = new SentenceSplitter({ chunkSize: 1 });
const textSplits = splitter.splitText("Hello World");
```
## MarkdownNodeParser
The `MarkdownNodeParser` is a more advanced `NodeParser` that can handle markdown documents. It will split the markdown into nodes and then parse the nodes into a `Document` object.
```typescript
import { MarkdownNodeParser } from "llamaindex";
const nodeParser = new MarkdownNodeParser();
const nodes = nodeParser.getNodesFromDocuments([
new Document({
text: `# Main Header
Main content
# Header 2
Header 2 content
## Sub-header
Sub-header content
`,
}),
]);
```
The output metadata will be something like:
```bash
[
TextNode {
id_: '008e41a8-b097-487c-bee8-bd88b9455844',
metadata: { 'Header 1': 'Main Header' },
excludedEmbedMetadataKeys: [],
excludedLlmMetadataKeys: [],
relationships: { PARENT: [Array] },
hash: 'KJ5e/um/RkHaNR6bonj9ormtZY7I8i4XBPVYHXv1A5M=',
text: 'Main Header\nMain content',
textTemplate: '',
metadataSeparator: '\n'
},
TextNode {
id_: '0f5679b3-ba63-4aff-aedc-830c4208d0b5',
metadata: { 'Header 1': 'Header 2' },
excludedEmbedMetadataKeys: [],
excludedLlmMetadataKeys: [],
relationships: { PARENT: [Array] },
hash: 'IP/g/dIld3DcbK+uHzDpyeZ9IdOXY4brxhOIe7wc488=',
text: 'Header 2\nHeader 2 content',
textTemplate: '',
metadataSeparator: '\n'
},
TextNode {
id_: 'e81e9bd0-121c-4ead-8ca7-1639d65fdf90',
metadata: { 'Header 1': 'Header 2', 'Header 2': 'Sub-header' },
excludedEmbedMetadataKeys: [],
excludedLlmMetadataKeys: [],
relationships: { PARENT: [Array] },
hash: 'B3kYNnxaYi9ghtAgwza0ZEVKF4MozobkNUlcekDL7JQ=',
text: 'Sub-header\nSub-header content',
textTemplate: '',
metadataSeparator: '\n'
}
]
```
## API Reference
- [SimpleNodeParser](../api/classes/SimpleNodeParser.md)
@@ -18,7 +18,7 @@ import {
Document,
OpenAI,
VectorStoreIndex,
serviceContextFromDefaults,
Settings,
} from "llamaindex";
```
@@ -29,13 +29,9 @@ For this example, we will use a single document. In a real-world scenario, you w
```ts
const document = new Document({ text: essay, id_: "essay" });
const serviceContext = serviceContextFromDefaults({
llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.1 }),
});
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.1 });
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Increase similarity topK to retrieve more results
@@ -36,7 +36,7 @@ const processor = new SimilarityPostprocessor({
similarityCutoff: 0.7,
});
const filteredNodes = processor.postprocessNodes(nodes);
const filteredNodes = await processor.postprocessNodes(nodes);
// cohere rerank: rerank nodes given query using trained model
const reranker = new CohereRerank({
@@ -58,7 +58,10 @@ Most commonly, node-postprocessors will be used in a query engine, where they ar
### Using Node Postprocessors in a Query Engine
```ts
import { Node, NodeWithScore, SimilarityPostprocessor, CohereRerank } from "llamaindex";
import { Node, NodeWithScore, SimilarityPostprocessor, CohereRerank, Settings } from "llamaindex";
// Use OpenAI LLM
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.1 });
const nodes: NodeWithScore[] = [
{
@@ -79,14 +82,6 @@ const reranker = new CohereRerank({
const document = new Document({ text: "essay", id_: "essay" });
const serviceContext = serviceContextFromDefaults({
llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.1 }),
});
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const queryEngine = index.asQueryEngine({
nodePostprocessors: [processor, reranker],
});
@@ -100,7 +95,7 @@ const response = await queryEngine.query("<user_query>");
```ts
import { SimilarityPostprocessor } from "llamaindex";
nodes = await index.asRetriever().retrieve("test query str");
nodes = await index.asRetriever().retrieve({ query: "test query str" });
const processor = new SimilarityPostprocessor({
similarityCutoff: 0.7,
@@ -0,0 +1,71 @@
# Jina AI Reranker
The Jina AI Reranker is a postprocessor that uses the Jina AI Reranker API to rerank the results of a search query.
## Setup
Firstly, you will need to install the `llamaindex` package.
```bash
pnpm install llamaindex
```
Now, you will need to sign up for an API key at [Jina AI](https://jina.ai/reranker). Once you have your API key you can import the necessary modules and create a new instance of the `JinaAIReranker` class.
```ts
import {
JinaAIReranker,
Document,
OpenAI,
VectorStoreIndex,
Settings,
} from "llamaindex";
```
## Load and index documents
For this example, we will use a single document. In a real-world scenario, you would have multiple documents to index.
```ts
const document = new Document({ text: essay, id_: "essay" });
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.1 });
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Increase similarity topK to retrieve more results
The default value for `similarityTopK` is 2. This means that only the most similar document will be returned. To retrieve more results, you can increase the value of `similarityTopK`.
```ts
const retriever = index.asRetriever();
retriever.similarityTopK = 5;
```
## Create a new instance of the JinaAIReranker class
Then you can create a new instance of the `JinaAIReranker` class and pass in the number of results you want to return.
The Jina AI Reranker API key is set in the `JINAAI_API_KEY` environment variable.
```bash
export JINAAI_API_KEY=<YOUR API KEY>
```
```ts
const nodePostprocessor = new JinaAIReranker({
topN: 5,
});
```
## Create a query engine with the retriever and node postprocessor
```ts
const queryEngine = index.asQueryEngine({
retriever,
nodePostprocessors: [nodePostprocessor],
});
// log the response
const response = await queryEngine.query("Where did the author grown up?");
```
@@ -0,0 +1,2 @@
label: "Prompts"
position: 0
+72
View File
@@ -0,0 +1,72 @@
# Prompts
Prompting is the fundamental input that gives LLMs their expressive power. LlamaIndex uses prompts to build the index, do insertion, perform traversal during querying, and to synthesize the final answer.
Users may also provide their own prompt templates to further customize the behavior of the framework. The best method for customizing is copying the default prompt from the link above, and using that as the base for any modifications.
## Usage Pattern
Currently, there are two ways to customize prompts in LlamaIndex:
For both methods, you will need to create an function that overrides the default prompt.
```ts
// Define a custom prompt
const newTextQaPrompt: TextQaPrompt = ({ context, query }) => {
return `Context information is below.
---------------------
${context}
---------------------
Given the context information and not prior knowledge, answer the query.
Answer the query in the style of a Sherlock Holmes detective novel.
Query: ${query}
Answer:`;
};
```
### 1. Customizing the default prompt on initialization
The first method is to create a new instance of `ResponseSynthesizer` (or the module you would like to update the prompt) and pass the custom prompt to the `responseBuilder` parameter. Then, pass the instance to the `asQueryEngine` method of the index.
```ts
// Create an instance of response synthesizer
const responseSynthesizer = new ResponseSynthesizer({
responseBuilder: new CompactAndRefine(undefined, newTextQaPrompt),
});
// Create index
const index = await VectorStoreIndex.fromDocuments([document]);
// Query the index
const queryEngine = index.asQueryEngine({ responseSynthesizer });
const response = await queryEngine.query({
query: "What did the author do in college?",
});
```
### 2. Customizing submodules prompt
The second method is that most of the modules in LlamaIndex have a `getPrompts` and a `updatePrompt` method that allows you to override the default prompt. This method is useful when you want to change the prompt on the fly or in submodules on a more granular level.
```ts
// Create index
const index = await VectorStoreIndex.fromDocuments([document]);
// Query the index
const queryEngine = index.asQueryEngine();
// Get a list of prompts for the query engine
const prompts = queryEngine.getPrompts();
// output: { "responseSynthesizer:textQATemplate": defaultTextQaPrompt, "responseSynthesizer:refineTemplate": defaultRefineTemplatePrompt }
// Now, we can override the default prompt
queryEngine.updatePrompt({
"responseSynthesizer:textQATemplate": newTextQaPrompt,
});
const response = await queryEngine.query({
query: "What did the author do in college?",
});
```
@@ -54,12 +54,13 @@ You can create a `ChromaVectorStore` to store the documents:
```ts
const chromaVS = new ChromaVectorStore({ collectionName });
const serviceContext = await storageContextFromDefaults({
const storageContext = await storageContextFromDefaults({
vectorStore: chromaVS,
});
const index = await VectorStoreIndex.fromDocuments(docs, {
storageContext: serviceContext,
storageContext: storageContext,
});
```
@@ -18,7 +18,7 @@ import {
SimpleNodeParser,
SummaryIndex,
VectorStoreIndex,
serviceContextFromDefaults,
Settings,
} from "llamaindex";
```
@@ -34,17 +34,13 @@ const documents = await new SimpleDirectoryReader().loadData({
## Service Context
Next, we need to define some basic rules and parse the documents into nodes. We will use the `SimpleNodeParser` to parse the documents into nodes and `ServiceContext` to define the rules (eg. LLM API key, chunk size, etc.):
Next, we need to define some basic rules and parse the documents into nodes. We will use the `SimpleNodeParser` to parse the documents into nodes and `Settings` to define the rules (eg. LLM API key, chunk size, etc.):
```ts
const nodeParser = new SimpleNodeParser({
Settings.llm = new OpenAI();
Settings.nodeParser = new SimpleNodeParser({
chunkSize: 1024,
});
const serviceContext = serviceContextFromDefaults({
nodeParser,
llm: new OpenAI(),
});
```
## Creating Indices
@@ -52,13 +48,8 @@ const serviceContext = serviceContextFromDefaults({
Next, we need to create some indices. We will create a `VectorStoreIndex` and a `SummaryIndex`:
```ts
const vectorIndex = await VectorStoreIndex.fromDocuments(documents, {
serviceContext,
});
const summaryIndex = await SummaryIndex.fromDocuments(documents, {
serviceContext,
});
const vectorIndex = await VectorStoreIndex.fromDocuments(documents);
const summaryIndex = await SummaryIndex.fromDocuments(documents);
```
## Creating Query Engines
@@ -88,7 +79,6 @@ const queryEngine = RouterQueryEngine.fromDefaults({
description: "Useful for retrieving specific context from Abramov",
},
],
serviceContext,
});
```
@@ -117,34 +107,23 @@ import {
SimpleNodeParser,
SummaryIndex,
VectorStoreIndex,
serviceContextFromDefaults,
Settings,
} from "llamaindex";
Settings.llm = new OpenAI();
Settings.nodeParser = new SimpleNodeParser({
chunkSize: 1024,
});
async function main() {
// Load documents from a directory
const documents = await new SimpleDirectoryReader().loadData({
directoryPath: "node_modules/llamaindex/examples",
});
// Parse the documents into nodes
const nodeParser = new SimpleNodeParser({
chunkSize: 1024,
});
// Create a service context
const serviceContext = serviceContextFromDefaults({
nodeParser,
llm: new OpenAI(),
});
// Create indices
const vectorIndex = await VectorStoreIndex.fromDocuments(documents, {
serviceContext,
});
const summaryIndex = await SummaryIndex.fromDocuments(documents, {
serviceContext,
});
const vectorIndex = await VectorStoreIndex.fromDocuments(documents);
const summaryIndex = await SummaryIndex.fromDocuments(documents);
// Create query engines
const vectorQueryEngine = vectorIndex.asQueryEngine();
@@ -162,7 +141,6 @@ async function main() {
description: "Useful for retrieving specific context from Abramov",
},
],
serviceContext,
});
// Query the router query engine
+1 -1
View File
@@ -11,7 +11,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Fetch nodes!
const nodesWithScore = await retriever.retrieve("query string");
const nodesWithScore = await retriever.retrieve({ query: "query string" });
```
## API Reference
+29
View File
@@ -14,6 +14,9 @@ Configure a variable once, and you'll be able to do things like the following:
Each provider has similarities and differences. Take a look below for the full set of guides for each one!
- [OpenLLMetry](#openllmetry)
- [Langtrace](#langtrace)
## OpenLLMetry
[OpenLLMetry](https://github.com/traceloop/openllmetry-js) is an open-source project based on OpenTelemetry for tracing and monitoring
@@ -33,3 +36,29 @@ traceloop.initialize({
disableBatch: true,
});
```
## Langtrace
Enhance your observability with Langtrace, a robust open-source tool supports OpenTelemetry and is designed to trace, evaluate, and manage LLM applications seamlessly. Langtrace integrates directly with LlamaIndex, offering detailed, real-time insights into performance metrics such as accuracy, evaluations, and latency.
#### Install
- Self-host or sign-up and generate an API key using [Langtrace](https://www.langtrace.ai) Cloud
```bash
npm install @langtrase/typescript-sdk
```
#### Initialize
```js
import * as Langtrace from "@langtrase/typescript-sdk";
Langtrace.init({ api_key: "<YOUR_API_KEY>" });
```
Features:
- OpenTelemetry compliant, ensuring broad compatibility with observability platforms.
- Provides comprehensive logs and detailed traces of all components.
- Real-time monitoring of accuracy, evaluations, usage, costs, and latency.
- For more configuration options and details, visit [Langtrace Docs](https://docs.langtrace.ai/introduction).
+2
View File
@@ -0,0 +1,2 @@
label: Recipes
position: 3
+14
View File
@@ -0,0 +1,14 @@
# Cost Analysis
This page shows how to track LLM cost using APIs.
## Callback Manager
The callback manager is a class that manages the callback functions.
You can register `llm-start`, `llm-end`, and `llm-stream` callbacks to the callback manager for tracking the cost.
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/recipes/cost-analysis";
<CodeBlock language="ts">{CodeSource}</CodeBlock>
+1 -1
View File
@@ -163,7 +163,7 @@ const config = {
"docusaurus-plugin-typedoc",
{
entryPoints: ["../../packages/core/src/index.ts"],
tsconfig: "../../packages/core/tsconfig.json",
tsconfig: "../../tsconfig.json",
readme: "none",
sourceLinkTemplate:
"https://github.com/run-llama/LlamaIndexTS/blob/{gitRevision}/{path}#L{line}",
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// جلب العقد!
const nodesWithScore = await retriever.retrieve("سلسلة الاستعلام");
const nodesWithScore = await retriever.retrieve({ query: "سلسلة الاستعلام" });
```
## مرجع الواجهة البرمجية (API Reference)
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Извличане на върхове!
const nodesWithScore = await retriever.retrieve("query string");
const nodesWithScore = await retriever.retrieve({ query: "query string" });
```
## API Reference (API справка)
@@ -13,7 +13,7 @@ const recuperador = vector_index.asRetriever();
recuperador.similarityTopK = 3;
// Obteniu els nodes!
const nodesAmbPuntuació = await recuperador.retrieve("cadena de consulta");
const nodesAmbPuntuació = await recuperador.retrieve({ query: "cadena de consulta" });
```
## Referència de l'API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Získání uzlů!
const nodesWithScore = await retriever.retrieve("dotazovací řetězec");
const nodesWithScore = await retriever.retrieve({ query: "dotazovací řetězec" });
```
## API Reference (Odkazy na rozhraní)
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Hent noder!
const nodesWithScore = await retriever.retrieve("forespørgselsstreng");
const nodesWithScore = await retriever.retrieve({ query: "forespørgselsstreng" });
```
## API Reference
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Knoten abrufen!
const nodesWithScore = await retriever.retrieve("Abfragezeichenfolge");
const nodesWithScore = await retriever.retrieve({ query: "Abfragezeichenfolge" });
```
## API-Referenz
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Ανάκτηση κόμβων!
const nodesWithScore = await retriever.retrieve("συμβολοσειρά ερωτήματος");
const nodesWithScore = await retriever.retrieve({ query: "συμβολοσειρά ερωτήματος" });
```
## Αναφορά API
@@ -13,7 +13,7 @@ const recuperador = vector_index.asRetriever();
recuperador.similarityTopK = 3;
// ¡Obtener nodos!
const nodosConPuntuación = await recuperador.retrieve("cadena de consulta");
const nodosConPuntuación = await recuperador.retrieve({ query: "cadena de consulta" });
```
## Referencia de la API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Too sõlmed!
const nodesWithScore = await retriever.retrieve("päringu string");
const nodesWithScore = await retriever.retrieve({ query: "päringu string" });
```
## API viide
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// بازیابی گره ها!
const nodesWithScore = await retriever.retrieve("رشته پرس و جو");
const nodesWithScore = await retriever.retrieve({ query: "رشته پرس و جو" });
```
## مرجع API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Hae solmut!
const nodesWithScore = await retriever.retrieve("kyselymerkkijono");
const nodesWithScore = await retriever.retrieve({ query: "kyselymerkkijono" });
```
## API-viite
@@ -11,7 +11,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Récupérer les nœuds !
const nodesWithScore = await retriever.retrieve("chaîne de requête");
const nodesWithScore = await retriever.retrieve({ query: "chaîne de requête" });
```
## Référence de l'API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// אחזור צמתים!
const nodesWithScore = await retriever.retrieve("מחרוזת שאילתה");
const nodesWithScore = await retriever.retrieve({ query: "מחרוזת שאילתה" });
```
## מדריך לממשק API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// नोड्स प्राप्त करें!
const nodesWithScore = await retriever.retrieve("क्वेरी स्ट्रिंग");
const nodesWithScore = await retriever.retrieve({ query: "क्वेरी स्ट्रिंग" });
```
## एपीआई संदर्भ (API Reference)
@@ -13,7 +13,7 @@ const dohvatnik = vector_index.asRetriever();
dohvatnik.similarityTopK = 3;
// Dohvati čvorove!
const čvoroviSaRezultatom = await dohvatnik.retrieve("upitni niz");
const čvoroviSaRezultatom = await dohvatnik.retrieve({ query: "upitni niz" });
```
## API Referenca
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Node-ok lekérése!
const nodesWithScore = await retriever.retrieve("lekérdezési karakterlánc");
const nodesWithScore = await retriever.retrieve({ query: "lekérdezési karakterlánc" });
```
## API Referencia
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Mengambil node!
const nodesWithScore = await retriever.retrieve("string query");
const nodesWithScore = await retriever.retrieve({ query: "string query" });
```
## Referensi API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Recupera i nodi!
const nodesWithScore = await retriever.retrieve("stringa di query");
const nodesWithScore = await retriever.retrieve({ query: "stringa di query" });
```
## Riferimento API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// ノードを取得します!
const nodesWithScore = await retriever.retrieve("クエリ文字列");
const nodesWithScore = await retriever.retrieve({ query: "クエリ文字列" });
```
## API リファレンス
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// 노드를 가져옵니다!
const nodesWithScore = await retriever.retrieve("쿼리 문자열");
const nodesWithScore = await retriever.retrieve({ query: "쿼리 문자열" });
```
## API 참조
@@ -13,7 +13,7 @@ const gavėjas = vector_index.asRetriever();
gavėjas.similarityTopK = 3;
// Išgaunami mazgai!
const mazgaiSuRezultatu = await gavėjas.retrieve("užklausos eilutė");
const mazgaiSuRezultatu = await gavėjas.retrieve({ query: "užklausos eilutė" });
```
## API nuorodos (API Reference)
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Haal knooppunten op!
const nodesWithScore = await retriever.retrieve("zoekopdracht");
const nodesWithScore = await retriever.retrieve({ query: "zoekopdracht" });
```
## API Referentie
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Hent noder!
const nodesWithScore = await retriever.retrieve("spørringsstreng");
const nodesWithScore = await retriever.retrieve({ query: "spørringsstreng" });
```
## API-referanse
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Pobierz węzły!
const nodesWithScore = await retriever.retrieve("ciąg zapytania");
const nodesWithScore = await retriever.retrieve({ query: "ciąg zapytania" });
```
## Dokumentacja interfejsu API
@@ -13,7 +13,7 @@ const recuperador = vector_index.asRetriever();
recuperador.similarityTopK = 3;
// Buscar nós!
const nósComPontuação = await recuperador.retrieve("string de consulta");
const nósComPontuação = await recuperador.retrieve({ query: "string de consulta" });
```
## Referência da API
@@ -13,7 +13,7 @@ const recuperator = vector_index.asRetriever();
recuperator.similarityTopK = 3;
// Preia nodurile!
const noduriCuScor = await recuperator.retrieve("șir de interogare");
const noduriCuScor = await recuperator.retrieve({ query: "șir de interogare" });
```
## Referință API
@@ -13,7 +13,7 @@ const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
// Получение узлов!
const nodesWithScore = await retriever.retrieve("строка запроса");
const nodesWithScore = await retriever.retrieve({ query: "строка запроса" });
```
## Справочник по API

Some files were not shown because too many files have changed in this diff Show More