mirror of
https://github.com/katanemo/plano.git
synced 2026-05-11 08:42:48 +02:00
replace production panics with graceful error handling in common crate (#844)
This commit is contained in:
parent
36fa42b364
commit
d8f4fd76e3
3 changed files with 9 additions and 4 deletions
|
|
@ -2,7 +2,6 @@ use crate::{
|
||||||
configuration::LlmProvider,
|
configuration::LlmProvider,
|
||||||
consts::{ARCH_FC_MODEL_NAME, ASSISTANT_ROLE},
|
consts::{ARCH_FC_MODEL_NAME, ASSISTANT_ROLE},
|
||||||
};
|
};
|
||||||
use core::{panic, str};
|
|
||||||
use serde::{ser::SerializeMap, Deserialize, Serialize};
|
use serde::{ser::SerializeMap, Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, VecDeque},
|
collections::{HashMap, VecDeque},
|
||||||
|
|
@ -193,7 +192,7 @@ impl Display for ContentType {
|
||||||
// skip image URLs or their data in text representation
|
// skip image URLs or their data in text representation
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
panic!("Unsupported content type: {:?}", part.content_type);
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,10 @@ pub trait Client: Context {
|
||||||
fn add_call_context(&self, id: u32, call_context: Self::CallContext) {
|
fn add_call_context(&self, id: u32, call_context: Self::CallContext) {
|
||||||
let callouts = self.callouts();
|
let callouts = self.callouts();
|
||||||
if callouts.borrow_mut().insert(id, call_context).is_some() {
|
if callouts.borrow_mut().insert(id, call_context).is_some() {
|
||||||
panic!("Duplicate http call with id={}", id);
|
log::warn!(
|
||||||
|
"Duplicate http call with id={}, previous context overwritten",
|
||||||
|
id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.active_http_calls().increment(1);
|
self.active_http_calls().increment(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,10 @@ impl RatelimitMap {
|
||||||
match new_ratelimit_map.datastore.get_mut(&ratelimit_config.model) {
|
match new_ratelimit_map.datastore.get_mut(&ratelimit_config.model) {
|
||||||
Some(limits) => match limits.get_mut(&ratelimit_config.selector) {
|
Some(limits) => match limits.get_mut(&ratelimit_config.selector) {
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
panic!("repeated selector. Selectors per provider must be unique")
|
log::error!(
|
||||||
|
"repeated selector for model '{}'. Selectors per provider must be unique, skipping duplicate",
|
||||||
|
ratelimit_config.model
|
||||||
|
);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
limits.insert(ratelimit_config.selector, limit);
|
limits.insert(ratelimit_config.selector, limit);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue