Skip to content

Commit 3f1e94b

Browse files
docs(sdk): make embeddings example first
1 parent eab8690 commit 3f1e94b

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 4
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-ee884a4336559147aacf9a927a540f21e9760f00d2d5588af00fa8a25e2707d9.yml
33
openapi_spec_hash: 2ba78bd360942c63a7d08dba791f00d2
4-
config_hash: efa2ea406c5ecd6883ff8b0fb428e579
4+
config_hash: a85580968a69d8d6fadf96e5e2d6870e

README.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ const client = new Isaacus({
2626
apiKey: process.env['ISAACUS_API_KEY'], // This is the default and can be omitted
2727
});
2828

29-
const universalClassificationResponse = await client.classifications.universal.create({
30-
model: 'kanon-universal-classifier',
31-
query: 'This is a confidentiality clause.',
32-
texts: ['I agree not to tell anyone about the document.'],
29+
const embeddingResponse = await client.embeddings.create({
30+
model: 'kanon-2-embedder',
31+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
3332
});
3433

35-
console.log(universalClassificationResponse.classifications);
34+
console.log(embeddingResponse.embeddings);
3635
```
3736

3837
### Request & Response types
@@ -47,13 +46,11 @@ const client = new Isaacus({
4746
apiKey: process.env['ISAACUS_API_KEY'], // This is the default and can be omitted
4847
});
4948

50-
const params: Isaacus.Classifications.UniversalCreateParams = {
51-
model: 'kanon-universal-classifier',
52-
query: 'This is a confidentiality clause.',
53-
texts: ['I agree not to tell anyone about the document.'],
49+
const params: Isaacus.EmbeddingCreateParams = {
50+
model: 'kanon-2-embedder',
51+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
5452
};
55-
const universalClassificationResponse: Isaacus.Classifications.UniversalClassificationResponse =
56-
await client.classifications.universal.create(params);
53+
const embeddingResponse: Isaacus.EmbeddingResponse = await client.embeddings.create(params);
5754
```
5855

5956
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -66,11 +63,10 @@ a subclass of `APIError` will be thrown:
6663

6764
<!-- prettier-ignore -->
6865
```ts
69-
const universalClassificationResponse = await client.classifications.universal
66+
const embeddingResponse = await client.embeddings
7067
.create({
71-
model: 'kanon-universal-classifier',
72-
query: 'This is a confidentiality clause.',
73-
texts: ['I agree not to tell anyone about the document.'],
68+
model: 'kanon-2-embedder',
69+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
7470
})
7571
.catch(async (err) => {
7672
if (err instanceof Isaacus.APIError) {
@@ -112,7 +108,7 @@ const client = new Isaacus({
112108
});
113109

114110
// Or, configure per-request:
115-
await client.classifications.universal.create({ model: 'kanon-universal-classifier', query: 'This is a confidentiality clause.', texts: ['I agree not to tell anyone about the document.'] }, {
111+
await client.embeddings.create({ model: 'kanon-2-embedder', texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'] }, {
116112
maxRetries: 5,
117113
});
118114
```
@@ -129,7 +125,7 @@ const client = new Isaacus({
129125
});
130126

131127
// Override per-request:
132-
await client.classifications.universal.create({ model: 'kanon-universal-classifier', query: 'This is a confidentiality clause.', texts: ['I agree not to tell anyone about the document.'] }, {
128+
await client.embeddings.create({ model: 'kanon-2-embedder', texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'] }, {
133129
timeout: 5 * 1000,
134130
});
135131
```
@@ -152,25 +148,23 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
152148
```ts
153149
const client = new Isaacus();
154150

155-
const response = await client.classifications.universal
151+
const response = await client.embeddings
156152
.create({
157-
model: 'kanon-universal-classifier',
158-
query: 'This is a confidentiality clause.',
159-
texts: ['I agree not to tell anyone about the document.'],
153+
model: 'kanon-2-embedder',
154+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
160155
})
161156
.asResponse();
162157
console.log(response.headers.get('X-My-Header'));
163158
console.log(response.statusText); // access the underlying Response object
164159

165-
const { data: universalClassificationResponse, response: raw } = await client.classifications.universal
160+
const { data: embeddingResponse, response: raw } = await client.embeddings
166161
.create({
167-
model: 'kanon-universal-classifier',
168-
query: 'This is a confidentiality clause.',
169-
texts: ['I agree not to tell anyone about the document.'],
162+
model: 'kanon-2-embedder',
163+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
170164
})
171165
.withResponse();
172166
console.log(raw.headers.get('X-My-Header'));
173-
console.log(universalClassificationResponse.classifications);
167+
console.log(embeddingResponse.embeddings);
174168
```
175169

176170
### Logging
@@ -250,7 +244,7 @@ parameter. This library doesn't validate at runtime that the request matches the
250244
send will be sent as-is.
251245

252246
```ts
253-
client.classifications.universal.create({
247+
client.embeddings.create({
254248
// ...
255249
// @ts-expect-error baz is not yet public
256250
baz: 'undocumented option',

0 commit comments

Comments
 (0)