-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Feat: CXA-1831 Persist latest model and reasoning effort in sqlite #14859
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 all commits
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| //! are used to preserve compatibility when older payloads omit newly introduced attributes. | ||
|
|
||
| use std::collections::HashMap; | ||
| use std::str::FromStr; | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::Deserialize; | ||
|
|
@@ -48,6 +49,15 @@ pub enum ReasoningEffort { | |
| XHigh, | ||
| } | ||
|
|
||
| impl FromStr for ReasoningEffort { | ||
| type Err = String; | ||
|
Collaborator
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. Generic string type error - open to have a custom error type if necessary but feel like an overkill. |
||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| serde_json::from_value(serde_json::Value::String(s.to_string())) | ||
| .map_err(|_| format!("invalid reasoning_effort: {s}")) | ||
| } | ||
| } | ||
|
Comment on lines
+52
to
+59
Collaborator
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. A simple string to enum parser so that read from db can be correctly converted. Better to keep such parser on the enum def side so that we can reuse down the line. |
||
|
|
||
| /// Canonical user-input modality tags advertised by a model. | ||
| #[derive( | ||
| Debug, | ||
|
|
@@ -552,6 +562,20 @@ mod tests { | |
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn reasoning_effort_from_str_accepts_known_values() { | ||
| assert_eq!("high".parse(), Ok(ReasoningEffort::High)); | ||
| assert_eq!("minimal".parse(), Ok(ReasoningEffort::Minimal)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn reasoning_effort_from_str_rejects_unknown_values() { | ||
| assert_eq!( | ||
| "unsupported".parse::<ReasoningEffort>(), | ||
| Err("invalid reasoning_effort: unsupported".to_string()) | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn get_model_instructions_uses_template_when_placeholder_present() { | ||
| let model = test_model(Some(ModelMessages { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TABLE threads ADD COLUMN model TEXT; | ||
|
Collaborator
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. @charley-oai if there is a migration here, maybe good to package yours in the same release |
||
| ALTER TABLE threads ADD COLUMN reasoning_effort TEXT; | ||
|
Comment on lines
+1
to
+2
Collaborator
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. Capture the latest model and reasoning effort per thread. |
||
Uh oh!
There was an error while loading. Please reload this page.