First pass on fixes
This commit is contained in:
parent
5826d89b97
commit
2f3be75fc7
269 changed files with 1593 additions and 2574 deletions
|
@ -633,12 +633,11 @@ pub fn into_anthropic(
|
|||
Role::Assistant => anthropic::Role::Assistant,
|
||||
Role::System => unreachable!("System role should never occur here"),
|
||||
};
|
||||
if let Some(last_message) = new_messages.last_mut() {
|
||||
if last_message.role == anthropic_role {
|
||||
if let Some(last_message) = new_messages.last_mut()
|
||||
&& last_message.role == anthropic_role {
|
||||
last_message.content.extend(anthropic_message_content);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the last segment of the message as cached
|
||||
if message.cache {
|
||||
|
|
|
@ -412,11 +412,10 @@ impl BedrockModel {
|
|||
.region(Region::new(region))
|
||||
.timeout_config(TimeoutConfig::disabled());
|
||||
|
||||
if let Some(endpoint_url) = endpoint {
|
||||
if !endpoint_url.is_empty() {
|
||||
if let Some(endpoint_url) = endpoint
|
||||
&& !endpoint_url.is_empty() {
|
||||
config_builder = config_builder.endpoint_url(endpoint_url);
|
||||
}
|
||||
}
|
||||
|
||||
match auth_method {
|
||||
None => {
|
||||
|
@ -728,12 +727,11 @@ pub fn into_bedrock(
|
|||
Role::Assistant => bedrock::BedrockRole::Assistant,
|
||||
Role::System => unreachable!("System role should never occur here"),
|
||||
};
|
||||
if let Some(last_message) = new_messages.last_mut() {
|
||||
if last_message.role == bedrock_role {
|
||||
if let Some(last_message) = new_messages.last_mut()
|
||||
&& last_message.role == bedrock_role {
|
||||
last_message.content.extend(bedrock_message_content);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
new_messages.push(
|
||||
BedrockMessage::builder()
|
||||
.role(bedrock_role)
|
||||
|
|
|
@ -597,8 +597,7 @@ impl CloudLanguageModel {
|
|||
.headers()
|
||||
.get(SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME)
|
||||
.and_then(|resource| resource.to_str().ok())
|
||||
{
|
||||
if let Some(plan) = response
|
||||
&& let Some(plan) = response
|
||||
.headers()
|
||||
.get(CURRENT_PLAN_HEADER_NAME)
|
||||
.and_then(|plan| plan.to_str().ok())
|
||||
|
@ -606,7 +605,6 @@ impl CloudLanguageModel {
|
|||
{
|
||||
return Err(anyhow!(ModelRequestLimitReachedError { plan }));
|
||||
}
|
||||
}
|
||||
} else if status == StatusCode::PAYMENT_REQUIRED {
|
||||
return Err(anyhow!(PaymentRequiredError));
|
||||
}
|
||||
|
@ -662,8 +660,8 @@ where
|
|||
|
||||
impl From<ApiError> for LanguageModelCompletionError {
|
||||
fn from(error: ApiError) -> Self {
|
||||
if let Ok(cloud_error) = serde_json::from_str::<CloudApiError>(&error.body) {
|
||||
if cloud_error.code.starts_with("upstream_http_") {
|
||||
if let Ok(cloud_error) = serde_json::from_str::<CloudApiError>(&error.body)
|
||||
&& cloud_error.code.starts_with("upstream_http_") {
|
||||
let status = if let Some(status) = cloud_error.upstream_status {
|
||||
status
|
||||
} else if cloud_error.code.ends_with("_error") {
|
||||
|
@ -685,7 +683,6 @@ impl From<ApiError> for LanguageModelCompletionError {
|
|||
retry_after: cloud_error.retry_after.map(Duration::from_secs_f64),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let retry_after = None;
|
||||
LanguageModelCompletionError::from_http_status(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue