From bac7e6cd83f079b5a765781013e06bfd8f5c3399 Mon Sep 17 00:00:00 2001 From: Julius Lipp Date: Fri, 19 Jan 2024 03:02:18 +0100 Subject: [PATCH] Initial SDK --- .gitignore | 1 + .openapi-generator-ignore | 8 +- .openapi-generator/FILES | 11 +- README.md | 59 ++- bun.lockb | Bin 0 -> 1353 bytes dist/apis/MixedbreadAiApi.d.ts | 31 -- dist/apis/MixedbreadAiApi.js | 68 ---- dist/apis/index.d.ts | 1 - dist/apis/index.js | 19 - dist/esm/apis/MixedbreadAiApi.d.ts | 31 -- dist/esm/apis/MixedbreadAiApi.js | 64 ---- dist/esm/apis/index.d.ts | 1 - dist/esm/apis/index.js | 3 - dist/esm/index.d.ts | 3 - dist/esm/index.js | 5 - dist/esm/models/Embeddings200Response.d.ts | 45 --- dist/esm/models/Embeddings200Response.js | 51 --- .../Embeddings200ResponseDataInner.d.ts | 43 --- .../models/Embeddings200ResponseDataInner.js | 47 --- .../models/Embeddings200ResponseUsage.d.ts | 37 -- dist/esm/models/Embeddings200ResponseUsage.js | 45 --- dist/esm/models/EmbeddingsRequest.d.ts | 43 --- dist/esm/models/EmbeddingsRequest.js | 47 --- dist/esm/models/ErrorResponse.d.ts | 45 --- dist/esm/models/ErrorResponse.js | 49 --- dist/esm/models/index.d.ts | 5 - dist/esm/models/index.js | 7 - dist/esm/runtime.d.ts | 178 --------- dist/esm/runtime.js | 339 ----------------- dist/index.d.ts | 3 - dist/index.js | 21 -- dist/models/Embeddings200Response.d.ts | 45 --- dist/models/Embeddings200Response.js | 58 --- .../Embeddings200ResponseDataInner.d.ts | 43 --- dist/models/Embeddings200ResponseDataInner.js | 54 --- dist/models/Embeddings200ResponseUsage.d.ts | 37 -- dist/models/Embeddings200ResponseUsage.js | 52 --- dist/models/EmbeddingsRequest.d.ts | 43 --- dist/models/EmbeddingsRequest.js | 54 --- dist/models/ErrorResponse.d.ts | 45 --- dist/models/ErrorResponse.js | 56 --- dist/models/index.d.ts | 5 - dist/models/index.js | 23 -- dist/runtime.d.ts | 178 --------- dist/runtime.js | 355 ------------------ package.json | 4 +- src/apis/MixedbreadAiApi.ts | 39 +- src/index.ts | 7 +- src/mixedbread-ai-types.ts | 24 ++ src/mixedbread-ai.ts | 51 +++ src/models/Embeddings200Response.ts | 97 ----- src/models/Embeddings200ResponseUsage.ts | 73 ---- src/models/EmbeddingsRequest.ts | 27 +- src/models/EmbeddingsRequestInput.ts | 50 --- src/models/EmbeddingsResponse.ts | 106 ++++++ ...nner.ts => EmbeddingsResponseDataInner.ts} | 28 +- src/models/ModelBaseResponse.ts | 82 ++++ src/models/ModelBaseResponseUsage.ts | 83 ++++ src/models/index.ts | 8 +- src/runtime.ts | 37 +- tsconfig.json | 7 +- 61 files changed, 501 insertions(+), 2580 deletions(-) create mode 100755 bun.lockb delete mode 100644 dist/apis/MixedbreadAiApi.d.ts delete mode 100644 dist/apis/MixedbreadAiApi.js delete mode 100644 dist/apis/index.d.ts delete mode 100644 dist/apis/index.js delete mode 100644 dist/esm/apis/MixedbreadAiApi.d.ts delete mode 100644 dist/esm/apis/MixedbreadAiApi.js delete mode 100644 dist/esm/apis/index.d.ts delete mode 100644 dist/esm/apis/index.js delete mode 100644 dist/esm/index.d.ts delete mode 100644 dist/esm/index.js delete mode 100644 dist/esm/models/Embeddings200Response.d.ts delete mode 100644 dist/esm/models/Embeddings200Response.js delete mode 100644 dist/esm/models/Embeddings200ResponseDataInner.d.ts delete mode 100644 dist/esm/models/Embeddings200ResponseDataInner.js delete mode 100644 dist/esm/models/Embeddings200ResponseUsage.d.ts delete mode 100644 dist/esm/models/Embeddings200ResponseUsage.js delete mode 100644 dist/esm/models/EmbeddingsRequest.d.ts delete mode 100644 dist/esm/models/EmbeddingsRequest.js delete mode 100644 dist/esm/models/ErrorResponse.d.ts delete mode 100644 dist/esm/models/ErrorResponse.js delete mode 100644 dist/esm/models/index.d.ts delete mode 100644 dist/esm/models/index.js delete mode 100644 dist/esm/runtime.d.ts delete mode 100644 dist/esm/runtime.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/models/Embeddings200Response.d.ts delete mode 100644 dist/models/Embeddings200Response.js delete mode 100644 dist/models/Embeddings200ResponseDataInner.d.ts delete mode 100644 dist/models/Embeddings200ResponseDataInner.js delete mode 100644 dist/models/Embeddings200ResponseUsage.d.ts delete mode 100644 dist/models/Embeddings200ResponseUsage.js delete mode 100644 dist/models/EmbeddingsRequest.d.ts delete mode 100644 dist/models/EmbeddingsRequest.js delete mode 100644 dist/models/ErrorResponse.d.ts delete mode 100644 dist/models/ErrorResponse.js delete mode 100644 dist/models/index.d.ts delete mode 100644 dist/models/index.js delete mode 100644 dist/runtime.d.ts delete mode 100644 dist/runtime.js create mode 100644 src/mixedbread-ai-types.ts create mode 100644 src/mixedbread-ai.ts delete mode 100644 src/models/Embeddings200Response.ts delete mode 100644 src/models/Embeddings200ResponseUsage.ts delete mode 100644 src/models/EmbeddingsRequestInput.ts create mode 100644 src/models/EmbeddingsResponse.ts rename src/models/{Embeddings200ResponseDataInner.ts => EmbeddingsResponseDataInner.ts} (59%) create mode 100644 src/models/ModelBaseResponse.ts create mode 100644 src/models/ModelBaseResponseUsage.ts diff --git a/.gitignore b/.gitignore index 149b576..1ef7f7c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ wwwroot/*.js node_modules typings dist +test.ts \ No newline at end of file diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index 1a2e657..fd70949 100644 --- a/.openapi-generator-ignore +++ b/.openapi-generator-ignore @@ -22,6 +22,10 @@ # Then explicitly reverse the ignore rule for a single file: #!docs/README.md -src/runtime.ts README.md -package.json \ No newline at end of file +package.json +src/index.ts +src/mixedbread-ai.ts +src/mixedbread-ai-types.ts +src/runtime.d.ts +tsconfig.json \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index c020689..7f2359a 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,15 +1,14 @@ .gitignore .npmignore -package.json src/apis/MixedbreadAiApi.ts src/apis/index.ts -src/index.ts -src/models/Embeddings200Response.ts -src/models/Embeddings200ResponseDataInner.ts -src/models/Embeddings200ResponseUsage.ts src/models/EmbeddingsRequest.ts -src/models/EmbeddingsRequestInput.ts +src/models/EmbeddingsResponse.ts +src/models/EmbeddingsResponseDataInner.ts src/models/ErrorResponse.ts +src/models/ModelBaseResponse.ts +src/models/ModelBaseResponseUsage.ts src/models/index.ts +src/runtime.ts tsconfig.esm.json tsconfig.json diff --git a/README.md b/README.md index 10aefab..7c27149 100644 --- a/README.md +++ b/README.md @@ -20,17 +20,68 @@ npm install @mixedbread-ai/sdk --save Here's an example of using the mixedbread ai SDK to create embeddings: ```typescript -import { MixedbreadAiApi, Configuration, EmbeddingsRequest } from "@mixedbread-ai/sdk"; +import { MixedbreadAi } from "@mixedbread-ai/sdk"; process.env.MIXEDBREADAI_API_KEY="{YOUR_API_KEY}" -const client = new MixedbreadAiApi(); +const mxbai = new MixedbreadAi(); const embeddings = await client.embeddings({ - texts: ["Hello world!"], + input: "Hello world!", model: "e5-large-v2" }) console.log(embeddings) ``` -Replace `"{YOUR_API_KEY}"` with your actual API key. If you don't hav e an API key, you can get one for free by signing up for an account at [mixedbread.ai](https://mixedbread.ai/). \ No newline at end of file +Replace `"{YOUR_API_KEY}"` with your actual API key. If you don't hav e an API key, you can get one for free by signing up for an account at [mixedbread.ai](https://mixedbread.ai/). + +## Configuration + +The mixedbread ai SDK can be configured by passing an object to the constructor. Here is a full example: + +```typescript +import { MixedbreadAi, ResponseError } from "@mixedbread-ai/sdk"; + +const mxbai = new MixedbreadAi({ + apiKey: "{YOUR_API_KEY}", + baseUrl: "https://api.mixedbread.ai", + headers: { + "X_CUSTOM_HEADER": "custom header value" + }, + middleware: [ + { + // Pre request + pre: async (context) => { + console.log("pre", context); + }, + // Post request + post: async (context) => { + console.log("post", context); + }, + // onError is triggered, when actually an error occurs. Response errors are not handled here. + onError(context) { + console.log("onError", context.init); + return Promise.resolve(); + } + } + ], + // custom fetch implementation + // fetch: ... + // custom query string implementation + // queryString: ... +}); + +const result = await mxbai.embeddings({ + input: ["Hello world!"], + model: "e5-large-v2", +}, { + // custom request overrides + // method: "POST" etc. +}).catch((err: ResponseError) => { + if (err.name === "ResponseError") { + console.log(err.message) + } +}); + +console.log(result) +``` diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..2ab095b460dc802f0d10081492e31894344bd010 GIT binary patch literal 1353 zcmY#Z)GsYA(of3F(@)JSQ%EY!;{sycoc!eMw9K4T-L(9o+{6;yG6OCq1_lOm!BV~( zhaX<;G|6`mTIyJ0tMx-;e`05KTSu$L?JOJ zGd(Xq4VYXY;NO1;0P(=?V1|gZKxrDHB9M85<Y3`5q*sA`HwXy;2oUL7 literal 0 HcmV?d00001 diff --git a/dist/apis/MixedbreadAiApi.d.ts b/dist/apis/MixedbreadAiApi.d.ts deleted file mode 100644 index e84ea36..0000000 --- a/dist/apis/MixedbreadAiApi.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import * as runtime from '../runtime'; -import type { Embeddings200Response, EmbeddingsRequest } from '../models/index'; -export interface EmbeddingsOperationRequest { - embeddingsRequest: EmbeddingsRequest; -} -/** - * - */ -export declare class MixedbreadAiApi extends runtime.BaseAPI { - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddingsRaw(requestParameters: EmbeddingsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddings(embeddingsRequest: EmbeddingsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; -} diff --git a/dist/apis/MixedbreadAiApi.js b/dist/apis/MixedbreadAiApi.js deleted file mode 100644 index 8bf02d2..0000000 --- a/dist/apis/MixedbreadAiApi.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MixedbreadAiApi = void 0; -const runtime = require("../runtime"); -const index_1 = require("../models/index"); -/** - * - */ -class MixedbreadAiApi extends runtime.BaseAPI { - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddingsRaw(requestParameters, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - if (requestParameters.embeddingsRequest === null || requestParameters.embeddingsRequest === undefined) { - throw new runtime.RequiredError('embeddingsRequest', 'Required parameter requestParameters.embeddingsRequest was null or undefined when calling embeddings.'); - } - const queryParameters = {}; - const headerParameters = {}; - headerParameters['Content-Type'] = 'application/json'; - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // MIXEDBREADAI_API_KEY authentication - } - const response = yield this.request({ - path: `/v1/embeddings/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: (0, index_1.EmbeddingsRequestToJSON)(requestParameters.embeddingsRequest), - }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.Embeddings200ResponseFromJSON)(jsonValue)); - }); - } - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddings(embeddingsRequest, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - const response = yield this.embeddingsRaw({ embeddingsRequest: embeddingsRequest }, initOverrides); - return yield response.value(); - }); - } -} -exports.MixedbreadAiApi = MixedbreadAiApi; diff --git a/dist/apis/index.d.ts b/dist/apis/index.d.ts deleted file mode 100644 index ff00187..0000000 --- a/dist/apis/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './MixedbreadAiApi'; diff --git a/dist/apis/index.js b/dist/apis/index.js deleted file mode 100644 index e6d0a9b..0000000 --- a/dist/apis/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -/* tslint:disable */ -/* eslint-disable */ -__exportStar(require("./MixedbreadAiApi"), exports); diff --git a/dist/esm/apis/MixedbreadAiApi.d.ts b/dist/esm/apis/MixedbreadAiApi.d.ts deleted file mode 100644 index e84ea36..0000000 --- a/dist/esm/apis/MixedbreadAiApi.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import * as runtime from '../runtime'; -import type { Embeddings200Response, EmbeddingsRequest } from '../models/index'; -export interface EmbeddingsOperationRequest { - embeddingsRequest: EmbeddingsRequest; -} -/** - * - */ -export declare class MixedbreadAiApi extends runtime.BaseAPI { - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddingsRaw(requestParameters: EmbeddingsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddings(embeddingsRequest: EmbeddingsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; -} diff --git a/dist/esm/apis/MixedbreadAiApi.js b/dist/esm/apis/MixedbreadAiApi.js deleted file mode 100644 index e978729..0000000 --- a/dist/esm/apis/MixedbreadAiApi.js +++ /dev/null @@ -1,64 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -import * as runtime from '../runtime'; -import { Embeddings200ResponseFromJSON, EmbeddingsRequestToJSON, } from '../models/index'; -/** - * - */ -export class MixedbreadAiApi extends runtime.BaseAPI { - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddingsRaw(requestParameters, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - if (requestParameters.embeddingsRequest === null || requestParameters.embeddingsRequest === undefined) { - throw new runtime.RequiredError('embeddingsRequest', 'Required parameter requestParameters.embeddingsRequest was null or undefined when calling embeddings.'); - } - const queryParameters = {}; - const headerParameters = {}; - headerParameters['Content-Type'] = 'application/json'; - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // MIXEDBREADAI_API_KEY authentication - } - const response = yield this.request({ - path: `/v1/embeddings/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: EmbeddingsRequestToJSON(requestParameters.embeddingsRequest), - }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => Embeddings200ResponseFromJSON(jsonValue)); - }); - } - /** - * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. - * Create embeddings - */ - embeddings(embeddingsRequest, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - const response = yield this.embeddingsRaw({ embeddingsRequest: embeddingsRequest }, initOverrides); - return yield response.value(); - }); - } -} diff --git a/dist/esm/apis/index.d.ts b/dist/esm/apis/index.d.ts deleted file mode 100644 index ff00187..0000000 --- a/dist/esm/apis/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './MixedbreadAiApi'; diff --git a/dist/esm/apis/index.js b/dist/esm/apis/index.js deleted file mode 100644 index 5296289..0000000 --- a/dist/esm/apis/index.js +++ /dev/null @@ -1,3 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export * from './MixedbreadAiApi'; diff --git a/dist/esm/index.d.ts b/dist/esm/index.d.ts deleted file mode 100644 index f6e3226..0000000 --- a/dist/esm/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './runtime'; -export * from './apis/index'; -export * from './models/index'; diff --git a/dist/esm/index.js b/dist/esm/index.js deleted file mode 100644 index bebe8bb..0000000 --- a/dist/esm/index.js +++ /dev/null @@ -1,5 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export * from './runtime'; -export * from './apis/index'; -export * from './models/index'; diff --git a/dist/esm/models/Embeddings200Response.d.ts b/dist/esm/models/Embeddings200Response.d.ts deleted file mode 100644 index 6ea2d87..0000000 --- a/dist/esm/models/Embeddings200Response.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import type { Embeddings200ResponseDataInner } from './Embeddings200ResponseDataInner'; -import type { Embeddings200ResponseUsage } from './Embeddings200ResponseUsage'; -/** - * - * @export - * @interface Embeddings200Response - */ -export interface Embeddings200Response { - /** - * The embeddings model used. - * @type {string} - * @memberof Embeddings200Response - */ - model: string; - /** - * - * @type {Array} - * @memberof Embeddings200Response - */ - data: Array; - /** - * - * @type {Embeddings200ResponseUsage} - * @memberof Embeddings200Response - */ - usage: Embeddings200ResponseUsage; -} -/** - * Check if a given object implements the Embeddings200Response interface. - */ -export declare function instanceOfEmbeddings200Response(value: object): boolean; -export declare function Embeddings200ResponseFromJSON(json: any): Embeddings200Response; -export declare function Embeddings200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200Response; -export declare function Embeddings200ResponseToJSON(value?: Embeddings200Response | null): any; diff --git a/dist/esm/models/Embeddings200Response.js b/dist/esm/models/Embeddings200Response.js deleted file mode 100644 index 42c5549..0000000 --- a/dist/esm/models/Embeddings200Response.js +++ /dev/null @@ -1,51 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import { Embeddings200ResponseDataInnerFromJSON, Embeddings200ResponseDataInnerToJSON, } from './Embeddings200ResponseDataInner'; -import { Embeddings200ResponseUsageFromJSON, Embeddings200ResponseUsageToJSON, } from './Embeddings200ResponseUsage'; -/** - * Check if a given object implements the Embeddings200Response interface. - */ -export function instanceOfEmbeddings200Response(value) { - let isInstance = true; - isInstance = isInstance && "model" in value; - isInstance = isInstance && "data" in value; - isInstance = isInstance && "usage" in value; - return isInstance; -} -export function Embeddings200ResponseFromJSON(json) { - return Embeddings200ResponseFromJSONTyped(json, false); -} -export function Embeddings200ResponseFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'model': json['model'], - 'data': (json['data'].map(Embeddings200ResponseDataInnerFromJSON)), - 'usage': Embeddings200ResponseUsageFromJSON(json['usage']), - }; -} -export function Embeddings200ResponseToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'model': value.model, - 'data': (value.data.map(Embeddings200ResponseDataInnerToJSON)), - 'usage': Embeddings200ResponseUsageToJSON(value.usage), - }; -} diff --git a/dist/esm/models/Embeddings200ResponseDataInner.d.ts b/dist/esm/models/Embeddings200ResponseDataInner.d.ts deleted file mode 100644 index 6ea7bad..0000000 --- a/dist/esm/models/Embeddings200ResponseDataInner.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface Embeddings200ResponseDataInner - */ -export interface Embeddings200ResponseDataInner { - /** - * The generated embeddings. - * @type {Array} - * @memberof Embeddings200ResponseDataInner - */ - embedding?: Array; - /** - * Index of the request text the embedding corresponds to. - * @type {number} - * @memberof Embeddings200ResponseDataInner - */ - index?: number; - /** - * Indicates if the text was truncated for the model. - * @type {boolean} - * @memberof Embeddings200ResponseDataInner - */ - wasTruncated?: boolean; -} -/** - * Check if a given object implements the Embeddings200ResponseDataInner interface. - */ -export declare function instanceOfEmbeddings200ResponseDataInner(value: object): boolean; -export declare function Embeddings200ResponseDataInnerFromJSON(json: any): Embeddings200ResponseDataInner; -export declare function Embeddings200ResponseDataInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200ResponseDataInner; -export declare function Embeddings200ResponseDataInnerToJSON(value?: Embeddings200ResponseDataInner | null): any; diff --git a/dist/esm/models/Embeddings200ResponseDataInner.js b/dist/esm/models/Embeddings200ResponseDataInner.js deleted file mode 100644 index 74e314d..0000000 --- a/dist/esm/models/Embeddings200ResponseDataInner.js +++ /dev/null @@ -1,47 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import { exists } from '../runtime'; -/** - * Check if a given object implements the Embeddings200ResponseDataInner interface. - */ -export function instanceOfEmbeddings200ResponseDataInner(value) { - let isInstance = true; - return isInstance; -} -export function Embeddings200ResponseDataInnerFromJSON(json) { - return Embeddings200ResponseDataInnerFromJSONTyped(json, false); -} -export function Embeddings200ResponseDataInnerFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'embedding': !exists(json, 'embedding') ? undefined : json['embedding'], - 'index': !exists(json, 'index') ? undefined : json['index'], - 'wasTruncated': !exists(json, 'was_truncated') ? undefined : json['was_truncated'], - }; -} -export function Embeddings200ResponseDataInnerToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'embedding': value.embedding, - 'index': value.index, - 'was_truncated': value.wasTruncated, - }; -} diff --git a/dist/esm/models/Embeddings200ResponseUsage.d.ts b/dist/esm/models/Embeddings200ResponseUsage.d.ts deleted file mode 100644 index aa6e2bc..0000000 --- a/dist/esm/models/Embeddings200ResponseUsage.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface Embeddings200ResponseUsage - */ -export interface Embeddings200ResponseUsage { - /** - * The number of prompt tokens used. - * @type {number} - * @memberof Embeddings200ResponseUsage - */ - promptTokens?: number; - /** - * The total number of tokens used. - * @type {number} - * @memberof Embeddings200ResponseUsage - */ - totalTokens?: number; -} -/** - * Check if a given object implements the Embeddings200ResponseUsage interface. - */ -export declare function instanceOfEmbeddings200ResponseUsage(value: object): boolean; -export declare function Embeddings200ResponseUsageFromJSON(json: any): Embeddings200ResponseUsage; -export declare function Embeddings200ResponseUsageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200ResponseUsage; -export declare function Embeddings200ResponseUsageToJSON(value?: Embeddings200ResponseUsage | null): any; diff --git a/dist/esm/models/Embeddings200ResponseUsage.js b/dist/esm/models/Embeddings200ResponseUsage.js deleted file mode 100644 index 1df3f0c..0000000 --- a/dist/esm/models/Embeddings200ResponseUsage.js +++ /dev/null @@ -1,45 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import { exists } from '../runtime'; -/** - * Check if a given object implements the Embeddings200ResponseUsage interface. - */ -export function instanceOfEmbeddings200ResponseUsage(value) { - let isInstance = true; - return isInstance; -} -export function Embeddings200ResponseUsageFromJSON(json) { - return Embeddings200ResponseUsageFromJSONTyped(json, false); -} -export function Embeddings200ResponseUsageFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'promptTokens': !exists(json, 'prompt_tokens') ? undefined : json['prompt_tokens'], - 'totalTokens': !exists(json, 'total_tokens') ? undefined : json['total_tokens'], - }; -} -export function Embeddings200ResponseUsageToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'prompt_tokens': value.promptTokens, - 'total_tokens': value.totalTokens, - }; -} diff --git a/dist/esm/models/EmbeddingsRequest.d.ts b/dist/esm/models/EmbeddingsRequest.d.ts deleted file mode 100644 index 0703d19..0000000 --- a/dist/esm/models/EmbeddingsRequest.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface EmbeddingsRequest - */ -export interface EmbeddingsRequest { - /** - * A list of texts for which the embedding should be generated. - * @type {Array} - * @memberof EmbeddingsRequest - */ - texts?: Array; - /** - * Specifies the model to be used for generating embeddings. - * @type {string} - * @memberof EmbeddingsRequest - */ - model?: string; - /** - * Required only for instruction based models. Specifies the instruction for generating embeddings. - * @type {string} - * @memberof EmbeddingsRequest - */ - instruction?: string; -} -/** - * Check if a given object implements the EmbeddingsRequest interface. - */ -export declare function instanceOfEmbeddingsRequest(value: object): boolean; -export declare function EmbeddingsRequestFromJSON(json: any): EmbeddingsRequest; -export declare function EmbeddingsRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): EmbeddingsRequest; -export declare function EmbeddingsRequestToJSON(value?: EmbeddingsRequest | null): any; diff --git a/dist/esm/models/EmbeddingsRequest.js b/dist/esm/models/EmbeddingsRequest.js deleted file mode 100644 index 119c5fc..0000000 --- a/dist/esm/models/EmbeddingsRequest.js +++ /dev/null @@ -1,47 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import { exists } from '../runtime'; -/** - * Check if a given object implements the EmbeddingsRequest interface. - */ -export function instanceOfEmbeddingsRequest(value) { - let isInstance = true; - return isInstance; -} -export function EmbeddingsRequestFromJSON(json) { - return EmbeddingsRequestFromJSONTyped(json, false); -} -export function EmbeddingsRequestFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'texts': !exists(json, 'texts') ? undefined : json['texts'], - 'model': !exists(json, 'model') ? undefined : json['model'], - 'instruction': !exists(json, 'instruction') ? undefined : json['instruction'], - }; -} -export function EmbeddingsRequestToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'texts': value.texts, - 'model': value.model, - 'instruction': value.instruction, - }; -} diff --git a/dist/esm/models/ErrorResponse.d.ts b/dist/esm/models/ErrorResponse.d.ts deleted file mode 100644 index 46d4791..0000000 --- a/dist/esm/models/ErrorResponse.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface ErrorResponse - */ -export interface ErrorResponse { - /** - * - * @type {number} - * @memberof ErrorResponse - */ - code: number; - /** - * - * @type {string} - * @memberof ErrorResponse - */ - message: string; - /** - * - * @type {{ [key: string]: any; }} - * @memberof ErrorResponse - */ - data: { - [key: string]: any; - }; -} -/** - * Check if a given object implements the ErrorResponse interface. - */ -export declare function instanceOfErrorResponse(value: object): boolean; -export declare function ErrorResponseFromJSON(json: any): ErrorResponse; -export declare function ErrorResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorResponse; -export declare function ErrorResponseToJSON(value?: ErrorResponse | null): any; diff --git a/dist/esm/models/ErrorResponse.js b/dist/esm/models/ErrorResponse.js deleted file mode 100644 index 2b45a56..0000000 --- a/dist/esm/models/ErrorResponse.js +++ /dev/null @@ -1,49 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * Check if a given object implements the ErrorResponse interface. - */ -export function instanceOfErrorResponse(value) { - let isInstance = true; - isInstance = isInstance && "code" in value; - isInstance = isInstance && "message" in value; - isInstance = isInstance && "data" in value; - return isInstance; -} -export function ErrorResponseFromJSON(json) { - return ErrorResponseFromJSONTyped(json, false); -} -export function ErrorResponseFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'code': json['code'], - 'message': json['message'], - 'data': json['data'], - }; -} -export function ErrorResponseToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'code': value.code, - 'message': value.message, - 'data': value.data, - }; -} diff --git a/dist/esm/models/index.d.ts b/dist/esm/models/index.d.ts deleted file mode 100644 index 509fbf5..0000000 --- a/dist/esm/models/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './Embeddings200Response'; -export * from './Embeddings200ResponseDataInner'; -export * from './Embeddings200ResponseUsage'; -export * from './EmbeddingsRequest'; -export * from './ErrorResponse'; diff --git a/dist/esm/models/index.js b/dist/esm/models/index.js deleted file mode 100644 index 41ac32e..0000000 --- a/dist/esm/models/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export * from './Embeddings200Response'; -export * from './Embeddings200ResponseDataInner'; -export * from './Embeddings200ResponseUsage'; -export * from './EmbeddingsRequest'; -export * from './ErrorResponse'; diff --git a/dist/esm/runtime.d.ts b/dist/esm/runtime.d.ts deleted file mode 100644 index a7bec55..0000000 --- a/dist/esm/runtime.d.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -export declare const BASE_PATH: string; -export interface ConfigurationParameters { - basePath?: string; - fetchApi?: FetchAPI; - middleware?: Middleware[]; - queryParamsStringify?: (params: HTTPQuery) => string; - apiKey?: string | ((name: string) => string); - headers?: HTTPHeaders; -} -export declare class Configuration { - private configuration; - constructor(configuration?: ConfigurationParameters); - set config(configuration: Configuration); - get basePath(): string; - get fetchApi(): FetchAPI | undefined; - get middleware(): Middleware[]; - get queryParamsStringify(): (params: HTTPQuery) => string; - get username(): string | undefined; - get password(): string | undefined; - get apiKey(): ((name: string) => string) | undefined; - get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined; - get headers(): HTTPHeaders | undefined; - get credentials(): RequestCredentials | undefined; -} -export declare const DefaultConfig: Configuration; -/** - * This is the base class for all generated API classes. - */ -export declare class BaseAPI { - protected configuration: Configuration; - private static readonly jsonRegex; - private middleware; - constructor(configuration?: Configuration); - withMiddleware(this: T, ...middlewares: Middleware[]): T; - withPreMiddleware(this: T, ...preMiddlewares: Array): T; - withPostMiddleware(this: T, ...postMiddlewares: Array): T; - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - protected isJsonMime(mime: string | null | undefined): boolean; - protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise; - private createFetchParams; - private fetchApi; - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone; -} -export declare class ResponseError extends Error { - response: Response; - name: "ResponseError"; - constructor(response: Response, msg?: string); -} -export declare class FetchError extends Error { - cause: Error; - name: "FetchError"; - constructor(cause: Error, msg?: string); -} -export declare class RequiredError extends Error { - field: string; - name: "RequiredError"; - constructor(field: string, msg?: string); -} -export declare const COLLECTION_FORMATS: { - csv: string; - ssv: string; - tsv: string; - pipes: string; -}; -export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; -export type Json = any; -export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; -export type HTTPHeaders = { - [key: string]: string; -}; -export type HTTPQuery = { - [key: string]: string | number | null | boolean | Array | Set | HTTPQuery; -}; -export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { - headers?: HTTPHeaders; - method: HTTPMethod; - credentials?: RequestCredentials; - body?: HTTPBody; -}; -export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; -export type InitOverrideFunction = (requestContext: { - init: HTTPRequestInit; - context: RequestOpts; -}) => Promise; -export interface FetchParams { - url: string; - init: RequestInit; -} -export interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; -} -export declare function exists(json: any, key: string): boolean; -export declare function querystring(params: HTTPQuery, prefix?: string): string; -export declare function mapValues(data: any, fn: (item: any) => any): {}; -export declare function canConsumeForm(consumes: Consume[]): boolean; -export interface Consume { - contentType: string; -} -export interface RequestContext { - fetch: FetchAPI; - url: string; - init: RequestInit; -} -export interface ResponseContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - response: Response; -} -export interface ErrorContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - error: unknown; - response?: Response; -} -export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; - onError?(context: ErrorContext): Promise; -} -export interface ApiResponse { - raw: Response; - value(): Promise; -} -export interface ResponseTransformer { - (json: any): T; -} -export declare class JSONApiResponse { - raw: Response; - private transformer; - constructor(raw: Response, transformer?: ResponseTransformer); - value(): Promise; -} -export declare class VoidApiResponse { - raw: Response; - constructor(raw: Response); - value(): Promise; -} -export declare class BlobApiResponse { - raw: Response; - constructor(raw: Response); - value(): Promise; -} -export declare class TextApiResponse { - raw: Response; - constructor(raw: Response); - value(): Promise; -} diff --git a/dist/esm/runtime.js b/dist/esm/runtime.js deleted file mode 100644 index ee8f1cf..0000000 --- a/dist/esm/runtime.js +++ /dev/null @@ -1,339 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -export const BASE_PATH = "https://api.mixedbread.ai".replace(/\/+$/, ""); -export class Configuration { - constructor(configuration = {}) { - this.configuration = configuration; - } - set config(configuration) { - this.configuration = configuration; - } - get basePath() { - return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; - } - get fetchApi() { - return this.configuration.fetchApi; - } - get middleware() { - return this.configuration.middleware || []; - } - get queryParamsStringify() { - return this.configuration.queryParamsStringify || querystring; - } - get username() { - return undefined; - } - get password() { - return undefined; - } - get apiKey() { - let apiKey = this.configuration.apiKey; - if (apiKey) { - if (typeof apiKey === 'function') { - // @ts-ignore - return (name) => 'Bearer ' + apiKey(name); - } - else { - return () => 'Bearer ' + apiKey; - } - } - else { - // @ts-ignore - apiKey = process.env.MIXEDBREADAI_API_KEY; - if (apiKey) { - return () => 'Bearer ' + apiKey; - } - } - return undefined; - } - get accessToken() { - return undefined; - } - get headers() { - return this.configuration.headers; - } - get credentials() { - return undefined; - } -} -export const DefaultConfig = new Configuration(); -/** - * This is the base class for all generated API classes. - */ -export class BaseAPI { - constructor(configuration = DefaultConfig) { - this.configuration = configuration; - this.fetchApi = (url, init) => __awaiter(this, void 0, void 0, function* () { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = (yield middleware.pre(Object.assign({ fetch: this.fetchApi }, fetchParams))) || fetchParams; - } - } - let response = undefined; - try { - response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); - } - catch (e) { - for (const middleware of this.middleware) { - if (middleware.onError) { - response = (yield middleware.onError({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - error: e, - response: response ? response.clone() : undefined, - })) || response; - } - } - if (response === undefined) { - if (e instanceof Error) { - throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); - } - else { - throw e; - } - } - } - for (const middleware of this.middleware) { - if (middleware.post) { - response = (yield middleware.post({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - response: response.clone(), - })) || response; - } - } - return response; - }); - this.middleware = configuration.middleware; - } - withMiddleware(...middlewares) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - withPreMiddleware(...preMiddlewares) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); - } - withPostMiddleware(...postMiddlewares) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - isJsonMime(mime) { - if (!mime) { - return false; - } - return BaseAPI.jsonRegex.test(mime); - } - request(context, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - const { url, init } = yield this.createFetchParams(context, initOverrides); - const response = yield this.fetchApi(url, init); - if (response && (response.status >= 200 && response.status < 300)) { - return response; - } - throw new ResponseError(response, 'Response returned an error code'); - }); - } - createFetchParams(context, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - let url = this.configuration.basePath + context.path; - if (context.query !== undefined && Object.keys(context.query).length !== 0) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += '?' + this.configuration.queryParamsStringify(context.query); - } - const headers = Object.assign({}, this.configuration.headers, context.headers); - Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); - const initOverrideFn = typeof initOverrides === "function" - ? initOverrides - : () => __awaiter(this, void 0, void 0, function* () { return initOverrides; }); - const initParams = { - method: context.method, - headers, - body: context.body, - credentials: this.configuration.credentials, - }; - const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({ - init: initParams, - context, - }))); - let body; - if (isFormData(overriddenInit.body) - || (overriddenInit.body instanceof URLSearchParams) - || isBlob(overriddenInit.body)) { - body = overriddenInit.body; - } - else if (this.isJsonMime(headers['Content-Type'])) { - body = JSON.stringify(overriddenInit.body); - } - else { - body = overriddenInit.body; - } - const init = Object.assign(Object.assign({}, overriddenInit), { body }); - return { url, init }; - }); - } - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - clone() { - const constructor = this.constructor; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; - } -} -BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); -; -function isBlob(value) { - return typeof Blob !== 'undefined' && value instanceof Blob; -} -function isFormData(value) { - return typeof FormData !== "undefined" && value instanceof FormData; -} -export class ResponseError extends Error { - constructor(response, msg) { - super(msg); - this.response = response; - this.name = "ResponseError"; - } -} -export class FetchError extends Error { - constructor(cause, msg) { - super(msg); - this.cause = cause; - this.name = "FetchError"; - } -} -export class RequiredError extends Error { - constructor(field, msg) { - super(msg); - this.field = field; - this.name = "RequiredError"; - } -} -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; -export function exists(json, key) { - const value = json[key]; - return value !== null && value !== undefined; -} -export function querystring(params, prefix = '') { - return Object.keys(params) - .map(key => querystringSingleKey(key, params[key], prefix)) - .filter(part => part.length > 0) - .join('&'); -} -function querystringSingleKey(key, value, keyPrefix = '') { - const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); - if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) - .join(`&${encodeURIComponent(fullKey)}=`); - return `${encodeURIComponent(fullKey)}=${multiValue}`; - } - if (value instanceof Set) { - const valueAsArray = Array.from(value); - return querystringSingleKey(key, valueAsArray, keyPrefix); - } - if (value instanceof Date) { - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; - } - if (value instanceof Object) { - return querystring(value, fullKey); - } - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; -} -export function mapValues(data, fn) { - return Object.keys(data).reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: fn(data[key]) })), {}); -} -export function canConsumeForm(consumes) { - for (const consume of consumes) { - if ('multipart/form-data' === consume.contentType) { - return true; - } - } - return false; -} -export class JSONApiResponse { - constructor(raw, transformer = (jsonValue) => jsonValue) { - this.raw = raw; - this.transformer = transformer; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return this.transformer(yield this.raw.json()); - }); - } -} -export class VoidApiResponse { - constructor(raw) { - this.raw = raw; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return undefined; - }); - } -} -export class BlobApiResponse { - constructor(raw) { - this.raw = raw; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return yield this.raw.blob(); - }); - } - ; -} -export class TextApiResponse { - constructor(raw) { - this.raw = raw; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return yield this.raw.text(); - }); - } - ; -} diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index f6e3226..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './runtime'; -export * from './apis/index'; -export * from './models/index'; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 495d716..0000000 --- a/dist/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -/* tslint:disable */ -/* eslint-disable */ -__exportStar(require("./runtime"), exports); -__exportStar(require("./apis/index"), exports); -__exportStar(require("./models/index"), exports); diff --git a/dist/models/Embeddings200Response.d.ts b/dist/models/Embeddings200Response.d.ts deleted file mode 100644 index 6ea2d87..0000000 --- a/dist/models/Embeddings200Response.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import type { Embeddings200ResponseDataInner } from './Embeddings200ResponseDataInner'; -import type { Embeddings200ResponseUsage } from './Embeddings200ResponseUsage'; -/** - * - * @export - * @interface Embeddings200Response - */ -export interface Embeddings200Response { - /** - * The embeddings model used. - * @type {string} - * @memberof Embeddings200Response - */ - model: string; - /** - * - * @type {Array} - * @memberof Embeddings200Response - */ - data: Array; - /** - * - * @type {Embeddings200ResponseUsage} - * @memberof Embeddings200Response - */ - usage: Embeddings200ResponseUsage; -} -/** - * Check if a given object implements the Embeddings200Response interface. - */ -export declare function instanceOfEmbeddings200Response(value: object): boolean; -export declare function Embeddings200ResponseFromJSON(json: any): Embeddings200Response; -export declare function Embeddings200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200Response; -export declare function Embeddings200ResponseToJSON(value?: Embeddings200Response | null): any; diff --git a/dist/models/Embeddings200Response.js b/dist/models/Embeddings200Response.js deleted file mode 100644 index 11238ce..0000000 --- a/dist/models/Embeddings200Response.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Embeddings200ResponseToJSON = exports.Embeddings200ResponseFromJSONTyped = exports.Embeddings200ResponseFromJSON = exports.instanceOfEmbeddings200Response = void 0; -const Embeddings200ResponseDataInner_1 = require("./Embeddings200ResponseDataInner"); -const Embeddings200ResponseUsage_1 = require("./Embeddings200ResponseUsage"); -/** - * Check if a given object implements the Embeddings200Response interface. - */ -function instanceOfEmbeddings200Response(value) { - let isInstance = true; - isInstance = isInstance && "model" in value; - isInstance = isInstance && "data" in value; - isInstance = isInstance && "usage" in value; - return isInstance; -} -exports.instanceOfEmbeddings200Response = instanceOfEmbeddings200Response; -function Embeddings200ResponseFromJSON(json) { - return Embeddings200ResponseFromJSONTyped(json, false); -} -exports.Embeddings200ResponseFromJSON = Embeddings200ResponseFromJSON; -function Embeddings200ResponseFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'model': json['model'], - 'data': (json['data'].map(Embeddings200ResponseDataInner_1.Embeddings200ResponseDataInnerFromJSON)), - 'usage': (0, Embeddings200ResponseUsage_1.Embeddings200ResponseUsageFromJSON)(json['usage']), - }; -} -exports.Embeddings200ResponseFromJSONTyped = Embeddings200ResponseFromJSONTyped; -function Embeddings200ResponseToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'model': value.model, - 'data': (value.data.map(Embeddings200ResponseDataInner_1.Embeddings200ResponseDataInnerToJSON)), - 'usage': (0, Embeddings200ResponseUsage_1.Embeddings200ResponseUsageToJSON)(value.usage), - }; -} -exports.Embeddings200ResponseToJSON = Embeddings200ResponseToJSON; diff --git a/dist/models/Embeddings200ResponseDataInner.d.ts b/dist/models/Embeddings200ResponseDataInner.d.ts deleted file mode 100644 index 6ea7bad..0000000 --- a/dist/models/Embeddings200ResponseDataInner.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface Embeddings200ResponseDataInner - */ -export interface Embeddings200ResponseDataInner { - /** - * The generated embeddings. - * @type {Array} - * @memberof Embeddings200ResponseDataInner - */ - embedding?: Array; - /** - * Index of the request text the embedding corresponds to. - * @type {number} - * @memberof Embeddings200ResponseDataInner - */ - index?: number; - /** - * Indicates if the text was truncated for the model. - * @type {boolean} - * @memberof Embeddings200ResponseDataInner - */ - wasTruncated?: boolean; -} -/** - * Check if a given object implements the Embeddings200ResponseDataInner interface. - */ -export declare function instanceOfEmbeddings200ResponseDataInner(value: object): boolean; -export declare function Embeddings200ResponseDataInnerFromJSON(json: any): Embeddings200ResponseDataInner; -export declare function Embeddings200ResponseDataInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200ResponseDataInner; -export declare function Embeddings200ResponseDataInnerToJSON(value?: Embeddings200ResponseDataInner | null): any; diff --git a/dist/models/Embeddings200ResponseDataInner.js b/dist/models/Embeddings200ResponseDataInner.js deleted file mode 100644 index 460aa13..0000000 --- a/dist/models/Embeddings200ResponseDataInner.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Embeddings200ResponseDataInnerToJSON = exports.Embeddings200ResponseDataInnerFromJSONTyped = exports.Embeddings200ResponseDataInnerFromJSON = exports.instanceOfEmbeddings200ResponseDataInner = void 0; -const runtime_1 = require("../runtime"); -/** - * Check if a given object implements the Embeddings200ResponseDataInner interface. - */ -function instanceOfEmbeddings200ResponseDataInner(value) { - let isInstance = true; - return isInstance; -} -exports.instanceOfEmbeddings200ResponseDataInner = instanceOfEmbeddings200ResponseDataInner; -function Embeddings200ResponseDataInnerFromJSON(json) { - return Embeddings200ResponseDataInnerFromJSONTyped(json, false); -} -exports.Embeddings200ResponseDataInnerFromJSON = Embeddings200ResponseDataInnerFromJSON; -function Embeddings200ResponseDataInnerFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'embedding': !(0, runtime_1.exists)(json, 'embedding') ? undefined : json['embedding'], - 'index': !(0, runtime_1.exists)(json, 'index') ? undefined : json['index'], - 'wasTruncated': !(0, runtime_1.exists)(json, 'was_truncated') ? undefined : json['was_truncated'], - }; -} -exports.Embeddings200ResponseDataInnerFromJSONTyped = Embeddings200ResponseDataInnerFromJSONTyped; -function Embeddings200ResponseDataInnerToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'embedding': value.embedding, - 'index': value.index, - 'was_truncated': value.wasTruncated, - }; -} -exports.Embeddings200ResponseDataInnerToJSON = Embeddings200ResponseDataInnerToJSON; diff --git a/dist/models/Embeddings200ResponseUsage.d.ts b/dist/models/Embeddings200ResponseUsage.d.ts deleted file mode 100644 index aa6e2bc..0000000 --- a/dist/models/Embeddings200ResponseUsage.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface Embeddings200ResponseUsage - */ -export interface Embeddings200ResponseUsage { - /** - * The number of prompt tokens used. - * @type {number} - * @memberof Embeddings200ResponseUsage - */ - promptTokens?: number; - /** - * The total number of tokens used. - * @type {number} - * @memberof Embeddings200ResponseUsage - */ - totalTokens?: number; -} -/** - * Check if a given object implements the Embeddings200ResponseUsage interface. - */ -export declare function instanceOfEmbeddings200ResponseUsage(value: object): boolean; -export declare function Embeddings200ResponseUsageFromJSON(json: any): Embeddings200ResponseUsage; -export declare function Embeddings200ResponseUsageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200ResponseUsage; -export declare function Embeddings200ResponseUsageToJSON(value?: Embeddings200ResponseUsage | null): any; diff --git a/dist/models/Embeddings200ResponseUsage.js b/dist/models/Embeddings200ResponseUsage.js deleted file mode 100644 index cf0f04c..0000000 --- a/dist/models/Embeddings200ResponseUsage.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Embeddings200ResponseUsageToJSON = exports.Embeddings200ResponseUsageFromJSONTyped = exports.Embeddings200ResponseUsageFromJSON = exports.instanceOfEmbeddings200ResponseUsage = void 0; -const runtime_1 = require("../runtime"); -/** - * Check if a given object implements the Embeddings200ResponseUsage interface. - */ -function instanceOfEmbeddings200ResponseUsage(value) { - let isInstance = true; - return isInstance; -} -exports.instanceOfEmbeddings200ResponseUsage = instanceOfEmbeddings200ResponseUsage; -function Embeddings200ResponseUsageFromJSON(json) { - return Embeddings200ResponseUsageFromJSONTyped(json, false); -} -exports.Embeddings200ResponseUsageFromJSON = Embeddings200ResponseUsageFromJSON; -function Embeddings200ResponseUsageFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'promptTokens': !(0, runtime_1.exists)(json, 'prompt_tokens') ? undefined : json['prompt_tokens'], - 'totalTokens': !(0, runtime_1.exists)(json, 'total_tokens') ? undefined : json['total_tokens'], - }; -} -exports.Embeddings200ResponseUsageFromJSONTyped = Embeddings200ResponseUsageFromJSONTyped; -function Embeddings200ResponseUsageToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'prompt_tokens': value.promptTokens, - 'total_tokens': value.totalTokens, - }; -} -exports.Embeddings200ResponseUsageToJSON = Embeddings200ResponseUsageToJSON; diff --git a/dist/models/EmbeddingsRequest.d.ts b/dist/models/EmbeddingsRequest.d.ts deleted file mode 100644 index 0703d19..0000000 --- a/dist/models/EmbeddingsRequest.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface EmbeddingsRequest - */ -export interface EmbeddingsRequest { - /** - * A list of texts for which the embedding should be generated. - * @type {Array} - * @memberof EmbeddingsRequest - */ - texts?: Array; - /** - * Specifies the model to be used for generating embeddings. - * @type {string} - * @memberof EmbeddingsRequest - */ - model?: string; - /** - * Required only for instruction based models. Specifies the instruction for generating embeddings. - * @type {string} - * @memberof EmbeddingsRequest - */ - instruction?: string; -} -/** - * Check if a given object implements the EmbeddingsRequest interface. - */ -export declare function instanceOfEmbeddingsRequest(value: object): boolean; -export declare function EmbeddingsRequestFromJSON(json: any): EmbeddingsRequest; -export declare function EmbeddingsRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): EmbeddingsRequest; -export declare function EmbeddingsRequestToJSON(value?: EmbeddingsRequest | null): any; diff --git a/dist/models/EmbeddingsRequest.js b/dist/models/EmbeddingsRequest.js deleted file mode 100644 index 0dee420..0000000 --- a/dist/models/EmbeddingsRequest.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.EmbeddingsRequestToJSON = exports.EmbeddingsRequestFromJSONTyped = exports.EmbeddingsRequestFromJSON = exports.instanceOfEmbeddingsRequest = void 0; -const runtime_1 = require("../runtime"); -/** - * Check if a given object implements the EmbeddingsRequest interface. - */ -function instanceOfEmbeddingsRequest(value) { - let isInstance = true; - return isInstance; -} -exports.instanceOfEmbeddingsRequest = instanceOfEmbeddingsRequest; -function EmbeddingsRequestFromJSON(json) { - return EmbeddingsRequestFromJSONTyped(json, false); -} -exports.EmbeddingsRequestFromJSON = EmbeddingsRequestFromJSON; -function EmbeddingsRequestFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'texts': !(0, runtime_1.exists)(json, 'texts') ? undefined : json['texts'], - 'model': !(0, runtime_1.exists)(json, 'model') ? undefined : json['model'], - 'instruction': !(0, runtime_1.exists)(json, 'instruction') ? undefined : json['instruction'], - }; -} -exports.EmbeddingsRequestFromJSONTyped = EmbeddingsRequestFromJSONTyped; -function EmbeddingsRequestToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'texts': value.texts, - 'model': value.model, - 'instruction': value.instruction, - }; -} -exports.EmbeddingsRequestToJSON = EmbeddingsRequestToJSON; diff --git a/dist/models/ErrorResponse.d.ts b/dist/models/ErrorResponse.d.ts deleted file mode 100644 index 46d4791..0000000 --- a/dist/models/ErrorResponse.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -/** - * - * @export - * @interface ErrorResponse - */ -export interface ErrorResponse { - /** - * - * @type {number} - * @memberof ErrorResponse - */ - code: number; - /** - * - * @type {string} - * @memberof ErrorResponse - */ - message: string; - /** - * - * @type {{ [key: string]: any; }} - * @memberof ErrorResponse - */ - data: { - [key: string]: any; - }; -} -/** - * Check if a given object implements the ErrorResponse interface. - */ -export declare function instanceOfErrorResponse(value: object): boolean; -export declare function ErrorResponseFromJSON(json: any): ErrorResponse; -export declare function ErrorResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorResponse; -export declare function ErrorResponseToJSON(value?: ErrorResponse | null): any; diff --git a/dist/models/ErrorResponse.js b/dist/models/ErrorResponse.js deleted file mode 100644 index 82ded30..0000000 --- a/dist/models/ErrorResponse.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ErrorResponseToJSON = exports.ErrorResponseFromJSONTyped = exports.ErrorResponseFromJSON = exports.instanceOfErrorResponse = void 0; -/** - * Check if a given object implements the ErrorResponse interface. - */ -function instanceOfErrorResponse(value) { - let isInstance = true; - isInstance = isInstance && "code" in value; - isInstance = isInstance && "message" in value; - isInstance = isInstance && "data" in value; - return isInstance; -} -exports.instanceOfErrorResponse = instanceOfErrorResponse; -function ErrorResponseFromJSON(json) { - return ErrorResponseFromJSONTyped(json, false); -} -exports.ErrorResponseFromJSON = ErrorResponseFromJSON; -function ErrorResponseFromJSONTyped(json, ignoreDiscriminator) { - if ((json === undefined) || (json === null)) { - return json; - } - return { - 'code': json['code'], - 'message': json['message'], - 'data': json['data'], - }; -} -exports.ErrorResponseFromJSONTyped = ErrorResponseFromJSONTyped; -function ErrorResponseToJSON(value) { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - 'code': value.code, - 'message': value.message, - 'data': value.data, - }; -} -exports.ErrorResponseToJSON = ErrorResponseToJSON; diff --git a/dist/models/index.d.ts b/dist/models/index.d.ts deleted file mode 100644 index 509fbf5..0000000 --- a/dist/models/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './Embeddings200Response'; -export * from './Embeddings200ResponseDataInner'; -export * from './Embeddings200ResponseUsage'; -export * from './EmbeddingsRequest'; -export * from './ErrorResponse'; diff --git a/dist/models/index.js b/dist/models/index.js deleted file mode 100644 index f03fd81..0000000 --- a/dist/models/index.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -/* tslint:disable */ -/* eslint-disable */ -__exportStar(require("./Embeddings200Response"), exports); -__exportStar(require("./Embeddings200ResponseDataInner"), exports); -__exportStar(require("./Embeddings200ResponseUsage"), exports); -__exportStar(require("./EmbeddingsRequest"), exports); -__exportStar(require("./ErrorResponse"), exports); diff --git a/dist/runtime.d.ts b/dist/runtime.d.ts deleted file mode 100644 index a7bec55..0000000 --- a/dist/runtime.d.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -export declare const BASE_PATH: string; -export interface ConfigurationParameters { - basePath?: string; - fetchApi?: FetchAPI; - middleware?: Middleware[]; - queryParamsStringify?: (params: HTTPQuery) => string; - apiKey?: string | ((name: string) => string); - headers?: HTTPHeaders; -} -export declare class Configuration { - private configuration; - constructor(configuration?: ConfigurationParameters); - set config(configuration: Configuration); - get basePath(): string; - get fetchApi(): FetchAPI | undefined; - get middleware(): Middleware[]; - get queryParamsStringify(): (params: HTTPQuery) => string; - get username(): string | undefined; - get password(): string | undefined; - get apiKey(): ((name: string) => string) | undefined; - get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined; - get headers(): HTTPHeaders | undefined; - get credentials(): RequestCredentials | undefined; -} -export declare const DefaultConfig: Configuration; -/** - * This is the base class for all generated API classes. - */ -export declare class BaseAPI { - protected configuration: Configuration; - private static readonly jsonRegex; - private middleware; - constructor(configuration?: Configuration); - withMiddleware(this: T, ...middlewares: Middleware[]): T; - withPreMiddleware(this: T, ...preMiddlewares: Array): T; - withPostMiddleware(this: T, ...postMiddlewares: Array): T; - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - protected isJsonMime(mime: string | null | undefined): boolean; - protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise; - private createFetchParams; - private fetchApi; - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone; -} -export declare class ResponseError extends Error { - response: Response; - name: "ResponseError"; - constructor(response: Response, msg?: string); -} -export declare class FetchError extends Error { - cause: Error; - name: "FetchError"; - constructor(cause: Error, msg?: string); -} -export declare class RequiredError extends Error { - field: string; - name: "RequiredError"; - constructor(field: string, msg?: string); -} -export declare const COLLECTION_FORMATS: { - csv: string; - ssv: string; - tsv: string; - pipes: string; -}; -export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; -export type Json = any; -export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; -export type HTTPHeaders = { - [key: string]: string; -}; -export type HTTPQuery = { - [key: string]: string | number | null | boolean | Array | Set | HTTPQuery; -}; -export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { - headers?: HTTPHeaders; - method: HTTPMethod; - credentials?: RequestCredentials; - body?: HTTPBody; -}; -export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; -export type InitOverrideFunction = (requestContext: { - init: HTTPRequestInit; - context: RequestOpts; -}) => Promise; -export interface FetchParams { - url: string; - init: RequestInit; -} -export interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; -} -export declare function exists(json: any, key: string): boolean; -export declare function querystring(params: HTTPQuery, prefix?: string): string; -export declare function mapValues(data: any, fn: (item: any) => any): {}; -export declare function canConsumeForm(consumes: Consume[]): boolean; -export interface Consume { - contentType: string; -} -export interface RequestContext { - fetch: FetchAPI; - url: string; - init: RequestInit; -} -export interface ResponseContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - response: Response; -} -export interface ErrorContext { - fetch: FetchAPI; - url: string; - init: RequestInit; - error: unknown; - response?: Response; -} -export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; - onError?(context: ErrorContext): Promise; -} -export interface ApiResponse { - raw: Response; - value(): Promise; -} -export interface ResponseTransformer { - (json: any): T; -} -export declare class JSONApiResponse { - raw: Response; - private transformer; - constructor(raw: Response, transformer?: ResponseTransformer); - value(): Promise; -} -export declare class VoidApiResponse { - raw: Response; - constructor(raw: Response); - value(): Promise; -} -export declare class BlobApiResponse { - raw: Response; - constructor(raw: Response); - value(): Promise; -} -export declare class TextApiResponse { - raw: Response; - constructor(raw: Response); - value(): Promise; -} diff --git a/dist/runtime.js b/dist/runtime.js deleted file mode 100644 index c18711a..0000000 --- a/dist/runtime.js +++ /dev/null @@ -1,355 +0,0 @@ -"use strict"; -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.canConsumeForm = exports.mapValues = exports.querystring = exports.exists = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.DefaultConfig = exports.Configuration = exports.BASE_PATH = void 0; -exports.BASE_PATH = "https://api.mixedbread.ai".replace(/\/+$/, ""); -class Configuration { - constructor(configuration = {}) { - this.configuration = configuration; - } - set config(configuration) { - this.configuration = configuration; - } - get basePath() { - return this.configuration.basePath != null ? this.configuration.basePath : exports.BASE_PATH; - } - get fetchApi() { - return this.configuration.fetchApi; - } - get middleware() { - return this.configuration.middleware || []; - } - get queryParamsStringify() { - return this.configuration.queryParamsStringify || querystring; - } - get username() { - return undefined; - } - get password() { - return undefined; - } - get apiKey() { - let apiKey = this.configuration.apiKey; - if (apiKey) { - if (typeof apiKey === 'function') { - // @ts-ignore - return (name) => 'Bearer ' + apiKey(name); - } - else { - return () => 'Bearer ' + apiKey; - } - } - else { - // @ts-ignore - apiKey = process.env.MIXEDBREADAI_API_KEY; - if (apiKey) { - return () => 'Bearer ' + apiKey; - } - } - return undefined; - } - get accessToken() { - return undefined; - } - get headers() { - return this.configuration.headers; - } - get credentials() { - return undefined; - } -} -exports.Configuration = Configuration; -exports.DefaultConfig = new Configuration(); -/** - * This is the base class for all generated API classes. - */ -class BaseAPI { - constructor(configuration = exports.DefaultConfig) { - this.configuration = configuration; - this.fetchApi = (url, init) => __awaiter(this, void 0, void 0, function* () { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = (yield middleware.pre(Object.assign({ fetch: this.fetchApi }, fetchParams))) || fetchParams; - } - } - let response = undefined; - try { - response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); - } - catch (e) { - for (const middleware of this.middleware) { - if (middleware.onError) { - response = (yield middleware.onError({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - error: e, - response: response ? response.clone() : undefined, - })) || response; - } - } - if (response === undefined) { - if (e instanceof Error) { - throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); - } - else { - throw e; - } - } - } - for (const middleware of this.middleware) { - if (middleware.post) { - response = (yield middleware.post({ - fetch: this.fetchApi, - url: fetchParams.url, - init: fetchParams.init, - response: response.clone(), - })) || response; - } - } - return response; - }); - this.middleware = configuration.middleware; - } - withMiddleware(...middlewares) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - withPreMiddleware(...preMiddlewares) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); - } - withPostMiddleware(...postMiddlewares) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - isJsonMime(mime) { - if (!mime) { - return false; - } - return BaseAPI.jsonRegex.test(mime); - } - request(context, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - const { url, init } = yield this.createFetchParams(context, initOverrides); - const response = yield this.fetchApi(url, init); - if (response && (response.status >= 200 && response.status < 300)) { - return response; - } - throw new ResponseError(response, 'Response returned an error code'); - }); - } - createFetchParams(context, initOverrides) { - return __awaiter(this, void 0, void 0, function* () { - let url = this.configuration.basePath + context.path; - if (context.query !== undefined && Object.keys(context.query).length !== 0) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += '?' + this.configuration.queryParamsStringify(context.query); - } - const headers = Object.assign({}, this.configuration.headers, context.headers); - Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); - const initOverrideFn = typeof initOverrides === "function" - ? initOverrides - : () => __awaiter(this, void 0, void 0, function* () { return initOverrides; }); - const initParams = { - method: context.method, - headers, - body: context.body, - credentials: this.configuration.credentials, - }; - const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({ - init: initParams, - context, - }))); - let body; - if (isFormData(overriddenInit.body) - || (overriddenInit.body instanceof URLSearchParams) - || isBlob(overriddenInit.body)) { - body = overriddenInit.body; - } - else if (this.isJsonMime(headers['Content-Type'])) { - body = JSON.stringify(overriddenInit.body); - } - else { - body = overriddenInit.body; - } - const init = Object.assign(Object.assign({}, overriddenInit), { body }); - return { url, init }; - }); - } - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - clone() { - const constructor = this.constructor; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; - } -} -exports.BaseAPI = BaseAPI; -BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); -; -function isBlob(value) { - return typeof Blob !== 'undefined' && value instanceof Blob; -} -function isFormData(value) { - return typeof FormData !== "undefined" && value instanceof FormData; -} -class ResponseError extends Error { - constructor(response, msg) { - super(msg); - this.response = response; - this.name = "ResponseError"; - } -} -exports.ResponseError = ResponseError; -class FetchError extends Error { - constructor(cause, msg) { - super(msg); - this.cause = cause; - this.name = "FetchError"; - } -} -exports.FetchError = FetchError; -class RequiredError extends Error { - constructor(field, msg) { - super(msg); - this.field = field; - this.name = "RequiredError"; - } -} -exports.RequiredError = RequiredError; -exports.COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; -function exists(json, key) { - const value = json[key]; - return value !== null && value !== undefined; -} -exports.exists = exists; -function querystring(params, prefix = '') { - return Object.keys(params) - .map(key => querystringSingleKey(key, params[key], prefix)) - .filter(part => part.length > 0) - .join('&'); -} -exports.querystring = querystring; -function querystringSingleKey(key, value, keyPrefix = '') { - const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); - if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) - .join(`&${encodeURIComponent(fullKey)}=`); - return `${encodeURIComponent(fullKey)}=${multiValue}`; - } - if (value instanceof Set) { - const valueAsArray = Array.from(value); - return querystringSingleKey(key, valueAsArray, keyPrefix); - } - if (value instanceof Date) { - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; - } - if (value instanceof Object) { - return querystring(value, fullKey); - } - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; -} -function mapValues(data, fn) { - return Object.keys(data).reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: fn(data[key]) })), {}); -} -exports.mapValues = mapValues; -function canConsumeForm(consumes) { - for (const consume of consumes) { - if ('multipart/form-data' === consume.contentType) { - return true; - } - } - return false; -} -exports.canConsumeForm = canConsumeForm; -class JSONApiResponse { - constructor(raw, transformer = (jsonValue) => jsonValue) { - this.raw = raw; - this.transformer = transformer; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return this.transformer(yield this.raw.json()); - }); - } -} -exports.JSONApiResponse = JSONApiResponse; -class VoidApiResponse { - constructor(raw) { - this.raw = raw; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return undefined; - }); - } -} -exports.VoidApiResponse = VoidApiResponse; -class BlobApiResponse { - constructor(raw) { - this.raw = raw; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return yield this.raw.blob(); - }); - } - ; -} -exports.BlobApiResponse = BlobApiResponse; -class TextApiResponse { - constructor(raw) { - this.raw = raw; - } - value() { - return __awaiter(this, void 0, void 0, function* () { - return yield this.raw.text(); - }); - } - ; -} -exports.TextApiResponse = TextApiResponse; diff --git a/package.json b/package.json index 634f584..5b0b595 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@mixedbread-ai/sdk", - "version": "1.0.2", - "description": "SDK for @mixedbread-ai/sdk", + "version": "1.1.0", + "description": "SDK for mixedbread.ai", "author": "mixedrbread.ai", "repository": { "type": "git", diff --git a/src/apis/MixedbreadAiApi.ts b/src/apis/MixedbreadAiApi.ts index 18c6b0c..548f57a 100644 --- a/src/apis/MixedbreadAiApi.ts +++ b/src/apis/MixedbreadAiApi.ts @@ -15,15 +15,15 @@ import * as runtime from '../runtime'; import type { - Embeddings200Response, EmbeddingsRequest, + EmbeddingsResponse, ErrorResponse, } from '../models/index'; import { - Embeddings200ResponseFromJSON, - Embeddings200ResponseToJSON, EmbeddingsRequestFromJSON, EmbeddingsRequestToJSON, + EmbeddingsResponseFromJSON, + EmbeddingsResponseToJSON, ErrorResponseFromJSON, ErrorResponseToJSON, } from '../models/index'; @@ -33,15 +33,40 @@ export interface EmbeddingsOperationRequest { } /** + * MixedbreadAiApi - interface * + * @export + * @interface MixedbreadAiApiInterface */ -export class MixedbreadAiApi extends runtime.BaseAPI { +export interface MixedbreadAiApiInterface { + /** + * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. + * @summary Create embeddings + * @param {EmbeddingsRequest} embeddingsRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof MixedbreadAiApiInterface + */ + embeddingsRaw(requestParameters: EmbeddingsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + + /** + * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. + * Create embeddings + */ + embeddings(embeddingsRequest: EmbeddingsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + +} + +/** + * + */ +export class MixedbreadAiApi extends runtime.BaseAPI implements MixedbreadAiApiInterface { /** * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. * Create embeddings */ - async embeddingsRaw(requestParameters: EmbeddingsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async embeddingsRaw(requestParameters: EmbeddingsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.embeddingsRequest === null || requestParameters.embeddingsRequest === undefined) { throw new runtime.RequiredError('embeddingsRequest','Required parameter requestParameters.embeddingsRequest was null or undefined when calling embeddings.'); } @@ -64,14 +89,14 @@ export class MixedbreadAiApi extends runtime.BaseAPI { body: EmbeddingsRequestToJSON(requestParameters.embeddingsRequest), }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => Embeddings200ResponseFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => EmbeddingsResponseFromJSON(jsonValue)); } /** * This endpoint allows you to post text data and receive embeddings in response. The embeddings are generated using the model specified in the request body. * Create embeddings */ - async embeddings(embeddingsRequest: EmbeddingsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async embeddings(embeddingsRequest: EmbeddingsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.embeddingsRaw({ embeddingsRequest: embeddingsRequest }, initOverrides); return await response.value(); } diff --git a/src/index.ts b/src/index.ts index bebe8bb..fdc09c7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ /* tslint:disable */ /* eslint-disable */ -export * from './runtime'; -export * from './apis/index'; -export * from './models/index'; +export * from './mixedbread-ai'; +export * from './mixedbread-ai-types'; +export {BASE_PATH, type ErrorContext, type Middleware, type RequestContext, type ResponseContext, type FetchAPI} from './runtime'; +export {type ErrorResponse} from "./models"; \ No newline at end of file diff --git a/src/mixedbread-ai-types.ts b/src/mixedbread-ai-types.ts new file mode 100644 index 0000000..bb543bc --- /dev/null +++ b/src/mixedbread-ai-types.ts @@ -0,0 +1,24 @@ +import {ConfigurationParameters, FetchError, RequiredError, ResponseError as ResponseErrorInternal} from "./runtime"; +import {MixedbreadAiApiInterface} from "./apis"; +import { + EmbeddingsRequest as EmbeddingsRequestInternal, + EmbeddingsResponse as EmbeddingsResponseInternal, + EmbeddingsResponseDataInner, ModelBaseResponse +} from "./models"; + +export interface MixedbreadAiConfig extends Omit {} + +export type RequestInitOverrides = Parameters[1]; + +export type Embedding = EmbeddingsResponseDataInner; + +export interface EmbeddingsRequest extends Omit { + input: string[] | string; +} +export interface EmbeddingsResponse extends Omit { + data: Embedding[]; +} + +export type BaseResponse = ModelBaseResponse; + +export type ResponseError = ResponseErrorInternal | FetchError | RequiredError; \ No newline at end of file diff --git a/src/mixedbread-ai.ts b/src/mixedbread-ai.ts new file mode 100644 index 0000000..5ae3e9c --- /dev/null +++ b/src/mixedbread-ai.ts @@ -0,0 +1,51 @@ +import { + EmbeddingsRequest as EmbeddingsRequestInternal, +} from "./models"; +import {MixedbreadAiApi} from "./apis"; +import {BASE_PATH, Configuration} from "./runtime"; +import { + EmbeddingsRequest, + EmbeddingsResponse, + RequestInitOverrides, + MixedbreadAiConfig +} from "./mixedbread-ai-types"; +import packageJson from "../package.json"; + +const sdkVersion = packageJson.version; + +export class MixedbreadAi { + private client: MixedbreadAiApi; + + constructor({ + basePath = BASE_PATH, + apiKey = process.env.MIXEDBREADAI_API_KEY, + ...config + }: MixedbreadAiConfig = {}) { + const cfg = new Configuration({ + ...config, + headers: { + "User-Agent": `@mixedbread-ai/typescript-sdk/${sdkVersion}`, + ...config.headers + }, + basePath, + apiKey: (name) => { + return `Bearer ${typeof apiKey === 'function' ? apiKey(name) : apiKey}`; + }, + }); + + this.client = new MixedbreadAiApi(cfg); + } + + /** + * @throws {ResponseError} + */ + public embeddings = async (embeddingsRequest: EmbeddingsRequest, requestInitOverrides?: RequestInitOverrides): Promise => { + if (typeof embeddingsRequest.input === 'string') { + embeddingsRequest.input = [embeddingsRequest.input]; + } + + return await this.client.embeddings(embeddingsRequest as EmbeddingsRequestInternal, requestInitOverrides); + } +} + +export default MixedbreadAi; \ No newline at end of file diff --git a/src/models/Embeddings200Response.ts b/src/models/Embeddings200Response.ts deleted file mode 100644 index 6391b15..0000000 --- a/src/models/Embeddings200Response.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { Embeddings200ResponseDataInner } from './Embeddings200ResponseDataInner'; -import { - Embeddings200ResponseDataInnerFromJSON, - Embeddings200ResponseDataInnerFromJSONTyped, - Embeddings200ResponseDataInnerToJSON, -} from './Embeddings200ResponseDataInner'; -import type { Embeddings200ResponseUsage } from './Embeddings200ResponseUsage'; -import { - Embeddings200ResponseUsageFromJSON, - Embeddings200ResponseUsageFromJSONTyped, - Embeddings200ResponseUsageToJSON, -} from './Embeddings200ResponseUsage'; - -/** - * - * @export - * @interface Embeddings200Response - */ -export interface Embeddings200Response { - /** - * The embeddings model used. - * @type {string} - * @memberof Embeddings200Response - */ - model: string; - /** - * - * @type {Array} - * @memberof Embeddings200Response - */ - data: Array; - /** - * - * @type {Embeddings200ResponseUsage} - * @memberof Embeddings200Response - */ - usage: Embeddings200ResponseUsage; -} - -/** - * Check if a given object implements the Embeddings200Response interface. - */ -export function instanceOfEmbeddings200Response(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "model" in value; - isInstance = isInstance && "data" in value; - isInstance = isInstance && "usage" in value; - - return isInstance; -} - -export function Embeddings200ResponseFromJSON(json: any): Embeddings200Response { - return Embeddings200ResponseFromJSONTyped(json, false); -} - -export function Embeddings200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200Response { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'model': json['model'], - 'data': ((json['data'] as Array).map(Embeddings200ResponseDataInnerFromJSON)), - 'usage': Embeddings200ResponseUsageFromJSON(json['usage']), - }; -} - -export function Embeddings200ResponseToJSON(value?: Embeddings200Response | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'model': value.model, - 'data': ((value.data as Array).map(Embeddings200ResponseDataInnerToJSON)), - 'usage': Embeddings200ResponseUsageToJSON(value.usage), - }; -} - diff --git a/src/models/Embeddings200ResponseUsage.ts b/src/models/Embeddings200ResponseUsage.ts deleted file mode 100644 index ff6fdfa..0000000 --- a/src/models/Embeddings200ResponseUsage.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface Embeddings200ResponseUsage - */ -export interface Embeddings200ResponseUsage { - /** - * The number of prompt tokens used. - * @type {number} - * @memberof Embeddings200ResponseUsage - */ - promptTokens?: number; - /** - * The total number of tokens used. - * @type {number} - * @memberof Embeddings200ResponseUsage - */ - totalTokens?: number; -} - -/** - * Check if a given object implements the Embeddings200ResponseUsage interface. - */ -export function instanceOfEmbeddings200ResponseUsage(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function Embeddings200ResponseUsageFromJSON(json: any): Embeddings200ResponseUsage { - return Embeddings200ResponseUsageFromJSONTyped(json, false); -} - -export function Embeddings200ResponseUsageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200ResponseUsage { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'promptTokens': !exists(json, 'prompt_tokens') ? undefined : json['prompt_tokens'], - 'totalTokens': !exists(json, 'total_tokens') ? undefined : json['total_tokens'], - }; -} - -export function Embeddings200ResponseUsageToJSON(value?: Embeddings200ResponseUsage | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'prompt_tokens': value.promptTokens, - 'total_tokens': value.totalTokens, - }; -} - diff --git a/src/models/EmbeddingsRequest.ts b/src/models/EmbeddingsRequest.ts index be36ed5..a71a33e 100644 --- a/src/models/EmbeddingsRequest.ts +++ b/src/models/EmbeddingsRequest.ts @@ -13,13 +13,6 @@ */ import { exists, mapValues } from '../runtime'; -import type { EmbeddingsRequestInput } from './EmbeddingsRequestInput'; -import { - EmbeddingsRequestInputFromJSON, - EmbeddingsRequestInputFromJSONTyped, - EmbeddingsRequestInputToJSON, -} from './EmbeddingsRequestInput'; - /** * * @export @@ -27,17 +20,17 @@ import { */ export interface EmbeddingsRequest { /** - * - * @type {EmbeddingsRequestInput} + * Specifies the model to be used for generating embeddings. + * @type {string} * @memberof EmbeddingsRequest */ - input?: EmbeddingsRequestInput; + model: string; /** - * Specifies the model to be used for generating embeddings. - * @type {string} + * A list of text strings for which the embeddings should be generated. + * @type {Array} * @memberof EmbeddingsRequest */ - model?: string; + input: Array; /** * Required only for instruction based models. Specifies the instruction for generating embeddings. * @type {string} @@ -57,6 +50,8 @@ export interface EmbeddingsRequest { */ export function instanceOfEmbeddingsRequest(value: object): boolean { let isInstance = true; + isInstance = isInstance && "model" in value; + isInstance = isInstance && "input" in value; return isInstance; } @@ -71,8 +66,8 @@ export function EmbeddingsRequestFromJSONTyped(json: any, ignoreDiscriminator: b } return { - 'input': !exists(json, 'input') ? undefined : EmbeddingsRequestInputFromJSON(json['input']), - 'model': !exists(json, 'model') ? undefined : json['model'], + 'model': json['model'], + 'input': json['input'], 'instruction': !exists(json, 'instruction') ? undefined : json['instruction'], 'normalized': !exists(json, 'normalized') ? undefined : json['normalized'], }; @@ -87,8 +82,8 @@ export function EmbeddingsRequestToJSON(value?: EmbeddingsRequest | null): any { } return { - 'input': EmbeddingsRequestInputToJSON(value.input), 'model': value.model, + 'input': value.input, 'instruction': value.instruction, 'normalized': value.normalized, }; diff --git a/src/models/EmbeddingsRequestInput.ts b/src/models/EmbeddingsRequestInput.ts deleted file mode 100644 index cf048b7..0000000 --- a/src/models/EmbeddingsRequestInput.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * mixedbread-ai - * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -/** - * @type EmbeddingsRequestInput - * Input text(s) for generating embeddings. Can be either a single string or an array of strings. - * @export - */ -export type EmbeddingsRequestInput = Array | string; - -export function EmbeddingsRequestInputFromJSON(json: any): EmbeddingsRequestInput { - return EmbeddingsRequestInputFromJSONTyped(json, false); -} - -export function EmbeddingsRequestInputFromJSONTyped(json: any, ignoreDiscriminator: boolean): EmbeddingsRequestInput { - if ((json === undefined) || (json === null)) { - return json; - } - return { ...ArrayFromJSONTyped(json, true), ...stringFromJSONTyped(json, true) }; -} - -export function EmbeddingsRequestInputToJSON(value?: EmbeddingsRequestInput | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - - if (instanceOfArray(value)) { - return ArrayToJSON(value as Array); - } - if (instanceOfstring(value)) { - return stringToJSON(value as string); - } - - return {}; -} - diff --git a/src/models/EmbeddingsResponse.ts b/src/models/EmbeddingsResponse.ts new file mode 100644 index 0000000..095cdba --- /dev/null +++ b/src/models/EmbeddingsResponse.ts @@ -0,0 +1,106 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * mixedbread-ai + * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { EmbeddingsResponseDataInner } from './EmbeddingsResponseDataInner'; +import { + EmbeddingsResponseDataInnerFromJSON, + EmbeddingsResponseDataInnerFromJSONTyped, + EmbeddingsResponseDataInnerToJSON, +} from './EmbeddingsResponseDataInner'; +import type { ModelBaseResponseUsage } from './ModelBaseResponseUsage'; +import { + ModelBaseResponseUsageFromJSON, + ModelBaseResponseUsageFromJSONTyped, + ModelBaseResponseUsageToJSON, +} from './ModelBaseResponseUsage'; + +/** + * + * @export + * @interface EmbeddingsResponse + */ +export interface EmbeddingsResponse { + /** + * Indicates if the embeddings were normalized. + * @type {boolean} + * @memberof EmbeddingsResponse + */ + normalized: boolean; + /** + * + * @type {Array} + * @memberof EmbeddingsResponse + */ + data: Array; + /** + * The embeddings model used. + * @type {string} + * @memberof EmbeddingsResponse + */ + model: string; + /** + * + * @type {ModelBaseResponseUsage} + * @memberof EmbeddingsResponse + */ + usage: ModelBaseResponseUsage; +} + +/** + * Check if a given object implements the EmbeddingsResponse interface. + */ +export function instanceOfEmbeddingsResponse(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "normalized" in value; + isInstance = isInstance && "data" in value; + isInstance = isInstance && "model" in value; + isInstance = isInstance && "usage" in value; + + return isInstance; +} + +export function EmbeddingsResponseFromJSON(json: any): EmbeddingsResponse { + return EmbeddingsResponseFromJSONTyped(json, false); +} + +export function EmbeddingsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): EmbeddingsResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'normalized': json['normalized'], + 'data': ((json['data'] as Array).map(EmbeddingsResponseDataInnerFromJSON)), + 'model': json['model'], + 'usage': ModelBaseResponseUsageFromJSON(json['usage']), + }; +} + +export function EmbeddingsResponseToJSON(value?: EmbeddingsResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'normalized': value.normalized, + 'data': ((value.data as Array).map(EmbeddingsResponseDataInnerToJSON)), + 'model': value.model, + 'usage': ModelBaseResponseUsageToJSON(value.usage), + }; +} + diff --git a/src/models/Embeddings200ResponseDataInner.ts b/src/models/EmbeddingsResponseDataInner.ts similarity index 59% rename from src/models/Embeddings200ResponseDataInner.ts rename to src/models/EmbeddingsResponseDataInner.ts index 225617a..5d2a0d3 100644 --- a/src/models/Embeddings200ResponseDataInner.ts +++ b/src/models/EmbeddingsResponseDataInner.ts @@ -16,43 +16,43 @@ import { exists, mapValues } from '../runtime'; /** * * @export - * @interface Embeddings200ResponseDataInner + * @interface EmbeddingsResponseDataInner */ -export interface Embeddings200ResponseDataInner { +export interface EmbeddingsResponseDataInner { /** * The generated embeddings. * @type {Array} - * @memberof Embeddings200ResponseDataInner + * @memberof EmbeddingsResponseDataInner */ embedding?: Array; /** * Index of the request text the embedding corresponds to. * @type {number} - * @memberof Embeddings200ResponseDataInner + * @memberof EmbeddingsResponseDataInner */ index?: number; /** * Indicates if the text was truncated for the model. * @type {boolean} - * @memberof Embeddings200ResponseDataInner + * @memberof EmbeddingsResponseDataInner */ - wasTruncated?: boolean; + truncated?: boolean; } /** - * Check if a given object implements the Embeddings200ResponseDataInner interface. + * Check if a given object implements the EmbeddingsResponseDataInner interface. */ -export function instanceOfEmbeddings200ResponseDataInner(value: object): boolean { +export function instanceOfEmbeddingsResponseDataInner(value: object): boolean { let isInstance = true; return isInstance; } -export function Embeddings200ResponseDataInnerFromJSON(json: any): Embeddings200ResponseDataInner { - return Embeddings200ResponseDataInnerFromJSONTyped(json, false); +export function EmbeddingsResponseDataInnerFromJSON(json: any): EmbeddingsResponseDataInner { + return EmbeddingsResponseDataInnerFromJSONTyped(json, false); } -export function Embeddings200ResponseDataInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Embeddings200ResponseDataInner { +export function EmbeddingsResponseDataInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): EmbeddingsResponseDataInner { if ((json === undefined) || (json === null)) { return json; } @@ -60,11 +60,11 @@ export function Embeddings200ResponseDataInnerFromJSONTyped(json: any, ignoreDis 'embedding': !exists(json, 'embedding') ? undefined : json['embedding'], 'index': !exists(json, 'index') ? undefined : json['index'], - 'wasTruncated': !exists(json, 'was_truncated') ? undefined : json['was_truncated'], + 'truncated': !exists(json, 'truncated') ? undefined : json['truncated'], }; } -export function Embeddings200ResponseDataInnerToJSON(value?: Embeddings200ResponseDataInner | null): any { +export function EmbeddingsResponseDataInnerToJSON(value?: EmbeddingsResponseDataInner | null): any { if (value === undefined) { return undefined; } @@ -75,7 +75,7 @@ export function Embeddings200ResponseDataInnerToJSON(value?: Embeddings200Respon 'embedding': value.embedding, 'index': value.index, - 'was_truncated': value.wasTruncated, + 'truncated': value.truncated, }; } diff --git a/src/models/ModelBaseResponse.ts b/src/models/ModelBaseResponse.ts new file mode 100644 index 0000000..04fe807 --- /dev/null +++ b/src/models/ModelBaseResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * mixedbread-ai + * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ModelBaseResponseUsage } from './ModelBaseResponseUsage'; +import { + ModelBaseResponseUsageFromJSON, + ModelBaseResponseUsageFromJSONTyped, + ModelBaseResponseUsageToJSON, +} from './ModelBaseResponseUsage'; + +/** + * + * @export + * @interface ModelBaseResponse + */ +export interface ModelBaseResponse { + /** + * The embeddings model used. + * @type {string} + * @memberof ModelBaseResponse + */ + model: string; + /** + * + * @type {ModelBaseResponseUsage} + * @memberof ModelBaseResponse + */ + usage: ModelBaseResponseUsage; +} + +/** + * Check if a given object implements the ModelBaseResponse interface. + */ +export function instanceOfModelBaseResponse(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "model" in value; + isInstance = isInstance && "usage" in value; + + return isInstance; +} + +export function ModelBaseResponseFromJSON(json: any): ModelBaseResponse { + return ModelBaseResponseFromJSONTyped(json, false); +} + +export function ModelBaseResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelBaseResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'model': json['model'], + 'usage': ModelBaseResponseUsageFromJSON(json['usage']), + }; +} + +export function ModelBaseResponseToJSON(value?: ModelBaseResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'model': value.model, + 'usage': ModelBaseResponseUsageToJSON(value.usage), + }; +} + diff --git a/src/models/ModelBaseResponseUsage.ts b/src/models/ModelBaseResponseUsage.ts new file mode 100644 index 0000000..c22400b --- /dev/null +++ b/src/models/ModelBaseResponseUsage.ts @@ -0,0 +1,83 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * mixedbread-ai + * Discover how to convert text into embeddings with the Embeddings API. Ideal for NLP tasks like text similarity and clustering. Use top open source models or your own fine-tuned models. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ModelBaseResponseUsage + */ +export interface ModelBaseResponseUsage { + /** + * The number of prompt tokens used. + * @type {number} + * @memberof ModelBaseResponseUsage + */ + promptTokens: number; + /** + * The total number of tokens used. + * @type {number} + * @memberof ModelBaseResponseUsage + */ + totalTokens: number; + /** + * The number of completion tokens used. + * @type {number} + * @memberof ModelBaseResponseUsage + */ + completionTokens?: number; +} + +/** + * Check if a given object implements the ModelBaseResponseUsage interface. + */ +export function instanceOfModelBaseResponseUsage(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "promptTokens" in value; + isInstance = isInstance && "totalTokens" in value; + + return isInstance; +} + +export function ModelBaseResponseUsageFromJSON(json: any): ModelBaseResponseUsage { + return ModelBaseResponseUsageFromJSONTyped(json, false); +} + +export function ModelBaseResponseUsageFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelBaseResponseUsage { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'promptTokens': json['prompt_tokens'], + 'totalTokens': json['total_tokens'], + 'completionTokens': !exists(json, 'completion_tokens') ? undefined : json['completion_tokens'], + }; +} + +export function ModelBaseResponseUsageToJSON(value?: ModelBaseResponseUsage | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'prompt_tokens': value.promptTokens, + 'total_tokens': value.totalTokens, + 'completion_tokens': value.completionTokens, + }; +} + diff --git a/src/models/index.ts b/src/models/index.ts index 7fcef3f..ecf43aa 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ -export * from './Embeddings200Response'; -export * from './Embeddings200ResponseDataInner'; -export * from './Embeddings200ResponseUsage'; export * from './EmbeddingsRequest'; -export * from './EmbeddingsRequestInput'; +export * from './EmbeddingsResponse'; +export * from './EmbeddingsResponseDataInner'; export * from './ErrorResponse'; +export * from './ModelBaseResponse'; +export * from './ModelBaseResponseUsage'; diff --git a/src/runtime.ts b/src/runtime.ts index 3cf44ca..1106dd5 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -20,8 +20,12 @@ export interface ConfigurationParameters { fetchApi?: FetchAPI; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -48,35 +52,26 @@ export class Configuration { } get username(): string | undefined { - return undefined; + return this.configuration.username; } get password(): string | undefined { - return undefined; + return this.configuration.password; } get apiKey(): ((name: string) => string) | undefined { - let apiKey = this.configuration.apiKey; - + const apiKey = this.configuration.apiKey; if (apiKey) { - if (typeof apiKey === 'function') { - // @ts-ignore - return (name: string) => 'Bearer ' + apiKey(name); - } else { - return () => 'Bearer ' + apiKey; - } - } else { - // @ts-ignore - apiKey = process.env.MIXEDBREADAI_API_KEY; - if (apiKey) { - return () => 'Bearer ' + apiKey; - } + return typeof apiKey === 'function' ? apiKey : () => apiKey; } - return undefined; } get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } return undefined; } @@ -85,7 +80,7 @@ export class Configuration { } get credentials(): RequestCredentials | undefined { - return undefined; + return this.configuration.credentials; } } @@ -265,21 +260,21 @@ function isFormData(value: any): value is FormData { export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { - super(msg); + super(`${msg || ''}. ${response.status} ${response.statusText}.`.trim()); } } export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { - super(msg); + super(`${msg || ''}. ${cause.message}`.trim()); } } export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { - super(msg); + super(`Required field missing: ${field}. ${msg || ''}`.trim()); } } diff --git a/tsconfig.json b/tsconfig.json index 250280d..469146f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,10 +7,13 @@ "outDir": "dist", "typeRoots": [ "node_modules/@types" - ] + ], + "resolveJsonModule": true, + "esModuleInterop": true, }, "exclude": [ "dist", - "node_modules" + "node_modules", + "test.ts" ] }