pub struct LLMApiCall {Show 24 fields
pub id: Uuid,
pub chat_session_id: Uuid,
pub agent_id: Uuid,
pub user_id: Uuid,
pub tenant_id: Uuid,
pub request_message_id: Uuid,
pub response_message_id: Uuid,
pub model_name: String,
pub prompt_tokens: i32,
pub prompt_tokens_details: Option<TokenDetails>,
pub completion_tokens: i32,
pub completion_tokens_details: Option<TokenDetails>,
pub total_tokens: i32,
pub total_price: Option<f64>,
pub price_details: Option<PriceDetails>,
pub latency_ms: Option<i32>,
pub time_to_first_token_ms: Option<i32>,
pub tokens_per_second: Option<f64>,
pub api_response_id: Option<String>,
pub status: ApiCallStatus,
pub error_message: Option<String>,
pub error_code: Option<String>,
pub create_time: DateTime<Utc>,
pub update_time: DateTime<Utc>,
}Expand description
LLM API 调用记录实体
对应 entity_llm_api_call 表
Fields§
§id: Uuid记录 ID
chat_session_id: Uuid会话 ID
agent_id: UuidAgent ID
user_id: Uuid用户 ID
tenant_id: Uuid§request_message_id: Uuid请求消息 ID
response_message_id: Uuid响应消息 ID
model_name: String模型名称
prompt_tokens: i32提示词 tokens
prompt_tokens_details: Option<TokenDetails>提示词 tokens 详情
completion_tokens: i32补全 tokens
completion_tokens_details: Option<TokenDetails>补全 tokens 详情
total_tokens: i32总 tokens
total_price: Option<f64>总价格
price_details: Option<PriceDetails>价格详情
latency_ms: Option<i32>延迟 (毫秒)
time_to_first_token_ms: Option<i32>首 token 时间 (毫秒)
tokens_per_second: Option<f64>tokens/秒
api_response_id: Option<String>API 响应 ID
status: ApiCallStatus调用状态
error_message: Option<String>错误消息
error_code: Option<String>错误代码
create_time: DateTime<Utc>创建时间
update_time: DateTime<Utc>更新时间
Implementations§
Source§impl LLMApiCall
impl LLMApiCall
Sourcepub fn success(
chat_session_id: Uuid,
agent_id: Uuid,
user_id: Uuid,
tenant_id: Uuid,
request_message_id: Uuid,
response_message_id: Uuid,
model_name: impl Into<String>,
prompt_tokens: i32,
completion_tokens: i32,
request_time: DateTime<Utc>,
response_time: DateTime<Utc>,
) -> LLMApiCall
pub fn success( chat_session_id: Uuid, agent_id: Uuid, user_id: Uuid, tenant_id: Uuid, request_message_id: Uuid, response_message_id: Uuid, model_name: impl Into<String>, prompt_tokens: i32, completion_tokens: i32, request_time: DateTime<Utc>, response_time: DateTime<Utc>, ) -> LLMApiCall
创建成功的 API 调用记录
Sourcepub fn failed(
chat_session_id: Uuid,
agent_id: Uuid,
user_id: Uuid,
tenant_id: Uuid,
request_message_id: Uuid,
model_name: impl Into<String>,
error_message: impl Into<String>,
error_code: Option<String>,
request_time: DateTime<Utc>,
) -> LLMApiCall
pub fn failed( chat_session_id: Uuid, agent_id: Uuid, user_id: Uuid, tenant_id: Uuid, request_message_id: Uuid, model_name: impl Into<String>, error_message: impl Into<String>, error_code: Option<String>, request_time: DateTime<Utc>, ) -> LLMApiCall
创建失败的 API 调用记录
Sourcepub fn with_api_response_id(self, id: impl Into<String>) -> LLMApiCall
pub fn with_api_response_id(self, id: impl Into<String>) -> LLMApiCall
设置 API 响应 ID
Sourcepub fn with_price(
self,
total_price: f64,
details: Option<PriceDetails>,
) -> LLMApiCall
pub fn with_price( self, total_price: f64, details: Option<PriceDetails>, ) -> LLMApiCall
设置价格信息
Sourcepub fn with_time_to_first_token(self, ttft_ms: i32) -> LLMApiCall
pub fn with_time_to_first_token(self, ttft_ms: i32) -> LLMApiCall
设置首 token 时间
Sourcepub fn with_token_details(
self,
prompt_details: Option<TokenDetails>,
completion_details: Option<TokenDetails>,
) -> LLMApiCall
pub fn with_token_details( self, prompt_details: Option<TokenDetails>, completion_details: Option<TokenDetails>, ) -> LLMApiCall
设置 token 详情
Trait Implementations§
Source§impl Clone for LLMApiCall
impl Clone for LLMApiCall
Source§fn clone(&self) -> LLMApiCall
fn clone(&self) -> LLMApiCall
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LLMApiCall
impl Debug for LLMApiCall
Source§impl<'de> Deserialize<'de> for LLMApiCall
impl<'de> Deserialize<'de> for LLMApiCall
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LLMApiCall, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LLMApiCall, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for LLMApiCall
impl Serialize for LLMApiCall
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for LLMApiCall
impl RefUnwindSafe for LLMApiCall
impl Send for LLMApiCall
impl Sync for LLMApiCall
impl Unpin for LLMApiCall
impl UnsafeUnpin for LLMApiCall
impl UnwindSafe for LLMApiCall
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage