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.1.1.tar.gz (17.2 kB 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.1.1.tar.gz.

File metadata

File hashes

Hashes for mightydatainc_gpt_conversation-1.1.1.tar.gz
Algorithm Hash digest
SHA256 4c1b9be52ed7c7a22981bec1f3c68e7b5bd16bba5f27f745ee9c5be423624724
MD5 6ec4b5fca4c1bc592d6c5531c0f93a32
BLAKE2b-256 6ba0c134836026e5506894839df4660752da4c96182603dd9a4625c9ad49a76e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mightydatainc_gpt_conversation-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e169b76fa5383b21c26c70fff90111f4e479d38006199713b6ad5356e578ec2a
MD5 359461cbd9861fe383dd3498471bda2b
BLAKE2b-256 4d06d3460c1cfd8b64e3b555c7f84f3adfaefc4f23e6af4122c21aa3b55a288b

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