Skip to main content

TextPy: Collaborative Agent Workflow through Programming and Prompting

Project description

TextPy

TextPy ── Collaborative Agent Workflow through Programming and Prompting

🚀 Core Philosophy

P1: Workflow = Programming + Prompting
P2: Programming <-> Prompting
P3: Workflow = Function Signature with Comment

⚡ Revolutionary Features

  • Mixed-Execution: Seamlessly integrates with legacy code
  • AICompiler: Just write function signatures, our powerful compiler will automatically generate natural language instructions or code instructions just in time
  • Self-Replication: Easier implementation of recursive workflows

🔧 Usage

Installation

$ pip install textpy-llm

In your python script, include the line

import textpy

Or use the image to run your code

$ docker pull ghcr.io/yezhengmao1/textpy:latest

🛠️ Quick Start - Simple Example

# examples/write_poem.py
from textpy import code, text

# the text/code will auto-generated by AICompiler(Just in Time)
# we use the litellm to call large language model, default model is deepseek/deepseek-chat
# if you want to use different large language model, @code(api_key="", base_url="", model="")

@text
def generate_poem(*, theme: str, style: str) -> str: ...

@code
# text should in center of the SVG, use a white background, add visually striking elements
def create_svg_from_text_with_svgwrite(*, text: str) -> str: ...

@code
def save_svg_to_file(*, svg: str, path: str): ...

# execute this code
poem = generate_poem(theme="Quantum Physics and Romance", style="haiku")
svg = create_svg_from_text_with_svgwrite(text=poem)
save_svg_to_file(svg=svg, path="poem.svg")

👾 Quick Start - Amazing Example

Example: Daily updates from arxiv via RSS link, filter the paper, translate the abstracts into Chinese, store them in a database, and generate a markdown file to display these contents.

😊: I also use TextPy to periodically push the generated markdown files (if there are new ones) to my blog.

Visit this in: Daily Arxiv

Highlight: We only need to define the function and use it. The powerful AICompiler will recognize its functionality and automatically generate code for it and execute it, or generate a prompt for it and invoke a large language model.

see examples/daily_arxiv.py for details.

@code
def get_the_rss_xml_file_str(*, url: str) -> str: ...

@code(pypi=[get_the_rss_xml_file_str(url=ARXIV_URL)])
def get_all_item_in_the_rss_file(*, xml_file_str: str) -> list[dict]: ...

@text
def check_topic_is_satisfactory(*, abstrct: str, topic: str) -> bool: ...

@text
def translate_the_en_abstract_to_zh(*, abstract: str) -> str: ...

@code
def check_link_in_db(*, db_path: str, link: str) -> bool: ...

@code
def save_article_to_db(*, db_path: str, item: dict): ...

🤩 Quick Start - Awesome Example

Example: Download pdf from arxiv using the arxiv id, extract text from the papers, and summarize them. What makes it powerful is that it can recursively read all cited references and perform the same operations on them. Then it displays the relationships between them in an HTML file. When the script is running, visit localhost:31108 to check if the script is executing correctly, and visit localhost:31108/arxiv.html to view the results.

Highlight: All the functionalities in these workflows are generated by AICompiler in TextPy (including calling and installing other Python packages), while all you do is write function definitions (function signatures) and ... provide comments!!

NOTE: We strongly recommend running this script within a container, as our powerful AICompiler manipulates the external environment during compilation, which can affect your system. You can still run the script directly, refer to examples/arxiv_search.sh for details.

cd ./examples
DEEPSEEK_API=xxx CACHE_DIR="/workspace/.cache" ARXIV_ID=<xxxx.xxxx> ./arxiv_search.sh

Example Video

📌 Contributing

Community contributions are more than welcome, whether it be to fix bugs or to add new features at github.

📜 Citation

@misc{ye2025textpy,
  author = {Zhengmao Ye, Shuyun Yang, Zelong Huang, Jie Zuo, Mingjie Tang},
  title = {TextPy: Collaborative Agent Workflow through Programming and Prompting},
  year = {2025},
  howpublished = {\url{https://github.com/yezhengmao1/TextPy}}
}

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

textpy_llm-0.1.3.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textpy_llm-0.1.3-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file textpy_llm-0.1.3.tar.gz.

File metadata

  • Download URL: textpy_llm-0.1.3.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for textpy_llm-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f60e09502cfd7269011c5423e2dd6405c71cb10c8ff6a424b97c9e52e76bf664
MD5 ef9870920ecafe3480611eb949c3fb6d
BLAKE2b-256 3a3c531e5638b54ec4c85529e025b1fe12ab045d5cc6f54d1660b2f8c87cc0b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for textpy_llm-0.1.3.tar.gz:

Publisher: python-publish.yml on yezhengmao1/TextPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file textpy_llm-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: textpy_llm-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for textpy_llm-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d81830a5ef4fb0b77ba7f3994fad2169aac5df96b873f00032ea0a01310ccc10
MD5 579f3b66a1753339dc4ec9bfa8e5135e
BLAKE2b-256 6f10315783792d635b866b20041172003d7c96bcd72d12e0f93a4361ef848e26

See more details on using hashes here.

Provenance

The following attestation bundles were made for textpy_llm-0.1.3-py3-none-any.whl:

Publisher: python-publish.yml on yezhengmao1/TextPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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