pub struct ContextLengthExceeded {
pub message: String,
}Expand description
The request’s prompt does not fit the model’s context. A ChatGenerator returns it (as the
anyhow error) so the server can answer 400 with OpenAI’s context_length_exceeded code:
OpenAI clients retry a 5xx unchanged, but treat this code as final and shorten the
conversation instead.
Fields§
§message: StringWhat the client is told: which counts did not fit.
Implementations§
Source§impl ContextLengthExceeded
impl ContextLengthExceeded
Sourcepub fn prompt_too_long(
input: &str,
context_length: usize,
prompt_tokens: usize,
) -> Self
pub fn prompt_too_long( input: &str, context_length: usize, prompt_tokens: usize, ) -> Self
A prompt of prompt_tokens that is longer than context_length, in OpenAI’s own wording
(client-side error mappers match on it). input names the request field the prompt came
from: messages on the chat route, prompt on /v1/completions.
Sourcepub fn reply_too_long(
input: &str,
context_length: usize,
prompt_tokens: usize,
reply_tokens: usize,
can_lower_reply: bool,
) -> Self
pub fn reply_too_long( input: &str, context_length: usize, prompt_tokens: usize, reply_tokens: usize, can_lower_reply: bool, ) -> Self
A prompt of prompt_tokens that fits, but not with the reply_tokens the reply was given
room for, in the same wording. Lowering the reply budget is suggested only when
can_lower_reply: a budget the client never chose, or one of zero, is nothing it can
lower. input is as for Self::prompt_too_long.
Trait Implementations§
Source§impl Clone for ContextLengthExceeded
impl Clone for ContextLengthExceeded
Source§impl Debug for ContextLengthExceeded
impl Debug for ContextLengthExceeded
Source§impl Display for ContextLengthExceeded
impl Display for ContextLengthExceeded
impl Eq for ContextLengthExceeded
Source§impl Error for ContextLengthExceeded
impl Error for ContextLengthExceeded
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for ContextLengthExceeded
impl PartialEq for ContextLengthExceeded
impl StructuralPartialEq for ContextLengthExceeded
Auto Trait Implementations§
impl Forget for ContextLengthExceeded
impl Freeze for ContextLengthExceeded
impl Move for ContextLengthExceeded
impl RefUnwindSafe for ContextLengthExceeded
impl Send for ContextLengthExceededwhere
RawVecInner: Send,
impl Sync for ContextLengthExceededwhere
RawVecInner: Sync,
impl Unpin for ContextLengthExceeded
impl UnsafeUnpin for ContextLengthExceeded
impl UnwindSafe for ContextLengthExceededwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more