@fencyai/js 0.1.12 → 0.1.15

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/README.md CHANGED
@@ -1,188 +1,11 @@
1
- # @fencyai/js
1
+ # `@fencyai/js`
2
2
 
3
- Core Fency library for browser integration - equivalent to `@stripe/stripe-js`. Load Fency instances with your publishable key.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @fencyai/js
9
- ```
3
+ > TODO: description
10
4
 
11
5
  ## Usage
12
6
 
13
- ### Basic Usage
14
-
15
- ```javascript
16
- import { loadFency } from '@fencyai/js';
17
-
18
- // Make sure to call `loadFency` outside of a component's render to avoid
19
- // recreating the Fency object on every render.
20
- const fencyPromise = loadFency('pk_test_your_publishable_key_here');
21
-
22
- // Use the promise
23
- fencyPromise.then((fency) => {
24
- console.log('Fency loaded:', fency.publishableKey);
25
- console.log('Version:', fency.version);
26
- });
27
- ```
28
-
29
- ### With Configuration Options
30
-
31
- ```javascript
32
- import { loadFency } from '@fencyai/js';
33
-
34
- const fencyPromise = loadFency('pk_test_your_key', {
35
- config: {
36
- apiVersion: '2024-01-01',
37
- endpoint: 'https://api.fency.ai'
38
- }
39
- });
40
- ```
41
-
42
- ### Error Handling
43
-
44
- ```javascript
45
- import { loadFency } from '@fencyai/js';
46
-
47
- const fencyPromise = loadFency('invalid_key')
48
- .then((fency) => {
49
- // Success
50
- })
51
- .catch((error) => {
52
- console.error('Failed to load Fency:', error.message);
53
- });
54
7
  ```
8
+ const js = require('@fencyai/js');
55
9
 
56
- ### Browser Usage
57
-
58
- ```html
59
- <!DOCTYPE html>
60
- <html>
61
- <head>
62
- <title>Fency JS Demo</title>
63
- </head>
64
- <body>
65
- <script type="module">
66
- import { loadFency } from 'https://unpkg.com/@fencyai/js@latest/dist/index.js';
67
-
68
- const fencyPromise = loadFency('pk_test_your_key');
69
- fencyPromise.then(fency => {
70
- document.body.innerHTML = `<p>Fency loaded: ${fency.version}</p>`;
71
- });
72
- </script>
73
- </body>
74
- </html>
10
+ // TODO: DEMONSTRATE API
75
11
  ```
76
-
77
- ## API Reference
78
-
79
- ### `loadFency(publishableKey, options?)`
80
-
81
- Loads the Fency library with the given publishable key.
82
-
83
- **Parameters:**
84
- - `publishableKey` (string): Your Fency publishable key (must start with `pk_`)
85
- - `options` (object, optional): Configuration options
86
- - `config.apiVersion` (string, optional): API version to use (default: `'2024-01-01'`)
87
- - `config.endpoint` (string, optional): Custom endpoint URL (default: `'https://api.fency.ai'`)
88
-
89
- **Returns:** Promise<FencyInstance>
90
-
91
- **Throws:** Error if publishable key is invalid
92
-
93
- ### `isFencyAvailable()`
94
-
95
- Check if Fency is available in the current environment.
96
-
97
- **Returns:** boolean
98
-
99
- ## Development
100
-
101
- ### Prerequisites
102
-
103
- - Node.js 16.0.0 or higher
104
- - npm
105
-
106
- ### Versioning
107
-
108
- This project follows [Semantic Versioning](https://semver.org/). See [VERSIONING.md](./VERSIONING.md) for detailed guidelines.
109
-
110
- **Quick version commands:**
111
- ```bash
112
- npm run version:patch # Bug fixes (0.1.0 → 0.1.1)
113
- npm run version:minor # New features (0.1.0 → 0.2.0)
114
- npm run version:major # Breaking changes (0.1.0 → 1.0.0)
115
- ```
116
-
117
- ### Setup
118
-
119
- 1. Clone the repository:
120
- ```bash
121
- git clone https://github.com/fencyai/fency-js.git
122
- cd fency-js
123
- ```
124
-
125
- 2. Install dependencies:
126
- ```bash
127
- npm install
128
- ```
129
-
130
- 3. Start development mode:
131
- ```bash
132
- npm run dev
133
- ```
134
-
135
- ### Build
136
-
137
- Build the project for production:
138
- ```bash
139
- npm run build
140
- ```
141
-
142
- This will:
143
- - Compile TypeScript to JavaScript
144
- - Generate type definitions
145
- - Bundle and minify the code for browser use
146
-
147
- ### Publishing
148
-
149
- Before publishing, make sure to:
150
-
151
- 1. Update the version: `npm run version:patch|minor|major`
152
- 2. Update the CHANGELOG.md with your changes
153
- 3. Build the project: `npm run build`
154
- 4. Publish to npm: `npm publish`
155
-
156
- **Quick publish commands:**
157
- ```bash
158
- npm run publish:patch # Bump patch + publish
159
- npm run publish:minor # Bump minor + publish
160
- npm run publish:major # Bump major + publish
161
- ```
162
-
163
- ## Project Structure
164
-
165
- ```
166
- fency-js/
167
- ├── src/
168
- │ └── index.ts # Main entry point with loadFency
169
- ├── dist/ # Built files (generated)
170
- ├── package.json # Package configuration
171
- ├── tsconfig.json # TypeScript configuration
172
- └── README.md # This file
173
- ```
174
-
175
- ## Features
176
-
177
- - ✅ TypeScript support with full type definitions
178
- - ✅ ESM module format for modern browsers
179
- - ✅ Tree-shakable exports
180
- - ✅ Minified production builds
181
- - ✅ Browser-compatible
182
- - ✅ Publishable key validation
183
- - ✅ Promise-based loading
184
- - ✅ npm package ready
185
-
186
- ## License
187
-
188
- MIT
@@ -1,7 +1,7 @@
1
1
  import { ChatCompletion, CreateChatCompletionRequest } from '../types.js';
2
2
  export interface CreateChatCompletionOptions {
3
3
  apiUrl?: string;
4
- request?: Partial<CreateChatCompletionRequest>;
4
+ request: CreateChatCompletionRequest;
5
5
  }
6
6
  /**
7
7
  * Creates a chat completion by making a POST request to the Fency API.
@@ -12,5 +12,7 @@ export interface CreateChatCompletionOptions {
12
12
  * @returns A promise that resolves to a ChatCompletionResponse
13
13
  * @throws Error if the request fails or the response is invalid
14
14
  */
15
- export declare function createChatCompletion(pk: string, streamId: string, options?: CreateChatCompletionOptions): Promise<ChatCompletion>;
16
- //# sourceMappingURL=createChatCompletion.d.ts.map
15
+ export declare function createChatCompletion(params: {
16
+ pk: string;
17
+ request: CreateChatCompletionRequest;
18
+ }): Promise<ChatCompletion>;
@@ -8,29 +8,15 @@ import { isChatCompletion } from '../types.js';
8
8
  * @returns A promise that resolves to a ChatCompletionResponse
9
9
  * @throws Error if the request fails or the response is invalid
10
10
  */
11
- export async function createChatCompletion(pk, streamId, options = {}) {
12
- const apiUrl = options.apiUrl || 'http://localhost:8080/v1/chat_completions';
13
- const requestBody = {
14
- ...options.request,
15
- streamId, // always override with provided streamId
16
- openai: {
17
- model: 'gpt-4o-mini',
18
- messages: [
19
- {
20
- role: 'user',
21
- content: 'Hello, how are you?',
22
- },
23
- ],
24
- ...options.request?.openai,
25
- },
26
- };
11
+ export async function createChatCompletion(params) {
12
+ const apiUrl = 'http://localhost:8080/v1/pub/chat-completions';
27
13
  const response = await fetch(apiUrl, {
28
14
  method: 'POST',
29
15
  headers: {
30
16
  'Content-Type': 'application/json',
31
- Authorization: `Bearer ${pk}`,
17
+ Authorization: `Bearer ${params.pk}`,
32
18
  },
33
- body: JSON.stringify(requestBody),
19
+ body: JSON.stringify(params.request),
34
20
  });
35
21
  if (!response.ok) {
36
22
  throw new Error(`Failed to create chat completion: ${response.status} ${response.statusText}`);
@@ -1,8 +1,4 @@
1
1
  import { ChatCompletionStream } from '../types.js';
2
- export interface CreateChatCompletionStreamOptions {
3
- apiUrl?: string;
4
- name?: string;
5
- }
6
2
  /**
7
3
  * Creates a new stream by making a POST request to the Fency API.
8
4
  *
@@ -11,5 +7,6 @@ export interface CreateChatCompletionStreamOptions {
11
7
  * @returns A promise that resolves to a ChatCompletionStream
12
8
  * @throws Error if the request fails or the response is invalid
13
9
  */
14
- export declare function createChatCompletionStream(pk: string, options?: CreateChatCompletionStreamOptions): Promise<ChatCompletionStream>;
15
- //# sourceMappingURL=createChatCompletionStream.d.ts.map
10
+ export declare function createChatCompletionStream(params: {
11
+ pk: string;
12
+ }): Promise<ChatCompletionStream>;
@@ -7,16 +7,14 @@ import { isChatCompletionStream } from '../types.js';
7
7
  * @returns A promise that resolves to a ChatCompletionStream
8
8
  * @throws Error if the request fails or the response is invalid
9
9
  */
10
- export async function createChatCompletionStream(pk, options = {}) {
11
- const apiUrl = options.apiUrl || 'http://localhost:8080/v1/chat_completion_streams';
12
- const name = options.name || pk;
10
+ export async function createChatCompletionStream(params) {
11
+ const apiUrl = 'http://localhost:8080/v1/pub/chat-completion-streams';
13
12
  const response = await fetch(apiUrl, {
14
13
  method: 'POST',
15
14
  headers: {
16
15
  'Content-Type': 'application/json',
17
- Authorization: `Bearer ${pk}`,
16
+ Authorization: `Bearer ${params.pk}`,
18
17
  },
19
- body: JSON.stringify({ name }),
20
18
  });
21
19
  if (!response.ok) {
22
20
  throw new Error(`Failed to create stream: ${response.status} ${response.statusText}`);
@@ -1,4 +1,4 @@
1
- import { FencyAvailabilityInfo } from './types.js';
1
+ import { FencyAvailabilityInfo } from './types';
2
2
  /**
3
3
  * Check if Fency is available in the current environment
4
4
  * This checks for browser compatibility and required APIs
@@ -9,4 +9,3 @@ export declare function isFencyAvailable(): boolean;
9
9
  * Returns an object with availability status and missing requirements
10
10
  */
11
11
  export declare function getFencyAvailabilityInfo(): FencyAvailabilityInfo;
12
- //# sourceMappingURL=availability.d.ts.map
@@ -1,14 +1,13 @@
1
- import { createChatCompletion } from './api/createChatCompletion.js';
2
- import { createChatCompletionStream } from './api/createChatCompletionStream.js';
3
- import { getFencyAvailabilityInfo, isFencyAvailable } from './availability.js';
4
- import { loadFency } from './loadFency.js';
5
- export type { ChatCompletion, ChatCompletionStream, FencyAvailabilityInfo, FencyInstance, FencyOptions } from './types.js';
6
- export { createChatCompletion } from './api/createChatCompletion.js';
7
- export type { CreateChatCompletionOptions } from './api/createChatCompletion.js';
8
- export { createChatCompletionStream } from './api/createChatCompletionStream.js';
9
- export type { CreateChatCompletionStreamOptions } from './api/createChatCompletionStream.js';
10
- export { getFencyAvailabilityInfo, isFencyAvailable } from './availability.js';
11
- export { loadFency } from './loadFency.js';
1
+ import { createChatCompletion } from './api/createChatCompletion';
2
+ import { createChatCompletionStream } from './api/createChatCompletionStream';
3
+ import { getFencyAvailabilityInfo, isFencyAvailable } from './availability';
4
+ import { loadFency } from './loadFency';
5
+ export type { ChatCompletion, ChatCompletionStream, FencyAvailabilityInfo, FencyInstance, FencyOptions } from './types';
6
+ export { createChatCompletion } from './api/createChatCompletion';
7
+ export type { CreateChatCompletionOptions } from './api/createChatCompletion';
8
+ export { createChatCompletionStream } from './api/createChatCompletionStream';
9
+ export { getFencyAvailabilityInfo, isFencyAvailable } from './availability';
10
+ export { loadFency } from './loadFency';
12
11
  declare const _default: {
13
12
  loadFency: typeof loadFency;
14
13
  isFencyAvailable: typeof isFencyAvailable;
@@ -17,4 +16,3 @@ declare const _default: {
17
16
  createChatCompletionStream: typeof createChatCompletionStream;
18
17
  };
19
18
  export default _default;
20
- //# sourceMappingURL=index.d.ts.map
package/lib/js.js ADDED
@@ -0,0 +1,20 @@
1
+ // Core Fency library - equivalent to @stripe/stripe-js
2
+ // This is the base library that provides the loadFency method
3
+ // Import main functions
4
+ import { createChatCompletion } from './api/createChatCompletion';
5
+ import { createChatCompletionStream } from './api/createChatCompletionStream';
6
+ import { getFencyAvailabilityInfo, isFencyAvailable } from './availability';
7
+ import { loadFency } from './loadFency';
8
+ // Re-export main functions
9
+ export { createChatCompletion } from './api/createChatCompletion';
10
+ export { createChatCompletionStream } from './api/createChatCompletionStream';
11
+ export { getFencyAvailabilityInfo, isFencyAvailable } from './availability';
12
+ export { loadFency } from './loadFency';
13
+ // Default export for convenience
14
+ export default {
15
+ loadFency,
16
+ isFencyAvailable,
17
+ getFencyAvailabilityInfo,
18
+ createChatCompletion,
19
+ createChatCompletionStream,
20
+ };
@@ -16,4 +16,3 @@ import { FencyInstance, FencyOptions } from './types.js';
16
16
  * ```
