KeyLLM error: AttributeError: 'str' object has no attribute 'completions'
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 385
- PR merge metrics
- No merged PRs in 30d
Description
I was trying to run the following code from your GitHub but got the following error:
import openai
from keybert.llm import OpenAI
from keybert import KeyLLM
from sentence_transformers import SentenceTransformer
# Extract embeddings
model = SentenceTransformer('all-MiniLM-L6-v2')
embeddings = model.encode(documents, convert_to_tensor=True)
# Create your LLM
openai.api_key = "sk..."#
llm = OpenAI(openai.api_key)
# Load it in KeyLLM
kw_model = KeyLLM(llm)
# Extract keywords
keywords = kw_model.extract_keywords(documents, embeddings=embeddings, threshold=.75)
AttributeError: 'str' object has no attribute 'completions'
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the OpenAI(...) initialization and KeyLLM usage shown in the report, then reproduce the AttributeError with the supplied example. Compare the expected OpenAI client interface with the version used by KeyBERT, and consider the issue complete when the example runs without this error or the supported usage is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100