-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brace/bump cohere #3263
Merged
Merged
Brace/bump cohere #3263
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e078e9a
bump cohere to support v3 embeddings
bracesproul 7b9c2f2
chore: lint files
bracesproul f53de92
nit
bracesproul 5ca73cd
Remove unused example file, add cohere example
bracesproul 5ddc1ab
wut
bracesproul eb5dc57
chore: lint files
bracesproul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -902,7 +902,7 @@ | |
"closevector-common": "0.1.0-alpha.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great work on the PR! I've noticed a change in the dev dependency "cohere-ai" from ">=6.0.0" to "^7.2.0". This comment is to flag the change for maintainers to review. |
||
"closevector-node": "0.1.0-alpha.10", | ||
"closevector-web": "0.1.0-alpha.15", | ||
"cohere-ai": ">=6.0.0", | ||
"cohere-ai": "^7.2.0", | ||
"convex": "^1.3.1", | ||
"d3-dsv": "^2.0.0", | ||
"dotenv": "^16.0.3", | ||
|
@@ -1019,7 +1019,7 @@ | |
"closevector-common": "0.1.0-alpha.1", | ||
"closevector-node": "0.1.0-alpha.10", | ||
"closevector-web": "0.1.0-alpha.16", | ||
"cohere-ai": ">=6.0.0", | ||
"cohere-ai": "^7.2.0", | ||
"convex": "^1.3.1", | ||
"d3-dsv": "^2.0.0", | ||
"epub2": "^3.0.1", | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This PR adds code that accesses an environment variable via
process.env
to retrieve the API key for theCohereEmbeddings
instance. Please review this change to ensure the environment variable is properly set and handled.