17
17
  */
18
18
  export declare function loadFency(publishableKey: string, options?: Omit<FencyOptions, 'publishableKey'>): Promise<FencyInstance>;
19
- //# sourceMappingURL=loadFency.d.ts.map
@@ -27,23 +27,26 @@ export interface FencyAvailabilityInfo {
27
27
  warnings: string[];
28
28
  }
29
29
  export interface ChatCompletionStream {
30
- id: string;
30
+ chatCompletionStreamId: string;
31
31
  }
32
32
  export declare const isChatCompletionStream: (data: any) => data is ChatCompletionStream;
33
33
  export type OpenAiModel = 'gpt-4o' | 'gpt-4o-mini' | 'gpt-3.5-turbo';
34
34
  export interface CreateChatCompletionRequest {
35
- streamId: string;
35
+ chatCompletionStreamId?: string;
36
36
  openai: {
37
37
  model: OpenAiModel;
38
+ responseJsonSchema?: string;
38
39
  messages: Array<{
39
40
  role: 'user' | 'assistant' | 'system';
40
41
  content: string;
41
42
  }>;
42
43
  };
43
44
  }
44
- export interface ChatCompletion {
45
- id: string;
45
+ export type ChatCompletion = {
46
+ chatCompletionId: string;
47
+ chatCompletionStreamId?: string;
48
+ response?: string;
49
+ responseIsStructured?: boolean;
46
50
  createdAt: string;
47
- }
51
+ };
48
52
  export declare const isChatCompletion: (data: any) => data is ChatCompletion;
