Python
ChatGPT run by python
First install openai module
$ pip install --upgrade openai
Collecting openai
Downloading openai-0.27.1.tar.gz (57 kB)
|████████████████████████████████| 57 kB 395 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
1 import openai
Installing backend dependencies ... done
Preparing wheel metadata ... done
Collecting aiohttp
Downloading aiohttp-3.8.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB)
|████████████████████████████████| 1.0 MB 7.6 MB/s
<snipped>
Second Deploy code by simple cat
cat <<EOF > openai-question.py
import openai
openai.api_key = "sk-키는 바꾸셔야 합니다"
question = input('openai에 질문 : ')
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": f"{question}"}])
print(completion.choices[0].message.content)
EOF
Third get a secret key from openai and change at "sk-키는 바꾸셔야 합니다" item.
Fouth run openai-question.py
$ python3 openai-question.py openai에 질문 : What is Kubernetes
Kubernetes is a powerful container orchestration tool that automates the deployment, scaling, and management of containerized applications running in cloud environments. It allows developers to easily manage and scale their applications by automating many of the tedious and repetitive tasks associated with deploying and managing containers. With Kubernetes, developers can focus on developing their applications while the system takes care of tasks like load balancing, scaling, and scheduling. Kubernetes is open source and widely used in cloud-native application development.
Enjoy it :)
Last updated