In the context of the profile as a whole, the "develojoping-ment" can be seen as a rough draft, for now, even if it may not follow the best approach completely. But this is not a big issue as long as the end result is not greatly affected. This initial section is dedicated to comprehending not only the programs and the code itself, but also, in principle, the underlying platforms and mechanisms of operation. After all, this is the first project, I was just learning and figuring things out. to repeat at my own risk, although mine are few if not none - after this short introduction, I attach all the materials that I have relied on and used. To be honest, there is more info than even needs for beginning, just be patient and attentive, and especially to these particularly helpful sources (libs and step-by-step tutorials).
github.com/openai/openai-quickstart-python
This repository hosts multiple quickstart apps for different OpenAI API endpoints (chat, assistants, etc). Check out the examples
folder to try out different examples and get started using the OpenAI API.
To send your first API request with the OpenAI Python SDK, make sure you have the right dependencies installed and then run the following code:
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
-
If you don’t have Python installed, install it from Python.org.
-
Clone this repository.
-
Navigate into the project directory:
$ cd openai-quickstart-python
-
Create a new virtual environment:
-
macOS:
$ python -m venv venv $ . venv/bin/activate
-
Windows:
> python -m venv venv > .\venv\Scripts\activate
-
-
Install the requirements:
$ pip install -r requirements.txt
-
Make a copy of the example environment variables file:
$ cp .env.example .env
-
Add your API key to the newly created
.env
file. -
Run the app:
This step depends on the app itself. If the code uses flask (like the chat-basic example), you can run:
$ flask run
You should now be able to access the app from your browser at the following URL: http://localhost:5000!
If the code is just a simple Python script, you can run it with:
$ python my_file.py
LICENSE here is similiar with what i got, because i have no idea which one i need.