49
- //# sourceMappingURL=types.d.ts.map
package/lib/types.js ADDED
@@ -0,0 +1,6 @@
1
+ export const isChatCompletionStream = (data) => {
2
+ return typeof data === 'object' && data !== null && 'chatCompletionStreamId' in data;
3
+ };
4
+ export const isChatCompletion = (data) => {
5
+ return typeof data === 'object' && data !== null && 'chatCompletionId' in data && 'createdAt' in data;
6
+ };
package/package.json CHANGED
@@ -1,62 +1,41 @@
1
1
  {
2
2
  "name": "@fencyai/js",
3
- "version": "0.1.12",
4
- "description": "Core Fency library for browser integration - load Fency instances with your publishable key",
3
+ "version": "0.1.15",
4
+ "description": "> TODO: description",
5
+ "author": "staklau <steinaageklaussen@gmail.com>",
6
+ "homepage": "",
7
+ "license": "MIT",
5
8
  "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
+ "main": "lib/js.js",
10
+ "types": "lib/js.d.ts",
9
11
  "exports": {
10
12
  ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
+ "import": "./lib/js.js",
14
+ "types": "./lib/js.d.ts"
13
15
  }
14
16
  },
17
+ "directories": {
18
+ "lib": "lib",
19
+ "test": "__tests__"
20
+ },
15
21
  "files": [
16
- "dist"
22
+ "lib"
17
23
  ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
18
27
  "scripts": {
19
- "build": "tsc && esbuild src/index.ts --bundle --format=esm --outfile=dist/index.js --minify",
28
+ "build": "tsc",
29
+ "test": "jest",
30
+ "test:watch": "jest --watch",
20
31
  "dev": "tsc --watch",
21
- "clean": "rm -rf dist",
22
- "prepublishOnly": "npm run clean && npm run build",
23
- "test": "echo \"Error: no test specified\" && exit 1",
24
- "version:patch": "npm version patch",
25
- "version:minor": "npm version minor",
26
- "version:major": "npm version major",
27
- "version:prepatch": "npm version prepatch",
28
- "version:preminor": "npm version preminor",
29
- "version:premajor": "npm version premajor",
30
- "version:prerelease": "npm version prerelease",
31
- "publish:patch": "npm run version:patch && npm publish --access public",
32
- "publish:minor": "npm run version:minor && npm publish --access public",
33
- "publish:major": "npm run version:major && npm publish --access public"
32
+ "prepublishOnly": "npm run build"
34
33
  },
35
- "keywords": [
36
- "fency",
37
- "fencyai",
38
- "browser",
39
- "typescript",
40
- "esm",
41
- "loadfency",
42
- "publishable-key"
43
- ],
44
- "author": "",
45
- "license": "MIT",
46
34
  "devDependencies": {
47
- "@types/node": "^20.10.0",
48
- "esbuild": "^0.19.0",
49
- "typescript": "^5.3.0"
50
- },
51
- "engines": {
52
- "node": ">=16.0.0"
53
- },
54
- "repository": {
55
- "type": "git",
56
- "url": "git+https://github.com/fencyai/fency-js.git"
57
- },
58
- "bugs": {
59
- "url": "https://github.com/fencyai/fency-js/issues"
60
- },
61
- "homepage": "https://github.com/fencyai/fency-js#readme"
35
+ "@types/jest": "^29.5.11",
36
+ "@types/node": "^20.10.5",
37
+ "jest": "^29.7.0",
38
+ "ts-jest": "^29.1.1",
39
+ "typescript": "^5.3.3"
40
+ }
62
41
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"createChatCompletion.d.ts","sourceRoot":"","sources":["../../src/api/createChatCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAoB,MAAM,aAAa,CAAC;AAE5F,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,cAAc,CAAC,CAmCzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createChatCompletionStream.d.ts","sourceRoot":"","sources":["../../src/api/createChatCompletionStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,aAAa,CAAC;AAE3E,MAAM,WAAW,iCAAiC;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,oBAAoB,CAAC,CAsB/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../src/availability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAgC1C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,qBAAqB,CAwChE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG3H,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,YAAY,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EACL,wBAAwB,EAAE,gBAAgB,EAC3C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;;;;;;;;AAG3C,wBAME"}
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- var f=t=>typeof t=="object"&&t!==null&&"id"in t,C=t=>typeof t=="object"&&t!==null&&"id"in t;async function a(t,o,e={}){let n=e.apiUrl||"http://localhost:8080/v1/chat_completions",i={...e.request,streamId:o,openai:{model:"gpt-4o-mini",messages:[{role:"user",content:"Hello, how are you?"}],...e.request?.openai}},r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(i)});if(!r.ok)throw new Error(`Failed to create chat completion: ${r.status} ${r.statusText}`);let m=await r.json();if(!C(m))throw new Error("Invalid chat completion response");return m}async function s(t,o={}){let e=o.apiUrl||"http://localhost:8080/v1/chat_completion_streams",n=o.name||t,i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({name:n})});if(!i.ok)throw new Error(`Failed to create stream: ${i.status} ${i.statusText}`);let r=await i.json();if(!f(r))throw new Error("Invalid stream response");return r}function p(){if(typeof window>"u")return!1;let t=["fetch","Promise","JSON"];for(let o of t)if(typeof window[o]>"u")return!1;if(typeof window.location<"u"){let o=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",e=window.location.protocol==="https:";!o&&!e&&console.warn("Fency: For security, we recommend using HTTPS in production.")}return!0}function l(){let t={available:!0,missing:[],warnings:[]};if(typeof window>"u")return t.available=!1,t.missing.push("Browser environment"),t;let o=["fetch","Promise","JSON"];for(let e of o)typeof window[e]>"u"&&(t.available=!1,t.missing.push(`${e} API`));if(typeof window.location<"u"){let e=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",n=window.location.protocol==="https:";!e&&!n&&t.warnings.push("HTTPS is recommended for production use")}return t}function c(t,o={}){return new Promise((e,n)=>{if(!t||typeof t!="string"){n(new Error("Fency: A valid publishable key is required."));return}if(!t.startsWith("pk_")){n(new Error('Fency: Invalid publishable key format. Keys should start with "pk_".'));return}let i={publishableKey:t,endpoint:o.endpoint||"https://api.fency.ai"};setTimeout(()=>{e(i)},0)})}var P={loadFency:c,isFencyAvailable:p,getFencyAvailabilityInfo:l,createChatCompletion:a,createChatCompletionStream:s};export{a as createChatCompletion,s as createChatCompletionStream,P as default,l as getFencyAvailabilityInfo,p as isFencyAvailable,c as loadFency};
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadFency.d.ts","sourceRoot":"","sources":["../src/loadFency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CACvB,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAM,GACjD,OAAO,CAAC,aAAa,CAAC,CAwBxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,SAAS,EAAE,OAAO,CAAC;IACnB,mCAAmC;IACnC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,eAAO,MAAM,sBAAsB,GAAI,MAAM,GAAG,KAAG,IAAI,IAAI,oBAE1D,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAA;AAEpE,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QACN,KAAK,EAAE,WAAW,CAAC;QACnB,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;YACtC,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC,CAAC;KACJ,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,GAAG,KAAG,IAAI,IAAI,cAEpD,CAAA"}
package/dist/types.js DELETED
@@ -1,6 +0,0 @@
1
- export const isChatCompletionStream = (data) => {
2
- return typeof data === 'object' && data !== null && 'id' in data;
3
- };
4
- export const isChatCompletion = (data) => {
5
- return typeof data === 'object' && data !== null && 'id' in data;
6
- };
File without changes
File without changes