mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
add logger (#529)
As talking #519, I made 2 PRs. this is the first PR for adding a logger. I am concerned about the following two points and would appreciate your opinion. 1. Since the logger is not formatted, the statement itself is output like a print statement, and I thought it was difficult to understand that it was a warning, so I put WARNING! at the beginning of the warning statement. After the logger formatting is done properly, the word WARNING can be repeated. 2. Statement `Please confirm that {field_name} is what you intended.` can be replaced like `If {field_name} is intended parameters, enter it to model_kwargs` thank you! Yongtae
This commit is contained in:
parent
020e73017b
commit
4b7b8229de
@ -1,4 +1,5 @@
|
|||||||
"""Wrapper around OpenAI APIs."""
|
"""Wrapper around OpenAI APIs."""
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Dict, Generator, List, Mapping, Optional, Tuple, Union
|
from typing import Any, Dict, Generator, List, Mapping, Optional, Tuple, Union
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ from langchain.llms.base import BaseLLM
|
|||||||
from langchain.schema import Generation, LLMResult
|
from langchain.schema import Generation, LLMResult
|
||||||
from langchain.utils import get_from_dict_or_env
|
from langchain.utils import get_from_dict_or_env
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BaseOpenAI(BaseLLM, BaseModel):
|
class BaseOpenAI(BaseLLM, BaseModel):
|
||||||
"""Wrapper around OpenAI large language models.
|
"""Wrapper around OpenAI large language models.
|
||||||
@ -67,6 +70,11 @@ class BaseOpenAI(BaseLLM, BaseModel):
|
|||||||
if field_name not in all_required_field_names:
|
if field_name not in all_required_field_names:
|
||||||
if field_name in extra:
|
if field_name in extra:
|
||||||
raise ValueError(f"Found {field_name} supplied twice.")
|
raise ValueError(f"Found {field_name} supplied twice.")
|
||||||
|
logger.warning(
|
||||||
|
f"""WARNING! {field_name} is not default parameter.
|
||||||
|
{field_name} was transfered to model_kwargs.
|
||||||
|
Please confirm that {field_name} is what you intended."""
|
||||||
|
)
|
||||||
extra[field_name] = values.pop(field_name)
|
extra[field_name] = values.pop(field_name)
|
||||||
values["model_kwargs"] = extra
|
values["model_kwargs"] = extra
|
||||||
return values
|
return values
|
||||||
|
Loading…
Reference in New Issue
Block a user