Skip to main content

A library for crafting, analyzing, and perfecting AI prompts

Project description

Blogus: Craft, Analyze, and Perfect Your AI Prompts

Blogus Logo

License: MIT PyPI version PRs Welcome

Why Blogus?

In the rapidly evolving field of AI and large language models, crafting effective prompts has become a crucial skill. Blogus is born out of the need for a sophisticated, user-friendly tool that empowers developers, researchers, and AI enthusiasts to:

  • Analyze and refine prompts in real-time
  • Generate and manage test cases
  • Execute prompts across multiple AI models
  • Visualize and understand prompt effectiveness
  • Separate target models (for execution) from judge models (for analysis)
  • Manage the complete prompt development lifecycle

Whether you're a seasoned prompt engineer or just starting your journey with AI, Blogus provides the tools you need to elevate your prompt crafting skills.

What is Blogus?

Blogus is an advanced prompt engineering tool available as:

  1. A Python library for programmatic use in your applications
  2. A command-line interface for quick analysis and testing
  3. A web interface with an intuitive frontend for interactive prompt engineering

Key features include:

  • Real-time Prompt Analysis: Get instant feedback on your prompts' effectiveness and alignment with your goals.
  • Multi-model Support: Test your prompts across various AI models, including GPT-4, Claude, and more.
  • Test Case Generation: Automatically generate relevant test cases for your prompts.
  • Interactive Code Editor: A feature-rich editor with syntax highlighting and real-time analysis feedback (in web UI).
  • Execution Environment: Run your prompts and see the results immediately.
  • Test Case Management: Store and download generated test cases as JSON files (in web UI).
  • Dynamic Goal Inference: Automatically infer the goal of your prompt if not provided.
  • Target vs Judge Models: Separate models for prompt execution and analysis for optimal cost and performance.
  • Complete Prompt Lifecycle: Tools for the entire prompt engineering workflow from creation to optimization.

Documentation

Comprehensive documentation is available in the docs directory:

Examples

Check out the examples directory for practical usage examples:

Installation

pip install blogus

For web interface support, install with the web extra:

pip install blogus[web]

Usage

As a Library

from blogus.core import TargetLLMModel, JudgeLLMModel, analyze_prompt, generate_test

prompt = "You are an AI assistant that helps people find information..."

# Analyze a prompt using a judge model
analysis = analyze_prompt(prompt, JudgeLLMModel.GPT_4)
print(f"Goal alignment: {analysis.overall_goal_alignment}/10")

# Generate a test case using a judge model
test_case = generate_test(prompt, JudgeLLMModel.GPT_4)

# Execute a prompt using a target model
result = execute_prompt(prompt, TargetLLMModel.GPT_4)

Command Line Interface

# Analyze a prompt with separate target and judge models
blogus analyze "You are an AI assistant that helps people find information..." \\
  --target-model gpt-4o \\
  --judge-model claude-3-opus-20240229

# Generate a test case with separate target and judge models
blogus test "You are an AI assistant that helps people find information..." \\
  --target-model gpt-4o \\
  --judge-model claude-3-opus-20240229

# Execute a prompt with a target model
blogus execute "You are an AI assistant that helps people find information..." \\
  --target-model gpt-4o

# Infer the goal of a prompt with a judge model
blogus goal "You are an AI assistant that helps people find information..." \\
  --judge-model claude-3-opus-20240229

# See all available commands
blogus --help

Web Interface

To run the web interface:

blogus-web  # If installed with web extras
# or
python -m blogus.web

Then navigate to http://localhost:8000 in your browser.

API Keys

Logus uses LiteLLM to support a wide range of AI models. You'll need API keys for the models you want to use:

  • OpenAI API key for GPT models
  • Anthropic API key for Claude models
  • Groq API key for Mixtral/Llama models

Set these as environment variables:

export OPENAI_API_KEY=your_openai_api_key
export ANTHROPIC_API_KEY=your_anthropic_api_key
export GROQ_API_KEY=your_groq_api_key

For other models supported by LiteLLM, please refer to the LiteLLM documentation for the required environment variables.

Contributing

We welcome contributions to Blogus! Please see our CONTRIBUTING.md for details on how to get started.

License

Logus is open-source software licensed under the MIT license. See the LICENSE file for more details.

Support

If you encounter any issues or have questions, please file an issue on our GitHub issue tracker.

Citation

If you use Logus in your research, please cite it as follows:

@article{sarkar2024blogus,
  title={Blogus: An Advanced Tool for Crafting, Analyzing, and Perfecting AI Prompts},
  author={Sarkar, Dipankar},
  journal={arXiv preprint arXiv:2024.xxxxx},
  year={2024},
  url={https://github.com/terraprompt/blogus},
  note={Software available from https://github.com/terraprompt/blogus},
  abstract={Blogus is an open-source software tool designed to facilitate the
    process of prompt engineering for large language models. It provides
    real-time analysis of prompts, supports multiple AI models, and offers
    features for test case generation and prompt execution. This tool aims to
    enhance the efficiency and effectiveness of prompt crafting in AI research
    and applications.}
}

For LaTeX users, you can use the following command to cite Blogus:

\cite{sarkar2024blogus}

Happy Prompt Engineering with Blogus! 🚀

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

blogus-0.1.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

blogus-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file blogus-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for blogus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 006d59f9f3be44fe06baa2d7f28f41b4507f20819ea2ca13d96692030af27128
MD5 57cafb6081b86179cb107774c0eee486
BLAKE2b-256 e518eaa98df3b7e0273ef935895a8822bd4845bdbc11b603adf71e24d3cac3e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for blogus-0.1.0.tar.gz:

Publisher: publish.yml on Skelf-Research/blogus

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

File details

Details for the file blogus-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for blogus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8616804bf8a1ef41d973389fbe50d60b896bce620e9983fce07d5ec3170b017
MD5 a967a1d707b7bab1eeb4c16f92952241
BLAKE2b-256 ae941b6d8c9f02765476dfb1ba5c765d4163b3e008b4a7122ec06509f2fd26ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for blogus-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Skelf-Research/blogus

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