Skip to content

Commit

Permalink
fix: move chunk config to setting
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn committed Apr 8, 2024
1 parent baaae79 commit 0303730
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 20 deletions.
3 changes: 0 additions & 3 deletions templates/components/vectordbs/typescript/astra/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export const CHUNK_SIZE = 512;
export const CHUNK_OVERLAP = 20;

const REQUIRED_ENV_VARS = [
"ASTRA_DB_APPLICATION_TOKEN",
"ASTRA_DB_ENDPOINT",
Expand Down
3 changes: 0 additions & 3 deletions templates/components/vectordbs/typescript/milvus/shared.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { MilvusClient } from "@zilliz/milvus2-sdk-node";

export const CHUNK_SIZE = 512;
export const CHUNK_OVERLAP = 20;

const REQUIRED_ENV_VARS = [
"MILVUS_ADDRESS",
"MILVUS_USERNAME",
Expand Down
3 changes: 0 additions & 3 deletions templates/components/vectordbs/typescript/mongo/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export const CHUNK_SIZE = 512;
export const CHUNK_OVERLAP = 20;

const REQUIRED_ENV_VARS = [
"MONGO_URI",
"MONGODB_DATABASE",
Expand Down
2 changes: 0 additions & 2 deletions templates/components/vectordbs/typescript/none/shared.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export const STORAGE_CACHE_DIR = "./cache";
export const CHUNK_SIZE = 512;
export const CHUNK_OVERLAP = 20;
2 changes: 0 additions & 2 deletions templates/components/vectordbs/typescript/pg/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export const PGVECTOR_COLLECTION = "data";
export const CHUNK_SIZE = 512;
export const CHUNK_OVERLAP = 20;
export const PGVECTOR_SCHEMA = "public";
export const PGVECTOR_TABLE = "llamaindex_embedding";

Expand Down
3 changes: 0 additions & 3 deletions templates/components/vectordbs/typescript/pinecone/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export const CHUNK_SIZE = 512;
export const CHUNK_OVERLAP = 20;

const REQUIRED_ENV_VARS = ["PINECONE_ENVIRONMENT", "PINECONE_API_KEY"];

export function checkRequiredEnvVars() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OpenAI, Settings } from "llamaindex";
import { CHUNK_OVERLAP, CHUNK_SIZE } from "./shared";

const CHUNK_SIZE = 512;
const CHUNK_OVERLAP = 20;

export const initSettings = async () => {
Settings.llm = new OpenAI({
model: (process.env.MODEL as any) ?? "gpt-3.5-turbo",
model: process.env.MODEL ?? "gpt-3.5-turbo",
maxTokens: 512,
});
Settings.chunkSize = CHUNK_SIZE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OpenAI, Settings } from "llamaindex";
import { CHUNK_OVERLAP, CHUNK_SIZE } from "./shared";

const CHUNK_SIZE = 512;
const CHUNK_OVERLAP = 20;

export const initSettings = async () => {
Settings.llm = new OpenAI({
model: (process.env.MODEL as any) ?? "gpt-3.5-turbo",
model: process.env.MODEL ?? "gpt-3.5-turbo",
maxTokens: 512,
});
Settings.chunkSize = CHUNK_SIZE;
Expand Down

0 comments on commit 0303730

Please sign in to comment.