Skip to content

Commit 780a9f8

Browse files
authored
fix: only pass down output_dimension when not default (#647)
1 parent 6b65150 commit 780a9f8

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

src/llm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait LlmGenerationClient: Send + Sync {
5656
pub struct LlmEmbeddingRequest<'a> {
5757
pub model: &'a str,
5858
pub text: Cow<'a, str>,
59-
pub output_dimension: u32,
59+
pub output_dimension: Option<u32>,
6060
pub task_type: Option<Cow<'a, str>>,
6161
}
6262

src/llm/openai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl LlmEmbeddingClient for Client {
129129
.create(CreateEmbeddingRequest {
130130
model: request.model.to_string(),
131131
input: EmbeddingInput::String(request.text.to_string()),
132-
dimensions: Some(request.output_dimension),
132+
dimensions: request.output_dimension,
133133
..Default::default()
134134
})
135135
.await?;

src/ops/functions/embed_text.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ struct Spec {
1414

1515
struct Args {
1616
client: Box<dyn LlmEmbeddingClient>,
17-
output_dimension: u32,
1817
text: ResolvedOpArg,
1918
}
2019

@@ -38,7 +37,7 @@ impl SimpleFunctionExecutor for Executor {
3837
let req = LlmEmbeddingRequest {
3938
model: &self.spec.model,
4039
text: Cow::Borrowed(text),
41-
output_dimension: self.args.output_dimension,
40+
output_dimension: self.spec.output_dimension,
4241
task_type: self
4342
.spec
4443
.task_type
@@ -80,14 +79,7 @@ impl SimpleFunctionFactoryBase for Factory {
8079
dimension: Some(output_dimension as usize),
8180
element_type: Box::new(BasicValueType::Float32),
8281
}));
83-
Ok((
84-
Args {
85-
client,
86-
text,
87-
output_dimension,
88-
},
89-
output_schema,
90-
))
82+
Ok((Args { client, text }, output_schema))
9183
}
9284

9385
async fn build_executor(

0 commit comments

Comments
 (0)