lida icon indicating copy to clipboard operation
lida copied to clipboard

OpenAITextGenerator.__init__() got an unexpected keyword argument 'api_base'

Open pxzbest opened this issue 1 year ago • 4 comments

When I use an OpenAI Compatible Endpoint, I get an error 'OpenAITextGenerator.init() got an unexpected keyword argument 'api_base'' How should I handle this error {1F9E54EF-7A6A-473e-99CD-AC64397471BB}

pxzbest avatar Jun 08 '24 07:06 pxzbest

I am also getting the same error . I checked there code 'api_base' have been removed from the class OpenAITextGenerator(TextGenerator)

vishaljeet828 avatar Jul 08 '24 13:07 vishaljeet828

It was removed, yet the README.md file shows the api_base as a usable option. I think it should be removed from the README.md file as well.

benayat avatar Sep 28 '24 07:09 benayat

Same error trying to use offline model (LM Studio at http://localhost:1234). Two workarounds:

Really Bad Way: Edit OpenAI class definition (_client.py) to change base_url default value FROM base_url = f"https://api.openai.com/v1" TO base_url = f"http://localhost:1234/v1"

Less Bad Way: Edit OpenAITextGenerator class definition (openai_textgen.py) as follows:

In def init() ADD base_url: str = None, In self.client_args ={} ADD "base_url": base_url,

The Really Bad Way got past the initial error but created new problems. The Less Bad Way worked with no errors. I am not a professional and welcome feedback/instruction on how to craft a more appropriate comment.

ghucaduk avatar Nov 13 '24 19:11 ghucaduk

I had a similar problem. I solved it by exporting the OPENAI_BASE_URL environment variable with my local environment, like this:

export OPENAI_BASE_URL="http://localhost:11434/v1"

This allows the openai Python library to automatically use the local endpoint. Hope this helps others!

jeanboy44 avatar Aug 28 '25 05:08 jeanboy44