LLMPredictorο
Our LLMPredictor is a wrapper around Langchainβs LLMChain that allows easy integration into LlamaIndex.
Wrapper functions around an LLM chain.
Our MockLLMPredictor is used for token prediction. See Cost Analysis How-To for more information.
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.
- Parameters
prompt (Prompt) β Prompt to use for prediction.
- Returns
Tuple of the predicted answer and the formatted prompt.
- Return type
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.
- Parameters
prompt (Prompt) β Prompt to use for prediction.
- Returns
Tuple of the predicted answer and the formatted prompt.
- Return type
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.
- Parameters
prompt (Prompt) β Prompt to use for prediction.
- Returns
The predicted answer.
- Return type
str
- property total_tokens_used: intο
Get the total tokens used so far.