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.3.2.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.3.2.tar.gz.

File metadata

File hashes

Hashes for mightydatainc_gpt_conversation-1.3.2.tar.gz
Algorithm Hash digest
SHA256 80915225159ea5523cf83c2cbe86a4356a9008b4734fb3d28996f947f5ba664b
MD5 bf7f2034669e731f07144a057aea4186
BLAKE2b-256 db42481ad41e3c7856bb55b3a763d9630018835e3834141a5886988578e5cd14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mightydatainc_gpt_conversation-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55648f3c8b590f3a5d42cc20eff219eb1ab6c1b49989748c6421f124bd798680
MD5 17e26a8af525e7187d74c183617cbcef
BLAKE2b-256 55936468035e9fbc5c9f62bc6839f2e4570af4e1b27170068dcbcb53dea8eaab

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