@ai-sdk/solid
Advanced tools
Comparing version 0.0.9 to 0.0.10
# @ai-sdk/solid | ||
## 0.0.10 | ||
### Patch Changes | ||
- d3100b9c: feat (ai/ui): support custom fetch function in useChat, useCompletion, useAssistant, useObject | ||
- Updated dependencies [d3100b9c] | ||
- @ai-sdk/ui-utils@0.0.8 | ||
## 0.0.9 | ||
@@ -4,0 +12,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions as UseChatOptions$1, RequestOptions, UseCompletionOptions } from '@ai-sdk/ui-utils'; | ||
import { Message, CreateMessage, ChatRequestOptions, JSONValue, FetchFunction, UseChatOptions as UseChatOptions$1, RequestOptions, UseCompletionOptions } from '@ai-sdk/ui-utils'; | ||
export { CreateMessage, Message, UseCompletionOptions } from '@ai-sdk/ui-utils'; | ||
@@ -47,2 +47,7 @@ import { Accessor, Setter, JSX } from 'solid-js'; | ||
data: Accessor<JSONValue[] | undefined>; | ||
/** | ||
Custom fetch implementation. You can use it as a middleware to intercept requests, | ||
or to provide a custom fetch implementation for e.g. testing. | ||
*/ | ||
fetch?: FetchFunction; | ||
}; | ||
@@ -110,2 +115,7 @@ type UseChatOptions = UseChatOptions$1 & { | ||
data: Accessor<JSONValue[] | undefined>; | ||
/** | ||
Custom fetch implementation. You can use it as a middleware to intercept requests, | ||
or to provide a custom fetch implementation for e.g. testing. | ||
*/ | ||
fetch?: FetchFunction; | ||
}; | ||
@@ -112,0 +122,0 @@ declare function useCompletion(rawUseCompletionOptions?: UseCompletionOptions | Accessor<UseCompletionOptions>): UseCompletionHelpers; |
@@ -32,3 +32,3 @@ "use strict"; | ||
var import_store = require("solid-js/store"); | ||
var getStreamedResponse = async (api, chatRequest, mutate, setStreamData, streamData, extraMetadata, messagesRef, abortController, generateId, streamMode, onFinish, onResponse, onToolCall, sendExtraMessageFields) => { | ||
var getStreamedResponse = async (api, chatRequest, mutate, setStreamData, streamData, extraMetadata, messagesRef, abortController, generateId, streamMode, onFinish, onResponse, onToolCall, sendExtraMessageFields, fetch) => { | ||
var _a, _b, _c; | ||
@@ -50,3 +50,2 @@ const previousMessages = messagesRef; | ||
api, | ||
messages: constructedMessagesPayload, | ||
body: { | ||
@@ -75,3 +74,4 @@ messages: constructedMessagesPayload, | ||
onFinish, | ||
generateId | ||
generateId, | ||
fetch | ||
}); | ||
@@ -141,3 +141,3 @@ }; | ||
getStreamedResponse: () => { | ||
var _a3, _b3, _c3, _d3, _e3, _f3, _g3, _h2, _i, _j; | ||
var _a3, _b3, _c3, _d3, _e3, _f3, _g3, _h2, _i, _j, _k, _l; | ||
return getStreamedResponse( | ||
@@ -157,3 +157,4 @@ api(), | ||
(_h2 = (_g3 = useChatOptions()).onToolCall) == null ? void 0 : _h2.call(_g3), | ||
(_j = (_i = useChatOptions()).sendExtraMessageFields) == null ? void 0 : _j.call(_i) | ||
(_j = (_i = useChatOptions()).sendExtraMessageFields) == null ? void 0 : _j.call(_i), | ||
(_l = (_k = useChatOptions()).fetch) == null ? void 0 : _l.call(_k) | ||
); | ||
@@ -379,3 +380,3 @@ }, | ||
const complete = async (prompt, options) => { | ||
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k; | ||
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m; | ||
const existingData = (_a2 = streamData()) != null ? _a2 : []; | ||
@@ -401,3 +402,4 @@ return (0, import_ui_utils2.callCompletionApi)({ | ||
setStreamData([...existingData, ...data != null ? data : []]); | ||
} | ||
}, | ||
fetch: (_m = (_l = useCompletionOptions()).fetch) == null ? void 0 : _m.call(_l) | ||
}); | ||
@@ -404,0 +406,0 @@ }; |
{ | ||
"name": "@ai-sdk/solid", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"license": "Apache-2.0", | ||
@@ -18,3 +18,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@ai-sdk/ui-utils": "0.0.7" | ||
"@ai-sdk/ui-utils": "0.0.8" | ||
}, | ||
@@ -21,0 +21,0 @@ "devDependencies": { |
@@ -5,2 +5,3 @@ import type { | ||
CreateMessage, | ||
FetchFunction, | ||
IdGenerator, | ||
@@ -80,2 +81,8 @@ JSONValue, | ||
data: Accessor<JSONValue[] | undefined>; | ||
/** | ||
Custom fetch implementation. You can use it as a middleware to intercept requests, | ||
or to provide a custom fetch implementation for e.g. testing. | ||
*/ | ||
fetch?: FetchFunction; | ||
}; | ||
@@ -93,7 +100,8 @@ | ||
generateId: IdGenerator, | ||
streamMode?: 'stream-data' | 'text', | ||
onFinish?: UseChatOptions['onFinish'], | ||
onResponse?: UseChatOptions['onResponse'], | ||
onToolCall?: UseChatOptions['onToolCall'], | ||
sendExtraMessageFields?: boolean, | ||
streamMode: 'stream-data' | 'text' | undefined, | ||
onFinish: UseChatOptions['onFinish'] | undefined, | ||
onResponse: UseChatOptions['onResponse'] | undefined, | ||
onToolCall: UseChatOptions['onToolCall'] | undefined, | ||
sendExtraMessageFields: boolean | undefined, | ||
fetch: FetchFunction | undefined, | ||
) => { | ||
@@ -103,2 +111,3 @@ // Do an optimistic update to the chat state to show the updated messages | ||
const previousMessages = messagesRef; | ||
mutate(chatRequest.messages); | ||
@@ -123,3 +132,2 @@ | ||
api, | ||
messages: constructedMessagesPayload, | ||
body: { | ||
@@ -149,2 +157,3 @@ messages: constructedMessagesPayload, | ||
generateId, | ||
fetch, | ||
}); | ||
@@ -257,2 +266,3 @@ }; | ||
useChatOptions().sendExtraMessageFields?.(), | ||
useChatOptions().fetch?.(), | ||
), | ||
@@ -259,0 +269,0 @@ experimental_onFunctionCall: |
import type { | ||
FetchFunction, | ||
JSONValue, | ||
@@ -64,2 +65,8 @@ RequestOptions, | ||
data: Accessor<JSONValue[] | undefined>; | ||
/** | ||
Custom fetch implementation. You can use it as a middleware to intercept requests, | ||
or to provide a custom fetch implementation for e.g. testing. | ||
*/ | ||
fetch?: FetchFunction; | ||
}; | ||
@@ -143,2 +150,3 @@ | ||
}, | ||
fetch: useCompletionOptions().fetch?.(), | ||
}); | ||
@@ -145,0 +153,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142425
2149
2
+ Added@ai-sdk/ui-utils@0.0.8(transitive)
- Removed@ai-sdk/ui-utils@0.0.7(transitive)
Updated@ai-sdk/ui-utils@0.0.8