The API v2 client is unopinionated. It accepts configuration options that are a 1:1 representation of the API configuration options. It also doesn't preprocess the results -- that's left to the consumer. This will make it easier for folks who are familiar with the API or reading the API docs to map concepts to the client.
To-do
[x] Enable using a JWT instead of an API key.
Bug fixes
Events might be very large, e.g. many or large search results, which causes them to be split across multiple chunks. Original code didn't accommodate for this, and risked a JSON.parse error. The code now buffers these chunks until it detects the completion of the event (indicated by a successful JSON.parse call), at which point it processes the buffered event.
New features
Errors are emitted as regular events to the onStreamEvent handler.
Calling streamQueryV2 returns { cancelStream } which can be used to cancel the stream.
Breaking changes
Package interface is now:
import {
streamQueryV1,
ApiV1,
streamQueryV2,
ApiV2,
} from "@vectara/stream-query-client";
The API has been dramatically simplified and ergonomics much improved, so I don't think we need to inject any opinions or sugar into the interface. As a result, requests are now configured with the same objects and fields as described in the Corpus Query docs.
Summary
The API v2 client is unopinionated. It accepts configuration options that are a 1:1 representation of the API configuration options. It also doesn't preprocess the results -- that's left to the consumer. This will make it easier for folks who are familiar with the API or reading the API docs to map concepts to the client.
To-do
Bug fixes
New features
onStreamEvent
handler.streamQueryV2
returns{ cancelStream }
which can be used to cancel the stream.Breaking changes
Package interface is now:
The API has been dramatically simplified and ergonomics much improved, so I don't think we need to inject any opinions or sugar into the interface. As a result, requests are now configured with the same objects and fields as described in the Corpus Query docs.
StreamEvent
now has this shape:References
https://javascript.info/fetch-abort https://github.com/whatwg/streams/issues/1255 https://github.com/openai/openai-node/blob/master/src/streaming.ts