Getting TypeError: OpenAI.__init__() missing 1 required positional argument: 'client' because older version of openai being used #242
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 385
- PR merge metrics
- No merged PRs in 30d
Description
I was trying to implement the code below that was provided in the [documentation](https://maartengr.github.io/KeyBERT/guides/keyllm.html#3-fine-tune-candidate-keywords)
```
import openai
from keybert.llm import OpenAI
from keybert import KeyLLM
# Create your LLM
openai.api_key = "sk-..."
prompt = """
I have the following document:
[DOCUMENT]
With the following candidate keywords:
[CANDIDATES]
Based on the information above, improve the candidate keywords to best describe the topic of the document.
Use the following format separated by commas:
"""
llm = OpenAI(model="gpt-3.5-turbo", prompt=prompt, chat=True)
# Load it in KeyLLM
kw_model = KeyLLM(llm)
# Extract keywords
candidate_keywords = [['website', 'couple of days', 'deliver', 'received'],
['received', 'package'],
['most powerful LLMs',
'limited APIs',
'Meta',
"LLaMA's model weights",
'research community',
'noncommercial license']]
keywords = kw_model.extract_keywords(documents, candidate_keywords=candidate_keywords); keywords
```
when I got the error,
> TypeError Traceback (most recent call last)
> [](https://localhost:8080/#) in ()
> 18
> 19 """
> ---> 20 llm = OpenAI(model="gpt-3.5-turbo", prompt=prompt, chat=True)
> 21
> 22 # Load it in KeyLLM
>
> TypeError: OpenAI.__init__() missing 1 required positional argument: 'client'
Is it because only the older version of Openai is supported?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the KeyBERT KeyLLM documentation example and the OpenAI(model="gpt-3.5-turbo", prompt=prompt, chat=True) entry point shown in the report. Reproduce the TypeError with the documented setup, then determine the supported OpenAI client interface and update the example or compatibility guidance so the documented code works with the supported version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100