Encapsulate ChatGPT on the web as a simple API for use in your code.
OpenAI's restrictions on reverse are becoming increasingly strict, and reverse is becoming increasingly difficult, and the APIs of each platform are already very cheap. For example, Groq's Llama 3 API has always been free. I don't recommend that you continue to study such projects. If you particularly need it, you can refer to another project of the author, juchats, and there are more free models to use.
pip3 install git+https://github.com/ultrasev/chatrapper.git Set TOKEN in the environment variable and then call the chat function.
export TOKEN= " eyJhbGci... " Use Rapper in your code:
import os
from chatrapper import Rapper
token = os . environ . get ( "TOKEN" )
rapper = Rapper (
access_token = token
model = "text-davinci-002-render-sha"
)
rapper ( "鲁迅为什么打周树人?" ) Or if you have asynchronous requirements, you can use AsyncRapper . In this case, it is best to have multiple accounts to support it. Under a single account, only one round of conversations can be supported at the same time.
import os
import asyncio
from chatrapper import AsyncRapper
token = os . environ . get ( "TOKEN" )
rapper = AsyncRapper (
access_token = token
model = "text-davinci-002-render-sha"
)
async def main ():
print ( await rapper ( "鲁迅为什么打周树人?" ))
asyncio . run ( main ())Demo: