Closed tmkx closed 1 month ago
can we add a new signal option? it will be more flexible and can be used to abort the stream when a user cancels chat sessions. it meets the timeout requirement as well, timeout is also very useful as it's more convenient BTW :)
signal
timeout
const model = genAI.getGenerativeModel({ model: "gemini-pro" }, { signal: AbortSignal.timeout(10000), });
https://github.com/google/generative-ai-js/blob/d8f22d2259c9e926dcc4ac955db896c235e0a3bc/packages/main/src/requests/request.ts#L103-L117
Originally posted by @tmkx in https://github.com/google/generative-ai-js/pull/31#issuecomment-1920556402
Just add this code below and the property signal in the requestOptions interface:
requestOptions
if (requestOptions?.signal) { fetchOptions.signal = requestOptions?.signal; }
Was released in https://github.com/google-gemini/generative-ai-js/releases/tag/%40google%2Fgenerative-ai%400.16.0
See PR https://github.com/google-gemini/generative-ai-js/pull/144 for details.
can we add a new
signal
option? it will be more flexible and can be used to abort the stream when a user cancels chat sessions. it meets the timeout requirement as well,timeout
is also very useful as it's more convenient BTW :)https://github.com/google/generative-ai-js/blob/d8f22d2259c9e926dcc4ac955db896c235e0a3bc/packages/main/src/requests/request.ts#L103-L117
Originally posted by @tmkx in https://github.com/google/generative-ai-js/pull/31#issuecomment-1920556402