@oxy.so/contracts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +10 -4
- package/dist/cjs/inference/embeddings.js +19 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/inference/embeddings.js +16 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/inference/catalogue.d.ts +24 -24
- package/dist/types/inference/embeddings.d.ts +455 -0
- package/dist/types/inference/modelDocumentation.d.ts +20 -20
- package/dist/types/inference/request.d.ts +4 -4
- package/dist/types/inference/streamEvents.d.ts +4 -4
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -126,6 +126,7 @@ INFERENCE_SCOPES, inferenceScopeSchema, billingPrincipalSchema, authenticatedPri
|
|
|
126
126
|
export {
|
|
127
127
|
// Closed error vocabulary + retryability + a leak-proof provider passthrough.
|
|
128
128
|
INFERENCE_ERROR_CODES, NON_RETRYABLE_INFERENCE_ERROR_CODES, inferenceErrorCodeSchema, upstreamErrorCategorySchema, safeErrorTextSchema, providerErrorPassthroughSchema, inferenceErrorSchema, } from './inference/errors.js';
|
|
129
|
+
export { embeddingVectorSchema, embeddingUsageSchema, embeddingSuccessSchema, embeddingFailureSchema, embeddingResponseSchema, } from './inference/embeddings.js';
|
|
129
130
|
export {
|
|
130
131
|
// Price versions and the snapshot a settled receipt keeps.
|
|
131
132
|
priceVersionStatusSchema, priceVersionSchema, priceSnapshotSchema, } from './inference/priceVersion.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { inferenceErrorSchema } from './errors.js';
|
|
3
|
+
export const embeddingVectorSchema = z.object({ index: z.number().int().nonnegative(), embedding: z.array(z.number().finite()).min(1).max(1024) }).strict();
|
|
4
|
+
export const embeddingUsageSchema = z.object({ inputTokens: z.number().int().nonnegative(), totalTokens: z.number().int().nonnegative() }).strict().refine((usage) => usage.totalTokens >= usage.inputTokens, { message: 'totalTokens must be greater than or equal to inputTokens', path: ['totalTokens'] });
|
|
5
|
+
export const embeddingSuccessSchema = z.object({ schemaVersion: z.literal(1), requestId: z.string().min(1).max(128), model: z.string().min(1).max(255), dimension: z.number().int().positive().max(1024), data: z.array(embeddingVectorSchema).min(1).max(2048), usage: embeddingUsageSchema }).strict().superRefine((result, context) => {
|
|
6
|
+
const indexes = new Set();
|
|
7
|
+
for (const [position, vector] of result.data.entries()) {
|
|
8
|
+
if (vector.embedding.length !== result.dimension)
|
|
9
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['data', position, 'embedding'], message: 'embedding length must equal dimension' });
|
|
10
|
+
if (indexes.has(vector.index))
|
|
11
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['data', position, 'index'], message: 'embedding indexes must be unique' });
|
|
12
|
+
indexes.add(vector.index);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export const embeddingFailureSchema = z.object({ schemaVersion: z.literal(1), requestId: z.string().min(1).max(128), error: inferenceErrorSchema }).strict();
|
|
16
|
+
export const embeddingResponseSchema = z.union([embeddingSuccessSchema, embeddingFailureSchema]);
|