Skip to content

Commit

Permalink
chore: fix building errors for vector_db provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jack0pan committed Jul 17, 2024
1 parent 7e71460 commit 7ba22d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions consts/envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const MODEL_KNOWLEDGE_CUTOFF = "MODEL_KNOWLEDGE_CUTOFF";
// this env names for embedding
export const EMBEDDING_POVIDER = "EMBEDDING_POVIDER";
export const EMBEDDING_MODELS = "EMBEDDING_MODELS";
export const EMBEDDING_DIMENSION = "EMBEDDING_DIMENSION";

// the env var names of anthropic
export const ANTHROPIC_API_URL = "ANTHROPIC_API_URL";
Expand All @@ -43,3 +44,5 @@ export const MODELS_MAPPING = "MODELS_MAPPING";
export const GOOGLE_API_URL = "GOOGLE_API_URL";
export const GOOGLE_API_KEY = "GOOGLE_API_KEY";
export const GOOGLE_API_VERSION = "GOOGLE_API_VERSION";

export const PGVECTOR_URL = "PGVECTOR_URL";
17 changes: 12 additions & 5 deletions providers/vector_db/pgvector.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { Pool, QueryArguments } from "$postgres/mod.ts";
import * as log from "$std/log/mod.ts";

const databaseUrl = Deno.env.get("PGVECTOR_URL")!;
const embeddingDimension = Deno.env.get("EMBEDDING_DIMENSION")!;
import { getEnv } from "$/utils/env.ts";
import { EMBEDDING_DIMENSION, PGVECTOR_URL } from "$/consts/envs.ts";

export default class Client {
static pool = new Pool(databaseUrl, 3, true);
static pool = new Pool(
getEnv(
PGVECTOR_URL,
"postgres://postgres:postgres@localhost:5432/assistant",
),
5,
true,
);
static embeddingDimension = getEnv(EMBEDDING_DIMENSION, "1536");

public static async create(vectorStoreId: string) {
const sql = `
Expand All @@ -14,7 +21,7 @@ export default class Client {
file_id TEXT NOT NULL,
file_name TEXT NOT NULL,
content TEXT NOT NULL,
embedding VECTOR(${embeddingDimension})
embedding VECTOR(${this.embeddingDimension})
)
`;
await this.query(sql);
Expand Down

0 comments on commit 7ba22d8

Please sign in to comment.