Skip to content

Commit 72079ca

Browse files
Fix formatting (#51)
* Fix formatting * fix format * fix clippy error * bump version
1 parent 8a4645f commit 72079ca

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "openai-harmony"
3-
version = "0.0.3"
3+
version = "0.0.4"
44
edition = "2021"
55
license = "Apache-2.0"
66
repository = "https://github.com/openai/harmony"

src/encoding.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,13 @@ impl Render<Message> for HarmonyEncoding {
836836
// finally content type
837837
if let Some(content_type) = &message.content_type {
838838
// <|constrain|> is a unique case which needs to be tokenized as a special token
839-
if let Some(constrain_marker) = self.mapped_format_token(FormattingToken::ConstrainedFormat) {
840-
if content_type.starts_with(constrain_marker) {
839+
if let Some(constrain_marker) =
840+
self.mapped_format_token(FormattingToken::ConstrainedFormat)
841+
{
842+
if let Some(rest) = content_type.strip_prefix(constrain_marker) {
841843
// Render the space, then the constrain marker as a special token, then the rest as text (if any)
842844
self.render_text_into(" ", into)?;
843845
self.render_formatting_token_into(FormattingToken::ConstrainedFormat, into)?;
844-
let rest = &content_type[constrain_marker.len()..];
845846
if !rest.is_empty() {
846847
self.render_text_into(rest, into)?;
847848
}

0 commit comments

Comments
 (0)