Feature Request
Problem with TranscriptionRequestBuilder:
If someone forgets to provide data, calling .build() will trigger panic.
Location: src/transcription.rs:
pub fn build(self) -> TranscriptionRequest {
if self.data.is_empty() {
panic!("Data cannot be empty!")
}
// ...
}
Problem with VectorSearchRequestBuilder:
Location: src/vector_store/request.rs:
Builder returns a runtime Result if query is missing forcing user to handle misconfiguration error.
pub fn build(self) -> Result<VectorSearchRequest<F>, VectorStoreError> {
let Some(query) = self.query else {
return Err(VectorStoreError::BuilderError("`query` is a required...".into()));
};
// ...
}
Both of these problems can be mitigated at compile-time similar to AgentBuilder and ClientBuilder by using Typestate pattern.
Motivation
- Eliminate runtime panic in
TranscriptionRequestBuilder
- Improved DX when building vector search requests
Proposal
- Define universal state markers:
Missing (default) and Provided for all builders.
- Initialize with
Missing state
- Implement state transitions to
Provided within .data() and .load_file() and similar methods
- Implement terminal methods (
.build() and .send()) only for Provided state
Alternatives
This might require introduction of additional generics, but is still arguably better and follows existing approach in other builders
Feature Request
Problem with
TranscriptionRequestBuilder:If someone forgets to provide data, calling
.build()will trigger panic.Location:
src/transcription.rs:Problem with
VectorSearchRequestBuilder:Location:
src/vector_store/request.rs:Builder returns a runtime
Resultifqueryis missing forcing user to handle misconfiguration error.Both of these problems can be mitigated at compile-time similar to
AgentBuilderandClientBuilderby using Typestate pattern.Motivation
TranscriptionRequestBuilderProposal
Missing(default) andProvidedfor all builders.MissingstateProvidedwithin.data()and.load_file()and similar methods.build()and.send()) only forProvidedstateAlternatives
This might require introduction of additional generics, but is still arguably better and follows existing approach in other builders