Skip to content

Commit

Permalink
Initial SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuslipp committed Jan 19, 2024
1 parent b903650 commit bac7e6c
Show file tree
Hide file tree
Showing 61 changed files with 501 additions and 2,580 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ wwwroot/*.js
node_modules
typings
dist
test.ts
8 changes: 6 additions & 2 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

src/runtime.ts
README.md
package.json
package.json
src/index.ts
src/mixedbread-ai.ts
src/mixedbread-ai-types.ts
src/runtime.d.ts
tsconfig.json
11 changes: 5 additions & 6 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -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
59 changes: 55 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
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)
```
Binary file added bun.lockb
Binary file not shown.
31 changes: 0 additions & 31 deletions dist/apis/MixedbreadAiApi.d.ts

This file was deleted.

68 changes: 0 additions & 68 deletions dist/apis/MixedbreadAiApi.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/apis/index.d.ts

This file was deleted.

19 changes: 0 additions & 19 deletions dist/apis/index.js

This file was deleted.

31 changes: 0 additions & 31 deletions dist/esm/apis/MixedbreadAiApi.d.ts

This file was deleted.

64 changes: 0 additions & 64 deletions dist/esm/apis/MixedbreadAiApi.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/esm/apis/index.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions dist/esm/apis/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions dist/esm/index.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions dist/esm/index.js

This file was deleted.

45 changes: 0 additions & 45 deletions dist/esm/models/Embeddings200Response.d.ts

This file was deleted.

Loading

0 comments on commit bac7e6c

Please sign in to comment.