@fencyai/js 0.1.42 → 0.1.44
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/lib/api/createChatCompletion.d.ts +0 -4
- package/lib/api/createChatCompletion.js +15 -31
- package/lib/api/createStream.d.ts +14 -0
- package/lib/api/createStream.js +53 -0
- package/lib/api/createUpload.d.ts +16 -0
- package/lib/api/createUpload.js +53 -0
- package/lib/api/createWebsite.d.ts +16 -0
- package/lib/api/createWebsite.js +39 -0
- package/lib/index.d.ts +17 -5
- package/lib/index.js +10 -4
- package/lib/openapi/core/ApiError.d.ts +10 -0
- package/lib/openapi/core/ApiError.js +11 -0
- package/lib/openapi/core/ApiRequestOptions.d.ts +13 -0
- package/lib/openapi/core/ApiRequestOptions.js +1 -0
- package/lib/openapi/core/ApiResult.d.ts +7 -0
- package/lib/openapi/core/ApiResult.js +1 -0
- package/lib/openapi/core/CancelablePromise.d.ts +20 -0
- package/lib/openapi/core/CancelablePromise.js +111 -0
- package/lib/openapi/core/OpenAPI.d.ts +16 -0
- package/lib/openapi/core/OpenAPI.js +11 -0
- package/lib/openapi/core/request.d.ts +30 -0
- package/lib/openapi/core/request.js +275 -0
- package/lib/openapi/index.d.ts +31 -0
- package/lib/openapi/index.js +11 -0
- package/lib/openapi/models/ApiDtoType.d.ts +6 -0
- package/lib/openapi/models/ApiDtoType.js +11 -0
- package/lib/openapi/models/ChatCompletionDto.d.ts +10 -0
- package/lib/openapi/models/ChatCompletionDto.js +1 -0
- package/lib/openapi/models/ChatCompletionStreamCompletedEventDto.d.ts +9 -0
- package/lib/openapi/models/ChatCompletionStreamCompletedEventDto.js +1 -0
- package/lib/openapi/models/CreateAnthropicChatCompletionDto.d.ts +8 -0
- package/lib/openapi/models/CreateAnthropicChatCompletionDto.js +1 -0
- package/lib/openapi/models/CreateChatCompletionRequest.d.ts +10 -0
- package/lib/openapi/models/CreateChatCompletionRequest.js +1 -0
- package/lib/openapi/models/CreateChatCompletionStreamRequest.d.ts +3 -0
- package/lib/openapi/models/CreateChatCompletionStreamRequest.js +1 -0
- package/lib/openapi/models/CreateGeminiChatCompletionDto.d.ts +8 -0
- package/lib/openapi/models/CreateGeminiChatCompletionDto.js +1 -0
- package/lib/openapi/models/CreateOpenAiChatCompletionDto.d.ts +8 -0
- package/lib/openapi/models/CreateOpenAiChatCompletionDto.js +1 -0
- package/lib/openapi/models/CreateOpenAiChatCompletionMessageDto.d.ts +4 -0
- package/lib/openapi/models/CreateOpenAiChatCompletionMessageDto.js +1 -0
- package/lib/openapi/models/CreateStreamRequest.d.ts +6 -0
- package/lib/openapi/models/CreateStreamRequest.js +1 -0
- package/lib/openapi/models/CreateWebsiteRequest.d.ts +3 -0
- package/lib/openapi/models/CreateWebsiteRequest.js +1 -0
- package/lib/openapi/models/FileUploadCompletedEventDto.d.ts +11 -0
- package/lib/openapi/models/FileUploadCompletedEventDto.js +1 -0
- package/lib/openapi/models/NewChatCompletionStreamChunkEventDto.d.ts +10 -0
- package/lib/openapi/models/NewChatCompletionStreamChunkEventDto.js +1 -0
- package/lib/openapi/models/PubCreateUploadRequest.d.ts +6 -0
- package/lib/openapi/models/PubCreateUploadRequest.js +1 -0
- package/lib/openapi/models/PubUploadDto.d.ts +6 -0
- package/lib/openapi/models/PubUploadDto.js +1 -0
- package/lib/openapi/models/PubWebsiteDto.d.ts +5 -0
- package/lib/openapi/models/PubWebsiteDto.js +1 -0
- package/lib/openapi/models/S3PostRequestDto.d.ts +10 -0
- package/lib/openapi/models/S3PostRequestDto.js +1 -0
- package/lib/openapi/models/StoredChatCompletionId.d.ts +3 -0
- package/lib/openapi/models/StoredChatCompletionId.js +1 -0
- package/lib/openapi/models/StoredFileId.d.ts +3 -0
- package/lib/openapi/models/StoredFileId.js +1 -0
- package/lib/openapi/models/StoredStreamId.d.ts +3 -0
- package/lib/openapi/models/StoredStreamId.js +1 -0
- package/lib/openapi/models/StoredUploadId.d.ts +3 -0
- package/lib/openapi/models/StoredUploadId.js +1 -0
- package/lib/openapi/models/StreamDto.d.ts +6 -0
- package/lib/openapi/models/StreamDto.js +1 -0
- package/lib/openapi/models/StreamEventType.d.ts +7 -0
- package/lib/openapi/models/StreamEventType.js +12 -0
- package/lib/openapi/models/StreamNotFoundEventDto.d.ts +7 -0
- package/lib/openapi/models/StreamNotFoundEventDto.js +1 -0
- package/lib/openapi/models/StreamTimeoutEventDto.d.ts +7 -0
- package/lib/openapi/models/StreamTimeoutEventDto.js +1 -0
- package/lib/openapi/models/StreamType.d.ts +4 -0
- package/lib/openapi/models/StreamType.js +9 -0
- package/lib/openapi/services/PubService.d.ts +50 -0
- package/lib/openapi/services/PubService.js +71 -0
- package/lib/types/CreateStreamRequest.d.ts +6 -0
- package/lib/types/CreateStreamRequest.js +1 -0
- package/lib/types/CreateStreamResponse.d.ts +9 -0
- package/lib/types/CreateStreamResponse.js +1 -0
- package/lib/types/CreateUploadRequest.d.ts +6 -0
- package/lib/types/CreateUploadRequest.js +1 -0
- package/lib/types/CreateUploadResponse.d.ts +9 -0
- package/lib/types/CreateUploadResponse.js +1 -0
- package/lib/types/CreateWebsiteRequest.d.ts +3 -0
- package/lib/types/CreateWebsiteRequest.js +1 -0
- package/lib/types/CreateWebsiteResponse.d.ts +9 -0
- package/lib/types/CreateWebsiteResponse.js +1 -0
- package/lib/types/FencyFile.d.ts +8 -0
- package/lib/types/FencyFile.js +1 -0
- package/lib/types/FencyUpload.d.ts +6 -0
- package/lib/types/FencyUpload.js +1 -0
- package/lib/types/FencyWebsite.d.ts +5 -0
- package/lib/types/FencyWebsite.js +1 -0
- package/lib/types/S3PostRequest.d.ts +10 -0
- package/lib/types/S3PostRequest.js +1 -0
- package/lib/types/Stream.d.ts +5 -0
- package/lib/types/{ChatCompletionStream.js → Stream.js} +2 -2
- package/lib/types/StreamData.d.ts +31 -0
- package/lib/types/StreamData.js +1 -0
- package/lib/utils/version.js +1 -1
- package/package.json +5 -3
- package/lib/api/createChatCompletionStream.d.ts +0 -21
- package/lib/api/createChatCompletionStream.js +0 -46
- package/lib/types/ChatCompletionStream.d.ts +0 -5
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ChatCompletionDto } from '../models/ChatCompletionDto';
|
|
2
|
+
import type { ChatCompletionStreamCompletedEventDto } from '../models/ChatCompletionStreamCompletedEventDto';
|
|
3
|
+
import type { CreateChatCompletionRequest } from '../models/CreateChatCompletionRequest';
|
|
4
|
+
import type { CreateStreamRequest } from '../models/CreateStreamRequest';
|
|
5
|
+
import type { CreateWebsiteRequest } from '../models/CreateWebsiteRequest';
|
|
6
|
+
import type { FileUploadCompletedEventDto } from '../models/FileUploadCompletedEventDto';
|
|
7
|
+
import type { NewChatCompletionStreamChunkEventDto } from '../models/NewChatCompletionStreamChunkEventDto';
|
|
8
|
+
import type { PubCreateUploadRequest } from '../models/PubCreateUploadRequest';
|
|
9
|
+
import type { PubUploadDto } from '../models/PubUploadDto';
|
|
10
|
+
import type { PubWebsiteDto } from '../models/PubWebsiteDto';
|
|
11
|
+
import type { StreamDto } from '../models/StreamDto';
|
|
12
|
+
import type { StreamNotFoundEventDto } from '../models/StreamNotFoundEventDto';
|
|
13
|
+
import type { StreamTimeoutEventDto } from '../models/StreamTimeoutEventDto';
|
|
14
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
15
|
+
export declare class PubService {
|
|
16
|
+
/**
|
|
17
|
+
* Create Chat Completion
|
|
18
|
+
* @param requestBody
|
|
19
|
+
* @returns any OK
|
|
20
|
+
* @throws ApiError
|
|
21
|
+
*/
|
|
22
|
+
static createChatCompletion(requestBody: CreateChatCompletionRequest): CancelablePromise<ChatCompletionDto>;
|
|
23
|
+
/**
|
|
24
|
+
* Create Chat Completion Stream
|
|
25
|
+
* @param requestBody
|
|
26
|
+
* @returns StreamDto Created
|
|
27
|
+
* @throws ApiError
|
|
28
|
+
*/
|
|
29
|
+
static createStream(requestBody: CreateStreamRequest): CancelablePromise<StreamDto>;
|
|
30
|
+
/**
|
|
31
|
+
* Get pub types
|
|
32
|
+
* @returns any OK
|
|
33
|
+
* @throws ApiError
|
|
34
|
+
*/
|
|
35
|
+
static getPubTypes(): CancelablePromise<(StreamTimeoutEventDto | StreamNotFoundEventDto | NewChatCompletionStreamChunkEventDto | ChatCompletionStreamCompletedEventDto | FileUploadCompletedEventDto)>;
|
|
36
|
+
/**
|
|
37
|
+
* Create Upload
|
|
38
|
+
* @param requestBody
|
|
39
|
+
* @returns PubUploadDto Created
|
|
40
|
+
* @throws ApiError
|
|
41
|
+
*/
|
|
42
|
+
static createUpload(requestBody: PubCreateUploadRequest): CancelablePromise<PubUploadDto>;
|
|
43
|
+
/**
|
|
44
|
+
* Create Website
|
|
45
|
+
* @param requestBody
|
|
46
|
+
* @returns PubWebsiteDto Created
|
|
47
|
+
* @throws ApiError
|
|
48
|
+
*/
|
|
49
|
+
static createWebsite(requestBody: CreateWebsiteRequest): CancelablePromise<PubWebsiteDto>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { OpenAPI } from '../core/OpenAPI';
|
|
2
|
+
import { request as __request } from '../core/request';
|
|
3
|
+
export class PubService {
|
|
4
|
+
/**
|
|
5
|
+
* Create Chat Completion
|
|
6
|
+
* @param requestBody
|
|
7
|
+
* @returns any OK
|
|
8
|
+
* @throws ApiError
|
|
9
|
+
*/
|
|
10
|
+
static createChatCompletion(requestBody) {
|
|
11
|
+
return __request(OpenAPI, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
url: '/v1/pub/chat-completions',
|
|
14
|
+
body: requestBody,
|
|
15
|
+
mediaType: 'application/json',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create Chat Completion Stream
|
|
20
|
+
* @param requestBody
|
|
21
|
+
* @returns StreamDto Created
|
|
22
|
+
* @throws ApiError
|
|
23
|
+
*/
|
|
24
|
+
static createStream(requestBody) {
|
|
25
|
+
return __request(OpenAPI, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
url: '/v1/pub/streams',
|
|
28
|
+
body: requestBody,
|
|
29
|
+
mediaType: 'application/json',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get pub types
|
|
34
|
+
* @returns any OK
|
|
35
|
+
* @throws ApiError
|
|
36
|
+
*/
|
|
37
|
+
static getPubTypes() {
|
|
38
|
+
return __request(OpenAPI, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
url: '/v1/pub/types',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create Upload
|
|
45
|
+
* @param requestBody
|
|
46
|
+
* @returns PubUploadDto Created
|
|
47
|
+
* @throws ApiError
|
|
48
|
+
*/
|
|
49
|
+
static createUpload(requestBody) {
|
|
50
|
+
return __request(OpenAPI, {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
url: '/v1/pub/uploads',
|
|
53
|
+
body: requestBody,
|
|
54
|
+
mediaType: 'application/json',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create Website
|
|
59
|
+
* @param requestBody
|
|
60
|
+
* @returns PubWebsiteDto Created
|
|
61
|
+
* @throws ApiError
|
|
62
|
+
*/
|
|
63
|
+
static createWebsite(requestBody) {
|
|
64
|
+
return __request(OpenAPI, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
url: '/v1/pub/websites',
|
|
67
|
+
body: requestBody,
|
|
68
|
+
mediaType: 'application/json',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type NewChatCompletionStreamChunk = {
|
|
2
|
+
type: 'NewChatCompletionStreamChunk';
|
|
3
|
+
streamId: string;
|
|
4
|
+
chatCompletionId: string;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
content: string;
|
|
7
|
+
};
|
|
8
|
+
export type ChatCompletionStreamCompleted = {
|
|
9
|
+
type: 'ChatCompletionStreamCompleted';
|
|
10
|
+
streamId: string;
|
|
11
|
+
chatCompletionId: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
};
|
|
14
|
+
export type StreamTimeout = {
|
|
15
|
+
type: 'StreamTimeout';
|
|
16
|
+
streamId: string;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
};
|
|
19
|
+
export type StreamNotFound = {
|
|
20
|
+
type: 'StreamNotFound';
|
|
21
|
+
streamId: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
};
|
|
24
|
+
export type FileUploadCompleted = {
|
|
25
|
+
type: 'FileUploadCompleted';
|
|
26
|
+
streamId: string;
|
|
27
|
+
uploadId: string;
|
|
28
|
+
fileId: string;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
};
|
|
31
|
+
export type StreamData = NewChatCompletionStreamChunk | ChatCompletionStreamCompleted | StreamTimeout | StreamNotFound | FileUploadCompleted;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/utils/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Browser-compatible version utility
|
|
2
2
|
// The version is set at build time and can be overridden if needed
|
|
3
3
|
// Build-time version constant - this should be updated during the build process
|
|
4
|
-
const SDK_VERSION = '0.1.
|
|
4
|
+
const SDK_VERSION = '0.1.44';
|
|
5
5
|
// Allow runtime override if needed
|
|
6
6
|
let versionOverride = null;
|
|
7
7
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "staklau <steinaageklaussen@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -30,14 +30,16 @@
|
|
|
30
30
|
"test": "jest",
|
|
31
31
|
"test:watch": "jest --watch",
|
|
32
32
|
"dev": "tsc --watch",
|
|
33
|
-
"prepublishOnly": "npm run build"
|
|
33
|
+
"prepublishOnly": "npm run build",
|
|
34
|
+
"codegen": "openapi --input http://localhost:8080/v1/pub/swagger.json --output ./src/openapi"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/jest": "^29.5.11",
|
|
37
38
|
"@types/node": "^20.10.5",
|
|
38
39
|
"jest": "^29.7.0",
|
|
40
|
+
"openapi-typescript-codegen": "^0.29.0",
|
|
39
41
|
"ts-jest": "^29.1.1",
|
|
40
42
|
"typescript": "^5.3.3"
|
|
41
43
|
},
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "307425eea348ef9758f06b91467a9e8ad5dad453"
|
|
43
45
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ApiError } from '../types/ApiError';
|
|
2
|
-
import { ChatCompletionStream } from '../types/ChatCompletionStream';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new stream by making a POST request to the Fency API.
|
|
5
|
-
*
|
|
6
|
-
* @param pk - The publishable key (used as Bearer token and default name)
|
|
7
|
-
* @param options - Optional configuration (apiUrl, name)
|
|
8
|
-
* @returns A promise that resolves to a ChatCompletionStream
|
|
9
|
-
* @throws Error if the request fails or the response is invalid
|
|
10
|
-
*/
|
|
11
|
-
export type CreateChatCompletionStreamResponse = {
|
|
12
|
-
type: 'success';
|
|
13
|
-
stream: ChatCompletionStream;
|
|
14
|
-
} | {
|
|
15
|
-
type: 'error';
|
|
16
|
-
error: ApiError;
|
|
17
|
-
};
|
|
18
|
-
export declare function createChatCompletionStream(params: {
|
|
19
|
-
pk: string;
|
|
20
|
-
baseUrl: string;
|
|
21
|
-
}): Promise<CreateChatCompletionStreamResponse>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { isChatCompletionStream, } from '../types/ChatCompletionStream';
|
|
2
|
-
import { parseNonOkResponse } from '../utils/parseNonOkResponse';
|
|
3
|
-
import { getPackageVersion } from '../utils/version';
|
|
4
|
-
export async function createChatCompletionStream(params) {
|
|
5
|
-
const apiUrl = `${params.baseUrl}/v1/pub/chat-completion-streams`;
|
|
6
|
-
try {
|
|
7
|
-
const response = await fetch(apiUrl, {
|
|
8
|
-
method: 'POST',
|
|
9
|
-
headers: {
|
|
10
|
-
'Content-Type': 'application/json',
|
|
11
|
-
Authorization: `Bearer ${params.pk}`,
|
|
12
|
-
'X-Fency-Sdk-Version': getPackageVersion(),
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
const error = await parseNonOkResponse(response);
|
|
17
|
-
return {
|
|
18
|
-
type: 'error',
|
|
19
|
-
error: error,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const stream = await response.json();
|
|
23
|
-
if (!isChatCompletionStream(stream)) {
|
|
24
|
-
return {
|
|
25
|
-
type: 'error',
|
|
26
|
-
error: {
|
|
27
|
-
code: 'InvalidResponse',
|
|
28
|
-
message: `Invalid stream response: ${JSON.stringify(stream)}`,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
type: 'success',
|
|
34
|
-
stream: stream,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
return {
|
|
39
|
-
type: 'error',
|
|
40
|
-
error: {
|
|
41
|
-
code: 'UnknownError',
|
|
42
|
-
message: `Unknown error!\n${error ? `Error: ${error}\n` : ''}`.trim(),
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|