mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-05 14:43:08 +00:00
Change multiline comment width
This commit is contained in:
parent
7979cef06a
commit
e71f4760db
@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Dict, List, Literal, Optional, Union
|
from typing import Any, Dict, List, Literal, Union
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -36,11 +36,15 @@ def _serialize_lc_message(message: BaseMessage) -> Dict[str, Any]:
|
|||||||
class LLMonitorCallbackHandler(BaseCallbackHandler):
|
class LLMonitorCallbackHandler(BaseCallbackHandler):
|
||||||
"""Initializes the `LLMonitorCallbackHandler`.
|
"""Initializes the `LLMonitorCallbackHandler`.
|
||||||
#### Parameters:
|
#### 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.
|
- `app_id`: The app id of the app you want to report to. Defaults to
|
||||||
- `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.
|
`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:
|
#### Raises:
|
||||||
- `ValueError`: if `app_id` is not provided either as an argument or as an environment variable.
|
- `ValueError`: if `app_id` is not provided either as an
|
||||||
|
argument or as an environment variable.
|
||||||
- `ConnectionError`: if the connection to the API fails.
|
- `ConnectionError`: if the connection to the API fails.
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +54,8 @@ class LLMonitorCallbackHandler(BaseCallbackHandler):
|
|||||||
from langchain.callbacks import LLMonitorCallbackHandler
|
from langchain.callbacks import LLMonitorCallbackHandler
|
||||||
|
|
||||||
llmonitor_callback = LLMonitorCallbackHandler()
|
llmonitor_callback = LLMonitorCallbackHandler()
|
||||||
llm = OpenAI(callbacks=[llmonitor_callback], metadata={"userId": "user-123"})
|
llm = OpenAI(callbacks=[llmonitor_callback],
|
||||||
|
metadata={"userId": "user-123"})
|
||||||
llm.predict("Hello, how are you?")
|
llm.predict("Hello, how are you?")
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
@ -68,7 +73,8 @@ class LLMonitorCallbackHandler(BaseCallbackHandler):
|
|||||||
_app_id = app_id or os.getenv("LLMONITOR_APP_ID")
|
_app_id = app_id or os.getenv("LLMONITOR_APP_ID")
|
||||||
if _app_id is None:
|
if _app_id is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"app_id must be provided either as an argument or as an environment variable"
|
"""app_id must be provided either as an argument or as
|
||||||
|
an environment variable"""
|
||||||
)
|
)
|
||||||
self.__app_id = _app_id
|
self.__app_id = _app_id
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user