Skip to main content

personasurvey

Small, resumable async simulations for persona-based surveys. The package is country- and candidate-agnostic.

Install

pip install -e .[dev]

For optional native providers: pip install -e .[gemini,anthropic].

Generic RunPod experiment

from personasurvey import PersonaPrompt, ResponseSchema, RunPodProvider, GPUPricing, run_simulation, continue_simulation

prompt = PersonaPrompt(
    demographic_cols=["age", "region", "education", "occupation"],
    persona_detail_cols=["persona_description", "hobby"],
    scenario="How would this fictional person divide support between Candidate A and Candidate B?",
    response_schema=ResponseSchema.probabilities(["Candidate A", "Candidate B"]),
)
provider = RunPodProvider(urls=[RUNPOD_1, RUNPOD_2], model="openai/gpt-oss-20b")

prompt.validate(df)
print(prompt.preview(df.iloc[0]))

run = await run_simulation(df=df, prompt=prompt, provider=provider, checkpoint="experiment_01.jsonl", n=200_000, max_tokens=500, temperature=0, reasoning_effort="low", pricing=GPUPricing(0.53))
resumed = await continue_simulation(df=df, prompt=prompt, provider=provider, checkpoint="experiment_01.jsonl")

results_df = run.results
merged_df = run.merged

continue_simulation never sends IDs already marked status="ok". Errors remain eligible for a later retry.

Other providers and API pricing

from personasurvey import APIPricing, OpenAIProvider, OpenRouterProvider, GeminiProvider, AnthropicProvider

provider = OpenAIProvider(model="gpt-4.1-mini")  # reads OPENAI_API_KEY
pricing = APIPricing(input_per_million=0.03, output_per_million=0.13)
# OpenRouterProvider(model="..."), GeminiProvider(model="..."), AnthropicProvider(model="...")

Credentials are supplied as arguments or environment variables; never put them in a notebook or source file.

Metadata

Release files for personasurvey 0.1.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 personasurvey 0.1.0
File Size Uploaded Provenance Actions
personasurvey-0.1.0.tar.gz 15.1 kB Without provenance Details for personasurvey-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for personasurvey 0.1.0
File Interpreter ABI Platform Actions
personasurvey-0.1.0-py3-none-any.whl Python 3 none any Details for personasurvey-0.1.0-py3-none-any.whl

Total release size: 30.5 kB

Release files / personasurvey-0.1.0.tar.gz

Download URL personasurvey-0.1.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
430be706baa3c713c92e1782193eee5d86fc57b44c745ad08584e2ec5caafb9d
BLAKE2b-256 checksum
How to use checksums
a6d5767af1e88ea5af1a2de2c27059bbb4e4dc84db9a5f238bc1418293606bc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / personasurvey-0.1.0-py3-none-any.whl

Download URL personasurvey-0.1.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfd6cba8ade1abf8136037ff9f2cf9014b7edd7047482b940bea6e1efe0284e5
BLAKE2b-256 checksum
How to use checksums
b3fd8388110b0568289b276eec0cb2538f9bed16a100b172d13d736fbdc28ebe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for personasurvey 0.1.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