Skip to content

implement conversions for inference objects #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2025
Merged

Conversation

generall
Copy link
Member

@generall generall commented Jun 16, 2025

Query with image

use qdrant_client::qdrant::{Image, Query, QueryPointsBuilder};
use qdrant_client::Qdrant;

let client = Qdrant::from_url("http://localhost:6334").build()?;

let query_image = Image::new_from_url(
    "https://picsum.photos/200/300.jpg",
    "Qdrant/clip-ViT-B-32-vision"
);

let query_request = QueryPointsBuilder::new("{collection_name}")
    .query(Query::new_nearest(query_image));

// ANN search with server-side inference
client.query(query_request).await?;

Upsert vector from Image

use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder, Image};
use qdrant_client::{Qdrant, Payload};
use serde_json::json;

let client = Qdrant::from_url("http://localhost:6334").build()?;

let image = Image::new_from_url("https://picsum.photos/200/300.jpg", "Qdrant/clip-ViT-B-32-vision");

client
    .upsert_points(
        UpsertPointsBuilder::new(
            "{collection_name}",
            vec![
                PointStruct::new(
                    1,
                    image,
                    Payload::try_from(json!(
                        {"color": "red"}
                    ))
                    .unwrap(),
                )
            ],
        )
        .wait(true),
    )
    .await?;

@generall generall requested a review from timvisee June 16, 2025 16:28
Comment on lines +34 to +52
pub fn new_from_url(url: impl Into<String>, model: impl Into<String>) -> Self {
Self {
image: Some(Value {
kind: Some(value::Kind::StringValue(url.into())),
}),
model: model.into(),
options: HashMap::new(),
}
}

pub fn new_from_base64(base64: impl Into<String>, model: impl Into<String>) -> Self {
Self {
image: Some(Value {
kind: Some(value::Kind::StringValue(base64.into())),
}),
model: model.into(),
options: HashMap::new(),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are basically exactly the same.

Is there any way we want to differentiate them other than the name?

  • Maybe validate URL or base64: prefix
  • Or explicitly specify the type

generall and others added 2 commits June 17, 2025 11:48
Co-authored-by: Tim Visée <tim@visee.me>
Co-authored-by: Tim Visée <tim@visee.me>
@generall generall merged commit a8b5448 into dev Jun 26, 2025
2 checks passed
@Anush008 Anush008 deleted the syntax-sugar-for-inference branch July 14, 2025 17:51
generall added a commit that referenced this pull request Jul 14, 2025
* implement conversions for inference objects

* fmt

* Update src/builders/document_builder.rs

Co-authored-by: Tim Visée <tim@visee.me>

* Update src/builders/image_builder.rs

Co-authored-by: Tim Visée <tim@visee.me>

---------

Co-authored-by: Tim Visée <tim@visee.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants