_Ref-LLM-Predictor:
LLMPredictor
我们的LLMPredictor是Langchain的`LLMChain`的一个包装器,可以轻松集成到LlamaIndex中。
Wrapper functions around an LLM chain.
我们的MockLLMPredictor用于令牌预测。有关更多信息,请参阅`成本分析How-To <../../how_to/analysis/cost_analysis.html>`_。
Mock chain wrapper.
- class llama_index.token_counter.mock_chain_wrapper.MockLLMPredictor(max_tokens: int = 256, llm: Optional[BaseLLM] = None)
Mock LLM Predictor.
- async apredict(prompt: Prompt, **prompt_args: Any) Tuple[str, str]
Async predict the answer to a query.
- 参数
prompt (Prompt) -- Prompt to use for prediction.
- 返回
Tuple of the predicted answer and the formatted prompt.
- 返回类型
Tuple[str, str]
- get_llm_metadata() LLMMetadata
Get LLM metadata.
- property last_token_usage: int
Get the last token usage.
- property llm: BaseLanguageModel
Get LLM.
- predict(prompt: Prompt, **prompt_args: Any) Tuple[str, str]
Predict the answer to a query.
- 参数
prompt (Prompt) -- Prompt to use for prediction.
- 返回
Tuple of the predicted answer and the formatted prompt.
- 返回类型
Tuple[str, str]
- stream(prompt: Prompt, **prompt_args: Any) Tuple[Generator, str]
Stream the answer to a query.
NOTE: this is a beta feature. Will try to build or use better abstractions about response handling.
- 参数
prompt (Prompt) -- Prompt to use for prediction.
- 返回
The predicted answer.
- 返回类型
str
- property total_tokens_used: int
Get the total tokens used so far.