langchain.callbacks.llmonitor_callback.LLMonitorCallbackHandler¶
class langchain.callbacks.llmonitor_callback.LLMonitorCallbackHandler(app_id: Optional[str] = None, api_url: Optional[str] = None, verbose: bool = False)[source]¶
Initializes the LLMonitorCallbackHandler.
#### Parameters:
app_id: The app id of the app you want to report to. Defaults to
None, which means that LLMONITOR_APP_ID will be used.
- api_url: The url of the LLMonitor API. Defaults to None,
which means that either LLMONITOR_API_URL environment variable
or https://app.llmonitor.com will be used.
#### Raises:
ValueError: if app_id is not provided either as an
argument or as an environment variable.
- ConnectionError: if the connection to the API fails.
#### Example:
```python
from langchain.llms import OpenAI
from langchain.callbacks import LLMonitorCallbackHandler
llmonitor_callback = LLMonitorCallbackHandler()
llm = OpenAI(callbacks=[llmonitor_callback],
metadata={“userId”: “user-123”})
llm.predict(“Hello, how are you?”)
```
Attributes
ignore_agent
Whether to ignore agent callbacks.
ignore_chain
Whether to ignore chain callbacks.
ignore_chat_model
Whether to ignore chat model callbacks.
ignore_llm
Whether to ignore LLM callbacks.
ignore_retriever
Whether to ignore retriever callbacks.
ignore_retry
Whether to ignore retry callbacks.
raise_error
run_inline
Methods
__init__([app_id, api_url, verbose])
on_agent_action(action, *, run_id[, ...])
Run on agent action.
on_agent_finish(finish, *, run_id[, ...])
Run on agent end.