Skip to content

Commit

Permalink
Merge pull request #268 from VesnaT/openai_version
Browse files Browse the repository at this point in the history
GPT: Migrate to newest API
  • Loading branch information
ajdapretnar committed Dec 8, 2023
2 parents 762a918 + 1734e75 commit 0414873
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions orangecontrib/prototypes/widgets/owchatgptbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def run_gpt(
prompt_start: str,
prompt_end: str
) -> str:
openai.api_key = api_key
client = openai.OpenAI(api_key=api_key)
enc = tiktoken.encoding_for_model(model)

text = enc.decode(enc.encode(text)[:3500])
content = f"{prompt_start}\n{text}.\n{prompt_end}"
response = openai.ChatCompletion.create(
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def include_documentation(local_dir, install_dir):
'pyqtgraph',
'AnyQt>=0.1.0',
'pandas>=1.3.0',
'openai',
'openai>=1',
'tiktoken',
],
extras_require={
Expand Down

0 comments on commit 0414873

Please sign in to comment.