[DEPRECATED] Reusable, mutable, prompt functions for LLMs. Please migrate to the new package: pypop.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Prompt Oriented Programming (POP)
Reusable, composable prompt functions for LLMs. POP treats prompts like first-class functions: reusable, mutable, and structured for programmatic execution. It supports prompt enhancement, function/code generation, multiple LLM backends, and embeddings.
PyPI Link: https://pypi.org/project/POP-guotai/
Table of Contents
Updates
- 0.3.1: add image support to gemini and openai client
Features
-
Prompt as a Function: Define reusable prompts with
<<<placeholders>>>for flexible execution. -
Multi-LLM Support: Use OpenAI (default), GCP Gemini, local PyTorch, or Deepseek stubs.
-
Function Schema & Code Generation:
- Turn natural language descriptions into OpenAI function schemas.
- Optionally generate full Python function code with docstrings and type hints.
-
Prompt Improvement: Enhance base prompts using Fabric-inspired meta-prompts.
-
Embeddings:
- OpenAI and Jina API embeddings
- Local Hugging Face model support
-
Utility Functions:
get_text_snapshot(url)for webpage-to-text extraction with optional image captioning.
Installation
Install from PyPI:
pip install POP-guotai
Or from source:
git clone https://github.com/sgt1796/POP.git
cd POP
pip install -e .
Setup & Configuration
- Create a
.envfile in your project root:
OPENAI_API_KEY=your_openai_key
GEMINI_API_KEY=your_gcp_gemini_key
JINAAI_API_KEY=your_jina_api_key
- Dependencies are automatically handled via
setup.py:
openai,requests,python-dotenv,pydantic,transformers,numpy,backoff
Usage
PromptFunction Class
from POP import PromptFunction
pf = PromptFunction(
sys_prompt="You are a helpful AI assistant.",
prompt="Write a short poem about <<<topic>>>."
)
result = pf.execute(topic="space travel")
print(result)
Improving Prompts
improved_prompt = pf._improve_prompt()
print(improved_prompt)
Function Schema & Code Generation
# 1. Generate a JSON function schema
schema = pf.generate_schema(description="Multiply two integers and return the product.")
# 2. Generate actual Python code
code = pf.generate_code(schema)
print(code)
Embeddings
from POP.Embedder import Embedder
embedder = Embedder(use_api="openai")
vectors = embedder.get_embedding(["Hello world", "POP is awesome!"])
print(vectors.shape) # (2, embedding_dim)
Web Snapshot Utility
from POP import get_text_snapshot
content = get_text_snapshot("https://example.com", image_caption=True)
print(content[:500])
Example
from POP import PromptFunction
pf = PromptFunction(
prompt="Draw a simple ASCII art of <<<object>>>."
)
print(pf.execute(object="a cat"))
print(pf.execute(object="a rocket"))
Sample Output:
/\_/\
( o.o )
> ^ <
/\
/ \
/ \
| |
| |
Future Plans
- Complete support for local PyTorch and Deepseek clients
- Prompt chaining and workflow composition
- Automated prompt testing framework
- Extended multimodal support (image + text prompts)
Contributing
- Fork the repo
- Create a feature branch
- Submit a PR with clear commit messages and examples/tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pop_guotai-0.3.3.tar.gz.
File metadata
- Download URL: pop_guotai-0.3.3.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf42eae7fc5a34473b21a373c61f30277a47cb4b4f50b40e3be6dadd8786059b
|
|
| MD5 |
77e23308bcef5817db42d8dfc04cf908
|
|
| BLAKE2b-256 |
fc07241cba7a110c6007969ad0094e5061a8d400d3721403c089835cd37f082f
|
File details
Details for the file pop_guotai-0.3.3-py3-none-any.whl.
File metadata
- Download URL: pop_guotai-0.3.3-py3-none-any.whl
- Upload date:
- Size: 31.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db4514716862e8184c2042b87f1c3cb9a583d4e6b702294a4fa46c9a42564f5
|
|
| MD5 |
10686c7dbf4e46de1ea06d25add3102a
|
|
| BLAKE2b-256 |
95b5b5f6d5aec49512b06314582a3d23cb70d22e8c5d4d52abcdcf0a09e4714d
|