Skip to main content

a ChatGPT API,no web ui

Project description

ChatGPT

a ChatGPT api,no web ui

一个不怎么使用网页的ChatGPT api PyPi

安装/Install

Ubuntu & Windows

pip install ChatGPTWeb

sudo playwright install-deps

playwright install firefox

MsgData() 数据类型

class MsgData(): 
    status: bool = False,
    msg_type: typing.Optional[typing.Literal["old_session","back_loop","new_session"]] = "new_session",
    msg_send: str = "hi",
    # your msg 
    msg_recv: str = "",
    # gpt's msg
    conversation_id: str = "",
    p_msg_id: str = "",
    # p_msg_id : the message's parent_message_id in this conversation id / 这个会话里某条消息的 parent_message_id
    next_msg_id: str = "",
    post_data: str = ""


from ChatGPTWeb.config import MsgData
data:MsgData = MsgData(conversation_id=c_id,p_msg_id=p_id)

使用/Used

just simple to use

简单使用

copy main.py or this code to start / 复制 main.py 或者以下code来开始

from ChatGPTWeb.ChatGPTWeb import chatgpt
from ChatGPTWeb.config import MsgData
import asyncio
import aioconsole

session_token=""
person = "hello,my name is 'pig'."
chat = chatgpt(session_token=session_token,personality=person,log_status=False)

async def main():
    
    c_id = await aioconsole.ainput("your conversation_id if you have:")
    p_id = await aioconsole.ainput("your parent_message_id if you have:")
    data:MsgData = MsgData(conversation_id=c_id,p_msg_id=p_id)
    while 1:
        print("\n------------------------------")
        data.msg_send = await aioconsole.ainput("input:")
        print("------------------------------\n")
        if data.msg_send == "quit":
            break
        elif data.msg_send == "re":
            data.msg_type = "back_loop"
            data.p_msg_id = await aioconsole.ainput("your parent_message_id if you go back:")
        elif data.msg_send == "reset":
            data = await chat.back_init_personality(data)
            print(f"ChatGPT:{data.msg_recv}")
            continue
        elif data.msg_send == "init_personality":
            data = await chat.init_personality(data)
            print(f"ChatGPT:{data.msg_recv}")
            continue
        elif data.msg_send == "history":
            print(await chat.show_chat_history(data))
            continue
        data = await chat.continue_chat(data)
        print(f"ChatGPT:{data.msg_recv}")
        
        
loop = asyncio.get_event_loop()
loop.run_until_complete(main())           
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ChatGPTWeb-0.0.4.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ChatGPTWeb-0.0.4-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file ChatGPTWeb-0.0.4.tar.gz.

File metadata

  • Download URL: ChatGPTWeb-0.0.4.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ChatGPTWeb-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b9e0b3b23b4e121a988fc3de7180d518532d9754bd89bcf93d7aa49cf1ca9666
MD5 d43b58bde27082685e80485443fce6f0
BLAKE2b-256 941479f97c2205f62c7434d56f7cec536457125824a23f2141ebfb675c340260

See more details on using hashes here.

File details

Details for the file ChatGPTWeb-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ChatGPTWeb-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ChatGPTWeb-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 60583ef9622389f7e42ccb5317e261a7359fb6e5d5a26886cd25e914bfb4426b
MD5 9fefea8f53b5d731d708c1549d36cec0
BLAKE2b-256 6eb1f6ad7132f007e5b261c3650c8ec66d1c6b97d02f923a9cc3b68b8b32ecaa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page