pub struct LLMResult {
pub content: String,
pub model: String,
pub token_usage: Option<TokenUsage>,
}Expand description
LLM 结果
Fields§
§content: String生成的内容
model: String模型名称
token_usage: Option<TokenUsage>Token 使用情况
Trait Implementations§
Source§impl BaseLanguageModel<Vec<Message>, LLMResult> for OpenAIChat
impl BaseLanguageModel<Vec<Message>, LLMResult> for OpenAIChat
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
获取模型名称
Source§fn temperature(&self) -> Option<f32>
fn temperature(&self) -> Option<f32>
获取温度参数
Source§fn max_tokens(&self) -> Option<usize>
fn max_tokens(&self) -> Option<usize>
获取最大 token 数
Source§fn with_temperature(self, temp: f32) -> Self
fn with_temperature(self, temp: f32) -> Self
设置温度参数
Source§fn with_max_tokens(self, max: usize) -> Self
fn with_max_tokens(self, max: usize) -> Self
设置最大 token 数
Source§impl Runnable<Vec<Message>, LLMResult> for OpenAIChat
impl Runnable<Vec<Message>, LLMResult> for OpenAIChat
Source§type Error = OpenAIError
type Error = OpenAIError
错误类型
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Vec<Message>,
_config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Vec<Message>,
_config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
将单个输入转换为输出 Read more
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
_input: Vec<Message>,
_config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LLMResult, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
_input: Vec<Message>,
_config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LLMResult, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
流式输出 - 用于流式响应 (LLM 等) Read more
Auto Trait Implementations§
impl Freeze for LLMResult
impl RefUnwindSafe for LLMResult
impl Send for LLMResult
impl Sync for LLMResult
impl Unpin for LLMResult
impl UnsafeUnpin for LLMResult
impl UnwindSafe for LLMResult
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