Skip to content

Commit a4ca081

Browse files
committed
refactor
1 parent 7c99322 commit a4ca081

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

async-openai/src/types/chat/impls.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::types::chat::{
88
ChatCompletionRequestSystemMessageContent, ChatCompletionRequestToolMessage,
99
ChatCompletionRequestToolMessageContent, ChatCompletionRequestUserMessage,
1010
ChatCompletionRequestUserMessageContent, ChatCompletionRequestUserMessageContentPart,
11-
FunctionName,
11+
FunctionName, ImageUrl,
1212
};
1313

1414
impl From<ChatCompletionRequestUserMessage> for ChatCompletionRequestMessage {
@@ -296,3 +296,21 @@ impl Default for ChatCompletionRequestUserMessageContent {
296296
ChatCompletionRequestUserMessageContent::Text("".into())
297297
}
298298
}
299+
300+
impl From<&str> for ImageUrl {
301+
fn from(value: &str) -> Self {
302+
Self {
303+
url: value.into(),
304+
detail: Default::default(),
305+
}
306+
}
307+
}
308+
309+
impl From<String> for ImageUrl {
310+
fn from(value: String) -> Self {
311+
Self {
312+
url: value,
313+
detail: Default::default(),
314+
}
315+
}
316+
}

async-openai/src/types/impls.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
CreateTranslationRequest, TimestampGranularity, TranscriptionInclude,
1515
},
1616
audio::{TranscriptionChunkingStrategy, TranslationResponseFormat},
17-
chat::{ImageUrl, Prompt, Role, StopConfiguration},
17+
chat::{Prompt, Role, StopConfiguration},
1818
containers::CreateContainerFileRequest,
1919
embeddings::EmbeddingInput,
2020
files::{CreateFileRequest, FileExpirationAfterAnchor, FileInput, FilePurpose},
@@ -688,24 +688,6 @@ impl_from_for_array_of_integer_array!(u32, Prompt);
688688

689689
// todo: write macro for bunch of same looking From trait implementations below
690690

691-
impl From<&str> for ImageUrl {
692-
fn from(value: &str) -> Self {
693-
Self {
694-
url: value.into(),
695-
detail: Default::default(),
696-
}
697-
}
698-
}
699-
700-
impl From<String> for ImageUrl {
701-
fn from(value: String) -> Self {
702-
Self {
703-
url: value,
704-
detail: Default::default(),
705-
}
706-
}
707-
}
708-
709691
impl From<String> for CreateMessageRequestContent {
710692
fn from(value: String) -> Self {
711693
Self::Content(value)

0 commit comments

Comments
 (0)