-
Notifications
You must be signed in to change notification settings - Fork 547
Spec conformance: meta support and spec updates #415
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
Changes from 3 commits
2a7e60d
3180808
76d5533
f021b00
e9c8069
1af6906
c8ff500
6ef61bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,8 @@ pub struct Annotations { | |
| pub audience: Option<Vec<Role>>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub priority: Option<f32>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub timestamp: Option<DateTime<Utc>>, | ||
| #[serde(skip_serializing_if = "Option::is_none", rename = "lastModified")] | ||
| pub last_modified: Option<DateTime<Utc>>, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was curious about this, I asked Goose, why did we change the timestamp to last_modified?
|
||
| } | ||
|
|
||
| impl Annotations { | ||
|
|
@@ -30,7 +30,7 @@ impl Annotations { | |
| ); | ||
| Annotations { | ||
| priority: Some(priority), | ||
| timestamp: Some(timestamp), | ||
| last_modified: Some(timestamp), | ||
| audience: None, | ||
| } | ||
| } | ||
|
|
@@ -72,7 +72,7 @@ impl<T: AnnotateAble> Annotated<T> { | |
| self.annotations.as_ref().and_then(|a| a.priority) | ||
| } | ||
| pub fn timestamp(&self) -> Option<DateTime<Utc>> { | ||
| self.annotations.as_ref().and_then(|a| a.timestamp) | ||
| self.annotations.as_ref().and_then(|a| a.last_modified) | ||
| } | ||
| pub fn with_audience(self, audience: Vec<Role>) -> Annotated<T> | ||
| where | ||
|
|
@@ -92,7 +92,7 @@ impl<T: AnnotateAble> Annotated<T> { | |
| annotations: Some(Annotations { | ||
| audience: Some(audience), | ||
| priority: None, | ||
| timestamp: None, | ||
| last_modified: None, | ||
| }), | ||
| } | ||
| } | ||
|
|
@@ -114,7 +114,7 @@ impl<T: AnnotateAble> Annotated<T> { | |
| raw: self.raw, | ||
| annotations: Some(Annotations { | ||
| priority: Some(priority), | ||
| timestamp: None, | ||
| last_modified: None, | ||
| audience: None, | ||
| }), | ||
| } | ||
|
|
@@ -128,15 +128,15 @@ impl<T: AnnotateAble> Annotated<T> { | |
| Annotated { | ||
| raw: self.raw, | ||
| annotations: Some(Annotations { | ||
| timestamp: Some(timestamp), | ||
| last_modified: Some(timestamp), | ||
| ..annotations | ||
| }), | ||
| } | ||
| } else { | ||
| Annotated { | ||
| raw: self.raw, | ||
| annotations: Some(Annotations { | ||
| timestamp: Some(timestamp), | ||
| last_modified: Some(timestamp), | ||
| priority: None, | ||
| audience: None, | ||
| }), | ||
|
|
@@ -211,7 +211,7 @@ pub trait AnnotateAble: sealed::Sealed { | |
| Self: Sized, | ||
| { | ||
| self.annotate(Annotations { | ||
| timestamp: Some(timestamp), | ||
| last_modified: Some(timestamp), | ||
| ..Default::default() | ||
| }) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,27 @@ impl PromptMessage { | |
| content: PromptMessageContent::Text { text: text.into() }, | ||
| } | ||
| } | ||
|
|
||
| /// Create a new text message with meta | ||
| pub fn new_text_with_meta<S: Into<String>>( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we should have ways to create each kind of prompt message with meta optionally supplied vs just this one type that has
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I think I've addressed this. LMK if me and Goose got it wrong, thanks! |
||
| role: PromptMessageRole, | ||
| text: S, | ||
| meta: Option<crate::model::Meta>, | ||
| ) -> Self { | ||
| use crate::model::{AnnotateAble, RawTextContent}; | ||
| let annotated = RawTextContent { | ||
| text: text.into(), | ||
| meta, | ||
| } | ||
| .no_annotation(); | ||
| // Map into Content using same tagging as PromptMessageContent::Text | ||
| Self { | ||
| role, | ||
| content: PromptMessageContent::Text { | ||
| text: annotated.raw.text, | ||
| }, | ||
| } | ||
| } | ||
| #[cfg(feature = "base64")] | ||
| pub fn new_image( | ||
| role: PromptMessageRole, | ||
|
|
@@ -131,6 +152,7 @@ impl PromptMessage { | |
| image: RawImageContent { | ||
| data: base64, | ||
| mime_type, | ||
| meta: None, | ||
| } | ||
| .optional_annotate(annotations), | ||
| }, | ||
|
|
@@ -184,6 +206,7 @@ mod tests { | |
| let image_content = RawImageContent { | ||
| data: "base64data".to_string(), | ||
| mime_type: "image/png".to_string(), | ||
| meta: None, | ||
| }; | ||
|
|
||
| let json = serde_json::to_string(&image_content).unwrap(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.