Created
December 1, 2023 14:30
-
-
Save youtube-jocoding/d3616cfede325122c76af6d029d7ff0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dotenv import load_dotenv | |
import os | |
from openai import OpenAI | |
load_dotenv() | |
API_KEY = os.environ['OPENAI_API_KEY'] | |
client = OpenAI(api_key=API_KEY) | |
#asst_18fIjCf97zSZnQA6HCHATxfh | |
# assistant = client.beta.assistants.create( | |
# name="Math Tutor2", | |
# instructions="You are a personal math tutor. Write and run code to answer math questions.", | |
# tools=[{"type": "code_interpreter"}], | |
# model="gpt-4-1106-preview" | |
# ) | |
# print(assistant) | |
#thread_dOJ8FjRmiUPPKYu831oh9mcp | |
# thread = client.beta.threads.create() | |
# print(thread) | |
#msg_0Ryoi6SRFol9PWpOvwpWER17 | |
# message = client.beta.threads.messages.create( | |
# thread_id="thread_dOJ8FjRmiUPPKYu831oh9mcp", | |
# role="user", | |
# content="I need to solve the equation `3x + 11 = 14`. Can you help me?" | |
# ) | |
# print(message) | |
#run_bOfqXbHLsQVMMQYqFCPw6l0L | |
# run = client.beta.threads.runs.create( | |
# thread_id="thread_dOJ8FjRmiUPPKYu831oh9mcp", | |
# assistant_id="asst_18fIjCf97zSZnQA6HCHATxfh", | |
# instructions="Please address the user as Jane Doe. The user has a premium account." | |
# ) | |
# print(run) | |
# run = client.beta.threads.runs.retrieve( | |
# thread_id="thread_dOJ8FjRmiUPPKYu831oh9mcp", | |
# run_id="run_bOfqXbHLsQVMMQYqFCPw6l0L" | |
# ) | |
# print(run) | |
messages = client.beta.threads.messages.list( | |
thread_id="thread_dOJ8FjRmiUPPKYu831oh9mcp" | |
) | |
print(messages.data[0].content[0].text.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment