-
Notifications
You must be signed in to change notification settings - Fork 0
Add ProviderAdapter, ProviderFormat, transform_request/response/stream_chunk patterns to lingua #50
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c8c1f9b to
a6019a6
Compare
| .unwrap_or_else(|| "end_turn".to_string()); | ||
|
|
||
| let mut obj = serde_json::json!({ | ||
| "id": resp.extras.get("id").and_then(Value::as_str).unwrap_or("transformed"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think extras are always an empty Map (see line 223 https://github.com/braintrustdata/lingua/pull/50/changes#diff-73d9a68f8109812b0b890dd8d1391334c99cbbee0595bd14a47a11f6dc0f06c5R223 ).
I'm not sure how important is this id though ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its required for anthropic response bodies but im gonna get rid of extras for now becuase it isn't really used. gonna just use a default value for id
| .map(|r| match r { | ||
| "STOP" => "stop".to_string(), | ||
| "MAX_TOKENS" => "length".to_string(), | ||
| "SAFETY" | "RECITATION" | "OTHER" => "stop".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| }); | ||
|
|
||
| Ok(UniversalResponse { | ||
| model: None, // Bedrock doesn't include model in response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, is that actually always the case? wonder if that might break things if we don't return the model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, response bodys that require a model have a default when we go from response_from_universal in a openai/anthropic adapter. I made the strings less magic and added https://github.com/braintrustdata/lingua/blob/5f9c000a3f021c5544e78b312a1f83346c9ae545/crates/lingua/src/universal/defaults.rs
…m_chunk patterns to lingua
a6019a6 to
5f9c000
Compare

This PR adds testing matrix + provider adapters for:
and callers use
transform_requestandtransform_responseto translate between providers.The file below explains how to add a new provider based on the
ProviderAdaptertrait and also a closed testing loop so LLMs can just iterate:https://github.com/braintrustdata/lingua/blob/a6019a6fc0a082a373d1f55c188df6483772b864/crates/lingua/docs/ADDING_PROVIDER_FORMAT.md
Current coverage status for the testing matrix is here ->:
https://github.com/braintrustdata/lingua/actions/runs/20666751649?pr=50