Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cohere-ai

Package Overview
Dependencies
Maintainers
3
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cohere-ai - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

23

dist/cohere.d.ts
import * as models from './models';
interface CohereService {
init(key: string, version?: string): void;
generate(model: string, config: models.generate): Promise<models.cohereResponse<models.text>>;
embed(model: string, config: models.embed): Promise<models.cohereResponse<models.embeddings>>;
chooseBest(model: string, config: models.chooseBest): Promise<models.cohereResponse<models.scores>>;
extract(model: string, config: models.extract): Promise<models.cohereResponse<models.extraction[]>>;
generate(config: models.generate): Promise<models.cohereResponse<models.text>>;
embed(config: models.embed): Promise<models.cohereResponse<models.embeddings>>;
extract(config: models.extract): Promise<models.cohereResponse<models.extraction[]>>;
}

@@ -15,3 +14,3 @@ declare class Cohere implements CohereService {

*/
generate(model: string, config: models.generate): Promise<models.cohereResponse<models.text>>;
generate(config: models.generate): Promise<models.cohereResponse<models.text>>;
/** Returns text embeddings. An embedding is a list of floating point numbers that captures semantic

@@ -21,21 +20,13 @@ * information about the text that it represents.

*/
embed(model: string, config: models.embed): Promise<models.cohereResponse<models.embeddings>>;
/** Uses likelihood to perform classification. Given a query text that you'd like to classify between
* a number of options, Choose Best will return a score between the query and each option.
* See: https://docs.cohere.ai/choose-best-reference
*/
embed(config: models.embed): Promise<models.cohereResponse<models.embeddings>>;
/**
* @deprecated Will be deleted in favor of 'classify'.
*/
chooseBest(model: string, config: models.chooseBest): Promise<models.cohereResponse<models.scores>>;
/**
* Classifies text as one of the given labels. Returns a confidence score for each label.
*/
classify(model: string, config: models.classify): Promise<models.cohereResponse<models.classifications>>;
classify(config: models.classify): Promise<models.cohereResponse<models.classifications>>;
/**
* Extract text from texts, with examples
*/
extract(model: string, config: models.extract): Promise<models.cohereResponse<models.extraction[]>>;
extract(config: models.extract): Promise<models.cohereResponse<models.extraction[]>>;
}
declare const cohere: Cohere;
export = cohere;

@@ -38,3 +38,2 @@ (function webpackUniversalModuleDefinition(root, factory) {

ENDPOINT["EMBED"] = "/embed";
ENDPOINT["CHOOSE_BEST"] = "/choose-best";
ENDPOINT["CLASSIFY"] = "/classify";

@@ -50,4 +49,4 @@ ENDPOINT["EXTRACT"] = "/extract";

};
Cohere.prototype.makeRequest = function (model, endpoint, data) {
return api_service_1.default.post("/" + model + endpoint, data);
Cohere.prototype.makeRequest = function (endpoint, data) {
return api_service_1.default.post(endpoint, data);
};

@@ -57,4 +56,4 @@ /** Generates realistic text conditioned on a given input.

*/
Cohere.prototype.generate = function (model, config) {
return this.makeRequest(model, ENDPOINT.GENERATE, config);
Cohere.prototype.generate = function (config) {
return this.makeRequest(ENDPOINT.GENERATE, config);
};

@@ -65,3 +64,3 @@ /** Returns text embeddings. An embedding is a list of floating point numbers that captures semantic

*/
Cohere.prototype.embed = function (model, config) {
Cohere.prototype.embed = function (config) {
var _this = this;

@@ -83,3 +82,3 @@ var createBatches = function (array) {

return Promise.all(createBatches(config.texts).map(function (texts) {
return _this.makeRequest(model, ENDPOINT.EMBED, __assign(__assign({}, config), { texts: texts }));
return _this.makeRequest(ENDPOINT.EMBED, __assign(__assign({}, config), { texts: texts }));
})).then(function (results) {

@@ -97,17 +96,7 @@ var embeddings = [];

};
/** Uses likelihood to perform classification. Given a query text that you'd like to classify between
* a number of options, Choose Best will return a score between the query and each option.
* See: https://docs.cohere.ai/choose-best-reference
*/
/**
* @deprecated Will be deleted in favor of 'classify'.
*/
Cohere.prototype.chooseBest = function (model, config) {
return this.makeRequest(model, ENDPOINT.CHOOSE_BEST, config);
};
/**
* Classifies text as one of the given labels. Returns a confidence score for each label.
*/
Cohere.prototype.classify = function (model, config) {
return this.makeRequest(model, ENDPOINT.CLASSIFY, config);
Cohere.prototype.classify = function (config) {
return this.makeRequest(ENDPOINT.CLASSIFY, config);
};

@@ -117,4 +106,4 @@ /**

*/
Cohere.prototype.extract = function (model, config) {
return this.makeRequest(model, ENDPOINT.EXTRACT, config);
Cohere.prototype.extract = function (config) {
return this.makeRequest(ENDPOINT.EXTRACT, config);
};

@@ -121,0 +110,0 @@ return Cohere;

@@ -8,2 +8,4 @@ export interface cohereResponse<T> {

export interface generate {
/** Denotes the model to be used. Defaults to the best performing model */
model?: string;
/** Represents the prompt or text to be completed. */

@@ -48,2 +50,4 @@ prompt: string;

export interface embed {
/** Denotes the model to be used. Defaults to the best performing model */
model?: string;
/** An array of strings for the model to embed. */

@@ -55,14 +59,5 @@ texts: string[];

export interface chooseBest {
/** Used to query the options. */
query: string;
/** Each string concatenates to the query. */
options: string[];
/** One of PREPEND_OPTION|APPEND_OPTION to specify where the option string will be placed and
* how to compute the log-likelihood.
*/
mode: 'PREPEND_OPTION' | 'APPEND_OPTION';
}
export interface classify {
/** Denotes the model to be used. Defaults to the best performing model */
model?: string;
/** An array of strings that you would like to classify. */

@@ -78,3 +73,3 @@ inputs: string[];

export type cohereParameters = generate | embed | chooseBest | classify | extract;
export type cohereParameters = generate | embed | classify | extract;

@@ -81,0 +76,0 @@ /* -- responses -- */

{
"name": "cohere-ai",
"version": "3.2.0",
"version": "4.0.0",
"description": "A Node.js SDK with TypeScript support for the Cohere API.",

@@ -12,3 +12,4 @@ "homepage": "https://docs.cohere.ai",

"dev": "webpack --progress --env development --env nodemon",
"test": "npm run build && mocha -r ts-node/register test/test.ts"
"test": "npm run build && mocha -r ts-node/register test/test.ts",
"publish": "npm run build && npm publish"
},

@@ -15,0 +16,0 @@ "files": [

@@ -40,3 +40,2 @@ # Welcome to the Cohere AI Node.js SDK.

/generate | cohere.generate()
/choose-best | cohere.chooseBest()
/embed | cohere.embed()

@@ -100,3 +99,3 @@

## Local development instructions
To tinker with the package library itself, please check the development instructions [readme](https://github.com/cohere-ai/cohere-node/blob/main/DEV.md).
## cohere-node package readme
If you'd like to help contribute to the package library itself or modify it locally, please check the development instructions [readme](https://github.com/cohere-ai/cohere-node/blob/main/DEV.md).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc