Skip to content

Commit

Permalink
SDK regeneration (#152)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Apr 16, 2024
1 parent 40c146c commit 2385563
Show file tree
Hide file tree
Showing 107 changed files with 1,472 additions and 593 deletions.
12 changes: 1 addition & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
node_modules
.DS_Store
/dist
/Client.d.ts
/Client.js
/environments.d.ts
/environments.js
/index.d.ts
/index.js
/api
/core
/errors
/serialization
/dist
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "cohere-ai",
"version": "7.9.3",
"version": "7.9.4",
"private": false,
"repository": "https://github.com/cohere-ai/cohere-typescript",
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"format": "prettier --write 'src/**/*.ts'",
"format": "prettier . --write --ignore-unknown",
"build": "tsc",
"prepack": "cp -rv dist/. .",
"test": "jest"
"prepack": "cp -rv dist/. ."
},
"dependencies": {
"url-join": "4.0.1",
Expand All @@ -22,11 +21,10 @@
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"jest": "^29.7.0",
"@types/jest": "^29.5.5",
"ts-jest": "^29.1.2",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4"
"typescript": "4.6.4",
"jest": "^29.7.0",
"ts-jest": "^29.1.2"
}
}
}
91 changes: 70 additions & 21 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: {
...(await serializers.ChatStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" })),
...(await serializers.ChatStreamRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
})),
stream: true,
},
responseType: "streaming",
Expand Down Expand Up @@ -147,13 +151,17 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: {
...(await serializers.ChatRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" })),
...(await serializers.ChatRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
})),
stream: false,
},
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
Expand Down Expand Up @@ -221,13 +229,17 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: {
...(await serializers.GenerateStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" })),
...(await serializers.GenerateStreamRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
})),
stream: true,
},
responseType: "streaming",
Expand Down Expand Up @@ -316,13 +328,17 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: {
...(await serializers.GenerateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" })),
...(await serializers.GenerateRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
})),
stream: false,
},
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
Expand Down Expand Up @@ -378,6 +394,15 @@ export class CohereClient {
* @throws {@link Cohere.BadRequestError}
* @throws {@link Cohere.TooManyRequestsError}
* @throws {@link Cohere.InternalServerError}
*
* @example
* await cohere.embed({
* texts: ["string"],
* model: "string",
* inputType: Cohere.EmbedInputType.SearchDocument,
* embeddingTypes: [Cohere.EmbeddingType.Float],
* truncate: Cohere.EmbedRequestTruncate.None
* })
*/
public async embed(
request: Cohere.EmbedRequest,
Expand All @@ -397,12 +422,16 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.EmbedRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" }),
body: await serializers.EmbedRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -476,12 +505,16 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.RerankRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" }),
body: await serializers.RerankRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -584,12 +617,16 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.ClassifyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" }),
body: await serializers.ClassifyRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -665,12 +702,16 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.SummarizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" }),
body: await serializers.SummarizeRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -741,12 +782,16 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.TokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" }),
body: await serializers.TokenizeRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -819,12 +864,16 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
"X-Fern-SDK-Version": "7.9.3",
"X-Fern-SDK-Version": "7.9.4",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.DetokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "passthrough" }),
body: await serializers.DetokenizeRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 300000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -896,7 +945,7 @@ export class CohereClient {
}

protected async _getAuthorizationHeader() {
const bearer = (await core.Supplier.get(this._options.token)) ?? process.env["CO_API_KEY"];
const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["CO_API_KEY"];
if (bearer == null) {
throw new errors.CohereError({
message: "Please specify CO_API_KEY when instantiating the client.",
Expand Down
30 changes: 30 additions & 0 deletions src/api/client/requests/ChatRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,36 @@
import * as Cohere from "../..";

/**
* @example
* {
* message: "Can you give me a global market overview of solar panels?",
* stream: false,
* chatHistory: [{
* role: Cohere.ChatMessageRole.Chatbot,
* message: "Hi!"
* }, {
* role: Cohere.ChatMessageRole.Chatbot,
* message: "How can I help you today?"
* }],
* promptTruncation: Cohere.ChatRequestPromptTruncation.Off,
* temperature: 0.3
* }
*
* @example
* {
* message: "Can you give me a global market overview of solar panels?",
* stream: false,
* chatHistory: [{
* role: Cohere.ChatMessageRole.Chatbot,
* message: "Hi!"
* }, {
* role: Cohere.ChatMessageRole.Chatbot,
* message: "How can I help you today?"
* }],
* promptTruncation: Cohere.ChatRequestPromptTruncation.Off,
* temperature: 0.3
* }
*
* @example
* {
* message: "Can you give me a global market overview of solar panels?",
Expand Down
46 changes: 46 additions & 0 deletions src/api/client/requests/ChatStreamRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,52 @@

import * as Cohere from "../..";

/**
* @example
* {
* message: "Can you give me a global market overview of solar panels?",
* stream: true,
* chatHistory: [{
* role: Cohere.ChatMessageRole.Chatbot,
* message: "Hi!"
* }, {
* role: Cohere.ChatMessageRole.Chatbot,
* message: "How can I help you today?"
* }],
* promptTruncation: Cohere.ChatStreamRequestPromptTruncation.Off,
* temperature: 0.3
* }
*
* @example
* {
* message: "Can you give me a global market overview of solar panels?",
* stream: true,
* chatHistory: [{
* role: Cohere.ChatMessageRole.Chatbot,
* message: "Hi!"
* }, {
* role: Cohere.ChatMessageRole.Chatbot,
* message: "How can I help you today?"
* }],
* promptTruncation: Cohere.ChatStreamRequestPromptTruncation.Off,
* temperature: 0.3
* }
*
* @example
* {
* message: "Can you give me a global market overview of solar panels?",
* stream: true,
* chatHistory: [{
* role: Cohere.ChatMessageRole.Chatbot,
* message: "Hi!"
* }, {
* role: Cohere.ChatMessageRole.Chatbot,
* message: "How can I help you today?"
* }],
* promptTruncation: Cohere.ChatStreamRequestPromptTruncation.Off,
* temperature: 0.3
* }
*/
export interface ChatStreamRequest {
/**
* Text input for the model to respond to.
Expand Down
Loading

0 comments on commit 2385563

Please sign in to comment.