Home  >  Article  >  Technology peripherals  >  ChatGPT and related open source project experience

ChatGPT and related open source project experience

王林
王林forward
2023-04-13 08:22:021426browse

At the beginning of this month, ChatGPT came out at an alarming rate, causing widespread discussion in the technology circle. Recently, a number of ChatGPT-related open source projects have been born on GitHub. The number is staggering. ChatGPT even dominates most of GitHub Trending. So, what kind of charm does it have that makes many developers so excited? Let’s explore it together.

Registration

Currently, ChatGPT cannot be registered directly in China. Access needs to be through an agent, and you need to use a mobile phone number in other countries to register. For the specific registration method, you can read this article [1 ]

Function Experience

ChatGPT can realize tasks such as intelligent chatting, poetry, writing, programming, bug correction, writing weekly reports, Zhihu Q&A, etc.

For example, I can use it to write

1. Front-end component

Use React hooks to write an echarts component

ChatGPT and related open source project experience

The above code implements basic components, but no sample code is given. We can continue to ask

give an example of options for a line chart

ChatGPT and related open source project experience

2. Optimization Weekly report

Optimize last week’s weekly report to make it richer

ChatGPT and related open source project experience

In the weekly report, not only did they help me optimize the content, but they also helped me arrange my work for next week. , what do you think of the organization of ChatGPT?

The author believes that although it is not perfect, the answers given within the given keywords are already very unexpected.

For more experience, you can explore it by yourself. Let’s take a look at the ChatGPT project on GitHub.

Node.js API interface

Front-end engineers are familiar with Nodejs, and the official website has a nodejs interface

openai

First install openai through npm

npm install openai

Then you can use the following code in any interface

const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: "你好",
max_tokens: 255,
temperature: 0.5,
});

// 打印 API 返回的结果
console.log(response.data.choices[0].text);
  • createCompletion means automatic completion, which is consistent with the official website's reply method;
  • max_tokens The largest tokens The quantity can be understood as the number of characters returned. Most content is within 2048. Of course, max_tokens returns the interface slower.
  • temperature: Between 0-1, the temperature parameter represents the degree of randomness or unpredictability in the generated text. Higher temperature values ​​will produce more creative and varied output, while lower temperature values ​​will produce more predictable and repetitive text.
  • OPENAI_API_KEY can be generated through the View API keys page.

ChatGPT and related open source project experience

chatgpt

The other is a personal development project, which re-encapsulates the API of ChatGPT, making customized development easy. More convenient.

Install chatgpt via npm.

npm install chatgpt
import { ChatGPTAPI } from 'chatgpt'

async function example() {
// sessionToken is required; see below for details
const api = new ChatGPTAPI({
sessionToken: process.env.SESSION_TOKEN
})

// ensure the API is properly authenticated
await api.ensureAuth()

// send a message and wait for the response
const response = await api.sendMessage(
'Write a python version of bubble sort.'
)

// response is a markdown-formatted string
console.log(response)
}

SESSION_TOKEN value needs to be copied through the chome console after logging in to the account.

ChatGPT and related open source project experience

GitHub: https://github.com/transitive-bullshit/chatgpt-api

  • chatgpt simulates the ChatGPT web version, which requires Using node server (generally overseas) and stream, the current attempt cannot be deployed to vercel
  • openai is an officially provided package and can be deployed to the vercel environment, but the return is subject to time limits and word count Limitation, you need to set the max_tokens value smaller, which will lead to incomplete replies.

WeChat Chat Assistant

WeChat GPT

This project is based on wechaty, allowing you to quickly initiate a conversation with ChatGPT through the WeChat chat window.

Before using it, you need to configure OpenAI’s Session Token information and the corresponding “keyword” trigger.

ChatGPT and related open source project experience

Function and Features

ChatGPT and related open source project experience

Access to the public account

GitHub: https://github. com/fuergaosi233/wechat-chatgpt

WeChat Bot

A WeChat bot based on chatgpt wechaty, which can be used to help you automatically reply to WeChat messages, or manage WeChat groups/friends. It is simple, easy to use, and can be played in 2 minutes.

Execute npm install after git cloning the project, modify the env related configuration,

Then modify the relevant logical files according to your needs

ChatGPT and related open source project experience

Modify the configuration

You can scan the QR code to log in

ChatGPT and related open source project experience

Scan the QR code to log in

This is the actual effect:

ChatGPT and related open source project experience

WeChat access demonstration

GitHub: https://github.com/wangrongding/wechat-bot

Browser plug-in

ChatGPT for Google

This plug-in supports Chrome / Edge / Firefox and other browsers.

After installation, in addition to the normal display of Google search content in the browser, ChatGPT feedback results will also be displayed on the right side, which can further improve search efficiency.

ChatGPT and related open source project experience

Search Demo

GitHub: https://github.com/wong2/chat-gpt-google-extension

ChatGPT Chrome Extension

This is a ChatGPT plug-in specially developed for Chrome users.

After installation, right-click in the text box on any page to pop up the "Ask ChatGPT" option.

ChatGPT will search based on the content in the current text box. This extension also includes a plugin system that provides greater control over the behavior of ChatGPT and the ability to interact with third-party APIs.

ChatGPT and related open source project experience

Plugin Demo

GitHub: https://github.com/gragland/chatgpt-chrome-extension

Grease Monkey Script

Will Baoge from Taiwan can turn ChatGPT into your voice assistant, realizing voice input and automatic reading functions. Let us say goodbye to typing mode through the Web Speech API that comes with the browser.

He has a video explanation at Station B [2], you can watch it, it is very interesting.

GitHub: https://github.com/doggy8088/TampermonkeyUserscripts

ChatGPT and related open source project experience

Reverse Engineering

Any project that makes engineers full of curiosity , cannot escape reversal, and ChatGPT is no exception in this regard.

Antonio Cheong, a developer from Malaysia on GitHub, reversed ChatGPT not long after its release and successfully extracted the API.

With these APIs, we can develop a fun chatbot, AI intelligent assistant, code assistance tool and other applications by ourselves.

ChatGPT and related open source project experience

GitHub: https://github.com/acheong08/ChatGPT

Mac software

is customized for Mac users A small tool: ChatGPT for desktop, supports M1 and Mac Intel. After installation, you can quickly launch ChatGPT in the system menu bar through the Cmd Shift G shortcut key.

ChatGPT and related open source project experience

GitHub: https://github.com/vincelwt/chatgpt-mac

Finally

For front-end engineers, we You can use the API to integrate ChatGPT into your own application, so it is necessary to understand nodejs and docker related knowledge.

Its advantage is that its language organization ability is very strong and it can be combined with context. But the answers it gives are not necessarily correct, and sometimes they are even wrong

As the official website says, it cannot be searched through the Internet.

Limited knowledge of world and events after 2021

There is limited knowledge about what will be gained after 2021. We can use it to strengthen our search capabilities. It is up to us to decide whether to adopt the answer.

The above is the entire content of this article. If it is helpful to you, you can give it a like. This is really important to me. I hope this article will be helpful to everyone. You can also refer to my previous articles. Or share your thoughts and experiences in the comment area. Welcome to explore the front end together.

[1]OpenAI launches the super powerful ChatGPT registration guide: https://juejin.cn/post/7173447848292253704

[2]ChatGPT Voice Monkey Script: https://www .bilibili.com/video/BV12P411K7gc/?vd_source=93efb77f3c9b0f1580f0a8d631b74ce2

The above is the detailed content of ChatGPT and related open source project experience. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete