mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix(rust): preserve OCR callback headers
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
ab27ee7efc
commit
dd2e6c17bc
2 changed files with 13 additions and 2 deletions
|
|
@ -44,6 +44,7 @@ pub struct LegacyLogging {
|
|||
response: Option<Py<PyAny>>,
|
||||
error: Option<Py<PyBaseException>>,
|
||||
body: Option<Py<PyDict>>,
|
||||
headers: Option<Py<PyDict>>,
|
||||
context: Option<RequestContext>,
|
||||
asynchronous: bool,
|
||||
internal: bool,
|
||||
|
|
@ -77,6 +78,7 @@ impl LegacyLogging {
|
|||
response: None,
|
||||
error: None,
|
||||
body: None,
|
||||
headers: None,
|
||||
context: None,
|
||||
asynchronous,
|
||||
internal: false,
|
||||
|
|
@ -245,6 +247,7 @@ impl PythonLifecycle for LegacyLogging {
|
|||
headers.set_item(name, value)?;
|
||||
}
|
||||
self.body = Some(body.clone().unbind());
|
||||
self.headers = Some(headers.clone().unbind());
|
||||
self.context = Some(context.clone());
|
||||
self.logger()?.pre_call(
|
||||
py,
|
||||
|
|
@ -299,8 +302,13 @@ impl PythonLifecycle for LegacyLogging {
|
|||
.as_ref()
|
||||
.and_then(|context| context.api_key.as_ref())
|
||||
.map(|api_key| api_key.expose());
|
||||
self.logger()?
|
||||
.post_call(py, &raw.body, api_key, self.body.as_ref())?;
|
||||
self.logger()?.post_call(
|
||||
py,
|
||||
&raw.body,
|
||||
api_key,
|
||||
self.body.as_ref(),
|
||||
self.headers.as_ref(),
|
||||
)?;
|
||||
Ok(LifecycleStep::Done)
|
||||
}
|
||||
(CallEvent::Succeeded { timing }, Some(PublicValue::Response(response))) => {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ pub trait LegacyCallbacks {
|
|||
original_response: &str,
|
||||
api_key: Option<&str>,
|
||||
body: Option<&Py<PyDict>>,
|
||||
headers: Option<&Py<PyDict>>,
|
||||
) -> PyResult<()>;
|
||||
|
||||
fn defers_async_logging(&self, py: Python<'_>) -> bool;
|
||||
|
|
@ -150,9 +151,11 @@ impl LegacyCallbacks for PythonLogger {
|
|||
original_response: &str,
|
||||
api_key: Option<&str>,
|
||||
body: Option<&Py<PyDict>>,
|
||||
headers: Option<&Py<PyDict>>,
|
||||
) -> PyResult<()> {
|
||||
let additional = PyDict::new(py);
|
||||
additional.set_item("complete_input_dict", body)?;
|
||||
additional.set_item("headers", headers)?;
|
||||
Logging::PostCall.call(
|
||||
py,
|
||||
(self.object(py), original_response, api_key, &additional),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue