Skip to main content

Mars ChatGPT API Lib

Project description

MarsGPT

A ChatGPT API

安装

pip install MarsGPT

使用

import sys
import asyncio
from MarsGPT import Chatbot

async def main():
    """
    Chat AI Test
    """
    # params
    email = "xxx@xxx.com"
    password = "xxxxxx"

    # login
    chatbot = Chatbot(email=email, password=password)
    
    # ask
    try:
        while True:
            print("You:")
            prompt = ""
            while(len(prompt.strip()) == 0):
                prompt = input()

            # # clear
            # chatbot.conversations.remove("default")

            print("ChatGPT:")
            # ret, res = self.chatbot.ask_sync(prompt)
            # print(res)
            async for line in chatbot.ask(prompt):
                result = line["choices"][0]["text"].replace("<|im_end|>", "")
                print(result, end="")
                sys.stdout.flush()
            print()


    except KeyboardInterrupt:
        print("Exiting...")
        sys.exit(0)

if __name__ == "__main__":
    asyncio.run(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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

MarsGPT-0.1.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file MarsGPT-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: MarsGPT-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.9

File hashes

Hashes for MarsGPT-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38b1369555be9e760625548cd4a5e9df2195b7c0e7b47bdccbe8c6e78debee9f
MD5 fc3538ecfe329dbc6fa3c98498c00749
BLAKE2b-256 b993dd15384f0420aaebe31fd09b026e4bfc82b18178cfafadac65ba51eca46e

See more details on using hashes here.

Supported by

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