Compare commits

..

3 Commits

Author SHA1 Message Date
github-actions[bot] a108911fc1 Release 0.3.13 (#424)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-11-13 20:36:32 +08:00
Huu Le 282eaa07fc Fix: ts upload file does not create index and document store (#422) 2024-11-13 19:47:28 +08:00
Marcus Schiesser 80db5f7c46 add help comment 2024-11-13 14:50:23 +08:00
8 changed files with 37 additions and 9 deletions
+6
View File
@@ -1,5 +1,11 @@
# create-llama
## 0.3.13
### Patch Changes
- 282eaa0: Ensure that the index and document store are created when uploading a file with no available index.
## 0.3.12
### Patch Changes
+7 -1
View File
@@ -217,7 +217,13 @@ Otherwise, use CHROMA_HOST and CHROMA_PORT config above`,
},
];
default:
return [];
return [
{
name: "STORAGE_CACHE_DIR",
description: "The directory to store the local storage cache.",
value: ".cache",
},
];
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "create-llama",
"version": "0.3.12",
"version": "0.3.13",
"description": "Create LlamaIndex-powered apps with one command",
"keywords": [
"rag",
@@ -3,6 +3,7 @@ import {
IngestionPipeline,
Settings,
SimpleNodeParser,
storageContextFromDefaults,
VectorStoreIndex,
} from "llamaindex";
@@ -28,11 +29,20 @@ export async function runPipeline(
return documents.map((document) => document.id_);
} else {
// Initialize a new index with the documents
const newIndex = await VectorStoreIndex.fromDocuments(documents);
newIndex.storageContext.docStore.persist();
console.log(
"Got empty index, created new index with the uploaded documents",
);
const persistDir = process.env.STORAGE_CACHE_DIR;
if (!persistDir) {
throw new Error("STORAGE_CACHE_DIR environment variable is required!");
}
const storageContext = await storageContextFromDefaults({
persistDir,
});
const newIndex = await VectorStoreIndex.fromDocuments(documents, {
storageContext,
});
await newIndex.storageContext.docStore.persist();
return documents.map((document) => document.id_);
}
}
@@ -5,7 +5,6 @@ import * as dotenv from "dotenv";
import { getDocuments } from "./loader";
import { initSettings } from "./settings";
import { STORAGE_CACHE_DIR } from "./shared";
// Load environment variables from local .env file
dotenv.config();
@@ -20,9 +19,13 @@ async function getRuntime(func: any) {
async function generateDatasource() {
console.log(`Generating storage context...`);
// Split documents, create embeddings and store them in the storage context
const persistDir = process.env.STORAGE_CACHE_DIR;
if (!persistDir) {
throw new Error("STORAGE_CACHE_DIR environment variable is required!");
}
const ms = await getRuntime(async () => {
const storageContext = await storageContextFromDefaults({
persistDir: STORAGE_CACHE_DIR,
persistDir,
});
const documents = await getDocuments();
@@ -1,10 +1,13 @@
import { SimpleDocumentStore, VectorStoreIndex } from "llamaindex";
import { storageContextFromDefaults } from "llamaindex/storage/StorageContext";
import { STORAGE_CACHE_DIR } from "./shared";
export async function getDataSource(params?: any) {
const persistDir = process.env.STORAGE_CACHE_DIR;
if (!persistDir) {
throw new Error("STORAGE_CACHE_DIR environment variable is required!");
}
const storageContext = await storageContextFromDefaults({
persistDir: `${STORAGE_CACHE_DIR}`,
persistDir,
});
const numberOfDocs = Object.keys(
@@ -1 +0,0 @@
export const STORAGE_CACHE_DIR = "./cache";
@@ -1,2 +1,3 @@
# TODO: You can add observability here. For templates re-start `create-llama` with `--pro` flag to generate a new project with observability.
def init_observability():
pass