@fencyai/react 0.1.46 → 0.1.47
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/hooks/useBasicChatCompletions/index.d.ts +2 -0
- package/lib/{useChatCompletions/useSynchronousChatCompletions.js → hooks/useBasicChatCompletions/index.js} +5 -3
- package/lib/hooks/useFiles/index.d.ts +3 -0
- package/lib/{useFileUploads → hooks/useFiles}/index.js +2 -2
- package/lib/hooks/useStream/index.d.ts +3 -0
- package/lib/{useStream → hooks/useStream}/index.js +1 -1
- package/lib/hooks/useStreamingChatCompletions/index.d.ts +2 -0
- package/lib/{useChatCompletions/useStreamingChatCompletions.js → hooks/useStreamingChatCompletions/index.js} +4 -3
- package/lib/hooks/useStructuredChatCompletions/index.d.ts +2 -0
- package/lib/{useChatCompletions/useStructuredChatCompletions.js → hooks/useStructuredChatCompletions/index.js} +3 -1
- package/lib/hooks/useWebsites/index.d.ts +2 -0
- package/lib/{useWebsites → hooks/useWebsites}/index.js +1 -1
- package/lib/index.d.ts +5 -3
- package/lib/index.js +5 -3
- package/lib/types/BasicChatCompletion.d.ts +8 -0
- package/lib/types/{SynchronousChatCompletionData.d.ts → BasicChatCompletionData.d.ts} +1 -1
- package/lib/types/BasicChatCompletionResponse.d.ts +9 -0
- package/lib/types/{CreateSynchronousChatCompletionParams.d.ts → CreateBasicChatCompletionParams.d.ts} +1 -1
- package/lib/types/CreateStreamingChatCompletionResponse.d.ts +9 -0
- package/lib/types/UseBasicChatCompletions.d.ts +7 -0
- package/lib/types/UseStreamingChatCompletions.d.ts +7 -0
- package/lib/types/UseStreamingChatCompletions.js +1 -0
- package/lib/types/UseStructuredChatCompletions.d.ts +8 -0
- package/lib/types/UseStructuredChatCompletions.js +1 -0
- package/lib/types/index.d.ts +4 -6
- package/lib/types/index.js +5 -8
- package/package.json +4 -4
- package/lib/types/CombinedChatCompletion.d.ts +0 -14
- package/lib/types/SynchronousChatCompletion.d.ts +0 -8
- package/lib/types/SynchronousChatCompletionResponse.d.ts +0 -9
- package/lib/types/UseChatCompletions.d.ts +0 -30
- package/lib/useChatCompletions/index.d.ts +0 -2
- package/lib/useChatCompletions/index.js +0 -66
- package/lib/useChatCompletions/useStreamingChatCompletions.d.ts +0 -16
- package/lib/useChatCompletions/useStructuredChatCompletions.d.ts +0 -9
- package/lib/useChatCompletions/useSynchronousChatCompletions.d.ts +0 -8
- package/lib/useFileUploads/index.d.ts +0 -3
- package/lib/useStream/index.d.ts +0 -3
- package/lib/useWebsites/index.d.ts +0 -2
- /package/lib/{useEventSource.d.ts → hooks/useEventSource/index.d.ts} +0 -0
- /package/lib/{useEventSource.js → hooks/useEventSource/index.js} +0 -0
- /package/lib/types/{CombinedChatCompletion.js → BasicChatCompletion.js} +0 -0
- /package/lib/types/{CreateSynchronousChatCompletionParams.js → BasicChatCompletionData.js} +0 -0
- /package/lib/types/{SynchronousChatCompletion.js → BasicChatCompletionResponse.js} +0 -0
- /package/lib/types/{SynchronousChatCompletionData.js → CreateBasicChatCompletionParams.js} +0 -0
- /package/lib/types/{SynchronousChatCompletionResponse.js → CreateStreamingChatCompletionResponse.js} +0 -0
- /package/lib/types/{UseChatCompletions.js → UseBasicChatCompletions.js} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createChatCompletion } from '@fencyai/js';
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
|
-
|
|
3
|
+
import { useFencyContext } from '../../provider/useFencyContext';
|
|
4
|
+
export const useBasicChatCompletions = () => {
|
|
5
|
+
const context = useFencyContext();
|
|
4
6
|
const [chatCompletions, setChatCompletions] = useState([]);
|
|
5
|
-
const
|
|
7
|
+
const createBasicChatCompletion = useCallback(async (params) => {
|
|
6
8
|
const triggeredAt = new Date().toISOString();
|
|
7
9
|
setChatCompletions((prev) => [
|
|
8
10
|
...prev,
|
|
@@ -101,6 +103,6 @@ export const useSynchronousChatCompletions = (context) => {
|
|
|
101
103
|
}, [context]);
|
|
102
104
|
return {
|
|
103
105
|
chatCompletions,
|
|
104
|
-
|
|
106
|
+
createBasicChatCompletion,
|
|
105
107
|
};
|
|
106
108
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createUpload } from '@fencyai/js';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import { useFencyContext } from '
|
|
3
|
+
import { useFencyContext } from '../../provider/useFencyContext';
|
|
4
4
|
import { useStream } from '../useStream';
|
|
5
|
-
export function
|
|
5
|
+
export function useFiles(props) {
|
|
6
6
|
const [fileUploads, setFileUploads] = useState([]);
|
|
7
7
|
const context = useFencyContext();
|
|
8
8
|
const { createStream } = useStream({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStream as createStreamApi, } from '@fencyai/js';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import { useFencyContext } from '
|
|
3
|
+
import { useFencyContext } from '../../provider/useFencyContext';
|
|
4
4
|
import { useEventSource } from '../useEventSource';
|
|
5
5
|
export const useStream = (props) => {
|
|
6
6
|
const context = useFencyContext();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { createChatCompletion
|
|
1
|
+
import { createChatCompletion } from '@fencyai/js';
|
|
2
2
|
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { useStream } from '../useStream';
|
|
4
|
-
|
|
4
|
+
import { useFencyContext } from '../../provider/useFencyContext';
|
|
5
|
+
export const useStreamingChatCompletions = () => {
|
|
6
|
+
const context = useFencyContext();
|
|
5
7
|
const [chatCompletions, setChatCompletions] = useState([]);
|
|
6
8
|
const [completedStreamIds, setCompletedStreamIds] = useState([]);
|
|
7
9
|
const [chunks, setChunks] = useState([]);
|
|
@@ -190,6 +192,5 @@ export const useStreamingChatCompletions = (context) => {
|
|
|
190
192
|
return {
|
|
191
193
|
chatCompletions,
|
|
192
194
|
createStreamingChatCompletion,
|
|
193
|
-
stream,
|
|
194
195
|
};
|
|
195
196
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createChatCompletion } from '@fencyai/js';
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
|
|
4
|
+
import { useFencyContext } from '../../provider/useFencyContext';
|
|
5
|
+
export const useStructuredChatCompletions = () => {
|
|
6
|
+
const context = useFencyContext();
|
|
5
7
|
const [chatCompletions, setChatCompletions] = useState([]);
|
|
6
8
|
const createStructuredChatCompletion = useCallback(async (params) => {
|
|
7
9
|
const triggeredAt = new Date().toISOString();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createWebsite } from '@fencyai/js';
|
|
2
|
-
import { useFencyContext } from '
|
|
2
|
+
import { useFencyContext } from '../../provider/useFencyContext';
|
|
3
3
|
export function useWebsites() {
|
|
4
4
|
const context = useFencyContext();
|
|
5
5
|
const scrapeContent = async (params) => {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { useBasicChatCompletions } from './hooks/useBasicChatCompletions';
|
|
2
|
+
export { useFiles } from './hooks/useFiles';
|
|
3
|
+
export { useStreamingChatCompletions } from './hooks/useStreamingChatCompletions';
|
|
4
|
+
export { useStructuredChatCompletions } from './hooks/useStructuredChatCompletions';
|
|
5
|
+
export { useWebsites } from './hooks/useWebsites';
|
|
4
6
|
export { FencyProvider } from './provider/FencyProvider';
|
|
5
7
|
export * from './types';
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Re-export components and hooks
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
2
|
+
export { useBasicChatCompletions } from './hooks/useBasicChatCompletions';
|
|
3
|
+
export { useFiles } from './hooks/useFiles';
|
|
4
|
+
export { useStreamingChatCompletions } from './hooks/useStreamingChatCompletions';
|
|
5
|
+
export { useStructuredChatCompletions } from './hooks/useStructuredChatCompletions';
|
|
6
|
+
export { useWebsites } from './hooks/useWebsites';
|
|
5
7
|
// Re-export providers
|
|
6
8
|
export { FencyProvider } from './provider/FencyProvider';
|
|
7
9
|
// Re-export all types from centralized location
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CreateOpenAiChatCompletionParams } from './CreateOpenAiChatCompletionParams';
|
|
2
2
|
import { CreateGeminiChatCompletionParams } from './CreateGeminiChatCompletionParams';
|
|
3
3
|
import { CreateAnthropicChatCompletionParams } from './CreateAnthropicChatCompletionParams';
|
|
4
|
-
export interface
|
|
4
|
+
export interface CreateBasicChatCompletionParams {
|
|
5
5
|
openai?: CreateOpenAiChatCompletionParams;
|
|
6
6
|
gemini?: CreateGeminiChatCompletionParams;
|
|
7
7
|
anthropic?: CreateAnthropicChatCompletionParams;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BasicChatCompletion } from "./BasicChatCompletion";
|
|
2
|
+
import { CreateBasicChatCompletionParams } from "./CreateBasicChatCompletionParams";
|
|
3
|
+
import { BasicChatCompletionResponse } from "./BasicChatCompletionResponse";
|
|
4
|
+
export interface UseBasicChatCompletions {
|
|
5
|
+
chatCompletions: BasicChatCompletion[];
|
|
6
|
+
createBasicChatCompletion: (params: CreateBasicChatCompletionParams) => Promise<BasicChatCompletionResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CreateStreamingChatCompletionParams } from "./CreateStreamingChatCompletionParams";
|
|
2
|
+
import { CreateStreamingChatCompletionResponse } from "./CreateStreamingChatCompletionResponse";
|
|
3
|
+
import { StreamingChatCompletion } from "./StreamingChatCompletion";
|
|
4
|
+
export interface UseStreamingChatCompletions {
|
|
5
|
+
chatCompletions: StreamingChatCompletion[];
|
|
6
|
+
createStreamingChatCompletion: (params: CreateStreamingChatCompletionParams) => Promise<CreateStreamingChatCompletionResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ZodTypeAny } from 'zod';
|
|
2
|
+
import { CreateStructuredChatCompletionParams } from './CreateStructuredChatCompletionParams';
|
|
3
|
+
import { StructuredChatCompletion } from './StructuredChatCompletion';
|
|
4
|
+
import { StructuredChatCompletionResponse } from './StructuredChatCompletionResponse';
|
|
5
|
+
export interface UseStructuredChatCompletions {
|
|
6
|
+
chatCompletions: StructuredChatCompletion<ZodTypeAny>[];
|
|
7
|
+
createStructuredChatCompletion: <T extends ZodTypeAny>(params: CreateStructuredChatCompletionParams<T>) => Promise<StructuredChatCompletionResponse<T>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export * from './FencyContext';
|
|
|
3
3
|
export * from './CreateOpenAiChatCompletionParams';
|
|
4
4
|
export * from './CreateGeminiChatCompletionParams';
|
|
5
5
|
export * from './CreateAnthropicChatCompletionParams';
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
6
|
+
export * from './BasicChatCompletionData';
|
|
7
|
+
export * from './BasicChatCompletion';
|
|
8
|
+
export * from './BasicChatCompletionResponse';
|
|
9
|
+
export * from './CreateBasicChatCompletionParams';
|
|
10
10
|
export * from './StreamingChatCompletionData';
|
|
11
11
|
export * from './StreamingChatCompletion';
|
|
12
12
|
export * from './CreateStreamingChatCompletionParams';
|
|
@@ -14,8 +14,6 @@ export * from './StructuredChatCompletionData';
|
|
|
14
14
|
export * from './StructuredChatCompletion';
|
|
15
15
|
export * from './StructuredChatCompletionResponse';
|
|
16
16
|
export * from './CreateStructuredChatCompletionParams';
|
|
17
|
-
export * from './CombinedChatCompletion';
|
|
18
|
-
export * from './UseChatCompletions';
|
|
19
17
|
export * from './UseStream';
|
|
20
18
|
export * from './CreateStreamResponse';
|
|
21
19
|
export * from './StreamError';
|
package/lib/types/index.js
CHANGED
|
@@ -5,11 +5,11 @@ export * from './FencyContext';
|
|
|
5
5
|
export * from './CreateOpenAiChatCompletionParams';
|
|
6
6
|
export * from './CreateGeminiChatCompletionParams';
|
|
7
7
|
export * from './CreateAnthropicChatCompletionParams';
|
|
8
|
-
//
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
8
|
+
// Basic chat completion types
|
|
9
|
+
export * from './BasicChatCompletionData';
|
|
10
|
+
export * from './BasicChatCompletion';
|
|
11
|
+
export * from './BasicChatCompletionResponse';
|
|
12
|
+
export * from './CreateBasicChatCompletionParams';
|
|
13
13
|
// Streaming chat completion types
|
|
14
14
|
export * from './StreamingChatCompletionData';
|
|
15
15
|
export * from './StreamingChatCompletion';
|
|
@@ -19,9 +19,6 @@ export * from './StructuredChatCompletionData';
|
|
|
19
19
|
export * from './StructuredChatCompletion';
|
|
20
20
|
export * from './StructuredChatCompletionResponse';
|
|
21
21
|
export * from './CreateStructuredChatCompletionParams';
|
|
22
|
-
// Combined chat completion types
|
|
23
|
-
export * from './CombinedChatCompletion';
|
|
24
|
-
export * from './UseChatCompletions';
|
|
25
22
|
// Stream types
|
|
26
23
|
export * from './UseStream';
|
|
27
24
|
export * from './CreateStreamResponse';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "staklau <steinaageklaussen@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"zod": "^4.0.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@fencyai/js": "^0.1.
|
|
39
|
+
"@fencyai/js": "^0.1.47",
|
|
40
40
|
"@types/jest": "^29.5.11",
|
|
41
41
|
"@types/node": "^20.10.5",
|
|
42
42
|
"@types/react": "^18.2.45",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "^5.3.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@fencyai/js": "^0.1.
|
|
48
|
+
"@fencyai/js": "^0.1.47",
|
|
49
49
|
"react": ">=16.8.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f86bd2ae856f0dfc51edbf434e62e63f4c86f79b"
|
|
52
52
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ZodTypeAny } from 'zod';
|
|
2
|
-
import { SynchronousChatCompletion } from './SynchronousChatCompletion';
|
|
3
|
-
import { StructuredChatCompletion } from './StructuredChatCompletion';
|
|
4
|
-
import { StreamingChatCompletion } from './StreamingChatCompletion';
|
|
5
|
-
export type CombinedChatCompletion = {
|
|
6
|
-
type: 'synchronous';
|
|
7
|
-
chatCompletion: SynchronousChatCompletion;
|
|
8
|
-
} | {
|
|
9
|
-
type: 'structured';
|
|
10
|
-
chatCompletion: StructuredChatCompletion<ZodTypeAny>;
|
|
11
|
-
} | {
|
|
12
|
-
type: 'streaming';
|
|
13
|
-
chatCompletion: StreamingChatCompletion;
|
|
14
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ApiError } from '@fencyai/js';
|
|
2
|
-
import { SynchronousChatCompletionData } from './SynchronousChatCompletionData';
|
|
3
|
-
export interface SynchronousChatCompletion {
|
|
4
|
-
triggeredAt: string;
|
|
5
|
-
data: SynchronousChatCompletionData | null;
|
|
6
|
-
error: ApiError | null;
|
|
7
|
-
loading: boolean;
|
|
8
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ApiError } from '@fencyai/js';
|
|
2
|
-
import { SynchronousChatCompletionData } from './SynchronousChatCompletionData';
|
|
3
|
-
export type SynchronousChatCompletionResponse = {
|
|
4
|
-
type: 'success';
|
|
5
|
-
data: SynchronousChatCompletionData;
|
|
6
|
-
} | {
|
|
7
|
-
type: 'error';
|
|
8
|
-
error: ApiError;
|
|
9
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ApiError } from '@fencyai/js';
|
|
2
|
-
import { ZodTypeAny } from 'zod';
|
|
3
|
-
import { CombinedChatCompletion } from './CombinedChatCompletion';
|
|
4
|
-
import { SynchronousChatCompletion } from './SynchronousChatCompletion';
|
|
5
|
-
import { StructuredChatCompletion } from './StructuredChatCompletion';
|
|
6
|
-
import { StreamingChatCompletion } from './StreamingChatCompletion';
|
|
7
|
-
import { CreateSynchronousChatCompletionParams } from './CreateSynchronousChatCompletionParams';
|
|
8
|
-
import { SynchronousChatCompletionResponse } from './SynchronousChatCompletionResponse';
|
|
9
|
-
import { CreateStructuredChatCompletionParams } from './CreateStructuredChatCompletionParams';
|
|
10
|
-
import { StructuredChatCompletionResponse } from './StructuredChatCompletionResponse';
|
|
11
|
-
import { CreateStreamingChatCompletionParams } from './CreateStreamingChatCompletionParams';
|
|
12
|
-
export interface UseChatCompletions {
|
|
13
|
-
latest: {
|
|
14
|
-
basic: SynchronousChatCompletion | null;
|
|
15
|
-
structured: StructuredChatCompletion<ZodTypeAny> | null;
|
|
16
|
-
streaming: StreamingChatCompletion | null;
|
|
17
|
-
response: string | null;
|
|
18
|
-
};
|
|
19
|
-
chatCompletions: CombinedChatCompletion[];
|
|
20
|
-
createChatCompletion: (params: CreateSynchronousChatCompletionParams) => Promise<SynchronousChatCompletionResponse>;
|
|
21
|
-
createStructuredChatCompletion: <T extends ZodTypeAny>(params: CreateStructuredChatCompletionParams<T>) => Promise<StructuredChatCompletionResponse<T>>;
|
|
22
|
-
createStreamingChatCompletion: (params: CreateStreamingChatCompletionParams) => Promise<{
|
|
23
|
-
type: 'success';
|
|
24
|
-
streamId: string;
|
|
25
|
-
chatCompletionId: string;
|
|
26
|
-
} | {
|
|
27
|
-
type: 'error';
|
|
28
|
-
error: ApiError;
|
|
29
|
-
}>;
|
|
30
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// hooks/useChatCompletion.ts
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { useFencyContext } from '../provider/useFencyContext';
|
|
4
|
-
import { useStreamingChatCompletions } from './useStreamingChatCompletions';
|
|
5
|
-
import { useStructuredChatCompletions } from './useStructuredChatCompletions';
|
|
6
|
-
import { useSynchronousChatCompletions } from './useSynchronousChatCompletions';
|
|
7
|
-
export function useChatCompletions() {
|
|
8
|
-
const context = useFencyContext();
|
|
9
|
-
const synchronousChatCompletions = useSynchronousChatCompletions(context);
|
|
10
|
-
const streamingChatCompletions = useStreamingChatCompletions(context);
|
|
11
|
-
const structuredChatCompletions = useStructuredChatCompletions(context);
|
|
12
|
-
const combinedChatCompletions = useMemo(() => {
|
|
13
|
-
const completions = [];
|
|
14
|
-
for (const chatCompletion of synchronousChatCompletions.chatCompletions) {
|
|
15
|
-
completions.push({
|
|
16
|
-
type: 'synchronous',
|
|
17
|
-
chatCompletion: chatCompletion,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
for (const chatCompletion of structuredChatCompletions.chatCompletions) {
|
|
21
|
-
completions.push({
|
|
22
|
-
type: 'structured',
|
|
23
|
-
chatCompletion: chatCompletion,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
for (const chatCompletion of streamingChatCompletions.chatCompletions) {
|
|
27
|
-
completions.push({
|
|
28
|
-
type: 'streaming',
|
|
29
|
-
chatCompletion: chatCompletion,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return completions;
|
|
33
|
-
}, [
|
|
34
|
-
synchronousChatCompletions.chatCompletions,
|
|
35
|
-
structuredChatCompletions.chatCompletions,
|
|
36
|
-
streamingChatCompletions.chatCompletions,
|
|
37
|
-
]);
|
|
38
|
-
const latest = useMemo(() => {
|
|
39
|
-
const lastCompletion = combinedChatCompletions[combinedChatCompletions.length - 1];
|
|
40
|
-
return {
|
|
41
|
-
basic: lastCompletion?.type === 'synchronous'
|
|
42
|
-
? lastCompletion.chatCompletion
|
|
43
|
-
: null,
|
|
44
|
-
structured: lastCompletion?.type === 'structured'
|
|
45
|
-
? lastCompletion.chatCompletion
|
|
46
|
-
: null,
|
|
47
|
-
streaming: lastCompletion?.type === 'streaming'
|
|
48
|
-
? lastCompletion.chatCompletion
|
|
49
|
-
: null,
|
|
50
|
-
response: lastCompletion?.type === 'synchronous'
|
|
51
|
-
? lastCompletion.chatCompletion.data?.response ?? null
|
|
52
|
-
: lastCompletion?.type === 'structured'
|
|
53
|
-
? JSON.stringify(lastCompletion.chatCompletion.data?.structuredResponse)
|
|
54
|
-
: lastCompletion?.type === 'streaming'
|
|
55
|
-
? lastCompletion.chatCompletion.response
|
|
56
|
-
: null,
|
|
57
|
-
};
|
|
58
|
-
}, [combinedChatCompletions]);
|
|
59
|
-
return {
|
|
60
|
-
createChatCompletion: synchronousChatCompletions.createSynchronousChatCompletion,
|
|
61
|
-
createStructuredChatCompletion: structuredChatCompletions.createStructuredChatCompletion,
|
|
62
|
-
createStreamingChatCompletion: streamingChatCompletions.createStreamingChatCompletion,
|
|
63
|
-
chatCompletions: combinedChatCompletions,
|
|
64
|
-
latest,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ApiError } from '@fencyai/js';
|
|
2
|
-
import { CreateStreamingChatCompletionParams } from '../types/CreateStreamingChatCompletionParams';
|
|
3
|
-
import { StreamingChatCompletion } from '../types/StreamingChatCompletion';
|
|
4
|
-
import { FencyContext } from '../types/FencyContext';
|
|
5
|
-
export declare const useStreamingChatCompletions: (context: FencyContext) => {
|
|
6
|
-
chatCompletions: StreamingChatCompletion[];
|
|
7
|
-
createStreamingChatCompletion: (params: CreateStreamingChatCompletionParams) => Promise<{
|
|
8
|
-
type: "success";
|
|
9
|
-
streamId: string;
|
|
10
|
-
chatCompletionId: string;
|
|
11
|
-
} | {
|
|
12
|
-
type: "error";
|
|
13
|
-
error: ApiError;
|
|
14
|
-
}>;
|
|
15
|
-
stream: import("@fencyai/js").Stream | null;
|
|
16
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z, ZodTypeAny } from 'zod';
|
|
2
|
-
import { CreateStructuredChatCompletionParams } from '../types/CreateStructuredChatCompletionParams';
|
|
3
|
-
import { StructuredChatCompletion } from '../types/StructuredChatCompletion';
|
|
4
|
-
import { StructuredChatCompletionResponse } from '../types/StructuredChatCompletionResponse';
|
|
5
|
-
import { FencyContext } from '../types/FencyContext';
|
|
6
|
-
export declare const useStructuredChatCompletions: (context: FencyContext) => {
|
|
7
|
-
chatCompletions: StructuredChatCompletion<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>[];
|
|
8
|
-
createStructuredChatCompletion: <T extends ZodTypeAny>(params: CreateStructuredChatCompletionParams<T>) => Promise<StructuredChatCompletionResponse<T>>;
|
|
9
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CreateSynchronousChatCompletionParams } from '../types/CreateSynchronousChatCompletionParams';
|
|
2
|
-
import { SynchronousChatCompletion } from '../types/SynchronousChatCompletion';
|
|
3
|
-
import { SynchronousChatCompletionResponse } from '../types/SynchronousChatCompletionResponse';
|
|
4
|
-
import { FencyContext } from '../types/FencyContext';
|
|
5
|
-
export declare const useSynchronousChatCompletions: (context: FencyContext) => {
|
|
6
|
-
chatCompletions: SynchronousChatCompletion[];
|
|
7
|
-
createSynchronousChatCompletion: (params: CreateSynchronousChatCompletionParams) => Promise<SynchronousChatCompletionResponse>;
|
|
8
|
-
};
|
package/lib/useStream/index.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/types/{SynchronousChatCompletionResponse.js → CreateStreamingChatCompletionResponse.js}
RENAMED
|
File without changes
|
|
File without changes
|