Skip to main content

a ChatGPT API,no web ui

Project description

ChatGPT

ChatGPT api,not openai api,no web ui

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

待填坑

  • 网页api对话构成
  • 多人格预设与切换
  • 聊天记录存储与导出
  • 自定义人设
  • 重置聊天或回到某一时刻
  • 多账号并发
  • GPT4
  • 代码过于混乱等优化
  • 抽空完善readme

安装/Install

Ubuntu & Windows

pip install ChatGPTWeb

sudo playwright install-deps

playwright install firefox

MsgData() 数据类型

from ChatGPTWeb.config import 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 = ""

# 使用/Used
just simple to use

简单使用

### copy __main__.py or this code to start / 复制 __main__.py 或者以下code来开始
```bash
from ChatGPTWeb.ChatGPTWeb import chatgpt
from ChatGPTWeb.config import Personality,MsgData
import asyncio
import aioconsole

session_token=""

personality_definition = Personality(
    [
        {
            "name":"猪咪",
            'value':'咩~ '
            },
        {
            "name":"cat",
            "value":"you are a cat"
        }
        ])

chat = chatgpt(session_token=session_token,log_status=False,personality=personality_definition)

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.msg_send = "your ..."
            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.13.tar.gz (25.2 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.13-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ChatGPTWeb-0.0.13.tar.gz
Algorithm Hash digest
SHA256 9dcb91c5055b7519d5bf43d0ab6ef6c0d279c8bfd6d9b33ce7dd8a520d9f7708
MD5 c67bf318bf638e75728d0f437fc39bf9
BLAKE2b-256 5cd9e1d65e775f9ffddf47718e29f421684a9044c20846ff8eb51857d6945fc8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ChatGPTWeb-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 49a3d6faf1606dc9565bdec8b9eab12cfd031527ef095cbbd0db81e891a420bc
MD5 fc3506eb2b4ce879e72fa6fa4d5761c3
BLAKE2b-256 5f98f0058819f13554b2ced9c05552e1bd3a8c9e4a3dc96ee23520a6e81d5d4c

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