From 6a094ed8cde37a01013e00a46134264634dce72e Mon Sep 17 00:00:00 2001 From: Jayanth Sai Yarlagadda Date: Thu, 6 Aug 2026 20:43:58 -0700 Subject: [PATCH 1/2] Export RenderConversationConfig from crate root --- README.md | 10 ++++++++-- docs/rust.md | 6 +++++- src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aeef157..97eae9d 100644 --- a/README.md +++ b/README.md @@ -115,13 +115,19 @@ openai-harmony = { git = "https://github.com/openai/harmony" } ```rust use openai_harmony::chat::{Message, Role, Conversation}; -use openai_harmony::{HarmonyEncodingName, load_harmony_encoding}; +use openai_harmony::{ + HarmonyEncodingName, RenderConversationConfig, load_harmony_encoding, +}; fn main() -> anyhow::Result<()> { let enc = load_harmony_encoding(HarmonyEncodingName::HarmonyGptOss)?; let convo = Conversation::from_messages([Message::from_role_and_content(Role::User, "Hello there!")]); - let tokens = enc.render_conversation_for_completion(&convo, Role::Assistant, None)?; + let config = RenderConversationConfig { + auto_drop_analysis: false, + }; + let tokens = + enc.render_conversation_for_completion(&convo, Role::Assistant, Some(&config))?; println!("{:?}", tokens); Ok(()) } diff --git a/docs/rust.md b/docs/rust.md index d4084f2..bc7e0cb 100644 --- a/docs/rust.md +++ b/docs/rust.md @@ -13,7 +13,7 @@ openai-harmony = { git = "https://github.com/openai/harmony" } and import the items you need: ```rust -use openai_harmony::{load_harmony_encoding, HarmonyEncodingName}; +use openai_harmony::{load_harmony_encoding, HarmonyEncodingName, RenderConversationConfig}; use openai_harmony::chat::{Message, Role, Conversation}; ``` @@ -94,6 +94,10 @@ Important methods: `ParseOptions` currently exposes a single field, `strict`, which defaults to `true`. Set it to `false` when you need to recover from malformed model output in downstream systems. +### `RenderConversationConfig` + +Controls conversation rendering. It defaults to `auto_drop_analysis: true`; set the field to `false` and pass `Some(&config)` to a conversation rendering method to preserve analysis content. + ### `StreamableParser` Incremental parser that consumes tokens one by one. Create with `StreamableParser::new(encoding, role)` and feed tokens via `process`. Access information via getters like `current_content`, `current_role`, `messages`, `tokens` and `state_json`. Use `StreamableParser::new_with_options(encoding, role, options)` when you need to override defaults such as `ParseOptions { strict: false }`. diff --git a/src/lib.rs b/src/lib.rs index 6c2fcfb..5449dc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ mod registry; mod tiktoken; pub mod tiktoken_ext; -pub use encoding::{HarmonyEncoding, ParseOptions, StreamableParser}; +pub use encoding::{HarmonyEncoding, ParseOptions, RenderConversationConfig, StreamableParser}; pub use registry::load_harmony_encoding; pub use registry::HarmonyEncodingName; From bcdd80d94db8d60410a7561c68203781a5edc488 Mon Sep 17 00:00:00 2001 From: Jayanth Sai Yarlagadda Date: Thu, 6 Aug 2026 22:10:17 -0700 Subject: [PATCH 2/2] Clarify omitted render config behavior --- docs/rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rust.md b/docs/rust.md index bc7e0cb..7029614 100644 --- a/docs/rust.md +++ b/docs/rust.md @@ -96,7 +96,7 @@ Important methods: ### `RenderConversationConfig` -Controls conversation rendering. It defaults to `auto_drop_analysis: true`; set the field to `false` and pass `Some(&config)` to a conversation rendering method to preserve analysis content. +Controls conversation rendering. Passing `None` preserves analysis content. To drop eligible prior analysis, pass `Some(&RenderConversationConfig::default())`; its `auto_drop_analysis` field defaults to `true`. Set the field to `false` to preserve analysis when passing a config explicitly. ### `StreamableParser`