Skip to main content

gpt-to-chatgpt-py

Convert a regular GPT call into a ChatGPT call

TYPESCRIPT VERSION HERE -> https://github.com/bramses/gpt-to-chatgpt-ts

Functions

toChatML()

Converts a string message into a Chat Markup Language (ChatML) object.

Usage

toChatML(message:str, options:Optional[dict]=None) -> List[dict]

Arguments

  • message: The string message to be converted to ChatML.
  • options (optional): A dictionary that can contain the following keys:
    • system_messages: A list of strings that represent system messages to be added to the ChatML object.
    • role: The role of the message (either Role.USER or Role.ASSISTANT).

Examples

toChatML('hello')
# Output: [{'role': Role.USER, 'content': 'hello'}]
toChatML('hello', {'system_messages': ['hi'], 'role': Role.ASSISTANT})
# Output: [{'role': Role.SYSTEM, 'content': 'hi'}, {'role': Role.ASSISTANT, 'content': 'hello'}]

get_message()

Extracts the message content from a response object.

Usage

get_message(response: dict, options: Optional[dict] = None) -> Union[str, dict]

Arguments

  • response: The response object from which to extract the message content.
  • options (optional): A dictionary that can contain the following keys:
    • usage: A boolean value that indicates whether to return the usage information of the response.
    • role: A boolean value that indicates whether to return the role of the message.
    • isMessages: A boolean value that indicates whether to return the message as a list of messages.

Examples

get_message(test_response)
# Output: 'The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which was the new home stadium for the Texas Rangers.'

get_message(test_response, {'usage': True, 'role': True, 'isMessages': True})
# Output: {'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87},
#          'roles': ['assistant'],
#          'messages': ['The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which was the new home stadium for the Texas Rangers.']}

get_message(test_response, {'usage': True, 'role': True})
# Output: {'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87},
#          'role': 'assistant',
#          'message': 'The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which was the new home stadium for the Texas Rangers.'}

get_message(test_response, {'usage': True, 'isMessages': True})
# Output: {'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87},
#          'messages': ['The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which was the new home stadium for the Texas Rangers.']}

About the Developer

This repository was written by Bram Adams, a writer and programmer based out of NYC.

Bram publishes a Zettelkasten, with a twice/weekly newsletter (which you can subscribe to here), is a community developer ambassador for OpenAI and does freeleance contracts (for hire!) related to AI/web dev/AR+VR.

Bram is also the creator of Stenography, a API and VSC Extension that automatically documents code on save.

You can learn more about him and his work on his website.

Metadata

Release files for gpt-to-chatgpt 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpt-to-chatgpt 0.1.4
File Size Uploaded Provenance Actions
gpt_to_chatgpt-0.1.4.tar.gz 4.0 kB Without provenance Details for gpt_to_chatgpt-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gpt-to-chatgpt 0.1.4
File Interpreter ABI Platform Actions
gpt_to_chatgpt-0.1.4-py3-none-any.whl Python 3 none any Details for gpt_to_chatgpt-0.1.4-py3-none-any.whl

Total release size: 7.8 kB

Release files / gpt_to_chatgpt-0.1.4.tar.gz

Download URL gpt_to_chatgpt-0.1.4.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e47254eb96922f5ab555fa26151dc180bd0ea6e31bbb2b76b33dccd5ea678f10
BLAKE2b-256 checksum
How to use checksums
a0fae5252cc0e906d9a4a95cfb5c8f5f261d946ea7bdd38ce6f31047be0ce6ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / gpt_to_chatgpt-0.1.4-py3-none-any.whl

Download URL gpt_to_chatgpt-0.1.4-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30b45c1886ed596801d0b9ff4e2fa9862a9965a6f850aa6df25b62abc67fc788
BLAKE2b-256 checksum
How to use checksums
f4b08a6532152e38e2ab38e2ec4a0d3fe08af107427487c962bff172ed11de59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Security for gpt-to-chatgpt 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page