langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Is Extra.forbid necessary?

Open Yongtae723 opened this issue 2 years ago • 5 comments

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

  1. the part of Extra.forbid at line 58
  2. 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

Yongtae723 avatar Jan 03 '23 09:01 Yongtae723

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

hwchase17 avatar Jan 03 '23 16:01 hwchase17

Hi @hwchase17 thank you for your kind response!

can I handle this issue?

after a fix, I will contact you.

Yongtae723 avatar Jan 04 '23 01:01 Yongtae723

@hwchase17 I have short question.

I notice that you didn't define logger. so can I make 2 pr below?

  1. define logger
  • If you are particular about the logger setup, you may do it. If not, let me do it.
  1. delete the part of Extra.forbid at line 58

Yongtae723 avatar Jan 04 '23 01:01 Yongtae723

@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 avatar Jan 04 '23 05:01 hwchase17

@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 avatar Jan 04 '23 06:01 Yongtae723

@Yongtae723 merged it in!

hwchase17 avatar Jan 04 '23 18:01 hwchase17

Thank you @hwchase17 ! I send the second PR! thank you!

Yongtae

Yongtae723 avatar Jan 05 '23 01:01 Yongtae723

looks great!

hwchase17 avatar Jan 05 '23 02:01 hwchase17

@hwchase17 Thank you for giving me the opportunity to make a contribution.

Yongtae723 avatar Jan 05 '23 02:01 Yongtae723

thank you :)

hwchase17 avatar Jan 05 '23 02:01 hwchase17