promptcog 2025.12.20200424
**
License: MIT
Requires Python: >=3.9

# promptcog

[![PyPI version](https://img.shields.io/pypi/v/promptcog.svg)](https://pypi.org/project/promptcog/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://img.shields.io/pypi/dm/promptcog.svg)](https://pypistats.org/packages/promptcog)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Eugene%20Evstafev-blue)](https://linkedin.com/in/eugene-evstafev)

**promptcog** is a lightweight AI‑powered tool that audits user prompts for their impact on **critical thinking, reasoning, and problem‑solving skills**.  
It scans a text prompt with an LLM, detects shallow or biased structures, and returns a structured assessment along with concrete suggestions for improvement.

---

## Table of Contents

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
  - [Default LLM](#default-llm)
  - [Custom LLMs](#custom-llms)
- [Function Signature](#function-signature)
- [Return Value](#return-value)
- [Configuration](#configuration)
- [License](#license)
- [Author](#author)

---

## Installation

```bash
pip install promptcog
```

---

## Quick Start

```python
from promptcog import promptcog

prompt = "Are these AI prompts damaging your thinking skills?"
results = promptcog(prompt)

print(results)
# Example output:
# [
#   "This prompt risks shallow responses by framing the question as a binary judgment",
#   "Reframe as: 'How might AI prompts influence critical thinking, and what evidence supports this?'",
#   "Lacks clarity, Needs evidence prompts, Encourages binary thinking"
# ]
```

---

## Usage

### Default LLM

`promptcog` will automatically instantiate the default **ChatLLM7** from the `langchain_llm7` package.  
If you do not supply an `api_key`, the free tier rate limits will be used.

```python
from promptcog import promptcog

response = promptcog("Provide a quick answer: 2+2?")
print(response)
```

### Custom LLMs

You can pass any **LangChain** compatible LLM instance:

```python
# Example with OpenAI
from langchain_openai import ChatOpenAI
from promptcog import promptcog

llm = ChatOpenAI()
response = promptcog("Explain quantum entanglement in layman's terms.", llm=llm)
```

```python
# Example with Anthropic
from langchain_anthropic import ChatAnthropic
from promptcog import promptcog

llm = ChatAnthropic()
response = promptcog("List three ways to improve memory.", llm=llm)
```

```python
# Example with Google Gemini
from langchain_google_genai import ChatGoogleGenerativeAI
from promptcog import promptcog

llm = ChatGoogleGenerativeAI()
response = promptcog("How can I prepare for a coding interview?", llm=llm)
```

If you wish to stay with the default **ChatLLM7** but need a higher rate‑limit quota, set an environment variable or pass the key directly:

```bash
export LLM7_API_KEY="your-free-tier-api-key"
```

or

```python
from promptcog import promptcog

response = promptcog(
    "Describe the benefits of regular exercise.",
    api_key="your-free-tier-api-key"
)
```

You can obtain a free API key by registering at <https://token.llm7.io/> .

---

## Function Signature

```python
promptcog(
    user_input: str,
    api_key: Optional[str] = None,
    llm: Optional[BaseChatModel] = None
) -> List[str]
```

- **user_input** – The raw text prompt you want to audit.  
- **llm** – Optional LangChain `BaseChatModel`. If omitted, a new `ChatLLM7` instance is created automatically.  
- **api_key** – Optional API key for the default LLM7 service. Missing it defaults to the `LLM7_API_KEY` environment variable or the free tier.

---

## Return Value

A list of strings containing:

1. A **damage assessment** comment.  
2. One or more **redesign suggestions**.  
3. A **comma‑separated list of skill tags**.

Feel free to parse this list or present it to users as you see fit.

---

## Configuration

| Environment Variable | Purpose | Default |
|-----------------------|---------|---------|
| `LLM7_API_KEY` | API key for the default ChatLLM7 | `None` |
| `PYTHONUNBUFFERED` | For continuous output in CI pipelines | `0` |

---

## License

MIT © Eugene Evstafev

---

## Author

- **Eugene Evstafev** – hi@euegne.plus  
- GitHub: [@chigwell](https://github.com/chigwell)

--- 

Repository & Issue Tracker: <https://github.com/chigwell/promptcog/issues>