pub struct ChatbotTurnContext {
pub user_id: Option<Uuid>,
pub course_id: Option<Uuid>,
pub course_name: Option<String>,
pub conversation_id: Option<Uuid>,
pub enabled_tool_categories: EnabledToolCategories,
roles: OnceCell<Vec<Role>>,
}Expand description
Context for a chatbot turn, in two halves:
- who is asking:
user_id,course_id,course_name, and the roles fetched from them. - what the configuration offers:
enabled_tool_categories, read once per request from the same configuration row the turn is assembled from.
Fields§
§user_id: Option<Uuid>§course_id: Option<Uuid>§course_name: Option<String>§conversation_id: Option<Uuid>The conversation this turn belongs to. None only in tests that build a context without
one; every production call site has a conversation id in scope.
enabled_tool_categories: EnabledToolCategories§roles: OnceCell<Vec<Role>>Implementations§
Source§impl ChatbotTurnContext
impl ChatbotTurnContext
Sourcepub fn new(
user_id: Option<Uuid>,
course_id: Option<Uuid>,
course_name: Option<String>,
conversation_id: Uuid,
configuration: &ChatbotConfiguration,
) -> Self
pub fn new( user_id: Option<Uuid>, course_id: Option<Uuid>, course_name: Option<String>, conversation_id: Uuid, configuration: &ChatbotConfiguration, ) -> Self
Collects what a chatbot request needs to know about its caller and about what the chatbot’s configuration offers.
Sourcepub fn turn_resource(&self) -> Resource
pub fn turn_resource(&self) -> Resource
The resource an offer-time check runs against, before any call has named a target: the course this chatbot belongs to, or global permissions for a chatbot that belongs to none.
Sourcepub(crate) async fn roles(
&self,
conn: &mut PgConnection,
) -> ChatbotResult<&[Role]>
pub(crate) async fn roles( &self, conn: &mut PgConnection, ) -> ChatbotResult<&[Role]>
The caller’s roles, fetched the first time an authorization check needs them.
One roles query per request however many authorization checks ask for them, and none at all for a request whose tools need no role.
Auto Trait Implementations§
impl !Freeze for ChatbotTurnContext
impl !RefUnwindSafe for ChatbotTurnContext
impl Send for ChatbotTurnContext
impl Sync for ChatbotTurnContext
impl Unpin for ChatbotTurnContext
impl UnsafeUnpin for ChatbotTurnContext
impl !UnwindSafe for ChatbotTurnContext
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
Mutably borrows from an owned value. Read more
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Decompress response bodies. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more