diff --git a/build/index.d.ts b/build/index.d.ts index 4393605..3db6882 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -1,3 +1,4 @@ +export * from './src/ai/stream'; export * from './src/auth/tokensPair'; export * from './src/base/businessOperation/businessOperation'; export * from './src/billing/planProlongrationPayload'; diff --git a/build/index.js b/build/index.js index 6f4a9ec..2fd6f5f 100644 --- a/build/index.js +++ b/build/index.js @@ -14,6 +14,7 @@ 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 }); +__exportStar(require("./src/ai/stream"), exports); __exportStar(require("./src/auth/tokensPair"), exports); __exportStar(require("./src/base/businessOperation/businessOperation"), exports); __exportStar(require("./src/billing/planProlongrationPayload"), exports); diff --git a/build/src/ai/stream.d.ts b/build/src/ai/stream.d.ts new file mode 100644 index 0000000..56e9ce4 --- /dev/null +++ b/build/src/ai/stream.d.ts @@ -0,0 +1,34 @@ +/** + * Stream part that carries generated text. + */ +export type AiStreamTextDeltaPart = { + /** + * Discriminant of a text-carrying part. + */ + type: 'text-delta'; + /** + * Text generated for this part. + */ + delta: string; +}; +/** + * Stream part that carries a generation failure. + */ +export type AiStreamErrorPart = { + /** + * Discriminant of a failure-carrying part. + */ + type: 'error'; + /** + * Description of the failure. + */ + errorText: string; +}; +/** + * Discriminated union of parts an AI stream consists of. + */ +export type AiStreamPart = AiStreamTextDeltaPart | AiStreamErrorPart; +/** + * Asynchronous sequence of parts forming an AI-generated answer. + */ +export type AiStream = AsyncIterable; diff --git a/build/src/ai/stream.js b/build/src/ai/stream.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/build/src/ai/stream.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/index.ts b/index.ts index 51425e7..265da3f 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,5 @@ +export * from './src/ai/stream'; + export * from './src/auth/tokensPair'; export * from './src/base/businessOperation/businessOperation'; diff --git a/package.json b/package.json index 122ff8d..14b645b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hawk.so/types", - "version": "0.6.5", + "version": "0.7.0", "description": "TypeScript definitions for Hawk", "types": "build/index.d.ts", "main": "build/index.js", diff --git a/src/ai/stream.ts b/src/ai/stream.ts new file mode 100644 index 0000000..c3291a6 --- /dev/null +++ b/src/ai/stream.ts @@ -0,0 +1,39 @@ +/** + * Stream part that carries generated text. + */ +export type AiStreamTextDeltaPart = { + /** + * Discriminant of a text-carrying part. + */ + type: 'text-delta'; + + /** + * Text generated for this part. + */ + delta: string; +}; + +/** + * Stream part that carries a generation failure. + */ +export type AiStreamErrorPart = { + /** + * Discriminant of a failure-carrying part. + */ + type: 'error'; + + /** + * Description of the failure. + */ + errorText: string; +}; + +/** + * Discriminated union of parts an AI stream consists of. + */ +export type AiStreamPart = AiStreamTextDeltaPart | AiStreamErrorPart; + +/** + * Asynchronous sequence of parts forming an AI-generated answer. + */ +export type AiStream = AsyncIterable; diff --git a/tsconfig.json b/tsconfig.json index 872f225..554c351 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ - "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ + "target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', 'ES2022', 'ES2023', 'ES2024', or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */