Skip to main content

psygen-llm

Python package implementing Psygen Revised: a three-stage (optional fourth) LLM pipeline that produces a structured psychological profile for a character from a natural-language query.

  • Schema: JSON Schema for each layer and the merged profile (package data).
  • Runner: ProfileGenerator chains axiom → intermediate → emergent calls, validates JSON, merges evidence.
  • Prompt surface: to_prompt_string() emits dialogue-ready text (20 emergent traits + coping style + role identity), capped at 600 characters per the design contract.

Install and publish (uv)

Requires uv and Python 3.10+ (see requires-python in pyproject.toml). PyPI name psygen-llm, import psygen_llm, CLI psygen-llm.

For publishing, the path is: build with uv, publish the artifacts. For using the package from PyPI, install into a local virtual environment (for example uv venv then activate the .venv, or use whatever venv your project already uses) — not system-wide Python.

From the repository root, bump version in pyproject.toml when publishing a new release, and configure PyPI credentials for Twine (for example ~/.pypirc or the usual TWINE_* environment variables).

Install dev mode

uv pip install -e .

Build and push (maintainers):

uv build
uvx twine upload dist/*

Install into the active venv (after the release is on PyPI; with that environment selected — no --system):

uv pip install "psygen-llm"

Use uv pip install "psygen-llm[openai]" for the optional OpenAI dependency. To remove: uv pip uninstall psygen-llm (it is fine if nothing is installed). Quote extras so the shell does not treat [openai] as a glob.

OpenAI config

Create a JSON file (e.g. psygen.json, keep it private — chmod 600 — and do not commit it):

{
  "openai": {
    "api_key": "sk-...",
    "model": "gpt-4o-mini",
    "base_url": null
  }
}

openai.api_key and openai.model are required. openai.base_url is optional; omit it or set it to null for the default OpenAI API URL.

Quick use

import asyncio
from psygen_llm import ProfileGenerator, OpenAiLlmClient

async def main():
    client = OpenAiLlmClient.from_config_file("psygen.json")
    gen = ProfileGenerator(client)
    profile = await gen.generate("Linus from Stardew Valley")
    print(profile.to_prompt_string())
    print(profile.to_json())

asyncio.run(main())

Custom LLM backend

Implement psygen_llm.protocols.LlmClient (complete(system, user) -> str) and pass it to ProfileGenerator.

CLI

By default the merged profile JSON is written to output/<slug>.json (slug derived from your query; the output/ directory is created if needed). Use -o for another path, or -o - to print JSON to stdout.

psygen-llm --config psygen.json "Linus from Stardew Valley"
psygen-llm --config psygen.json "Linus from Stardew Valley" -o /tmp/linus.json
psygen-llm --config psygen.json "Linus from Stardew Valley" -o -

Design

See DESIGN.md and PLAN.md in this directory.

License

MIT

Metadata

Release files for psygen-llm 0.3.0

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

Source distribution (sdist)

Source distribution for psygen-llm 0.3.0
File Size Uploaded Provenance Actions
psygen_llm-0.3.0.tar.gz 18.0 kB Without provenance Details for psygen_llm-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for psygen-llm 0.3.0
File Interpreter ABI Platform Actions
psygen_llm-0.3.0-py3-none-any.whl Python 3 none any Details for psygen_llm-0.3.0-py3-none-any.whl

Total release size: 41.9 kB

Release files / psygen_llm-0.3.0.tar.gz

Download URL psygen_llm-0.3.0.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6f63a46e9cfe7c5af623ee1c47d016ede36201e42e57657b1dbb4400a412825d
BLAKE2b-256 checksum
How to use checksums
6134b22c62208776bd1228833af02396fe30e952171ebbc19d6929ece8179936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / psygen_llm-0.3.0-py3-none-any.whl

Download URL psygen_llm-0.3.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
081418c3db0c6d580ba021f062c03df5b8edc014f8c433acf3d2f862c582d25a
BLAKE2b-256 checksum
How to use checksums
a4f392624ba6cfbbe4498ec448556626e085041ebefeceb7a90515f62f94676e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for psygen-llm 0.3.0

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