Skip to content

Commit

Permalink
fix(openai): changed openai api response parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaferrario committed Mar 13, 2024
1 parent dcf31dd commit ad85c14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keybert/llm/_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ def extract_keywords(self, documents: List[str], candidate_keywords: List[List[s
response = chat_completions_with_backoff(self.client, **kwargs)
else:
response = self.client.chat.completions.create(**kwargs)
keywords = response.choices[0].message.content.strip()
keywords = response.choices[0].text.strip()

# Use a non-chat model
else:
if self.exponential_backoff:
response = completions_with_backoff(self.client, model=self.model, prompt=prompt, **self.generator_kwargs)
else:
response = self.client.completions.create(model=self.model, prompt=prompt, **self.generator_kwargs)
keywords = response.choices[0].message.content.strip()
keywords = response.choices[0].text.strip()
keywords = [keyword.strip() for keyword in keywords.split(",")]
all_keywords.append(keywords)

Expand Down

0 comments on commit ad85c14

Please sign in to comment.