Skip to main content

Utilities for managing multi-shot conversations and structured data handling in LLM applications

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

mightydatainc-gpt-conversation

Utilities for managing multi-shot LLM conversations and structured JSON responses with OpenAI's Responses API.

Installation

pip install mightydatainc-gpt-conversation

Quick Start

gpt_submit

from openai import OpenAI
from gpt_conversation import gpt_submit

client = OpenAI()

reply = gpt_submit(
    messages=[{"role": "user", "content": "Say hello."}],
    openai_client=client,
)
print(reply)

GptConversation

from openai import OpenAI
from gpt_conversation import GptConversation

client = OpenAI()
conversation = GptConversation(openai_client=client)

reply = conversation.submit_user_message("Give me three project name ideas.")
print(reply)

JSON Response Mode

from openai import OpenAI
from gpt_conversation import gpt_submit

client = OpenAI()

result = gpt_submit(
    messages=[{"role": "user", "content": "Return JSON with keys a and b."}],
    openai_client=client,
    json_response=True,
)

print(type(result))  # dict or list
print(result)

JSONSchemaFormat

from openai import OpenAI
from gpt_conversation import gpt_submit, json_schema_format, JSON_INTEGER

client = OpenAI()

response_format = json_schema_format(
    "answer_payload",
    {
        "answer": "The final answer",
        "confidence": ["Confidence score", [0, 100], []],
        "rank": JSON_INTEGER,
    },
    "Structured answer payload",
)

result = gpt_submit(
    messages=[{"role": "user", "content": "Return answer as structured JSON."}],
    openai_client=client,
    json_response=response_format,
)
print(result)

Local dev (Windows)

From packages/python-gpt-conversation, activate the package venv and run tests:

.\.venv\Scripts\Activate.ps1
python -c "import sys; print(sys.executable)"
python -m unittest discover -v -s tests

Live integration tests (real API) require OPENAI_API_KEY in your environment.

Notes

  • Package name for pip install is gpt-conversation.
  • Python import package is gpt_conversation.
  • gpt_submit supports optional warning reporting via warning_callback.

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

mightydatainc_gpt_conversation-1.2.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file mightydatainc_gpt_conversation-1.2.0.tar.gz.

File metadata

File hashes

Hashes for mightydatainc_gpt_conversation-1.2.0.tar.gz
Algorithm Hash digest
SHA256 52af75bd9918278b83e08cd7318f28dc5bf525cd77e568e74a5e945b2077d210
MD5 1b7587d7b23317ac427bb3b225a4b86d
BLAKE2b-256 8de7babb9e8a9cdb2319004893b141589573a1188f3b226770b2e30286c1e1cf

See more details on using hashes here.

File details

Details for the file mightydatainc_gpt_conversation-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mightydatainc_gpt_conversation-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a035e5914b78943f6996b81673574be58d55c94de920a884a13f0a61cb251308
MD5 336851ad48bb41e71ffcf1770bbe8ad4
BLAKE2b-256 297a0aa5b0e4898a732f4ef3af5a117661d87cace26533cd69c9ba126a29277b

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