langchain
langchain copied to clipboard
Is Extra.forbid necessary?
Hello!
First of all, thank you for opening such an excellent code! I am truly excited and want to contribute somehow.
Now I try to read codes regarding openai.py and found that Extra.forbid at here.
However, I can initialize it like the code below.
OpenAI(temperatures=0, hey = "hey", hello = "how are you?")
The reason is OpenAI class sets all extras inputs as model_args at here
I assume this validation was added to accommodate future changes in the GPT API parameter, but I think it is likely to cause confusion for the reader.
Therefore my suggestion is simply to delete one of the following part
- the part of
Extra.forbidat line 58 - Or delete the validation part, which starts from line 60, and add a document like
if you want to set more parameter of GPT API, please add parameter in model_args.
please tell me how you feel about my suggestion.
thank you. Yongtae
good point. you are correct in all your assumptions.
i think in order to provide flexiblity for the user, id prefer to do suggestion 1. maybe at the same time, we can add a logger.warning when extra model_args are provided?
did you want to take a stab at this? if not, im happy to - lmk
Hi @hwchase17 thank you for your kind response!
can I handle this issue?
after a fix, I will contact you.
@hwchase17 I have short question.
I notice that you didn't define logger. so can I make 2 pr below?
- define logger
- If you are particular about the logger setup, you may do it. If not, let me do it.
- delete the part of Extra.forbid at line 58
@Yongtae723 that sounds good for me
for logger, lets just use the default python logger, eg
import logging
logger = logging.getLogger(__name__)
....
logger.warning(..)
@hwchase17 I Created PR for adding a logger. If this PR is merged, I will make a new pr for removing Extra into main.
Thank you.
@Yongtae723 merged it in!
Thank you @hwchase17 ! I send the second PR! thank you!
Yongtae
looks great!
@hwchase17 Thank you for giving me the opportunity to make a contribution.
thank you :)