Skip to content

Commit

Permalink
by openai migrate - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Mar 23, 2024
1 parent e5014fa commit 9d62550
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion openai_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

DESCRIPTION = f"{ICON} tools for the OpenAI API"

VERSION = "2.246.1"
VERSION = "2.247.1"
10 changes: 6 additions & 4 deletions openai_cli/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
Python package installed and an OpenAI API key set before running this script.
"""

import openai
from openai import OpenAI

from openai_cli.env import OPENAI_API_KEY
from openai_cli.logger import logger

client = OpenAI(api_key=OPENAI_API_KEY)


def chat_with_openai():
openai.api_key = OPENAI_API_KEY

conversation = []
logger.info("ChatGPT: Hello! How can I assist you today?")
Expand All @@ -21,13 +23,13 @@ def chat_with_openai():
user_input = input("> ")
conversation.append(user_input)

response = openai.ChatCompletion.create(
response = client.chat.completions.create(
model="gpt-4.0-turbo",
messages=[{"role": "user", "content": user_input}],
max_tokens=150,
)

answer = response["choices"][0]["message"]["content"].strip()
answer = response.choices[0].message.content.strip()
logger.info(f"ChatGPT: {answer}")

conversation.append(answer)
Expand Down

0 comments on commit 9d62550

Please sign in to comment.