|
1 | 1 | use std::collections::HashMap; |
2 | 2 |
|
3 | 3 | use crate::qdrant::vectors::VectorsOptions; |
4 | | -use crate::qdrant::{NamedVectors, Vector, Vectors}; |
| 4 | +use crate::qdrant::{vector, Document, Image, InferenceObject, NamedVectors, Vector, Vectors}; |
5 | 5 |
|
6 | 6 | impl From<Vec<f32>> for Vector { |
7 | 7 | fn from(vector: Vec<f32>) -> Self { |
@@ -139,3 +139,93 @@ impl From<NamedVectors> for VectorsOptions { |
139 | 139 | Self::Vectors(value) |
140 | 140 | } |
141 | 141 | } |
| 142 | + |
| 143 | +impl From<Document> for Vector { |
| 144 | + fn from(value: Document) -> Self { |
| 145 | + Vector { |
| 146 | + vector: Some(vector::Vector::Document(value)), |
| 147 | + ..Default::default() |
| 148 | + } |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | +impl From<Document> for Vectors { |
| 153 | + fn from(value: Document) -> Self { |
| 154 | + Vectors { |
| 155 | + vectors_options: Some(VectorsOptions::Vector(Vector::from(value))), |
| 156 | + } |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | +impl From<HashMap<String, Document>> for Vectors { |
| 161 | + fn from(value: HashMap<String, Document>) -> Self { |
| 162 | + Vectors { |
| 163 | + vectors_options: Some(VectorsOptions::Vectors(NamedVectors { |
| 164 | + vectors: value |
| 165 | + .into_iter() |
| 166 | + .map(|(k, v)| (k, Vector::from(v))) |
| 167 | + .collect(), |
| 168 | + })), |
| 169 | + } |
| 170 | + } |
| 171 | +} |
| 172 | + |
| 173 | +impl From<Image> for Vector { |
| 174 | + fn from(value: Image) -> Self { |
| 175 | + Vector { |
| 176 | + vector: Some(vector::Vector::Image(value)), |
| 177 | + ..Default::default() |
| 178 | + } |
| 179 | + } |
| 180 | +} |
| 181 | + |
| 182 | +impl From<Image> for Vectors { |
| 183 | + fn from(value: Image) -> Self { |
| 184 | + Vectors { |
| 185 | + vectors_options: Some(VectorsOptions::Vector(Vector::from(value))), |
| 186 | + } |
| 187 | + } |
| 188 | +} |
| 189 | + |
| 190 | +impl From<HashMap<String, Image>> for Vectors { |
| 191 | + fn from(value: HashMap<String, Image>) -> Self { |
| 192 | + Vectors { |
| 193 | + vectors_options: Some(VectorsOptions::Vectors(NamedVectors { |
| 194 | + vectors: value |
| 195 | + .into_iter() |
| 196 | + .map(|(k, v)| (k, Vector::from(v))) |
| 197 | + .collect(), |
| 198 | + })), |
| 199 | + } |
| 200 | + } |
| 201 | +} |
| 202 | + |
| 203 | +impl From<InferenceObject> for Vector { |
| 204 | + fn from(value: InferenceObject) -> Self { |
| 205 | + Vector { |
| 206 | + vector: Some(vector::Vector::Object(value)), |
| 207 | + ..Default::default() |
| 208 | + } |
| 209 | + } |
| 210 | +} |
| 211 | + |
| 212 | +impl From<InferenceObject> for Vectors { |
| 213 | + fn from(value: InferenceObject) -> Self { |
| 214 | + Vectors { |
| 215 | + vectors_options: Some(VectorsOptions::Vector(Vector::from(value))), |
| 216 | + } |
| 217 | + } |
| 218 | +} |
| 219 | + |
| 220 | +impl From<HashMap<String, InferenceObject>> for Vectors { |
| 221 | + fn from(value: HashMap<String, InferenceObject>) -> Self { |
| 222 | + Vectors { |
| 223 | + vectors_options: Some(VectorsOptions::Vectors(NamedVectors { |
| 224 | + vectors: value |
| 225 | + .into_iter() |
| 226 | + .map(|(k, v)| (k, Vector::from(v))) |
| 227 | + .collect(), |
| 228 | + })), |
| 229 | + } |
| 230 | + } |
| 231 | +} |
0 commit comments