Skip to content

Commit

Permalink
feat(integrations): qdrant and openai builder should be consistent (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv committed Jun 16, 2024
1 parent 1f6a0f9 commit b211002
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions swiftide/src/integrations/openai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod simple_prompt;
/// The `OpenAI` struct encapsulates an OpenAI client and default options for embedding and prompt models.
/// It uses the `Builder` pattern for flexible and customizable instantiation.
#[derive(Debug, Builder, Clone)]
#[builder(setter(into, strip_option))]
pub struct OpenAI {
/// The OpenAI client, wrapped in an `Arc` for thread-safe reference counting.
/// Defaults to a new instance of `async_openai::Client`.
Expand Down
10 changes: 6 additions & 4 deletions swiftide/src/integrations/qdrant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ const DEFAULT_COLLECTION_NAME: &str = "swiftide";
/// This struct is used to interact with the Qdrant vector database, providing methods to create and manage
/// vector collections, store data, and ensure proper indexing for efficient searches.
#[derive(Builder)]
#[builder(pattern = "owned")]
#[builder(pattern = "owned", setter(strip_option))]
pub struct Qdrant {
/// The Qdrant client used to interact with the Qdrant vector database.
#[builder(setter(into))]
client: QdrantClient,
/// The name of the collection to be used in Qdrant. Defaults to "swiftide".
#[builder(default = "DEFAULT_COLLECTION_NAME.to_string()")]
#[builder(setter(into))]
collection_name: String,
/// The size of the vectors to be stored in the collection.
vector_size: usize,
vector_size: u64,
/// The batch size for operations. Optional.
#[builder(default, setter(strip_option))]
#[builder(default)]
batch_size: Option<usize>,
}

Expand Down Expand Up @@ -73,7 +75,7 @@ impl Qdrant {
collection_name: self.collection_name.to_string(),
vectors_config: Some(VectorsConfig {
config: Some(Config::Params(VectorParams {
size: self.vector_size as u64,
size: self.vector_size,
distance: Distance::Cosine.into(),
..Default::default()
})),
Expand Down

0 comments on commit b211002

Please sign in to comment.