Skip to content

Commit

Permalink
added right params for caching, length
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed Feb 14, 2025
1 parent 18dee81 commit 8657273
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@ packages/*/dist/*
**/.docusaurus/**
**/docs/build/**

**lock**
**lock**

packages/agent/local_**
13 changes: 7 additions & 6 deletions packages/plugin-anthropic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ export const anthropicPlugin: Plugin = {
return text;
},
[ModelClass.TEXT_EMBEDDING]: async (runtime, text: string | null) => {

// TODO: Make this fallback only!!!
// TODO: pass on cacheDir to FlagEmbedding.init
if (!text) return new Array(1536).fill(0);

const model = await FlagEmbedding.init({ model: EmbeddingModel.BGESmallENV15 });
// TODO: check if other plugin provides TEXT_EMBEDDING model
// Runtime will break if openai was used for TEXT_EMBEDDING before
const model = await FlagEmbedding.init({
model: EmbeddingModel.BGESmallENV15,
cacheDir: runtime.cacheDir,
maxLength: 512
});
const embedding = await model.queryEmbed(text);

const finalEmbedding = Array.isArray(embedding)
Expand Down

0 comments on commit 8657273

Please sign in to comment.