Compare commits

...

218 Commits

Author SHA1 Message Date
github-actions[bot] c69e740c56 Release 0.5.6 (#1048)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-18 15:20:19 -07:00
Alex Yang 6cf6ae631c feat: abstract query type (#1052) 2024-07-18 13:27:02 -07:00
Alex Yang 2562244fb6 feat: add gpt4o-mini (#1057) 2024-07-18 12:50:51 -07:00
Thuc Pham a2691ee163 fix: always return false when key not exist in metadata (#1056) 2024-07-18 22:52:00 +07:00
Marcus Schiesser ab700ea546 fix: Add missing authentication to LlamaCloudIndex.fromDocuments (#1055) 2024-07-18 16:32:07 +07:00
Marcus Schiesser e775afc3f2 docs: clarify similarityTopK usage (#1053) 2024-07-18 16:24:49 +07:00
Alex Yang 92f07824a7 feat: use query bundle (#702) 2024-07-17 20:17:06 -07:00
Igor Soares b7cfe5bce6 fix: passing max_token option to replicate's api call (#1050)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-07-17 12:00:30 -07:00
Chris Paganon 3ccfb28352 docs: fix deprecated similarityTopK for retriever (#1049) 2024-07-17 11:59:28 -07:00
Thuc Pham 325aa51e51 feat: implement Jina embedding through Jina api (#995)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-07-17 20:57:14 +07:00
Marcus Schiesser d1d9bd6e41 docs: add metadata filter operators (#1047) 2024-07-17 17:00:37 +07:00
github-actions[bot] 9a71382243 Release 0.5.5 (#1046)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-17 16:26:38 +07:00
Thuc Pham b974eea341 feat: add MetadataFilter for SimpleVectorStore and Milvus (#1030)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-07-17 16:21:21 +07:00
github-actions[bot] e82632f83d Release 0.5.4 (#1043)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-16 14:53:20 -07:00
Fabian Wimmer 1a65ead849 feat: add vendorMultiModal params to LlamaParseReader (#1042) 2024-07-16 14:20:34 -07:00
Alex Yang 50b7d1b7bb refactor: put embedding into core (#1041) 2024-07-16 10:49:03 -07:00
github-actions[bot] 09beb72f5b Release 0.5.3 (#1038)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-16 10:25:27 -07:00
Fabian Wimmer 9bbbc67c8e feat: add a reader for Discord messages (#1040) 2024-07-16 10:19:48 -07:00
Brian Peiris b3681bf681 fix: DataCloneError when using FunctionTool (#1037) 2024-07-14 15:24:49 -07:00
Alex Yang b548b1443b chore: bump version (#1032) 2024-07-12 15:14:27 -07:00
github-actions[bot] 0e980d962d Release 0.5.2 (#1035)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-12 11:44:32 -07:00
Alex Yang 3ed6acc6a6 chore: bump cloud api (#1036) 2024-07-12 11:21:37 -07:00
Parham Saidi 56746c240f fix: bedrock handle empty content and added max tokens export (#1034) 2024-07-12 09:47:49 -07:00
Alex Yang 5c1c2c7f5b ci: only commit lock file (#1031) 2024-07-10 10:17:35 -07:00
github-actions[bot] a699086f46 Release 0.5.1 (#1028)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-09 15:36:20 -07:00
Alex Yang 454c204112 chore: bump version (#1029) 2024-07-09 13:42:09 -07:00
Julius Lipp 277468160d feat: add mixedbread ai integration (#953) 2024-07-09 09:36:43 -07:00
Ranjan Mangla a0f424e592 fix: corrected the regex in the ReactAgent (#1022)
Signed-off-by: ranjanmangla1 <ranjanmangla1@gmail.com>
2024-07-09 08:55:38 -07:00
github-actions[bot] 3ae832ca28 Release 0.5.0 (#1024)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: himself65 <himself65@users.noreply.github.com>
2024-07-08 17:16:46 -07:00
Alex Yang 16ef5dd631 feat: simplify callback manager (#1027) 2024-07-08 16:44:54 -07:00
Alex Yang c4bd0a5215 refactor: move llm & callback manager to core module (#1026) 2024-07-08 15:48:59 -07:00
Alex Yang f5c8ca7dfb chore: use bunchee bundler for all (#1025) 2024-07-08 09:45:55 -07:00
Sacha Bron 36ddec44af fix: typo in custom page separator parameter for LlamaParse (#1023) 2024-07-08 09:27:51 -07:00
github-actions[bot] c147d8a271 Release 0.4.14 (#1021)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-05 15:26:31 -07:00
Alex Yang 1c444d58b6 feat(cloud): update openapi.json (#1020) 2024-07-05 15:01:22 -07:00
github-actions[bot] 1f910f7566 Release 0.4.13 (#1016)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-05 11:44:37 -07:00
Thuc Pham 99826cff43 fix: missing dispatch retrieve event on llamacloud retriever (#1018) 2024-07-05 20:43:26 +07:00
Fabian Wimmer e8f8bea969 feat: add boundingBox and targetPages to LlamaParseReader (#1017) 2024-07-05 14:32:26 +07:00
Fabian Wimmer 304484b77a feat: add ignoreErrors flag to LlamaParse (#959)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
2024-07-04 20:51:05 +07:00
abgita 29fed77d58 Fixed a typo in the retriever description (#1009) 2024-07-04 20:15:20 +07:00
Alex Yang db070588c8 ci: fix setup pnpm (#1014) 2024-07-03 12:11:48 -07:00
github-actions[bot] 76deca7fea Release 0.4.12 (#1013)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-03 10:24:22 -07:00
Alex Yang f326ab86d2 chore: bump version 2024-07-03 10:20:46 -07:00
Cássio de Freitas e Silva ca8d9709e0 feat: add support for Meta LLMs in AWS Bedrock (#960) 2024-07-03 01:27:58 -07:00
github-actions[bot] e0af059221 Release 0.4.11 (#1008)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-02 15:07:03 -07:00
Alex Yang 8bf5b4acfd fix: llama parse input spreadsheet (#1007) 2024-07-02 14:48:51 -07:00
Alex Yang 93a003baa0 ci: pre release (#1005) 2024-07-02 00:40:45 -07:00
github-actions[bot] 5d9b0bd3f0 Release 0.4.10 (#1003)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-01 23:59:52 -07:00
Alex Yang 9a5525e1b3 refactor(core): migrate llms type (#1002) 2024-07-01 20:13:35 -07:00
Peron 7dce3d28d3 fix: disable External Filters for Gemini (#994)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-07-01 18:28:22 -07:00
github-actions[bot] d4c1482c1c Release 0.4.9 (#1001)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-01 17:20:47 -07:00
Alex Yang 3a96a483a6 fix: anthropic image input (#999) 2024-07-01 16:03:30 -07:00
Alex Yang 7467fce2d4 docs: remove cloudflare worker section (#1000) 2024-07-01 16:01:55 -07:00
github-actions[bot] 06af08cac4 Release 0.4.8 (#998)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-01 15:07:50 -07:00
Alex Yang 83ebdfb1c5 fix: next.js binding (#997) 2024-07-01 14:52:57 -07:00
github-actions[bot] 835b1ac000 Release 0.4.7 (#986)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-28 22:58:14 -07:00
Alex Yang f10b41dbc1 chore: fix release files (#991) 2024-06-28 13:36:55 -07:00
Wassim Chegham 41fe871e2f feat: add support for azure dynamic session tool (#942)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
2024-06-27 13:18:05 -07:00
Alex Yang 321c39ddc7 fix: generate api as class (#988) 2024-06-27 09:58:00 -07:00
Alex Yang f7f1af0139 fix: llamacloud sdk edge case (#985) 2024-06-26 23:10:04 -07:00
github-actions[bot] a8c9c279d6 Release 0.4.6 (#981)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-26 17:22:28 -07:00
Alex Yang eece129831 feat: migrate @llamaindex/cloud package (#984) 2024-06-26 16:51:47 -07:00
Alex Yang 80e4f51a83 fix: remove check-minor-version.mjs
We no longer need that
2024-06-26 15:31:08 -07:00
Alex Yang 22ff0837c3 feat: init @llamaindex/core (#938) 2024-06-26 15:28:57 -07:00
Alex Yang 74d7e05bcb ci: continue when commit lockfile error (#982) 2024-06-26 11:06:06 -07:00
Parham Saidi 1feb23bb83 feat: added Gemini tool calling support (#973) 2024-06-26 10:49:11 -07:00
Marcus Schiesser 08c55ec258 fix: Add metadata to PDFs and use Uint8Array for readers content (#980) 2024-06-26 10:16:23 -07:00
github-actions[bot] 394e797567 Release 0.4.5 (#979)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-26 17:42:19 +07:00
Parham Saidi 6c3e5d08b8 fix: switch to correct reference for a static function (#978) 2024-06-26 17:35:22 +07:00
github-actions[bot] 6e19482814 Release 0.4.4 (#977)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-26 14:46:48 +07:00
Marcus Schiesser 42eb73a08f fix: IngestionPipeline not working without vectorStores (#976) 2024-06-26 14:30:58 +07:00
github-actions[bot] 4b59ffee45 Release 0.4.3 (#971)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-25 15:38:10 -07:00
Alex Yang d4e853c8b5 fix: stronger type declaration (#975) 2024-06-25 15:22:13 -07:00
Alex Yang a94b8ec3d2 chore: fix misc (#974) 2024-06-25 14:41:26 -07:00
Alex Yang ed57e6b7be docs: remove i18n temporary (#972) 2024-06-25 14:00:07 -07:00
Alex Yang 05f006e7e1 chore: fix llamaindex version 2024-06-25 12:21:22 -07:00
Alex Yang c3aed72c29 chore: skip install when releasing new version 2024-06-25 12:08:53 -07:00
Alex Yang 7deba94e6b chore: fix lock file 2024-06-25 11:57:04 -07:00
github-actions[bot] d15811f09f Release 0.4.2 (#966)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-25 11:23:01 -07:00
Tasmiyah Iqbal 2ef62a93bb feat: added support for embeddings via HuggingFace Inference API (#929) 2024-06-25 11:16:41 -07:00
Fabian Wimmer 9015aea527 docs: LlamaParse JSON + SimpleDirectoryReader (#970) 2024-06-25 11:16:27 -07:00
Emanuel Ferreira 4bb401e6f9 feat: upgrade llamacloud index (#944)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-25 10:52:06 -07:00
Parham Saidi a87a4d1222 feat: tool calling for Bedrock's Claude and General LLM Agent (#955) 2024-06-25 10:51:40 -07:00
Marcus Schiesser d27ad16335 test: add e2e test for nextjs/node with tokenizer (#963) 2024-06-25 10:02:01 -07:00
Marcus Schiesser 20498a2bce fix: use tiktoken instead of tiktoken/lite (#967) 2024-06-25 09:51:08 -07:00
Andy Garvin 0730140e62 fix: include node relationships when converting jsonToDoc (#968) 2024-06-25 22:59:16 +07:00
Andy Garvin 810711d355 docs: change references from core package to llamaindex (#969) 2024-06-25 22:55:37 +07:00
Marcus Schiesser f3b34b457c docs: add changeset (#965) 2024-06-25 21:36:00 +07:00
Fabian Wimmer 6f4b9f3372 docs: fix broken links, add API References (#962) 2024-06-24 19:10:16 -07:00
Fabian Wimmer 01658fdb31 docs: update data loaders (#961) 2024-06-24 10:45:17 -07:00
Alex Yang 66c26d9cce fix: json import (#958) 2024-06-21 11:27:08 -07:00
Marcus Schiesser a4060a7914 docs: update anthropic examples to use claude 3.5 (#954) 2024-06-21 17:27:56 +07:00
github-actions[bot] 469e438741 Release 0.4.1 (#949)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-21 17:26:01 +07:00
Marcus Schiesser 56fabbb4f5 fix: Release env changes to tokenizer (#952) 2024-06-21 16:58:02 +07:00
Alex Yang dfd8cc1ba4 chore: fix new-version script (#950) 2024-06-20 16:34:09 -07:00
Fabian Wimmer cba54061a2 fix: every Llama Parse job being called "blob" (#946)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-20 16:32:20 -07:00
Peter Goldstein ed467a9889 feat: add Anthropic Claude 3.5 Sonnet model (#948) 2024-06-20 16:21:58 -07:00
Alex Yang 3c4791007f fix: groq llm (#947) 2024-06-20 16:19:55 -07:00
Alex Yang 8f16a179c3 chore: fix lock 2024-06-20 12:51:34 -07:00
github-actions[bot] ce3a4cac6c Release 0.4.0 (#923)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-20 12:38:05 -07:00
Alex Yang be46044b98 build: fix check-minor-version.mjs 2024-06-20 12:31:13 -07:00
Alex Yang 154c7f8e36 chore: bump version (#945) 2024-06-20 12:25:59 -07:00
Alex Yang 8b6c2b45a6 chore: fix version release (#937) 2024-06-17 16:42:38 -07:00
Parham Saidi b1a4a74270 docs: updated Bedrock Opus region and added a basic README (#935) 2024-06-17 14:34:14 -07:00
Alex Yang d7fb095fbd refactor: rename directory core to llamaindex (#936) 2024-06-17 14:33:53 -07:00
Alex Yang 58791d4bdd fix: tokenizer type (#934) 2024-06-17 10:34:37 -07:00
Parham Saidi d3b635b193 fix: agents to use chat history (#933) 2024-06-17 10:33:57 -07:00
Marcus Schiesser 436bc41f82 refactor: unify response and agent response (#930) 2024-06-17 09:01:08 -07:00
Vishwasa Navada K 834f49275a docs: fixed the broken link on Getting Started Section (#932) 2024-06-17 22:56:10 +07:00
Marcus Schiesser a44e54f9ec feat: truncate embedding tokens (#918)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-15 02:13:39 +08:00
Wassim Chegham a51ed8dd70 feat: add support for managed identity for Azure OpenAI (#922)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-11 16:32:39 -07:00
Fabian Wimmer c8cfc6c06d fix: LlamaParse json mode returns array + basic example (#914)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-11 10:56:52 -07:00
github-actions[bot] 83b2f0b0af Release 0.3.17 (#920)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 10:52:40 -07:00
Alex Yang 1a6abb38bc build: community package cleanup before release (#897) 2024-06-11 10:47:35 -07:00
Fabian Wimmer 6bc5bddb59 feat: add new options to LlamaParseReader (#915) 2024-06-11 16:31:01 +07:00
Alex Yang e6d6576b2f chore: use unpdf (#849) 2024-06-10 16:45:09 -07:00
Alex Yang bf25ff6104 fix: polyfill for cloudflare worker (#919) 2024-06-10 14:08:47 -07:00
Talha Jubair Siam 32ad0992cf docs : fix correctness and relevancy example (#913) 2024-06-10 20:19:06 +07:00
Marcus Schiesser af650343d9 fix: remove debugger statement (#917) 2024-06-10 20:14:26 +07:00
Thuc Pham f6f4ca44bd feat: add gpt-4o tool call fail example (#916)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-10 17:29:25 +07:00
github-actions[bot] 9aa918f026 Release 0.3.16 (#896)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-06 07:20:58 -07:00
Marcus Schiesser 00a92cd125 fix: custom reader example 2024-06-06 12:04:27 +02:00
Marcus Schiesser 73819bf19d feat: Unify metadata and ID handling of documents, allow files to be read by Buffer 2024-06-06 11:51:54 +02:00
Marcus Schiesser d10cca28fc chore: use FileReader interface when possible (#912) 2024-06-06 15:37:20 +07:00
Alex Yang 1378ec4e50 feat: set default model to gpt-4o (#911) 2024-06-05 22:44:52 -07:00
Fabian Wimmer 24a9d1e816 feat: add json mode and image retrieval to LlamaParse (#910)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-05 13:50:51 -07:00
Yi Ding b100684bad chore: bump version (#892)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-05 13:50:33 -07:00
Alex Yang c375cd5c6b fix: multiple tool call (#905) 2024-06-05 10:23:41 -07:00
Fabian Wimmer 45952dee59 feat: add parallel processing to SimpleDirectoryReader (#908)
Co-authored-by: Alex Yang <himself65@outlook.com>
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-05 23:17:47 +07:00
Marcus Schiesser 6db7f23ec7 Revert "feat: add parallel processing to SimpleDirectoryReader (#883)"
This reverts commit da1f025229.
2024-06-05 13:35:58 +02:00
Marcus Schiesser 0721a84900 fix: ignore empty vector store (#861) 2024-06-04 10:26:16 -07:00
Marcus Schiesser 4d4bd85448 fix: calling tools with large inputs (#901) 2024-06-04 09:07:19 -07:00
Philipp Serrer 11ae9267ae feat: add numCandidates setting to MongoDBAtlasVectorStore for tuning queries (#893)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
2024-06-04 16:11:54 +07:00
Fabian Wimmer 174cb3e6da docs: update data loader documentation (#900)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 13:50:48 -07:00
Alex Yang 5ab5e5191d fix: empty prefix with inputs (#899) 2024-06-03 12:11:57 -07:00
Parham Saidi 54230f0477 feat: Gemini latest GA released models (#898)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 11:41:15 -07:00
Oguz Vuruskaner 3d484da1c5 feat: DeepInfra Embeddings implementation (#890)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 11:34:07 -07:00
Oguz Vuruskaner 631f0001ef feat: DeepInfra LLM implementation (#894)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 11:21:23 -07:00
Alex Yang 060b700e09 chore: fix changelog 2024-06-03 09:53:15 -07:00
justinmann 83c24f4d50 cannot pass embedModel to MongoDBAtlasVectorStore (#887) 2024-06-03 23:08:33 +07:00
Parham Saidi 883266939e feat: Bedrock support added, only for Anthropic models (#847)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 09:07:17 -07:00
Philipp Serrer a29d8351c8 fix: setDocumentHash should be async (#868) 2024-06-03 09:05:23 -07:00
Fabian Wimmer da1f025229 feat: add parallel processing to SimpleDirectoryReader (#883)
Co-authored-by: Alex Yang <himself65@outlook.com>
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-03 23:01:27 +07:00
Fabian Wimmer 6b1ded41a9 feat: LlamaParse: add gpt4o-mode, invalidate cache, skip diagonal text, update supported file types (#889)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
2024-06-03 22:22:18 +07:00
github-actions[bot] e01cc053e3 Release 0.3.15 (#884)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-03 21:29:46 +07:00
Marcus Schiesser 6e156edb11 feat: use images in context chat engine (#886) 2024-06-03 21:24:43 +07:00
Marcus Schiesser 0b519958e9 chore: downgrade changeset to patch 2024-06-03 11:18:15 +02:00
Philipp Serrer 265976df12 fix: incorrect hash because of missing params in decorator (#891) 2024-05-28 16:05:24 -07:00
Marcus Schiesser 7e1b96a2db fix: default to Settings.llm (#885) 2024-05-24 22:15:09 +07:00
Marcus Schiesser 8e26f753b7 feat: Add retrieval for images using multi-modal messages (#870) 2024-05-24 22:08:20 +07:00
github-actions[bot] 31e3251435 Release 0.3.14 (#878)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-23 16:00:09 -07:00
Yi Ding 058c275a72 New azure versions (#877) 2024-05-23 09:27:04 -07:00
Parham Saidi 6ff7576eb9 feature: added the latest gpt-4o to azure (#875) 2024-05-23 09:22:25 -07:00
Parham Saidi 94543decad feature: added latest gemini pro models (#876) 2024-05-23 09:21:52 -07:00
Marcus Schiesser b963782137 docs: reorder installation steps (#869) 2024-05-22 06:54:27 -07:00
github-actions[bot] 52c47cada3 Release 0.3.13 (#856)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-22 16:31:23 +07:00
Marcus Schiesser 9216312b11 docs: fix changsets and format 2024-05-22 11:25:09 +02:00
Philipp Serrer 660a2b3495 fix: text before heading in markdown reader (#864) 2024-05-22 16:49:52 +08:00
Henry Heng 6d21092805 Fix/Agent llm initialization (#866) 2024-05-21 15:35:18 -07:00
Laurie Voss fb2c1fa917 Docs update: (#857)
Co-authored-by: Yi Ding <yi.s.ding@gmail.com>
2024-05-20 13:53:23 -07:00
Parham Saidi 37525df529 feat: Gemini Access via Vertex AI (#838) 2024-05-20 17:09:25 +07:00
Marcus Schiesser a1f24753d9 docs: systemprompt changeset 2024-05-20 11:05:20 +02:00
Thuc Pham aa0f586330 feat: allow adding system prompt to chat engine (#855)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-05-20 15:57:58 +07:00
Alex Yang ff03139799 Revert "fix: cloudflare dev (#851)"
`@xenova/transformers` only ship node.js and browser output, it's not possible to load this in edge runtime and workerd

This reverts commit 34fb1d8992.
2024-05-17 12:11:31 -07:00
Marcus Schiesser 1b1081b9c9 feat: bind embedding models to vec stores and use vector store map (#821)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-05-17 22:30:33 +07:00
Thuc Pham 047ae07e74 feat: add local hugging face LLM (#854) 2024-05-17 16:01:10 +07:00
github-actions[bot] d8aa29a115 Release 0.3.12 (#852)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-16 17:45:09 -07:00
Alex Yang 34fb1d8992 fix: cloudflare dev (#851) 2024-05-16 17:25:32 -07:00
github-actions[bot] c517f35526 Release 0.3.11 (#835)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-16 16:35:57 -07:00
Alex Yang e072c45393 fix: remove non-standard API pipeline (#850) 2024-05-16 16:31:48 -07:00
Alex Yang 51241865f8 feat: improve BaseNode (#848) 2024-05-16 16:29:16 -07:00
Thuc Pham 10c83485d2 fix: allow custom task query for agents (#846) 2024-05-16 12:48:50 -07:00
Alex Yang 1e6a18ad2d build: fix jsr release 2024-05-15 18:03:22 -07:00
Alex Yang 9e133ac10d refactor: remove defaultFS from parameters (#841) 2024-05-15 17:37:51 -07:00
Alex Yang ba217eec2c chore: remove test.py (#842) 2024-05-15 16:47:39 -07:00
Alex Yang 64ef70b735 build: ignore example project 2024-05-15 16:10:08 -07:00
Alex Yang 6615aaa4ab chore: use pnpm format
Using `pnpm format:write` will cause two commits which is not expected
2024-05-15 13:11:53 -07:00
Parham Saidi 447105a6dc fix: Gemini text chat - prevent sending broken messageContent and history (#822) 2024-05-15 16:33:55 +07:00
Huu Le (Lee) 320be3fab6 chore: rollback chromadb version to 1.7.3 (#834)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-05-14 16:07:44 +07:00
Alex Yang bbd9f85a45 chore: bump openai (#833) 2024-05-13 12:53:12 -07:00
github-actions[bot] 5f29ba5e2c Release 0.3.10 (#832)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-13 10:53:59 -07:00
Alex Yang 4aba02eb82 feat: support gpt4-o (#831) 2024-05-13 10:51:10 -07:00
Alex Yang 75736ad01b build: release output files 2024-05-10 14:08:21 -07:00
Alex Yang 68a508fcd0 test: fix check host (#829) 2024-05-10 11:07:40 -07:00
github-actions[bot] 6281fc8c91 Release 0.3.9 (#828)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-09 11:16:08 -07:00
Alex Yang c3747d092a feat: add nextjs plugin for llamaindex (#824) 2024-05-09 02:29:11 -05:00
Marcus Schiesser 24a39aefb8 feat: send retrieve start and end events (#827) 2024-05-09 14:16:34 +07:00
Alex Yang 0b1299036d chore: bump version (#826) 2024-05-09 00:11:21 -05:00
Alex Yang 2c8d7941f0 ci: fix publish (#825) 2024-05-08 23:30:17 -05:00
Fabian Wimmer a1a72ab223 feat: LlamaParseReader: update Supported File Types to match python version (#823) 2024-05-09 09:51:01 +07:00
Alex Yang b99ab056d1 feat: init @llamaindex/autotool (#819) 2024-05-08 02:56:42 -05:00
github-actions[bot] 1a45b44307 Release 0.3.8 (#816)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-07 13:05:08 -05:00
JT-Dev-215 804c57519f fix: PGVector similarity score (#817) 2024-05-07 12:54:13 -05:00
Marcus Schiesser ce94780b95 feat: add page number to read PDFs (#815) 2024-05-07 10:45:55 +07:00
ezirmusitua 645fcf6c24 fix: use sha256 hash value as the Document.id_ in MarkdownReader (#768)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-05-07 10:07:39 +07:00
Marcus Schiesser e37fa5d9ca docs: add retriever tool example (#814) 2024-05-07 09:41:14 +07:00
github-actions[bot] 97e4ecd5b8 Release 0.3.7 (#812)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-05 22:11:54 -05:00
Alex Yang b6a660651b feat: allow to change ollama port (#811) 2024-05-05 19:08:00 -05:00
github-actions[bot] 456d3fb0b3 Release 0.3.6 (#810)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-05 18:40:58 -05:00
Alex Yang efa326a871 chore: update package.json and usage of lodash (#809) 2024-05-05 18:30:46 -05:00
Alex Yang 5765b637ce build: fix jsr release 2024-05-03 18:21:08 -05:00
github-actions[bot] 72687b4f69 Release 0.3.5 (#805)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-03 18:16:39 -05:00
Alex Yang 0c67e1f8f3 build: fix new version script 2024-05-03 18:13:24 -05:00
Alex Yang 4a0619758a chore: fix jsr.json 2024-05-03 18:09:05 -05:00
Alex Yang bc7a11cdbe fix: inline ollama build (#807) 2024-05-03 18:03:23 -05:00
Alex Yang 5596e31947 feat: improve @llamaindex/env (#787) 2024-05-03 18:03:14 -05:00
Alex Yang 2fe2b813ba fix: filter with multiple filters in ChromaDB (#784) 2024-05-03 17:07:45 -05:00
Alex Yang be5df5b01b fix(core): multple chat on anthropic agent (#799) 2024-05-03 16:18:46 -05:00
JT-Dev-215 e74fe88342 fix: change <-> to <=> in the SELECT query (#804)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-05-03 12:10:36 -05:00
github-actions[bot] f1862ccab1 Release 0.3.4 (#797)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-02 20:02:06 -05:00
Yi Ding 9e74a4327f feat: add top k to asQueryEngine (#801)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-05-02 19:59:36 -05:00
Alex Yang 5e61934d5a fix: remove clone object in CallbackManager.dispatchEvent (#802) 2024-05-02 19:55:41 -05:00
Alex Yang 2008efe0ee feat: add verbose mode to Agent (#800) 2024-05-02 19:54:05 -05:00
Alex Yang ee719a1fda fix: streaming for ReAct Agent (#798) 2024-05-02 18:52:18 -05:00
Alex Yang 1dce275a7c fix: export StorageContext on edge runtime (#793) 2024-05-02 14:52:16 -05:00
Thuc Pham d10533ef77 feat: add hugging face llm (#796) 2024-05-02 18:43:05 +08:00
github-actions[bot] 8aeb8ae690 Release 0.3.3 (#792)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-01 21:47:16 -05:00
Thuc Pham e8c41c5c27 fix: wrong gemini streaming chat response (#791) 2024-05-02 08:39:57 +07:00
1921 changed files with 83094 additions and 95320 deletions
+4 -1
View File
@@ -1,3 +1,5 @@
const { join } = require("node:path");
module.exports = {
root: true,
extends: [
@@ -6,7 +8,7 @@ module.exports = {
"plugin:@typescript-eslint/recommended-type-checked-only",
],
parserOptions: {
project: true,
project: join(__dirname, "tsconfig.eslint.json"),
__tsconfigRootDir: __dirname,
},
settings: {
@@ -23,6 +25,7 @@ module.exports = {
ignoreIIFE: true,
},
],
"no-debugger": "error",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
+28
View File
@@ -0,0 +1,28 @@
name: Publish Preview
on: [pull_request]
jobs:
pre_release:
name: Pre Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- 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
- name: Pre Release
run: pnpx pkg-pr-new publish ./packages/*
-36
View File
@@ -1,36 +0,0 @@
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 }}
+4 -4
View File
@@ -12,7 +12,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -26,12 +26,12 @@ jobs:
- name: Build tarball
run: |
pnpm pack
working-directory: packages/core
working-directory: packages/llamaindex
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "packages/core/llamaindex-*.tgz"
artifacts: "packages/llamaindex/llamaindex-*.tgz"
name: Release ${{ github.ref }}
bodyFile: "packages/core/CHANGELOG.md"
bodyFile: "packages/llamaindex/CHANGELOG.md"
token: ${{ secrets.GITHUB_TOKEN }}
+14 -1
View File
@@ -15,7 +15,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -55,3 +55,16 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Refs: https://github.com/changesets/changesets/issues/421
- name: Update lock file
continue-on-error: true
run: pnpm install --lockfile-only
- name: Commit lock file
continue-on-error: true
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update lock file"
branch: changeset-release/main
file_pattern: "pnpm-lock.yaml"
+24 -17
View File
@@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -60,7 +60,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -69,34 +69,35 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build --filter llamaindex
run: pnpm run build
- name: Use Build For Examples
run: pnpm link ../packages/core/
run: pnpm link ../packages/llamaindex/
working-directory: ./examples
- name: Run Type Check
run: pnpm run type-check
- name: Run Circular Dependency Check
run: pnpm run circular-check
working-directory: ./packages/core
run: pnpm dlx turbo run circular-check
- uses: actions/upload-artifact@v3
if: failure()
with:
name: typecheck-build-dist
path: ./packages/core/dist
path: ./packages/llamaindex/dist
if-no-files-found: error
e2e-core-examples:
e2e-llamaindex-examples:
strategy:
fail-fast: false
matrix:
packages:
- cloudflare-worker-agent
- nextjs-agent
- nextjs-edge-runtime
- waku-query-engine
- nextjs-node-runtime
# - waku-query-engine
runs-on: ubuntu-latest
name: Build Core Example (${{ matrix.packages }})
name: Build LlamaIndex Example (${{ matrix.packages }})
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -105,17 +106,17 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Build llamaindex
run: pnpm run build --filter llamaindex
run: pnpm run build
- name: Build ${{ matrix.packages }}
run: pnpm run build
working-directory: packages/core/e2e/examples/${{ matrix.packages }}
working-directory: packages/llamaindex/e2e/examples/${{ matrix.packages }}
typecheck-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -124,15 +125,21 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build --filter llamaindex
run: pnpm run build
- name: Copy examples
run: rsync -rv --exclude=node_modules ./examples ${{ runner.temp }}
- name: Pack @llamaindex/cloud
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/cloud
- name: Pack @llamaindex/core
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/core
- 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
working-directory: packages/llamaindex
- name: Install
run: npm add ${{ runner.temp }}/*.tgz
working-directory: ${{ runner.temp }}/examples
+3
View File
@@ -48,3 +48,6 @@ playwright/.cache/
# intellij
**/.idea
# generated API
packages/cloud/src/client
+1 -1
View File
@@ -1,3 +1,3 @@
pnpm format:write
pnpm format
pnpm lint
npx lint-staged
+3 -3
View File
@@ -6,7 +6,7 @@ This is a monorepo built with Turborepo
Right now there are two packages of importance:
packages/core which is the main NPM library llamaindex
packages/llamaindex which is the main NPM library llamaindex
examples is where the demo code lives
@@ -41,7 +41,7 @@ To run them, run
pnpm run test
```
To write new test cases write them in [packages/core/src/tests](/packages/core/src/tests)
To write new test cases write them in [packages/llamaindex/tests](/packages/llamaindex/tests)
We use Jest https://jestjs.io/ to write our test cases. Jest comes with a bunch of built in assertions using the expect function: https://jestjs.io/docs/expect
@@ -56,7 +56,7 @@ You can create new demo applications in the apps folder. Just run pnpm init in t
To install packages for a specific package or demo application, run
```
pnpm add [NPM Package] --filter [package or application i.e. core or docs]
pnpm add [NPM Package] --filter [package or application i.e. llamaindex or docs]
```
To install packages for every package or application run
+19 -42
View File
@@ -76,7 +76,18 @@ main();
node --import tsx ./main.ts
```
### Next.js
### React Server Component (Next.js, Waku, Redwood.JS...)
First, you will need to add a llamaindex plugin to your Next.js project.
```js
// next.config.js
const withLlamaIndex = require("llamaindex/next");
module.exports = withLlamaIndex({
// your next.js config
});
```
You can combine `ai` with `llamaindex` in Next.js with RSC (React Server Components).
@@ -143,59 +154,25 @@ export async function chatWithAgent(
}
```
### Cloudflare Workers
```ts
// src/index.ts
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext,
): Promise<Response> {
const { setEnvs } = await import("@llamaindex/env");
// set environment variables so that the OpenAIAgent can use them
setEnvs(env);
const { OpenAIAgent } = await import("llamaindex");
const agent = new OpenAIAgent({
tools: [],
});
const responseStream = await agent.chat({
stream: true,
message: "Hello? What is the weather today?",
});
const textEncoder = new TextEncoder();
const response = responseStream.pipeThrough(
new TransformStream({
transform: (chunk, controller) => {
controller.enqueue(textEncoder.encode(chunk.response.delta));
},
}),
);
return new Response(response);
},
};
```
## Playground
Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
## Core concepts for getting started:
- [Document](/packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
- [Document](/packages/llamaindex/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
- [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.
- [Node](/packages/llamaindex/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/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)).
- [Embedding](/packages/llamaindex/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/llamaindex/src/embeddings/OllamaEmbedding.ts) (see all [here](/packages/llamaindex/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.
- [Indices](/packages/llamaindex/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/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).
- [QueryEngine](/packages/llamaindex/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/llamaindex/src/indices/BaseIndex.ts) method on your Index. See all query engines [here](/packages/llamaindex/src/engines/query).
- [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).
- [ChatEngine](/packages/llamaindex/src/engines/chat/SimpleChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices. See all chat engines [here](/packages/llamaindex/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.
- [SimplePrompt](/packages/llamaindex/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.
## Tips when using in non-Node.js environments
+315
View File
@@ -1,5 +1,320 @@
# docs
## 0.0.47
### Patch Changes
- Updated dependencies [2562244]
- Updated dependencies [325aa51]
- Updated dependencies [ab700ea]
- Updated dependencies [92f0782]
- Updated dependencies [6cf6ae6]
- Updated dependencies [b7cfe5b]
- llamaindex@0.5.6
## 0.0.46
### Patch Changes
- Updated dependencies [b974eea]
- llamaindex@0.5.5
## 0.0.45
### Patch Changes
- Updated dependencies [1a65ead]
- llamaindex@0.5.4
## 0.0.44
### Patch Changes
- Updated dependencies [9bbbc67]
- Updated dependencies [b3681bf]
- llamaindex@0.5.3
## 0.0.43
### Patch Changes
- llamaindex@0.5.2
## 0.0.42
### Patch Changes
- 2774681: Add mixedbread's embeddings and reranking API
- Updated dependencies [2774681]
- Updated dependencies [a0f424e]
- llamaindex@0.5.1
## 0.0.41
### Patch Changes
- 36ddec4: fix: typo in custom page separator parameter for LlamaParse
- Updated dependencies [16ef5dd]
- Updated dependencies [16ef5dd]
- Updated dependencies [36ddec4]
- llamaindex@0.5.0
- @llamaindex/examples@0.0.7
## 0.0.40
### Patch Changes
- llamaindex@0.4.14
## 0.0.39
### Patch Changes
- Updated dependencies [e8f8bea]
- Updated dependencies [304484b]
- llamaindex@0.4.13
## 0.0.38
### Patch Changes
- Updated dependencies [f326ab8]
- llamaindex@0.4.12
## 0.0.37
### Patch Changes
- Updated dependencies [8bf5b4a]
- llamaindex@0.4.11
## 0.0.36
### Patch Changes
- Updated dependencies [7dce3d2]
- llamaindex@0.4.10
## 0.0.35
### Patch Changes
- Updated dependencies [3a96a48]
- llamaindex@0.4.9
## 0.0.34
### Patch Changes
- Updated dependencies [83ebdfb]
- llamaindex@0.4.8
## 0.0.33
### Patch Changes
- Updated dependencies [41fe871]
- Updated dependencies [321c39d]
- Updated dependencies [f7f1af0]
- llamaindex@0.4.7
## 0.0.32
### Patch Changes
- Updated dependencies [1feb23b]
- Updated dependencies [08c55ec]
- llamaindex@0.4.6
## 0.0.31
### Patch Changes
- Updated dependencies [6c3e5d0]
- llamaindex@0.4.5
## 0.0.30
### Patch Changes
- Updated dependencies [42eb73a]
- llamaindex@0.4.4
## 0.0.29
### Patch Changes
- Updated dependencies [2ef62a9]
- llamaindex@0.4.3
- @llamaindex/examples@0.0.6
## 0.0.28
### Patch Changes
- Updated dependencies [a87a4d1]
- Updated dependencies [0730140]
- llamaindex@0.4.2
## 0.0.27
### Patch Changes
- Updated dependencies [3c47910]
- Updated dependencies [ed467a9]
- Updated dependencies [cba5406]
- llamaindex@0.4.1
## 0.0.26
### Patch Changes
- b1a4a74: docs: updated Bedrock Opus region and added a basic README
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
- @llamaindex/examples@0.0.5
## 0.0.25
### Patch Changes
- Updated dependencies [6bc5bdd]
- Updated dependencies [bf25ff6]
- Updated dependencies [e6d6576]
- llamaindex@0.3.17
## 0.0.24
### Patch Changes
- 631f000: feat: DeepInfra LLM implementation
- 8832669: Community bedrock support added
- a29d835: setDocumentHash should be async
- Updated dependencies [11ae926]
- Updated dependencies [631f000]
- Updated dependencies [1378ec4]
- Updated dependencies [6b1ded4]
- Updated dependencies [4d4bd85]
- Updated dependencies [24a9d1e]
- Updated dependencies [45952de]
- Updated dependencies [54230f0]
- Updated dependencies [a29d835]
- Updated dependencies [73819bf]
- llamaindex@0.3.16
## 0.0.23
### Patch Changes
- Updated dependencies [6e156ed]
- Updated dependencies [265976d]
- Updated dependencies [8e26f75]
- llamaindex@0.3.15
## 0.0.22
### Patch Changes
- Updated dependencies [6ff7576]
- Updated dependencies [94543de]
- llamaindex@0.3.14
## 0.0.21
### Patch Changes
- Updated dependencies [1b1081b]
- Updated dependencies [37525df]
- Updated dependencies [660a2b3]
- Updated dependencies [a1f2475]
- llamaindex@0.3.13
## 0.0.20
### Patch Changes
- Updated dependencies [34fb1d8]
- llamaindex@0.3.12
## 0.0.19
### Patch Changes
- Updated dependencies [e072c45]
- Updated dependencies [9e133ac]
- Updated dependencies [447105a]
- Updated dependencies [320be3f]
- llamaindex@0.3.11
## 0.0.18
### Patch Changes
- Updated dependencies [4aba02e]
- llamaindex@0.3.10
## 0.0.17
### Patch Changes
- Updated dependencies [c3747d0]
- llamaindex@0.3.9
## 0.0.16
### Patch Changes
- Updated dependencies [ce94780]
- llamaindex@0.3.8
## 0.0.15
### Patch Changes
- Updated dependencies [b6a6606]
- Updated dependencies [b6a6606]
- llamaindex@0.3.7
## 0.0.14
### Patch Changes
- Updated dependencies [efa326a]
- llamaindex@0.3.6
## 0.0.13
### Patch Changes
- Updated dependencies [bc7a11c]
- Updated dependencies [2fe2b81]
- Updated dependencies [5596e31]
- Updated dependencies [e74fe88]
- Updated dependencies [be5df5b]
- llamaindex@0.3.5
## 0.0.12
### Patch Changes
- Updated dependencies [1dce275]
- Updated dependencies [d10533e]
- Updated dependencies [2008efe]
- Updated dependencies [5e61934]
- Updated dependencies [9e74a43]
- Updated dependencies [ee719a1]
- llamaindex@0.3.4
## 0.0.11
### Patch Changes
- Updated dependencies [e8c41c5]
- llamaindex@0.3.3
## 0.0.10
### Patch Changes
+1 -1
View File
@@ -1,2 +1,2 @@
label: Examples
position: 2
position: 3
+6
View File
@@ -0,0 +1,6 @@
# Gemini Agent
import CodeBlock from "@theme/CodeBlock";
import CodeSourceGemini from "!raw-loader!../../../../examples/gemini/agent.ts";
<CodeBlock language="ts">{CodeSourceGemini}</CodeBlock>
+1 -1
View File
@@ -1,5 +1,5 @@
---
sidebar_position: 1
sidebar_position: 2
---
import CodeBlock from "@theme/CodeBlock";
+77
View File
@@ -0,0 +1,77 @@
# Local LLMs
LlamaIndex.TS supports OpenAI and [other remote LLM APIs](other_llms). You can also run a local LLM on your machine!
## Using a local model via Ollama
The easiest way to run a local LLM is via the great work of our friends at [Ollama](https://ollama.com/), who provide a simple to use client that will download, install and run a [growing range of models](https://ollama.com/library) for you.
### Install Ollama
They provide a one-click installer for Mac, Linux and Windows on their [home page](https://ollama.com/).
### Pick and run a model
Since we're going to be doing agentic work, we'll need a very capable model, but the largest models are hard to run on a laptop. We think `mixtral 8x7b` is a good balance between power and resources, but `llama3` is another great option. You can run Mixtral by running
```bash
ollama run mixtral:8x7b
```
The first time you run it will also automatically download and install the model for you.
### Switch the LLM in your code
To tell LlamaIndex to use a local LLM, use the `Settings` object:
```javascript
Settings.llm = new Ollama({
model: "mixtral:8x7b",
});
```
### Use local embeddings
If you're doing retrieval-augmented generation, LlamaIndex.TS will also call out to OpenAI to index and embed your data. To be entirely local, you can use a local embedding model like this:
```javascript
Settings.embedModel = new HuggingFaceEmbedding({
modelType: "BAAI/bge-small-en-v1.5",
quantized: false,
});
```
The first time this runs it will download the embedding model to run it.
### Try it out
With a local LLM and local embeddings in place, you can perform RAG as usual and everything will happen on your machine without calling an API:
```typescript
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
// 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().catch(console.error);
```
You can see the [full example file](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/vectorIndexLocal.ts).
+19 -3
View File
@@ -1,7 +1,23 @@
---
sidebar_position: 5
sidebar_position: 1
---
# More examples
# See all examples
You can check out more examples in the [examples](https://github.com/run-llama/LlamaIndexTS/tree/main/examples) folder of the repository.
Our GitHub repository has a wealth of examples to explore and try out. You can check out our [examples folder](https://github.com/run-llama/LlamaIndexTS/tree/main/examples) to see them all at once, or browse the pages in this section for some selected highlights.
## Check out all examples
It may be useful to check out all the examples at once so you can try them out locally. To do this into a folder called `my-new-project`, run these commands:
```bash npm2yarn
npx degit run-llama/LlamaIndexTS/examples my-new-project
cd my-new-project
npm install
```
Then you can run any example in the folder with `tsx`, e.g.:
```bash npm2yarn
npx tsx ./vectorIndex.ts
```
+41
View File
@@ -0,0 +1,41 @@
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/mistral";
# Using other LLM APIs
By default LlamaIndex.TS uses OpenAI's LLMs and embedding models, but we support [lots of other LLMs](../modules/llms) including models from Mistral (Mistral, Mixtral), Anthropic (Claude) and Google (Gemini).
If you don't want to use an API at all you can [run a local model](../../examples/local_llm)
## Using another LLM
You can specify what LLM LlamaIndex.TS will use on the `Settings` object, like this:
```typescript
import { MistralAI, Settings } from "llamaindex";
Settings.llm = new MistralAI({
model: "mistral-tiny",
apiKey: "<YOUR_API_KEY>",
});
```
You can see examples of other APIs we support by checking out "Available LLMs" in the sidebar of our [LLMs section](../modules/llms).
## Using another embedding model
A frequent gotcha when trying to use a different API as your LLM is that LlamaIndex will also by default index and embed your data using OpenAI's embeddings. To completely switch away from OpenAI you will need to set your embedding model as well, for example:
```typescript
import { MistralAIEmbedding, Settings } from "llamaindex";
Settings.embedModel = new MistralAIEmbedding();
```
We support [many different embeddings](../modules/embeddings).
## Full example
This example uses Mistral's `mistral-tiny` model as the LLM and Mistral for embeddings as well.
<CodeBlock language="ts">{CodeSource}</CodeBlock>
+2 -2
View File
@@ -32,7 +32,7 @@ LlamaIndex.TS help you prepare the knowledge base with a suite of data connector
![](../_static/concepts/indexing.jpg)
[**Data Loaders**](../modules/data_loader.md):
[**Data Loaders**](../modules/data_loaders/index.mdx):
A data connector (i.e. `Reader`) ingest data from different data sources and data formats into a simple `Document` representation (text and simple metadata).
[**Documents / Nodes**](../modules/documents_and_nodes/index.md): A `Document` is a generic container around any data source - for instance, a PDF, an API output, or retrieved data from a database. A `Node` is the atomic unit of data in LlamaIndex and represents a "chunk" of a source `Document`. It's a rich representation that includes metadata and relationships (to other nodes) to enable accurate and expressive retrieval operations.
@@ -62,7 +62,7 @@ These building blocks can be customized to reflect ranking preferences, as well
[**Retrievers**](../modules/retriever.md):
A retriever defines how to efficiently retrieve relevant context from a knowledge base (i.e. index) when given a query.
The specific retrieval logic differs for difference indices, the most popular being dense retrieval against a vector index.
The specific retrieval logic differs for different indices, the most popular being dense retrieval against a vector index.
[**Response Synthesizers**](../modules/response_synthesizer.md):
A response synthesizer generates a response from an LLM, using a user query and a given set of retrieved text chunks.
@@ -4,7 +4,7 @@ sidebar_position: 2
# Environments
LlamaIndex currently officially supports NodeJS 18 and NodeJS 20.
We support Node.JS versions 18, 20 and 22, with experimental support for Deno, Bun and Vercel Edge functions.
## NextJS App Router
+13 -42
View File
@@ -4,45 +4,7 @@ sidebar_position: 0
# Installation and Setup
Make sure you have NodeJS v18 or higher.
## Using create-llama
The easiest way to get started with LlamaIndex is by using `create-llama`. This CLI tool enables you to quickly start building a new LlamaIndex application, with everything set up for you.
Just run
<Tabs>
<TabItem value="1" label="npm" default>
```bash
npx create-llama@latest
```
</TabItem>
<TabItem value="2" label="Yarn">
```bash
yarn create llama
```
</TabItem>
<TabItem value="3" label="pnpm">
```bash
pnpm create llama@latest
```
</TabItem>
</Tabs>
to get started. Once your app is generated, run
```bash npm2yarn
npm run dev
```
to start the development server. You can then visit [http://localhost:3000](http://localhost:3000) to see your app
We support Node.JS versions 18, 20 and 22, with experimental support for Deno, Bun and Vercel Edge functions.
## Installation from NPM
@@ -52,12 +14,21 @@ npm install llamaindex
### Environment variables
Our examples use OpenAI by default. You'll need to set up your Open AI key like so:
Our examples use OpenAI by default. You can use [other LLMs](../examples/other_llms) via their APIs; if you would prefer to use local models check out our [local LLM example](../examples/local_llm).
To use OpenAI, you'll need to [get an OpenAI API key](https://platform.openai.com/account/api-keys) and then make it available as an environment variable this way:
```bash
export OPENAI_API_KEY="sk-......" # Replace with your key from https://platform.openai.com/account/api-keys
export OPENAI_API_KEY="sk-......" # Replace with your key
```
If you want to have it automatically loaded every time, add it to your `.zshrc/.bashrc`.
WARNING: do not check in your OpenAI key into version control.
**WARNING:** do not check in your OpenAI key into version control. GitHub automatically invalidates OpenAI keys checked in by accident.
## What next?
- The easiest way to started is to [build a full-stack chat app with `create-llama`](starter_tutorial/chatbot).
- Try our other [getting started tutorials](starter_tutorial/retrieval_augmented_generation)
- Learn more about the [high level concepts](concepts) behind how LlamaIndex works
- Check out our [many examples](../examples/more_examples) of LlamaIndex.TS in action
@@ -1,51 +0,0 @@
---
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
```
@@ -0,0 +1,2 @@
label: Starter Tutorials
position: 1
@@ -0,0 +1,49 @@
---
sidebar_position: 4
---
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../examples/agent/openai";
# Agent tutorial
We have a comprehensive, step-by-step [guide to building agents in LlamaIndex.TS](../../guides/agents/setup) that we recommend to learn what agents are and how to build them for production. But building a basic agent is simple:
## Set up
In a new folder:
```bash npm2yarn
npm init
npm install -D typescript @types/node
```
## Run agent
Create the file `example.ts`. This code will:
- Create two tools for use by the agent:
- A `sumNumbers` tool that adds two numbers
- A `divideNumbers` tool that divides numbers
-
- Give an example of the data structure we wish to generate
- Prompt the LLM with instructions and the example, plus a sample transcript
<CodeBlock language="ts">{CodeSource}</CodeBlock>
To run the code:
```bash
npx tsx example.ts
```
You should expect output something like:
```
{
content: 'The sum of 5 + 5 is 10. When you divide 10 by 2, you get 5.',
role: 'assistant',
options: {}
}
Done
```
@@ -0,0 +1,27 @@
---
sidebar_position: 2
---
# Chatbot tutorial
Once you've mastered basic [retrieval-augment generation](retrieval_augmented_generation) you may want to create an interface to chat with your data. You can do this step-by-step, but we recommend getting started quickly using `create-llama`.
## Using create-llama
`create-llama` is a powerful but easy to use command-line tool that generates a working, full-stack web application that allows you to chat with your data. You can learn more about it on [the `create-llama` README page](https://www.npmjs.com/package/create-llama).
Run it once and it will ask you a series of questions about the kind of application you want to generate. Then you can customize your application to suit your use-case. To get started, run:
```bash npm2yarn
npx create-llama@latest
```
Once your app is generated, `cd` into your app directory and run
```bash npm2yarn
npm run dev
```
to start the development server. You can then visit [http://localhost:3000](http://localhost:3000) to see your app, which should look something like this:
![create-llama interface](./images/create_llama.png)
Binary file not shown.

After

Width:  |  Height:  |  Size: 540 KiB

@@ -0,0 +1,58 @@
---
sidebar_position: 1
---
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../examples/vectorIndex";
import TSConfigSource from "!!raw-loader!../../../../../examples/tsconfig.json";
# Retrieval Augmented Generation (RAG) Tutorial
One of the most common use-cases for LlamaIndex is Retrieval-Augmented Generation or RAG, in which your data is indexed and selectively retrieved to be given to an LLM as source material for responding to a query. You can learn more about the [concepts behind RAG](../concepts).
## Set up the project
In a new folder, run:
```bash npm2yarn
npm init
npm install -D typescript @types/node
```
Then, check out the [installation](../installation) steps to install LlamaIndex.TS and prepare an OpenAI key.
You can use [other LLMs](../../examples/other_llms) via their APIs; if you would prefer to use local models check out our [local LLM example](../../examples/local_llm).
## Run queries
Create the file `example.ts`. This code will
- load an example file
- convert it into a Document object
- index it (which creates embeddings using OpenAI)
- create a 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
```
You should expect output something like:
```
In college, the author studied subjects like linear algebra and physics, but did not find them particularly interesting. They started slacking off, skipping lectures, and eventually stopped attending classes altogether. They also had a negative experience with their English classes, where they were required to pay for catch-up training despite getting verbal approval to skip most of the classes. Ultimately, the author lost motivation for college due to their job as a software developer and stopped attending classes, only returning years later to pick up their papers.
0: Score: 0.8305309270895813 - I started this decade as a first-year college stud...
1: Score: 0.8286388215713089 - A short digression. Im not saying colleges are wo...
```
Once you've mastered basic RAG, you may want to consider [chatting with your data](chatbot).
@@ -0,0 +1,52 @@
---
sidebar_position: 3
---
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../examples/jsonExtract";
# Structured data extraction tutorial
Make sure you have installed LlamaIndex.TS and have an OpenAI key. If you haven't, check out the [installation](../installation) guide.
You can use [other LLMs](../../examples/other_llms) via their APIs; if you would prefer to use local models check out our [local LLM example](../../examples/local_llm).
## Set up
In a new folder:
```bash npm2yarn
npm init
npm install -D typescript @types/node
```
## Extract data
Create the file `example.ts`. This code will:
- Set up an LLM connection to GPT-4
- Give an example of the data structure we wish to generate
- Prompt the LLM with instructions and the example, plus a sample transcript
<CodeBlock language="ts">{CodeSource}</CodeBlock>
To run the code:
```bash
npx tsx example.ts
```
You should expect output something like:
```json
{
"summary": "Sarah from XYZ Company called John to introduce the XYZ Widget, a tool designed to automate tasks and improve productivity. John expressed interest and requested case studies and a product demo. Sarah agreed to send the information and follow up to schedule the demo.",
"products": ["XYZ Widget"],
"rep_name": "Sarah",
"prospect_name": "John",
"action_items": [
"Send case studies and additional product information to John",
"Follow up with John to schedule a product demo"
]
}
```
+2
View File
@@ -0,0 +1,2 @@
label: Guides
position: 2
+41
View File
@@ -0,0 +1,41 @@
---
sidebar_position: 1
---
# Getting started
In this guide we'll walk you through the process of building an Agent in JavaScript using the LlamaIndex.TS library, starting from nothing and adding complexity in stages.
## What is an Agent?
In LlamaIndex, an agent is a semi-autonomous piece of software powered by an LLM that is given a task and executes a series of steps towards solving that task. It is given a set of tools, which can be anything from arbitrary functions up to full LlamaIndex query engines, and it selects the best available tool to complete each step. When each step is completed, the agent judges whether the task is now complete, in which case it returns a result to the user, or whether it needs to take another step, in which case it loops back to the start.
![agent flow](./images/agent_flow.png)
## Install LlamaIndex.TS
You'll need to have a recent version of [Node.js](https://nodejs.org/en) installed. Then you can install LlamaIndex.TS by running
```bash
npm install llamaindex
```
## Choose your model
By default we'll be using OpenAI with GPT-4, as it's a powerful model and easy to get started with. If you'd prefer to run a local model, see [using a local model](local_model).
## Get an OpenAI API key
If you don't already have one, you can sign up for an [OpenAI API key](https://platform.openai.com/api-keys). You should then put the key in a `.env` file in the root of the project; the file should look like
```
OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXXXXXX
```
We'll use `dotenv` to pull the API key out of that .env file, so also run:
```bash
npm install dotenv
```
Now you're ready to [create your agent](create_agent).
@@ -0,0 +1,179 @@
# Create a basic agent
We want to use `await` so we're going to wrap all of our code in a `main` function, like this:
```typescript
// Your imports go here
async function main() {
// the rest of your code goes here
}
main().catch(console.error);
```
For the rest of this guide we'll assume your code is wrapped like this so we can use `await`. You can run the code this way:
```bash
npx tsx example.ts
```
### Load your dependencies
First we'll need to pull in our dependencies. These are:
- The OpenAI class to use the OpenAI LLM
- FunctionTool to provide tools to our agent
- OpenAIAgent to create the agent itself
- Settings to define some global settings for the library
- Dotenv to load our API key from the .env file
```javascript
import { OpenAI, FunctionTool, OpenAIAgent, Settings } from "llamaindex";
import "dotenv/config";
```
### Initialize your LLM
We need to tell our OpenAI class where its API key is, and which of OpenAI's models to use. We'll be using `gpt-4o`, which is capable while still being pretty cheap. This is a global setting, so anywhere an LLM is needed will use the same model.
```javascript
Settings.llm = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
model: "gpt-4o",
});
```
### Turn on logging
We want to see what our agent is up to, so we're going to hook into some events that the library generates and print them out. There are several events possible, but we'll specifically tune in to `llm-tool-call` (when a tool is called) and `llm-tool-result` (when it responds).
```javascript
Settings.callbackManager.on("llm-tool-call", (event) => {
console.log(event.detail.payload);
});
Settings.callbackManager.on("llm-tool-result", (event) => {
console.log(event.detail.payload);
});
```
### Create a function
We're going to create a very simple function that adds two numbers together. This will be the tool we ask our agent to use.
```javascript
const sumNumbers = ({ a, b }) => {
return `${a + b}`;
};
```
Note that we're passing in an object with two named parameters, `a` and `b`. This is a little unusual, but important for defining a tool that an LLM can use.
### Turn the function into a tool for the agent
This is the most complicated part of creating an agent. We need to define a `FunctionTool`. We have to pass in:
- The function itself (`sumNumbers`)
- A name for the function, which the LLM will use to call it
- A description of the function. The LLM will read this description to figure out what the tool does, and if it needs to call it
- A schema for function. We tell the LLM that the parameter is an `object`, and we tell it about the two named parameters we gave it, `a` and `b`. We describe each parameter as a `number`, and we say that both are required.
- You can see [more examples of function schemas](https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models).
```javascript
const tool = FunctionTool.from(sumNumbers, {
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: {
type: "object",
properties: {
a: {
type: "number",
description: "First number to sum",
},
b: {
type: "number",
description: "Second number to sum",
},
},
required: ["a", "b"],
},
});
```
We then wrap up the tools into an array. We could provide lots of tools this way, but for this example we're just using the one.
```javascript
const tools = [tool];
```
### Create the agent
With your LLM already set up and your tools defined, creating an agent is simple:
```javascript
const agent = new OpenAIAgent({ tools });
```
### Ask the agent a question
We can use the `chat` interface to ask our agent a question, and it will use the tools we've defined to find an answer.
```javascript
let response = await agent.chat({
message: "Add 101 and 303",
});
console.log(response);
```
Let's see what running this looks like using `npx tsx agent.ts`
**_Output_**
```javascript
{
toolCall: {
id: 'call_ze6A8C3mOUBG4zmXO8Z4CPB5',
name: 'sumNumbers',
input: { a: 101, b: 303 }
},
toolResult: {
tool: FunctionTool { _fn: [Function: sumNumbers], _metadata: [Object] },
input: { a: 101, b: 303 },
output: '404',
isError: false
}
}
```
```javascript
{
response: {
raw: {
id: 'chatcmpl-9KwauZku3QOvH78MNvxJs81mDvQYK',
object: 'chat.completion',
created: 1714778824,
model: 'gpt-4-turbo-2024-04-09',
choices: [Array],
usage: [Object],
system_fingerprint: 'fp_ea6eb70039'
},
message: {
content: 'The sum of 101 and 303 is 404.',
role: 'assistant',
options: {}
}
},
sources: [Getter]
}
```
We're seeing two pieces of output here. The first is our callback firing when the tool is called. You can see in `toolResult` that the LLM has correctly passed `101` and `303` to our `sumNumbers` function, which adds them up and returns `404`.
The second piece of output is the response from the LLM itself, where the `message.content` key is giving us the answer.
Great! We've built an agent with tool use! Next you can:
- [See the full code](https://github.com/run-llama/ts-agents/blob/main/1_agent/agent.ts)
- [Switch to a local LLM](local_model)
- Move on to [add Retrieval-Augmented Generation to your agent](agentic_rag)
@@ -0,0 +1,90 @@
# Using a local model via Ollama
If you're happy using OpenAI, you can skip this section, but many people are interested in using models they run themselves. The easiest way to do this is via the great work of our friends at [Ollama](https://ollama.com/), who provide a simple to use client that will download, install and run a [growing range of models](https://ollama.com/library) for you.
### Install Ollama
They provide a one-click installer for Mac, Linux and Windows on their [home page](https://ollama.com/).
### Pick and run a model
Since we're going to be doing agentic work, we'll need a very capable model, but the largest models are hard to run on a laptop. We think `mixtral 8x7b` is a good balance between power and resources, but `llama3` is another great option. You can run it simply by running
```bash
ollama run mixtral:8x7b
```
The first time you run it will also automatically download and install the model for you.
### Switch the LLM in your code
There are two changes you need to make to the code we already wrote in `1_agent` to get Mixtral 8x7b to work. First, you need to switch to that model. Replace the call to `Settings.llm` with this:
```javascript
Settings.llm = new Ollama({
model: "mixtral:8x7b",
});
```
### Swap to a ReActAgent
In our original code we used a specific OpenAIAgent, so we'll need to switch to a more generic agent pattern, the ReAct pattern. This is simple: change the `const agent` line in your code to read
```javascript
const agent = new ReActAgent({ tools });
```
(You will also need to bring in `Ollama` and `ReActAgent` in your imports)
### Run your totally local agent
Because your embeddings were already local, your agent can now run entirely locally without making any API calls.
```bash
node agent.mjs
```
Note that your model will probably run a lot slower than OpenAI, so be prepared to wait a while!
**_Output_**
```javascript
{
response: {
message: {
role: 'assistant',
content: ' Thought: I need to use a tool to add the numbers 101 and 303.\n' +
'Action: sumNumbers\n' +
'Action Input: {"a": 101, "b": 303}\n' +
'\n' +
'Observation: 404\n' +
'\n' +
'Thought: I can answer without using any more tools.\n' +
'Answer: The sum of 101 and 303 is 404.'
},
raw: {
model: 'mixtral:8x7b',
created_at: '2024-05-09T00:24:30.339473Z',
message: [Object],
done: true,
total_duration: 64678371209,
load_duration: 57394551334,
prompt_eval_count: 475,
prompt_eval_duration: 4163981000,
eval_count: 94,
eval_duration: 3116692000
}
},
sources: [Getter]
}
```
Tada! You can see all of this in the folder `1a_mixtral`.
### Extending to other examples
You can use a ReActAgent instead of an OpenAIAgent in any of the further examples below, but keep in mind that GPT-4 is a lot more capable than Mixtral 8x7b, so you may see more errors or failures in reasoning if you are using an entirely local setup.
### Next steps
Now you've got a local agent, you can [add Retrieval-Augmented Generation to your agent](agentic_rag).
@@ -0,0 +1,165 @@
# Adding Retrieval-Augmented Generation (RAG)
While an agent that can perform math is nifty (LLMs are usually not very good at math), LLM-based applications are always more interesting when they work with large amounts of data. In this case, we're going to use a 200-page PDF of the proposed budget of the city of San Francisco for fiscal years 2024-2024 and 2024-2025. It's a great example because it's extremely wordy and full of tables of figures, which present a challenge for humans and LLMs alike.
To learn more about RAG, we recommend this [introduction](https://docs.llamaindex.ai/en/stable/getting_started/concepts/) from our Python docs. We'll assume you know the basics:
- You need to parse your source data into chunks of text
- You need to encode that text as numbers, called embeddings
- You need to search your embeddings for the most relevant chunks of text
- You feed your relevant chunks and a query to an LLM to answer a question
We're going to start with the same agent we [built in step 1](https://github.com/run-llama/ts-agents/blob/main/1_agent/agent.ts), but make a few changes. You can find the finished version [in the repository](https://github.com/run-llama/ts-agents/blob/main/2_agentic_rag/agent.ts).
### New dependencies
We'll be bringing in `SimpleDirectoryReader`, `HuggingFaceEmbedding`, `VectorStoreIndex`, and `QueryEngineTool` from LlamaIndex.TS, as well as the dependencies we previously used.
```javascript
import {
OpenAI,
FunctionTool,
OpenAIAgent,
Settings,
SimpleDirectoryReader,
HuggingFaceEmbedding,
VectorStoreIndex,
QueryEngineTool,
} from "llamaindex";
```
### Add an embedding model
To encode our text into embeddings, we'll need an embedding model. We could use OpenAI for this but to save on API calls we're going to use a local embedding model from HuggingFace.
```javascript
Settings.embedModel = new HuggingFaceEmbedding({
modelType: "BAAI/bge-small-en-v1.5",
quantized: false,
});
```
### Load data using SimpleDirectoryReader
SimpleDirectoryReader is a flexible tool that can read a variety of file formats. We're going to point it at our data directory, which contains just the single PDF file, and get it to return a set of documents.
```javascript
const reader = new SimpleDirectoryReader();
const documents = await reader.loadData("../data");
```
### Index our data
Now we turn our text into embeddings. The `VectorStoreIndex` class takes care of this for us when we use the `fromDocuments` method (it uses the embedding model we defined in `Settings` earlier).
```javascript
const index = await VectorStoreIndex.fromDocuments(documents);
```
### Configure a retriever
Before LlamaIndex can send a query to the LLM, it needs to find the most relevant chunks to send. That's the purpose of a `Retriever`. We're going to get `VectorStoreIndex` to act as a retriever for us
```javascript
const retriever = await index.asRetriever();
```
### Configure how many documents to retrieve
By default LlamaIndex will retrieve just the 2 most relevant chunks of text. This document is complex though, so we'll ask for more context.
```javascript
retriever.similarityTopK = 10;
```
### Create a query engine
And our final step in creating a RAG pipeline is to create a query engine that will use the retriever to find the most relevant chunks of text, and then use the LLM to answer the question.
```javascript
const queryEngine = await index.asQueryEngine({
retriever,
});
```
### Define the query engine as a tool
Just as before we created a `FunctionTool`, we're going to create a `QueryEngineTool` that uses our `queryEngine`.
```javascript
const tools = [
new QueryEngineTool({
queryEngine: queryEngine,
metadata: {
name: "san_francisco_budget_tool",
description: `This tool can answer detailed questions about the individual components of the budget of San Francisco in 2023-2024.`,
},
}),
];
```
As before, we've created an array of tools with just one tool in it. The metadata is slightly different: we don't need to define our parameters, we just give the tool a name and a natural-language description.
### Create the agent as before
Creating the agent and asking a question is exactly the same as before, but we'll ask a different question.
```javascript
// create the agent
const agent = new OpenAIAgent({ tools });
let response = await agent.chat({
message: "What's the budget of San Francisco in 2023-2024?",
});
console.log(response);
```
Once again we'll run `npx tsx agent.ts` and see what we get:
**_Output_**
```javascript
{
toolCall: {
id: 'call_iNo6rTK4pOpOBbO8FanfWLI9',
name: 'san_francisco_budget_tool',
input: { query: 'total budget' }
},
toolResult: {
tool: QueryEngineTool {
queryEngine: [RetrieverQueryEngine],
metadata: [Object]
},
input: { query: 'total budget' },
output: 'The total budget for the City and County of San Francisco for Fiscal Year (FY) 2023-24 is $14.6 billion, which represents a $611.8 million, or 4.4 percent, increase over the FY 2022-23 budget. For FY 2024-25, the total budget is also projected to be $14.6 billion, reflecting a $40.5 million, or 0.3 percent, decrease from the FY 2023-24 proposed budget. This budget includes various expenditures across different departments and services, with significant allocations to public works, transportation, commerce, public protection, and health services.',
isError: false
}
}
```
```javascript
{
response: {
raw: {
id: 'chatcmpl-9KxUkwizVCYCmxwFQcZFSHrInzNFU',
object: 'chat.completion',
created: 1714782286,
model: 'gpt-4-turbo-2024-04-09',
choices: [Array],
usage: [Object],
system_fingerprint: 'fp_ea6eb70039'
},
message: {
content: "The total budget for the City and County of San Francisco for the fiscal year 2023-2024 is $14.6 billion. This represents a $611.8 million, or 4.4 percent, increase over the previous fiscal year's budget. The budget covers various expenditures across different departments and services, including significant allocations to public works, transportation, commerce, public protection, and health services.",
role: 'assistant',
options: {}
}
},
sources: [Getter]
}
```
Once again we see a `toolResult`. You can see the query the LLM decided to send to the query engine ("total budget"), and the output the engine returned. In `response.message` you see that the LLM has returned the output from the tool almost verbatim, although it trimmed out the bit about 2024-2025 since we didn't ask about that year.
So now we have an agent that can index complicated documents and answer questions about them. Let's [combine our math agent and our RAG agent](rag_and_tools)!
@@ -0,0 +1,128 @@
# A RAG agent that does math
In [our third iteration of the agent](https://github.com/run-llama/ts-agents/blob/main/3_rag_and_tools/agent.ts) we've combined the two previous agents, so we've defined both `sumNumbers` and a `QueryEngineTool` and created an array of two tools:
```javascript
// define the query engine as a tool
const tools = [
new QueryEngineTool({
queryEngine: queryEngine,
metadata: {
name: "san_francisco_budget_tool",
description: `This tool can answer detailed questions about the individual components of the budget of San Francisco in 2023-2024.`,
},
}),
FunctionTool.from(sumNumbers, {
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: {
type: "object",
properties: {
a: {
type: "number",
description: "First number to sum",
},
b: {
type: "number",
description: "Second number to sum",
},
},
required: ["a", "b"],
},
}),
];
```
These tool descriptions are identical to the ones we previously defined. Now let's ask it 3 questions in a row:
```javascript
let response = await agent.chat({
message:
"What's the budget of San Francisco for community health in 2023-24?",
});
console.log(response);
let response2 = await agent.chat({
message:
"What's the budget of San Francisco for public protection in 2023-24?",
});
console.log(response2);
let response3 = await agent.chat({
message:
"What's the combined budget of San Francisco for community health and public protection in 2023-24?",
});
console.log(response3);
```
We'll abbreviate the output, but here are the important things to spot:
```javascript
{
toolCall: {
id: 'call_ZA1LPx03gO4ABre1r6XowLWq',
name: 'san_francisco_budget_tool',
input: { query: 'community health budget 2023-2024' }
},
toolResult: {
tool: QueryEngineTool {
queryEngine: [RetrieverQueryEngine],
metadata: [Object]
},
input: { query: 'community health budget 2023-2024' },
output: 'The proposed Fiscal Year (FY) 2023-24 budget for the Department of Public Health is $3.2 billion
}
}
```
This is the first tool call, where it used the query engine to get the public health budget.
```javascript
{
toolCall: {
id: 'call_oHu1KjEvA47ER6HYVfFIq9yp',
name: 'san_francisco_budget_tool',
input: { query: 'public protection budget 2023-2024' }
},
toolResult: {
tool: QueryEngineTool {
queryEngine: [RetrieverQueryEngine],
metadata: [Object]
},
input: { query: 'public protection budget 2023-2024' },
output: "The budget for Public Protection in San Francisco for Fiscal Year (FY) 2023-24 is $2,012.5 million."
}
}
```
In the second tool call, it got the police budget also from the query engine.
```javascript
{
toolCall: {
id: 'call_SzG4yGUnLbv1T7IyaLAOqg3t',
name: 'sumNumbers',
input: { a: 3200, b: 2012.5 }
},
toolResult: {
tool: FunctionTool { _fn: [Function: sumNumbers], _metadata: [Object] },
input: { a: 3200, b: 2012.5 },
output: '5212.5',
isError: false
}
}
```
In the final tool call, it used the `sumNumbers` function to add the two budgets together. Perfect! This leads to the final answer:
```javascript
{
message: {
content: 'The combined budget of San Francisco for community health and public protection in Fiscal Year (FY) 2023-24 is $5,212.5 million.',
role: 'assistant',
options: {}
}
}
```
Great! Now let's improve accuracy by improving our parsing with [LlamaParse](llamaparse).
@@ -0,0 +1,18 @@
# Adding LlamaParse
Complicated PDFs can be very tricky for LLMs to understand. To help with this, LlamaIndex provides LlamaParse, a hosted service that parses complex documents including PDFs. To use it, get a `LLAMA_CLOUD_API_KEY` by [signing up for LlamaCloud](https://cloud.llamaindex.ai/) (it's free for up to 1000 pages/day) and adding it to your `.env` file just as you did for your OpenAI key:
```bash
LLAMA_CLOUD_API_KEY=llx-XXXXXXXXXXXXXXXX
```
Then replace `SimpleDirectoryReader` with `LlamaParseReader`:
```javascript
const reader = new LlamaParseReader({ resultType: "markdown" });
const documents = await reader.loadData("../data/sf_budget_2023_2024.pdf");
```
Now you will be able to ask more complicated questions of the same PDF and get better results. You can find this code [in our repo](https://github.com/run-llama/ts-agents/blob/main/4_llamaparse/agent.ts).
Next up, let's persist our embedded data so we don't have to re-parse every time by [using a vector store](qdrant).
+75
View File
@@ -0,0 +1,75 @@
# Adding persistent vector storage
In the previous examples, we've been loading our data into memory each time we run the agent. This is fine for small datasets, but for larger datasets you'll want to store your embeddings in a database. LlamaIndex.TS provides a `VectorStore` class that can store your embeddings in a variety of databases. We're going to use [Qdrant](https://qdrant.tech/), a popular vector store, for this example.
We can get a local instance of Qdrant running very simply with Docker (make sure you [install Docker](https://www.docker.com/products/docker-desktop/) first):
```bash
docker pull qdrant/qdrant
docker run -p 6333:6333 qdrant/qdrant
```
And in our code we initialize a `VectorStore` with the Qdrant URL:
```javascript
// initialize qdrant vector store
const vectorStore = new QdrantVectorStore({
url: "http://localhost:6333",
});
```
Now once we have loaded our documents, we can instantiate an index with the vector store:
```javascript
// create a query engine from our documents
const index = await VectorStoreIndex.fromDocuments(documents, { vectorStore });
```
In [the final iteration](https://github.com/run-llama/ts-agents/blob/main/5_qdrant/agent.ts) you can see that we have also implemented a very naive caching mechanism to avoid re-parsing the PDF each time we run the agent:
```javascript
// load cache.json and parse it
let cache = {};
let cacheExists = false;
try {
await fs.access(PARSING_CACHE, fs.constants.F_OK);
cacheExists = true;
} catch (e) {
console.log("No cache found");
}
if (cacheExists) {
cache = JSON.parse(await fs.readFile(PARSING_CACHE, "utf-8"));
}
const filesToParse = ["../data/sf_budget_2023_2024.pdf"];
// load our data, reading only files we haven't seen before
let documents = [];
const reader = new LlamaParseReader({ resultType: "markdown" });
for (let file of filesToParse) {
if (!cache[file]) {
documents = documents.concat(await reader.loadData(file));
cache[file] = true;
}
}
// write the cache back to disk
await fs.writeFile(PARSING_CACHE, JSON.stringify(cache));
```
Since parsing a PDF can be slow, especially a large one, using the pre-parsed chunks in Qdrant can significantly speed up your agent.
## Next steps
In this guide you've learned how to
- [Create an agent](create_agent)
- Use remote LLMs like GPT-4
- [Use local LLMs like Mixtral](local_model)
- [Create a RAG query engine](agentic_rag)
- [Turn functions and query engines into agent tools](rag_and_tools)
- Combine those tools
- [Enhance your parsing with LlamaParse](llamaparse)
- Persist your data in a vector store
The next steps are up to you! Try creating more complex functions and query engines, and set your agent loose on the world.
@@ -0,0 +1,2 @@
label: Agents
position: 1
Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

+13 -15
View File
@@ -3,33 +3,31 @@ sidebar_position: 0
slug: /
---
# What is LlamaIndex.TS?
# What is LlamaIndex?
LlamaIndex.TS is a data framework for LLM applications to ingest, structure, and access private or domain-specific data. While a python package is also available (see [here](https://docs.llamaindex.ai/en/stable/)), LlamaIndex.TS offers core features in a simple package, optimized for usage with TypeScript.
LlamaIndex is a framework for building LLM-powered applications. LlamaIndex helps you ingest, structure, and access private or domain-specific data. It's available [as a Python package](https://docs.llamaindex.ai/en/stable/) and in TypeScript (this package). LlamaIndex.TS offers the core features of LlamaIndex for popular runtimes like Node.js (official support), Vercel Edge Functions (experimental), and Deno (experimental).
## 🚀 Why LlamaIndex.TS?
At their core, LLMs offer a natural language interface between humans and inferred data. Widely available models come pre-trained on huge amounts of publicly available data, from Wikipedia and mailing lists to textbooks and source code.
LLMs offer a natural language interface between humans and inferred data. Widely available models come pre-trained on huge amounts of publicly available data, from Wikipedia and mailing lists to textbooks and source code.
Applications built on top of LLMs often require augmenting these models with private or domain-specific data. Unfortunately, that data can be distributed across siloed applications and data stores. It's behind APIs, in SQL databases, or trapped in PDFs and slide decks.
Applications built on top of LLMs often require augmenting these models with private or domain-specific data. That data is often distributed across siloed applications and data stores. It's behind APIs, in SQL databases, or trapped in PDFs and slide decks.
That's where **LlamaIndex.TS** comes in.
LlamaIndex.TS helps you unlock that data and then build powerful applications with it.
## 🦙 How can LlamaIndex.TS help?
## 🦙 What is LlamaIndex for?
LlamaIndex.TS provides the following tools:
LlamaIndex.TS handles several major use cases:
- **Data loading** ingest your existing `.txt`, `.pdf`, `.csv`, `.md` and `.docx` data directly
- **Data indexes** structure your data in intermediate representations that are easy and performant for LLMs to consume.
- **Engines** provide natural language access to your data. For example:
- Query engines are powerful retrieval interfaces for knowledge-augmented output.
- Chat engines are conversational interfaces for multi-message, "back and forth" interactions with your data.
- **Structured Data Extraction**: turning complex, unstructured and semi-structured data into uniform, programmatically accessible formats.
- **Retrieval-Augmented Generation (RAG)**: answering queries across your internal data by providing LLMs with up-to-date, semantically relevant context including Question and Answer systems and chat bots.
- **Autonomous Agents**: building software that is capable of intelligently selecting and using tools to accomplish tasks in an interative, unsupervised manner.
## 👨‍👩‍👧‍👦 Who is LlamaIndex for?
LlamaIndex.TS provides a core set of tools, essential for anyone building LLM apps with JavaScript and TypeScript.
LlamaIndex targets the "AI Engineer": developers building software in any domain that can be enhanced by LLM-powered functionality, without needing to be an expert in machine learning or natural language processing.
Our high-level API allows beginner users to use LlamaIndex.TS to ingest and query their data.
Our high-level API allows beginner users to use LlamaIndex.TS to ingest, index, and query their data in just a few lines of code.
For more complex applications, our lower-level APIs allow advanced users to customize and extend any module—data connectors, indices, retrievers, and query engines, to fit their needs.
@@ -37,7 +35,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.mdx) to build your first application.
Our documentation includes [Installation Instructions](./getting_started/installation.mdx) and a [Starter Tutorial](./getting_started/starter_tutorial/retrieval_augmented_generation.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.
+9 -1
View File
@@ -12,9 +12,17 @@ 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
- Anthropic Agent
- Anthropic Agent both via Anthropic and Bedrock (in `@llamaIndex/community`)
- Gemini Agent
- ReACT Agent
## Examples
- [OpenAI Agent](../../examples/agent.mdx)
- [Gemini Agent](../../examples/agent_gemini.mdx)
## Api References
- [OpenAIAgent](../../api/classes/OpenAIAgent.md)
- [AnthropicAgent](../../api/classes/AnthropicAgent.md)
- [ReActAgent](../../api/classes/ReActAgent.md)
-48
View File
@@ -1,48 +0,0 @@
---
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
Before you can start indexing your documents, you need to load them into memory.
### SimpleDirectoryReader
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples/readers?file=src/simple-directory-reader.ts&title=Simple%20Directory%20Reader)
LlamaIndex.TS supports easy loading of files from folders using the `SimpleDirectoryReader` class.
It is a simple reader that reads all files from a directory and its subdirectories.
<CodeBlock language="ts">{CodeSource}</CodeBlock>
Currently, it supports reading `.csv`, `.docx`, `.html`, `.md` and `.pdf` files,
but support for other file types is planned.
Also, you can provide a `defaultReader` as a fallback for files with unsupported extensions.
Or pass new readers for `fileExtToReader` to support more file types.
<CodeBlock language="ts" showLineNumbers metastring="{8-12,17-21}">
{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)
@@ -0,0 +1,2 @@
label: "Loaders"
position: 1
@@ -0,0 +1,34 @@
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../examples/readers/src/discord";
# DiscordReader
DiscordReader is a simple data loader that reads all messages in a given Discord channel and returns them as Document objects.
It uses the [@discordjs/rest](https://github.com/discordjs/discord.js/tree/main/packages/rest) library to fetch the messages.
## Usage
First step is to create a Discord Application and generating a bot token [here](https://discord.com/developers/applications).
In your Discord Application, go to the `OAuth2` tab and generate an invite URL by selecting `bot` and click `Read Messages/View Channels` as wells as `Read Message History`.
This will invite the bot with the necessary permissions to read messages.
Copy the URL in your browser and select the server you want your bot to join.
<CodeBlock language="ts">{CodeSource}</CodeBlock>
### Params
#### DiscordReader()
- `discordToken?`: The Discord bot token.
- `makeRequest?`: Optionally provide a custom request function for edge environments, e.g. `fetch`. See discord.js for more info.
#### DiscordReader.loadData
- `channelIDs`: The ID(s) of discord channels as an array of strings.
- `limit?`: Optionally limit the number of messages to read
- `additionalInfo?`: An optional flag to include embedded messages and attachment urls in the document.
- `oldestFirst?`: An optional flag to return the oldest messages first.
## API Reference
- [DiscordReader](../../api/classes/DiscordReader.md)
@@ -0,0 +1,37 @@
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";
# Loader
Before you can start indexing your documents, you need to load them into memory.
## SimpleDirectoryReader
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples/readers?file=src/simple-directory-reader.ts&title=Simple%20Directory%20Reader)
LlamaIndex.TS supports easy loading of files from folders using the `SimpleDirectoryReader` class.
It is a simple reader that reads all files from a directory and its subdirectories.
<CodeBlock language="ts">{CodeSource}</CodeBlock>
Currently, it supports reading `.txt`, `.pdf`, `.csv`, `.md`, `.docx`, `.htm`, `.html`, `.jpg`, `.jpeg`, `.png` and `.gif` files, but support for other file types is planned.
You can modify the reader three different ways:
- `overrideReader` overrides the reader for all file types, including unsupported ones.
- `fileExtToReader` maps a reader to a specific file type. Can override reader for existing file types or add support for new file types.
- `defaultReader` sets a fallback reader for files with unsupported extensions. By default it is `TextFileReader`.
SimpleDirectoryReader supports up to 9 concurrent requests. Use the `numWorkers` option to set the number of concurrent requests. By default it runs in sequential mode, i.e. set to 1.
### Example
<CodeBlock language="ts" showLineNumbers metastring="{8-12,17-21}">
{CodeSource2}
</CodeBlock>
## API Reference
- [SimpleDirectoryReader](../../api/classes/SimpleDirectoryReader.md)
@@ -0,0 +1 @@
label: "LlamaParse"
@@ -0,0 +1,117 @@
---
sidebar_position: 2
---
# Image Retrieval
LlamaParse `json` mode supports extracting any images found in a page object by using the `getImages` function. They are downloaded to a local folder and can then be sent to a multimodal LLM for further processing.
## Usage
We use the `getImages` method to input our array of JSON objects, download the images to a specified folder and get a list of ImageNodes.
```ts
const reader = new LlamaParseReader();
const jsonObjs = await reader.loadJson("../data/uber_10q_march_2022.pdf");
const imageDicts = await reader.getImages(jsonObjs, "images");
```
### Multimodal Indexing
You can create an index across both text and image nodes by requesting alternative text for the image from a multimodal LLM.
```ts
import {
Document,
ImageNode,
LlamaParseReader,
OpenAI,
VectorStoreIndex,
} from "llamaindex";
import { createMessageContent } from "llamaindex/synthesizers/utils";
const reader = new LlamaParseReader();
async function main() {
// Load PDF using LlamaParse JSON mode and return an array of json objects
const jsonObjs = await reader.loadJson("../data/uber_10q_march_2022.pdf");
// Access the first "pages" (=a single parsed file) object in the array
const jsonList = jsonObjs[0]["pages"];
const textDocs = getTextDocs(jsonList);
const imageTextDocs = await getImageTextDocs(jsonObjs);
const documents = [...textDocs, ...imageTextDocs];
// Split text, create embeddings and query the index
const index = await VectorStoreIndex.fromDocuments(documents);
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({
query:
"What does the bar graph titled 'Monthly Active Platform Consumers' show?",
});
console.log(response.toString());
}
main().catch(console.error);
```
We use two helper functions to create documents from the text and image nodes provided.
#### Text Documents
To create documents from the text nodes of the json object, we just map the needed values to a new `Document` object. In this case we assign the text as text and the page number as metadata.
```ts
function getTextDocs(jsonList: { text: string; page: number }[]): Document[] {
return jsonList.map(
(page) => new Document({ text: page.text, metadata: { page: page.page } }),
);
}
```
#### Image Documents
To create documents from the images, we need to use a multimodal LLM to generate alt text.
For this we create `ImageNodes` and add them as part of our message.
We can use the `createMessageContent` function to simplify this.
```ts
async function getImageTextDocs(
jsonObjs: Record<string, any>[],
): Promise<Document[]> {
const llm = new OpenAI({
model: "gpt-4o",
temperature: 0.2,
maxTokens: 1000,
});
const imageDicts = await reader.getImages(jsonObjs, "images");
const imageDocs = [];
for (const imageDict of imageDicts) {
const imageDoc = new ImageNode({ image: imageDict.path });
const prompt = () => `Describe the image as alt text`;
const message = await createMessageContent(prompt, [imageDoc]);
const response = await llm.complete({
prompt: message,
});
const doc = new Document({
text: response.text,
metadata: { path: imageDict.path },
});
imageDocs.push(doc);
}
return imageDocs;
}
```
The returned `imageDocs` have the alt text assigned as text and the image path as metadata.
You can see the full example file [here](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/readers/src/llamaparse-json.ts).
## API Reference
- [LlamaParseReader](../../../api/classes/LlamaParseReader.md)
@@ -0,0 +1,63 @@
import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../../examples/readers/src/llamaparse";
import CodeSource2 from "!raw-loader!../../../../../../examples/readers/src/simple-directory-reader-with-llamaparse.ts";
# 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 as `apiKey` parameter or in the environment variable `LLAMA_CLOUD_API_KEY`.
Official documentation for LlamaParse can be found [here](https://docs.cloud.llamaindex.ai/).
## Usage
You can then use the `LlamaParseReader` class to load local files and convert them into a parsed document that can be used by LlamaIndex.
See [LlamaParseReader.ts](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/llamaindex/src/readers/LlamaParseReader.ts) for a list of supported file types:
<CodeBlock language="ts">{CodeSource}</CodeBlock>
### Params
All options can be set with the `LlamaParseReader` constructor.
They can be divided into two groups.
#### General params:
- `apiKey` is required. Can be set as an environment variable `LLAMA_CLOUD_API_KEY`
- `checkInterval` is the interval in seconds to check if the parsing is done. Default is `1`.
- `maxTimeout` is the maximum timeout to wait for parsing to finish. Default is `2000`
- `verbose` shows progress of the parsing. Default is `true`
- `ignoreErrors` set to false to get errors while parsing. Default is `true` and returns an empty array on error.
#### Advanced params:
- `resultType` can be set to `markdown`, `text` or `json`. Defaults to `text`. More information about `json` mode on the next pages.
- `language` primarily helps with OCR recognition. Defaults to `en`. Click [here](../../../api/type-aliases/Language.md) for a list of supported languages.
- `parsingInstructions?` Optional. Can help with complicated document structures. See this [LlamaIndex Blog Post](https://www.llamaindex.ai/blog/launching-the-first-genai-native-document-parsing-platform) for an example.
- `skipDiagonalText?` Optional. Set to true to ignore diagonal text. (Text that is not rotated 0, 90, 180 or 270 degrees)
- `invalidateCache?` Optional. Set to true to ignore the LlamaCloud cache. All document are kept in cache for 48hours after the job was completed to avoid processing the same document twice. Can be useful for testing when trying to re-parse the same document with, e.g. different `parsingInstructions`.
- `doNotCache?` Optional. Set to true to not cache the document.
- `fastMode?` Optional. Set to true to use the fast mode. This mode will skip OCR of images, and table/heading reconstruction. Note: Non-compatible with `gpt4oMode`.
- `doNotUnrollColumns?` Optional. Set to true to keep the text according to document layout. Reduce reconstruction accuracy, and LLMs/embeddings performances in most cases.
- `pageSeparator?` Optional. The page separator to use. Defaults is `\\n---\\n`.
- `gpt4oMode` Deprecated. Use vendorMultimodal params. Set to true to use GPT-4o to extract content. Default is `false`.
- `gpt4oApiKey?` Deprecated. Use vendorMultimodal params. Optional. Set the GPT-4o API key. Lowers the cost of parsing by using your own API key. Your OpenAI account will be charged. Can also be set in the environment variable `LLAMA_CLOUD_GPT4O_API_KEY`.
- `boundingBox?` Optional. Specify an area of the document to parse. Expects the bounding box margins as a string in clockwise order, e.g. `boundingBox = "0.1,0,0,0"` to not parse the top 10% of the document.
- `targetPages?` Optional. Specify which pages to parse by specifying them as a comma-separated list. First page is `0`.
- `useVendorMultimodalModel` set to true to use a multimodal model. Default is `false`.
- `vendorMultimodalModel?` Optional. Specify which multimodal model to use. Default is GPT4o. See [here](https://docs.cloud.llamaindex.ai/llamaparse/features/multimodal) for a list of available models and cost.
- `vendorMultimodalApiKey?` Optional. Set the multimodal model API key. Can also be set in the environment variable `LLAMA_CLOUD_VENDOR_MULTIMODAL_API_KEY`.
- `numWorkers` as in the python version, is set in `SimpleDirectoryReader`. Default is 1.
### LlamaParse with SimpleDirectoryReader
Below a full example of `LlamaParse` integrated in `SimpleDirectoryReader` with additional options.
<CodeBlock language="ts">{CodeSource2}</CodeBlock>
## API Reference
- [SimpleDirectoryReader](../../../api/classes/SimpleDirectoryReader.md)
- [LlamaParseReader](../../../api/classes/LlamaParseReader.md)
@@ -0,0 +1,95 @@
---
sidebar_position: 1
---
# JSON Mode
In JSON mode, LlamaParse will return a data structure representing the parsed object.
## Usage
For Json mode, you need to use `loadJson`. The `resultType` is automatically set with this method.
More information about indexing the results on the next page.
```ts
const reader = new LlamaParseReader();
async function main() {
// Load the file and return an array of json objects
const jsonObjs = await reader.loadJson("../data/uber_10q_march_2022.pdf");
// Access the first "pages" (=a single parsed file) object in the array
const jsonList = jsonObjs[0]["pages"];
// Further process the jsonList object as needed.
}
```
### Output
The result format of the response, written to `jsonObjs` in the example, follows this structure:
```json
{
"pages": [
..page objects..
],
"job_metadata": {
"credits_used": int,
"credits_max": int,
"job_credits_usage": int,
"job_pages": int,
"job_is_cache_hit": boolean
},
"job_id": string ,
"file_path": string,
}
}
```
#### Page objects
Within page objects, the following keys may be present depending on your document.
- `page`: The page number of the document.
- `text`: The text extracted from the page.
- `md`: The markdown version of the extracted text.
- `images`: Any images extracted from the page.
- `items`: An array of heading, text and table objects in the order they appear on the page.
### JSON Mode with SimpleDirectoryReader
All Readers share a `loadData` method with `SimpleDirectoryReader` that promises to return a uniform Document with Metadata. This makes JSON mode incompatible with SimpleDirectoryReader.
However, a simple work around is to create a new reader class that extends `LlamaParseReader` and adds a new method or overrides `loadData`, wrapping around JSON mode, extracting the required values, and returning a Document object.
```ts
import { LlamaParseReader, Document } from "llamaindex";
class LlamaParseReaderWithJson extends LlamaParseReader {
// Override the loadData method
override async loadData(filePath: string): Promise<Document[]> {
// Call loadJson method that was inherited by LlamaParseReader
const jsonObjs = await super.loadJson(filePath);
let documents: Document[] = [];
jsonObjs.forEach((jsonObj) => {
// Making sure it's an array before iterating over it
if (Array.isArray(jsonObj.pages)) {
}
const docs = jsonObj.pages.map(
(page: { text: string; page: number }) =>
new Document({ text: page.text, metadata: { page: page.page } }),
);
documents = documents.concat(docs);
});
return documents;
}
}
```
Now we have documents with page number as metadata. This new reader can be used like any other and be integrated with SimpleDirectoryReader. Since it extends `LlamaParseReader`, you can use the same params.
You can assign any other values of the JSON response to the Document as needed.
## API Reference
- [LlamaParseReader](../../../api/classes/LlamaParseReader.md)
- [SimpleDirectoryReader](../../../api/classes/SimpleDirectoryReader.md)
@@ -14,5 +14,5 @@ document = new Document({ text: "text", metadata: { key: "val" } });
## API Reference
- [Document](../api/classes/Document.md)
- [TextNode](../api/classes/TextNode.md)
- [Document](../../api/classes/Document.md)
- [TextNode](../../api/classes/TextNode.md)
@@ -43,3 +43,10 @@ async function main() {
main().then(() => console.log("done"));
```
## API Reference
- [SummaryExtractor](../../api/classes/SummaryExtractor.md)
- [QuestionsAnsweredExtractor](../../api/classes/QuestionsAnsweredExtractor.md)
- [TitleExtractor](../../api/classes/TitleExtractor.md)
- [KeywordExtractor](../../api/classes/KeywordExtractor.md)
@@ -0,0 +1,83 @@
# DeepInfra
To use DeepInfra embeddings, you need to import `DeepInfraEmbedding` from llamaindex.
Check out available embedding models [here](https://deepinfra.com/models/embeddings).
```ts
import {
DeepInfraEmbedding,
Settings,
Document,
VectorStoreIndex,
} from "llamaindex";
// Update Embed Model
Settings.embedModel = new DeepInfraEmbedding();
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,
});
```
By default, DeepInfraEmbedding is using the sentence-transformers/clip-ViT-B-32 model. You can change the model by passing the model parameter to the constructor.
For example:
```ts
import { DeepInfraEmbedding } from "llamaindex";
const model = "intfloat/e5-large-v2";
Settings.embedModel = new DeepInfraEmbedding({
model,
});
```
You can also set the `maxRetries` and `timeout` parameters when initializing `DeepInfraEmbedding` for better control over the request behavior.
For example:
```ts
import { DeepInfraEmbedding, Settings } from "llamaindex";
const model = "intfloat/e5-large-v2";
const maxRetries = 5;
const timeout = 5000; // 5 seconds
Settings.embedModel = new DeepInfraEmbedding({
model,
maxRetries,
timeout,
});
```
Standalone usage:
```ts
import { DeepInfraEmbedding } from "llamaindex";
import { config } from "dotenv";
// For standalone usage, you need to configure DEEPINFRA_API_TOKEN in .env file
config();
const main = async () => {
const model = "intfloat/e5-large-v2";
const embeddings = new DeepInfraEmbedding({ model });
const text = "What is the meaning of life?";
const response = await embeddings.embed([text]);
console.log(response);
};
main();
```
For questions or feedback, please contact us at [feedback@deepinfra.com](mailto:feedback@deepinfra.com)
## API Reference
- [DeepInfraEmbedding](../../../api/classes/DeepInfraEmbedding.md)
@@ -31,3 +31,7 @@ Settings.embedModel = new GeminiEmbedding({
model: GEMINI_MODEL.GEMINI_PRO_LATEST,
});
```
## API Reference
- [GeminiEmbedding](../../../api/classes/GeminiEmbedding.md)
@@ -32,3 +32,7 @@ Settings.embedModel = new HuggingFaceEmbedding({
quantized: false,
});
```
## API Reference
- [HuggingFaceEmbedding](../../../api/classes/HuggingFaceEmbedding.md)
@@ -19,3 +19,7 @@ const results = await queryEngine.query({
query,
});
```
## API Reference
- [JinaAIEmbedding](../../../api/classes/JinaAIEmbedding.md)
@@ -22,3 +22,7 @@ const results = await queryEngine.query({
query,
});
```
## API Reference
- [MistralAIEmbedding](../../../api/classes/MistralAIEmbedding.md)
@@ -0,0 +1,100 @@
# MixedbreadAI
Welcome to the mixedbread embeddings guide! This guide will help you use the mixedbread ai's API to generate embeddings for your text documents, ensuring you get the most relevant information, just like picking the freshest bread from the bakery.
To find out more about the latest features, updates, and available models, visit [mixedbread.ai](https://mixedbread-ai.com/).
## Table of Contents
1. [Setup](#setup)
2. [Usage with LlamaIndex](#integration-with-llamaindex)
3. [Embeddings with Custom Parameters](#embeddings-with-custom-parameters)
## Setup
First, you will need to install the `llamaindex` package.
```bash
pnpm install llamaindex
```
Next, sign up for an API key at [mixedbread.ai](https://mixedbread.ai/). Once you have your API key, you can import the necessary modules and create a new instance of the `MixedbreadAIEmbeddings` class.
```ts
import { MixedbreadAIEmbeddings, Document, Settings } from "llamaindex";
```
## Usage with LlamaIndex
This section will guide you through integrating mixedbread embeddings with LlamaIndex for more advanced usage.
### Step 1: 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, like a variety of breads in a bakery.
```ts
Settings.embedModel = new MixedbreadAIEmbeddings({
apiKey: "<MIXEDBREAD_API_KEY>",
model: "mixedbread-ai/mxbai-embed-large-v1",
});
const document = new Document({
text: "The true source of happiness.",
id_: "bread",
});
const index = await VectorStoreIndex.fromDocuments([document]);
```
### Step 2: Create a Query Engine
Combine the retriever and the embed model to create a query engine. This setup ensures that your queries are processed to provide the best results, like arranging the bread in the order of freshness and quality.
Models can require prompts to generate embeddings for queries, in the 'mixedbread-ai/mxbai-embed-large-v1' model's case, the prompt is `Represent this sentence for searching relevant passages:`.
```ts
const queryEngine = index.asQueryEngine();
const query =
"Represent this sentence for searching relevant passages: What is bread?";
// Log the response
const results = await queryEngine.query(query);
console.log(results); // Serving up the freshest, most relevant results.
```
## Embeddings with Custom Parameters
This section will guide you through generating embeddings with custom parameters and usage with f.e. matryoshka and binary embeddings.
### Step 1: Create an Instance of MixedbreadAIEmbeddings
Create a new instance of the `MixedbreadAIEmbeddings` class with custom parameters. For example, to use the `mixedbread-ai/mxbai-embed-large-v1` model with a batch size of 64, normalized embeddings, and binary encoding format:
```ts
const embeddings = new MixedbreadAIEmbeddings({
apiKey: "<MIXEDBREAD_API_KEY>",
model: "mixedbread-ai/mxbai-embed-large-v1",
batchSize: 64,
normalized: true,
dimensions: 512,
encodingFormat: MixedbreadAI.EncodingFormat.Binary,
});
```
### Step 2: Define Texts
Define the texts you want to generate embeddings for.
```ts
const texts = ["Bread is life", "Bread is love"];
```
### Step 3: Generate Embeddings
Use the `embedDocuments` method to generate embeddings for the texts.
```ts
const result = await embeddings.embedDocuments(texts);
console.log(result); // Perfectly customized embeddings, ready to serve.
```
@@ -27,3 +27,7 @@ const results = await queryEngine.query({
query,
});
```
## API Reference
- [OllamaEmbedding](../../../api/classes/OllamaEmbedding.md)
@@ -19,3 +19,7 @@ const results = await queryEngine.query({
query,
});
```
## API Reference
- [OpenAIEmbedding](../../../api/classes/OpenAIEmbedding.md)
@@ -21,3 +21,7 @@ const results = await queryEngine.query({
query,
});
```
## API Reference
- [TogetherEmbedding](../../../api/classes/TogetherEmbedding.md)
@@ -21,7 +21,7 @@ export OPENAI_API_KEY=your-api-key
Import the required modules:
```ts
import { CorrectnessEvaluator, OpenAI, Settings } from "llamaindex";
import { CorrectnessEvaluator, OpenAI, Settings, Response } from "llamaindex";
```
Let's setup gpt-4 for better results:
@@ -45,7 +45,7 @@ const evaluator = new CorrectnessEvaluator();
const result = await evaluator.evaluateResponse({
query,
response,
response: new Response(response),
});
console.log(
@@ -56,3 +56,7 @@ console.log(
```bash
the response is not correct with a score of 2.5
```
## API Reference
- [CorrectnessEvaluator](../../../api/classes/CorrectnessEvaluator.md)
@@ -76,3 +76,7 @@ console.log(`the response is ${result.passing ? "faithful" : "not faithful"}`);
```bash
the response is faithful
```
## API Reference
- [FaithfulnessEvaluator](../../../api/classes/FaithfulnessEvaluator.md)
@@ -21,7 +21,13 @@ export OPENAI_API_KEY=your-api-key
Import the required modules:
```ts
import { RelevancyEvaluator, OpenAI, Settings } from "llamaindex";
import {
RelevancyEvaluator,
OpenAI,
Settings,
Document,
VectorStoreIndex,
} from "llamaindex";
```
Let's setup gpt-4 for better results:
@@ -64,3 +70,7 @@ console.log(`the response is ${result.passing ? "relevant" : "not relevant"}`);
```bash
the response is relevant
```
## API Reference
- [RelevancyEvaluator](../../../api/classes/RelevancyEvaluator.md)
@@ -97,3 +97,7 @@ async function main() {
main().catch(console.error);
```
## API Reference
- [IngestionPipeline](../../api/classes/IngestionPipeline.md)
@@ -4,9 +4,9 @@ A transformation is something that takes a list of nodes as an input, and return
Currently, the following components are Transformation objects:
- [SimpleNodeParser](../api/classes/SimpleNodeParser.md)
- [SimpleNodeParser](../../api/classes/SimpleNodeParser.md)
- [MetadataExtractor](../documents_and_nodes/metadata_extraction.md)
- Embeddings
- [Embeddings](../embeddings/index.md)
## Usage Pattern
@@ -63,3 +63,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [Anthropic](../../../api/classes/Anthropic.md)
@@ -74,3 +74,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [OpenAI](../../../api/classes/OpenAI.md)
@@ -0,0 +1,66 @@
# Bedrock
## Usage
```ts
import { BEDROCK_MODELS, Bedrock } from "@llamaindex/community";
Settings.llm = new Bedrock({
model: BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
region: "us-east-1", // can be provided via env AWS_REGION
credentials: {
accessKeyId: "...", // optional and can be provided via env AWS_ACCESS_KEY_ID
secretAccessKey: "...", // optional and can be provided via env AWS_SECRET_ACCESS_KEY
},
});
```
Currently only supports Anthropic and Meta models:
```ts
ANTHROPIC_CLAUDE_INSTANT_1 = "anthropic.claude-instant-v1";
ANTHROPIC_CLAUDE_2 = "anthropic.claude-v2";
ANTHROPIC_CLAUDE_2_1 = "anthropic.claude-v2:1";
ANTHROPIC_CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0";
ANTHROPIC_CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0";
ANTHROPIC_CLAUDE_3_OPUS = "anthropic.claude-3-opus-20240229-v1:0"; // available on us-west-2
ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20240620-v1:0";
META_LLAMA2_13B_CHAT = "meta.llama2-13b-chat-v1";
META_LLAMA2_70B_CHAT = "meta.llama2-70b-chat-v1";
META_LLAMA3_8B_INSTRUCT = "meta.llama3-8b-instruct-v1:0";
META_LLAMA3_70B_INSTRUCT = "meta.llama3-70b-instruct-v1:0";
```
Sonnet, Haiku and Opus are multimodal, image_url only supports base64 data url format, e.g. `data:image/jpeg;base64,SGVsbG8sIFdvcmxkIQ==`
## Full Example
```ts
import { BEDROCK_MODELS, Bedrock } from "llamaindex";
Settings.llm = new Bedrock({
model: BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
});
async function main() {
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document]);
// Create a query engine
const queryEngine = index.asQueryEngine({
retriever,
});
const query = "What is the meaning of life?";
// Query
const response = await queryEngine.query({
query,
});
// Log the response
console.log(response.response);
}
```
@@ -0,0 +1,87 @@
# DeepInfra
Check out available LLMs [here](https://deepinfra.com/models/text-generation).
```ts
import { DeepInfra, Settings } from "llamaindex";
// Get the API key from `DEEPINFRA_API_TOKEN` environment variable
import { config } from "dotenv";
config();
Settings.llm = new DeepInfra();
// Set the API key
apiKey = "YOUR_API_KEY";
Settings.llm = new DeepInfra({ apiKey });
```
You can setup the apiKey on the environment variables, like:
```bash
export DEEPINFRA_API_TOKEN="<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
```ts
import { DeepInfra, Document, VectorStoreIndex, Settings } from "llamaindex";
// Use custom LLM
const model = "meta-llama/Meta-Llama-3-8B-Instruct";
Settings.llm = new DeepInfra({ model, temperature: 0 });
async function main() {
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
retriever,
});
const query = "What is the meaning of life?";
// Query
const response = await queryEngine.query({
query,
});
// Log the response
console.log(response.response);
}
```
## Feedback
If you have any feedback, please reach out to us at [feedback@deepinfra.com](mailto:feedback@deepinfra.com)
## API Reference
- [DeepInfra](../../../api/classes/DeepInfra)
@@ -59,3 +59,7 @@ async function main() {
main().catch(console.error);
```
## API Reference
- [FireworksLLM](../../../api/classes/FireworksLLM.md)
@@ -10,6 +10,36 @@ Settings.llm = new Gemini({
});
```
### Usage with Vertex AI
To use Gemini via Vertex AI you can use `GeminiVertexSession`.
GeminiVertexSession accepts the env variables: `GOOGLE_VERTEX_LOCATION` and `GOOGLE_VERTEX_PROJECT`
```ts
import { Gemini, GEMINI_MODEL, GeminiVertexSession } from "llamaindex";
const gemini = new Gemini({
model: GEMINI_MODEL.GEMINI_PRO,
session: new GeminiVertexSession({
location: "us-central1", // optional if provided by GOOGLE_VERTEX_LOCATION env variable
project: "project1", // optional if provided by GOOGLE_VERTEX_PROJECT env variable
googleAuthOptions: {...}, // optional, but useful for production. It accepts all values from `GoogleAuthOptions`
}),
});
```
[GoogleAuthOptions](https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts)
To authenticate for local development:
```bash
npm install @google-cloud/vertexai
gcloud auth application-default login
```
To authenticate for production you'll have to use a [service account](https://cloud.google.com/docs/authentication/). `googleAuthOptions` has `credentials` which might be useful for you.
## 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.
@@ -69,3 +99,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [Gemini](../../../api/classes/Gemini.md)
@@ -50,3 +50,7 @@ const results = await queryEngine.query({
<CodeBlock language="ts" showLineNumbers>
{CodeSource}
</CodeBlock>
## API Reference
- [Groq](../../../api/classes/Groq.md)
@@ -89,3 +89,8 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [LlamaDeuce](../../../api/variables/LlamaDeuce.md)
- [DeuceChatStrategy](../../../api/variables/DeuceChatStrategy.md)
@@ -3,7 +3,7 @@
## Usage
```ts
import { Ollama, Settings } from "llamaindex";
import { MistralAI, Settings } from "llamaindex";
Settings.llm = new MistralAI({
model: "mistral-tiny",
@@ -66,3 +66,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [MistralAI](../../../api/classes/MistralAI.md)
@@ -71,3 +71,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [Ollama](../../../api/classes/Ollama.md)
@@ -67,3 +67,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [OpenAI](../../../api/classes/OpenAI.md)
@@ -68,3 +68,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [Portkey](../../../api/classes/Portkey.md)
@@ -66,3 +66,7 @@ async function main() {
console.log(response.response);
}
```
## API Reference
- [TogetherLLM](../../../api/classes/TogetherLLM.md)
+1 -1
View File
@@ -32,4 +32,4 @@ For local LLMs, currently we recommend the use of [Ollama](./available_llms/olla
## API Reference
- [OpenAI](../api/classes/OpenAI.md)
- [OpenAI](../../api/classes/OpenAI.md)
+1
View File
@@ -95,3 +95,4 @@ The output metadata will be something like:
- [SimpleNodeParser](../api/classes/SimpleNodeParser.md)
- [SentenceSplitter](../api/classes/SentenceSplitter.md)
- [MarkdownNodeParser](../api/classes/MarkdownNodeParser.md)
@@ -39,8 +39,9 @@ const index = await VectorStoreIndex.fromDocuments([document]);
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;
const retriever = index.asRetriever({
similarityTopK: 5,
});
```
## Create a new instance of the CohereRerank class
@@ -65,3 +66,7 @@ const queryEngine = index.asQueryEngine({
// log the response
const response = await queryEngine.query("Where did the author grown up?");
```
## API Reference
- [CohereRerank](../../api/classes/CohereRerank.md)
@@ -103,3 +103,7 @@ const processor = new SimilarityPostprocessor({
const filteredNodes = processor.postprocessNodes(nodes);
```
## API Reference
- [SimilarityPostprocessor](../../api/classes/SimilarityPostprocessor.md)
@@ -39,8 +39,9 @@ const index = await VectorStoreIndex.fromDocuments([document]);
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;
const retriever = index.asRetriever({
similarityTopK: 5,
});
```
## Create a new instance of the JinaAIReranker class
@@ -69,3 +70,7 @@ const queryEngine = index.asQueryEngine({
// log the response
const response = await queryEngine.query("Where did the author grown up?");
```
## API Reference
- [JinaAIReranker](../../api/classes/JinaAIReranker.md)
@@ -0,0 +1,165 @@
# MixedbreadAI
Welcome to the mixedbread ai reranker guide! This guide will help you use mixedbread ai's API to rerank search query results, ensuring you get the most relevant information, just like picking the freshest bread from the bakery.
To find out more about the latest features and updates, visit the [mixedbread.ai](https://mixedbread.ai/).
## Table of Contents
1. [Setup](#setup)
2. [Usage with LlamaIndex](#integration-with-llamaindex)
3. [Simple Reranking Guide](#simple-reranking-guide)
4. [Reranking with Objects](#reranking-with-objects)
## Setup
First, you will need to install the `llamaindex` package.
```bash
pnpm install llamaindex
```
Next, sign up for an API key at [mixedbread.ai](https://mixedbread.ai/). Once you have your API key, you can import the necessary modules and create a new instance of the `MixedbreadAIReranker` class.
```ts
import {
MixedbreadAIReranker,
Document,
OpenAI,
VectorStoreIndex,
Settings,
} from "llamaindex";
```
## Usage with LlamaIndex
This section will guide you through integrating mixedbread's reranker with LlamaIndex.
### Step 1: 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, like a variety of breads in a bakery.
```ts
const document = new Document({
text: "This is a sample document.",
id_: "sampleDoc",
});
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.1 });
const index = await VectorStoreIndex.fromDocuments([document]);
```
### Step 2: Increase Similarity TopK
The default value for `similarityTopK` is 2, which means only the most similar document will be returned. To get more results, like picking a variety of fresh breads, you can increase the value of `similarityTopK`.
```ts
const retriever = index.asRetriever({
similarityTopK: 5,
});
```
### Step 3: Create a MixedbreadAIReranker Instance
Create a new instance of the `MixedbreadAIReranker` class.
```ts
const nodePostprocessor = new MixedbreadAIReranker({
apiKey: "<MIXEDBREAD_API_KEY>",
topN: 4,
});
```
### Step 4: Create a Query Engine
Combine the retriever and node postprocessor to create a query engine. This setup ensures that your queries are processed and reranked to provide the best results, like arranging the bread in the order of freshness and quality.
```ts
const queryEngine = index.asQueryEngine({
retriever,
nodePostprocessors: [nodePostprocessor],
});
// Log the response
const response = await queryEngine.query("Where did the author grow up?");
console.log(response);
```
With mixedbread's Reranker, you're all set to serve up the most relevant and well-ordered results, just like a skilled baker arranging their best breads for eager customers. Enjoy the perfect blend of technology and culinary delight!
## Simple Reranking Guide
This section will guide you through a simple reranking process using mixedbread ai.
### Step 1: Create an Instance of MixedbreadAIReranker
Create a new instance of the `MixedbreadAIReranker` class, passing in your API key and the number of results you want to return. It's like setting up your bakery to offer a specific number of freshly baked items.
```ts
const reranker = new MixedbreadAIReranker({
apiKey: "<MIXEDBREAD_API_KEY>",
topN: 4,
});
```
### Step 2: Define Nodes and Query
Define the nodes (documents) you want to rerank and the query.
```ts
const nodes = [
{ node: new BaseNode("To bake bread you need flour") },
{ node: new BaseNode("To bake bread you need yeast") },
];
const query = "What do you need to bake bread?";
```
### Step 3: Perform Reranking
Use the `postprocessNodes` method to rerank the nodes based on the query.
```ts
const result = await reranker.postprocessNodes(nodes, query);
console.log(result); // Like pulling freshly baked nodes out of the oven.
```
## Reranking with Objects
This section will guide you through reranking when working with objects.
### Step 1: Create an Instance of MixedbreadAIReranker
Create a new instance of the `MixedbreadAIReranker` class, just like before.
```ts
const reranker = new MixedbreadAIReranker({
apiKey: "<MIXEDBREAD_API_KEY>",
model: "mixedbread-ai/mxbai-rerank-large-v1",
topK: 5,
rankFields: ["title", "content"],
returnInput: true,
maxRetries: 5,
});
```
### Step 2: Define Documents and Query
Define the documents (objects) you want to rerank and the query.
```ts
const documents = [
{ title: "Bread Recipe", content: "To bake bread you need flour" },
{ title: "Bread Recipe", content: "To bake bread you need yeast" },
];
const query = "What do you need to bake bread?";
```
### Step 3: Perform Reranking
Use the `rerank` method to reorder the documents based on the query.
```ts
const result = await reranker.rerank(documents, query);
console.log(result); // Perfectly customized results, ready to serve.
```
+6
View File
@@ -70,3 +70,9 @@ const response = await queryEngine.query({
query: "What did the author do in college?",
});
```
## API Reference
- [TextQaPrompt](../../api/type-aliases/TextQaPrompt.md)
- [ResponseSynthesizer](../../api/classes/ResponseSynthesizer.md)
- [CompactAndRefine](../../api/classes/CompactAndRefine.md)
@@ -38,4 +38,4 @@ You can learn more about Tools by taking a look at the LlamaIndex Python documen
- [RetrieverQueryEngine](../../api/classes/RetrieverQueryEngine.md)
- [SubQuestionQueryEngine](../../api/classes/SubQuestionQueryEngine.md)
- [QueryEngineTool](../../api/interfaces/QueryEngineTool.md)
- [QueryEngineTool](../../api/classes/QueryEngineTool.md)
@@ -75,7 +75,7 @@ const queryEngine = index.asQueryEngine({
{
key: "dogId",
value: "2",
filterType: "ExactMatch",
operator: "==",
},
],
},
@@ -88,6 +88,8 @@ const response = await queryEngine.query({
console.log(response.toString());
```
Besides using the equal operator (`==`), you can also use a whole set of different [operators](../../api/interfaces/MetadataFilter.md#operator) to filter your documents.
## Full Code
```ts
@@ -135,7 +137,7 @@ async function main() {
{
key: "dogId",
value: "2",
filterType: "ExactMatch",
operator: "==",
},
],
},
@@ -151,3 +153,9 @@ async function main() {
main();
```
## API Reference
- [VectorStoreIndex](../../api/classes/VectorStoreIndex.md)
- [ChromaVectorStore](../../api/classes/ChromaVectorStore.md)
- [MetadataFilter](../../api/interfaces/MetadataFilter.md)
@@ -165,3 +165,7 @@ async function main() {
main().then(() => console.log("Done"));
```
## API Reference
- [RouterQueryEngine](../../api/classes/RouterQueryEngine.md)
+3 -2
View File
@@ -7,8 +7,9 @@ sidebar_position: 5
A retriever in LlamaIndex is what is used to fetch `Node`s from an index using a query string. Aa `VectorIndexRetriever` will fetch the top-k most similar nodes. Meanwhile, a `SummaryIndexRetriever` will fetch all nodes no matter the query.
```typescript
const retriever = vector_index.asRetriever();
retriever.similarityTopK = 3;
const retriever = vectorIndex.asRetriever({
similarityTopK: 3,
});
// Fetch nodes!
const nodesWithScore = await retriever.retrieve({ query: "query string" });
+1 -1
View File
@@ -23,4 +23,4 @@ const index = await VectorStoreIndex.fromDocuments([document], {
## API Reference
- [StorageContext](../api/interfaces//StorageContext.md)
- [StorageContext](../api/interfaces/StorageContext.md)
@@ -84,3 +84,7 @@ async function main() {
main().catch(console.error);
```
## API Reference
- [QdrantVectorStore](../../api/classes/QdrantVectorStore.md)
+1 -25
View File
@@ -25,30 +25,6 @@ const config = {
onBrokenLinks: "warn",
onBrokenMarkdownLinks: "warn",
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: "en",
locales: [
"en",
"zh-Hans",
"es",
"fr",
"de",
"ja",
"ko",
"pt",
"ar",
"it",
"tr",
"pl",
"nl",
"vi",
"th",
], // "fa", "ru", "ro", "sv", "hu", "cs", "el", "da", "fi", "he", "no", "hi", "in", "sl", "se", "sk", "uk", "bg", "hr", "lt", "lv", "et", "cat"
},
presets: [
[
"@docusaurus/preset-classic",
@@ -167,7 +143,7 @@ const config = {
[
"docusaurus-plugin-typedoc",
{
entryPoints: ["../../packages/core/src/index.ts"],
entryPoints: ["../../packages/llamaindex/src/index.ts"],
tsconfig: "../../tsconfig.json",
readme: "none",
sourceLinkTemplate:
Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

@@ -1 +0,0 @@
../../../../docs/api
@@ -1,86 +0,0 @@
---
sidebar_position: 3
---
# المفاهيم على المستوى العالي
`تمت ترجمة هذه الوثيقة تلقائيًا وقد تحتوي على أخطاء. لا تتردد في فتح طلب سحب لاقتراح تغييرات.`
يساعدك LlamaIndex.TS في بناء تطبيقات قائمة على LLM (مثل Q&A و chatbot) على بيانات مخصصة.
في هذا الدليل عن المفاهيم على المستوى العالي، ستتعلم:
- كيف يمكن لـ LLM الإجابة على الأسئلة باستخدام بياناتك الخاصة.
- المفاهيم الرئيسية والوحدات في LlamaIndex.TS لبناء خط أنابيب الاستعلام الخاص بك.
## الإجابة على الأسئلة عبر بياناتك
يستخدم LlamaIndex طريقة مكونة من مرحلتين عند استخدام LLM مع بياناتك:
1. **مرحلة الفهرسة**: إعداد قاعدة المعرفة، و
2. **مرحلة الاستعلام**: استرداد السياق ذي الصلة من المعرفة لمساعدة LLM في الاستجابة لسؤال
![](./_static/concepts/rag.jpg)
تُعرف هذه العملية أيضًا باسم "استرجاع معزز للتوليد" (RAG).
يوفر LlamaIndex.TS أدوات أساسية لجعل كلا المرحلتين سهلتين للغاية.
دعنا نستكشف كل مرحلة بالتفصيل.
### مرحلة الفهرسة
يساعدك LlamaIndex.TS في إعداد قاعدة المعرفة باستخدام مجموعة من موصلات البيانات والفهارس.
![](./_static/concepts/indexing.jpg)
[**محمّلات البيانات**](./modules/high_level/data_loader.md):
موصل البيانات (أي `Reader`) يقوم بتجميع البيانات من مصادر بيانات مختلفة وتنسيقات بيانات مختلفة في تمثيل بسيط للـ `Document` (نص وبيانات تعريفية بسيطة).
[**المستندات / العقد**](./modules/high_level/documents_and_nodes.md): المستند هو حاوية عامة حول أي مصدر بيانات - على سبيل المثال، ملف PDF، نتائج واجهة برمجة التطبيقات، أو بيانات استرداد من قاعدة بيانات. العقد هو الوحدة الذرية للبيانات في LlamaIndex ويمثل "قطعة" من المستند الأصلي. إنه تمثيل غني يتضمن بيانات تعريفية وعلاقات (مع عقد أخرى) لتمكين عمليات الاسترجاع الدقيقة والتعبيرية.
[**فهارس البيانات**](./modules/high_level/data_index.md):
بمجرد أن تقوم بتجميع بياناتك، يساعدك LlamaIndex في فهرسة البيانات في تنسيق سهل الاسترداد.
تحت الغطاء، يقوم LlamaIndex بتحليل المستندات الخام إلى تمثيلات وسيطة، وحساب تضمينات الناقلات، وتخزين بياناتك في الذاكرة أو على القرص.
"
### مرحلة الاستعلام
في مرحلة الاستعلام، يقوم خط الأنابيب للاستعلام بجلب السياق الأكثر صلة بناءً على استعلام المستخدم،
ويمرر ذلك إلى LLM (جنبًا إلى جنب مع الاستعلام) لتوليد استجابة.
يمنح ذلك LLM معرفة محدثة ليست موجودة في بيانات التدريب الأصلية لديه،
(مما يقلل أيضًا من الهلوسة).
التحدي الرئيسي في مرحلة الاستعلام هو الاسترجاع والتنسيق والاستدلال عبر قواعد المعرفة (المحتملة).
يوفر LlamaIndex وحدات قابلة للتركيب تساعدك في بناء ودمج خطوط أنابيب RAG لـ Q&A (محرك الاستعلام)، chatbot (محرك الدردشة)، أو كجزء من وكيل.
يمكن تخصيص هذه الكتل البنائية لتعكس تفضيلات التصنيف، وكذلك تركيبها للاستدلال عبر عدة قواعد معرفة بطريقة منظمة.
![](./_static/concepts/querying.jpg)
#### الكتل الأساسية
[**مسترجعات**](./modules/low_level/retriever.md):
يحدد المسترجع كيفية استرجاع السياق ذي الصلة بكفاءة من قاعدة المعرفة (أي الفهرس) عند إعطاء استعلام.
تختلف منطق الاسترجاع المحددة حسب الفهارس المختلفة، والأكثر شيوعًا هو الاسترجاع الكثيف ضد فهرس الناقل.
[**مركبات الاستجابة**](./modules/low_level/response_synthesizer.md):
تقوم مركبة الاستجابة بتوليد استجابة من LLM باستخدام استعلام المستخدم ومجموعة معينة من أجزاء النص المسترجعة.
"
#### خطوط الأنابيب
[**محركات الاستعلام**](./modules/high_level/query_engine.md):
محرك الاستعلام هو خط أنابيب شامل يتيح لك طرح الأسئلة على بياناتك.
يأخذ استعلامًا بلغة طبيعية ويعيد استجابة، جنبًا إلى جنب مع السياق المرجعي المسترجع والممرر إلى LLM.
[**محركات الدردشة**](./modules/high_level/chat_engine.md):
محرك الدردشة هو خط أنابيب شامل لإجراء محادثة مع بياناتك
(عدة تفاعلات بدلاً من سؤال وجواب واحد).
"
@@ -1,61 +0,0 @@
---
sidebar_position: 4
---
# أمثلة من البداية إلى النهاية
`تمت ترجمة هذه الوثيقة تلقائيًا وقد تحتوي على أخطاء. لا تتردد في فتح طلب سحب لاقتراح تغييرات.`
نقدم العديد من الأمثلة من البداية إلى النهاية باستخدام LlamaIndex.TS في المستودع
تحقق من الأمثلة أدناه أو جربها وأكملها في دقائق مع دروس تفاعلية على Github Codespace المقدمة من Dev-Docs [هنا](https://codespaces.new/team-dev-docs/lits-dev-docs-playground?devcontainer_path=.devcontainer%2Fjavascript_ltsquickstart%2Fdevcontainer.json):
## [محرك الدردشة](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/chatEngine.ts)
اقرأ ملفًا وتحدث عنه مع LLM.
## [فهرس الفيكتور](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/vectorIndex.ts)
إنشاء فهرس فيكتور واستعلامه. سيستخدم فهرس الفيكتور التضمينات لاسترداد أعلى k عقد ذات صلة. بشكل افتراضي ، يكون k الأعلى هو 2.
"
## [مؤشر الملخص](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/summaryIndex.ts)
إنشاء مؤشر قائمة واستعلامه. يستخدم هذا المثال أيضًا `LLMRetriever` ، الذي سيستخدم LLM لتحديد أفضل العقد لاستخدامها عند إنشاء الإجابة.
"
## [حفظ / تحميل فهرس](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/storageContext.ts)
إنشاء وتحميل فهرس ناقل. يحدث التخزين المؤقت على القرص تلقائيًا في LlamaIndex.TS بمجرد إنشاء كائن سياق التخزين.
"
## [فهرس الناقل المخصص](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/vectorIndexCustomize.ts)
إنشاء فهرس ناقل واستعلامه، مع تكوين `LLM` و `ServiceContext` و `similarity_top_k`.
"
## [OpenAI LLM](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/openai.ts)
أنشئ OpenAI LLM واستخدمه مباشرة للدردشة.
"
## [Llama2 DeuceLLM](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/llamadeuce.ts)
إنشاء Llama-2 LLM واستخدامه مباشرة للدردشة.
"
## [محرك استعلام الأسئلة الفرعية](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/subquestion.ts)
يستخدم `محرك استعلام الأسئلة الفرعية` الذي يقسم الاستعلامات المعقدة إلى أسئلة فرعية متعددة، ثم يجمع الاستجابة عبر الإجابات على جميع الأسئلة الفرعية.
"
## [وحدات منخفضة المستوى](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/lowlevel.ts)
يستخدم هذا المثال العديد من المكونات منخفضة المستوى، مما يزيل الحاجة إلى محرك استعلام فعلي. يمكن استخدام هذه المكونات في أي مكان، في أي تطبيق، أو تخصيصها وتصنيفها الفرعي لتلبية احتياجاتك الخاصة.
@@ -1,17 +0,0 @@
---
sidebar_position: 5
---
# البيئات
`تمت ترجمة هذه الوثيقة تلقائيًا وقد تحتوي على أخطاء. لا تتردد في فتح طلب سحب لاقتراح تغييرات.`
يدعم LlamaIndex حاليًا رسميًا NodeJS 18 و NodeJS 20.
## NextJS App Router
إذا كنت تستخدم معالج الطرق / الوظائف الخادمة في NextJS App Router ، فستحتاج إلى استخدام وضع NodeJS:
```js
export const runtime = "nodejs"; // الافتراضي
```
@@ -1,67 +0,0 @@
---
sidebar_position: 1
---
# التثبيت والإعداد
`تمت ترجمة هذه الوثيقة تلقائيًا وقد تحتوي على أخطاء. لا تتردد في فتح طلب سحب لاقتراح تغييرات.`
تأكد من أن لديك NodeJS v18 أو أحدث.
## باستخدام create-llama
أسهل طريقة للبدء مع LlamaIndex هي باستخدام `create-llama`. هذه الأداة سطر الأوامر تمكنك من بدء بناء تطبيق LlamaIndex جديد بسرعة، مع كل شيء معد لك.
ما عليك سوى تشغيل
<Tabs>
<TabItem value="1" label="npm" default>
```bash
npx create-llama@latest
```
</TabItem>
<TabItem value="2" label="Yarn">
```bash
yarn create llama
```
</TabItem>
<TabItem value="3" label="pnpm">
```bash
pnpm create llama@latest
```
</TabItem>
</Tabs>
للبدء. بمجرد إنشاء التطبيق الخاص بك، قم بتشغيل
```bash npm2yarn
npm run dev
```
لبدء خادم التطوير. يمكنك ثم زيارة [http://localhost:3000](http://localhost:3000) لرؤية تطبيقك.
## التثبيت من NPM
```bash npm2yarn
npm install llamaindex
```
### المتغيرات البيئية
تستخدم أمثلتنا OpenAI افتراضيًا. ستحتاج إلى إعداد مفتاح Open AI الخاص بك على النحو التالي:
```bash
export OPENAI_API_KEY="sk-......" # استبدله بالمفتاح الخاص بك من https://platform.openai.com/account/api-keys
```
إذا كنت ترغب في تحميله تلقائيًا في كل مرة، قم بإضافته إلى ملف .zshrc/.bashrc الخاص بك.
تحذير: لا تقم بإضافة مفتاح OpenAI الخاص بك إلى نظام التحكم في الإصدارات.
"
@@ -1,60 +0,0 @@
---
sidebar_position: 0
slug: /
---
# ما هو LlamaIndex.TS؟
`تمت ترجمة هذه الوثيقة تلقائيًا وقد تحتوي على أخطاء. لا تتردد في فتح طلب سحب لاقتراح تغييرات.`
LlamaIndex.TS هو إطار بيانات لتطبيقات LLM لاستيعاب وتنظيم والوصول إلى البيانات الخاصة أو الخاصة بالمجال. في حين أن حزمة Python متاحة أيضًا (انظر [هنا](https://docs.llamaindex.ai/en/stable/)), يوفر LlamaIndex.TS ميزات أساسية في حزمة بسيطة ، محسنة للاستخدام مع TypeScript.
## 🚀 لماذا LlamaIndex.TS؟
في جوهرها ، توفر LLMs واجهة لغة طبيعية بين البشر والبيانات المستنتجة. تأتي النماذج المتاحة على نطاق واسع محملة مسبقًا بكميات هائلة من البيانات المتاحة للجمهور ، من ويكيبيديا وقوائم البريد الإلكتروني إلى الكتب المدرسية وشفرة المصدر.
غالبًا ما تتطلب التطبيقات المبنية على LLMs تعزيز هذه النماذج بالبيانات الخاصة أو الخاصة بالمجال. للأسف ، يمكن توزيع هذه البيانات عبر تطبيقات ومخازن بيانات معزولة. إنها خلف واجهات برمجة التطبيقات ، في قواعد البيانات SQL ، أو محبوسة في ملفات PDF وعروض تقديمية.
هنا يأتي دور **LlamaIndex.TS**.
## 🦙 كيف يمكن أن يساعد LlamaIndex.TS؟
يوفر LlamaIndex.TS الأدوات التالية:
- **تحميل البيانات**: استيعاب البيانات الحالية الخاصة بك بتنسيقات `.txt`, `.pdf`, `.csv`, `.md` و `.docx` مباشرة.
- **فهارس البيانات**: تنظيم البيانات الخاصة بك في تمثيلات وسيطة سهلة وفعالة للاستخدام من قبل LLMs.
- **المحركات**: توفر واجهات الوصول إلى اللغة الطبيعية لبياناتك. على سبيل المثال:
- محركات الاستعلام هي واجهات استرجاع قوية للإخراج المعزز بالمعرفة.
- محركات الدردشة هي واجهات محادثة للتفاعلات "ذهابًا وإيابًا" متعددة الرسائل مع بياناتك.
## 👨‍👩‍👧‍👦 من أجل من هو LlamaIndex؟
يوفر LlamaIndex.TS مجموعة أدوات أساسية ، ضرورية لأي شخص يقوم ببناء تطبيقات LLM باستخدام JavaScript و TypeScript.
يتيح لنا واجهة برمجة التطبيقات على مستوى عالي استخدام LlamaIndex.TS لاستيعاب واستعلام البيانات الخاصة بهم.
بالنسبة للتطبيقات المعقدة أكثر ، تتيح لنا واجهات برمجة التطبيقات على مستوى أدنى للمستخدمين المتقدمين تخصيص وتوسيع أي وحدة - موصلات البيانات والفهارس وأجهزة الاسترجاع ومحركات الاستعلام - لتناسب احتياجاتهم.
## البدء
`npm install llamaindex`
تتضمن وثائقنا [تعليمات التثبيت](./installation.mdx) و[دليل البداية](./starter.md) لبناء تطبيقك الأول.
بمجرد أن تكون جاهزًا وتعمل ، يحتوي [مفاهيم عالية المستوى](./getting_started/concepts.md) على نظرة عامة على الهندسة المعمارية المتعددة المستويات لـ LlamaIndex. لمزيد من الأمثلة العملية التفصيلية ، يمكنك الاطلاع على [دروس النهاية إلى النهاية](./end_to_end.md).
## 🗺️ النظام البيئي
لتنزيل أو المساهمة ، ابحث عن LlamaIndex على:
- Github: https://github.com/run-llama/LlamaIndexTS
- NPM: https://www.npmjs.com/package/llamaindex
"
## المجتمع
هل تحتاج إلى مساعدة؟ هل لديك اقتراح لميزة؟ انضم إلى مجتمع LlamaIndex:
- تويتر: https://twitter.com/llama_index
- ديسكورد: https://discord.gg/dGcwcsnxhU

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