GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - wzpan/ChatGPT-python-example: 演示如何使用4行代码调用ChatGPT的官方API

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bot.py
bot.py
 
 

Repository files navigation

ChatGPT-python-example

演示如何使用 4 行代码调用 ChatGPT 的官方API。要求 Python 版本 > 3.6 。

1. 安装依赖

pip3 install openai

2. 执行demo

python3 bot.py

3. 修改对话内容

修改第 4 行代码里的 content 参数即可。例如:

completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", \
                                       messages=[{"role": "user", "content": "请使用 Python 实现一个二分查找算法"}])

4. 切换模型(可选)

通过修改第 4 行代码里的 model 参数即可指定模型。可选的模型详见 models 。

About

演示如何使用4行代码调用ChatGPT的官方API

Topics

chatgptchatgpt-apichatgpt-python

Resources

Readme
MIT license
Activity

Stars

25 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.