-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bump cohere to support v3 embeddings * chore: lint files * nit * Remove unused example file, add cohere example * wut * chore: lint files
- Loading branch information
1 parent
3983e5c
commit 95f8563
Showing
7 changed files
with
130 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
import { CohereEmbeddings } from "langchain/embeddings/cohere"; | ||
|
||
export const run = async () => { | ||
const model = new CohereEmbeddings(); | ||
const res = await model.embedQuery( | ||
"What would be a good company name a company that makes colorful socks?" | ||
); | ||
console.log({ res }); | ||
}; | ||
const cohere = new CohereEmbeddings({ | ||
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.COHERE_API_KEY | ||
batchSize: 48, // Default value if omitted is 48. Max value is 96 | ||
modelName: "embed-english-v3.0", // Default value if omitted is "small". | ||
inputType: "classification", // Optional parameter unless using a v3 model. | ||
}); | ||
|
||
const texts = [ | ||
"I love Cohere!", | ||
"I hate Cohere!", | ||
"I feel neutral about Cohere.", | ||
]; | ||
|
||
const embeddings = await cohere.embedDocuments(texts); | ||
console.log(embeddings); | ||
/** | ||
* [ | ||
[ | ||
-0.007194519, -0.009376526, -0.10015869, -0.06750488, | ||
-0.011001587, -0.034454346, -0.074523926, 0.03756714, | ||
... 943 more items | ||
], | ||
[ | ||
-0.009613037, -0.022705078, -0.07318115, -0.02255249, -0.019729614, | ||
0.009689331, -0.024749756, -0.06665039, -0.02128601, -0.010520935, | ||
... 943 more items | ||
], | ||
[ | ||
0.009689331, -0.024749756, -0.06665039, -0.02128601, -0.010520935, | ||
-0.007194519, -0.009376526, -0.10015869, -0.06750488, -0.02128601, | ||
... 943 more items | ||
] | ||
] | ||
*/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95f8563
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
langchainjs-docs – ./docs/core_docs/
langchainjs-docs-langchain.vercel.app
langchainjs-docs-git-main-langchain.vercel.app
langchainjs-docs-ruddy.vercel.app
js.langchain.com