PromptLab MCP Server

Integrations

  • Used for environment variable management to configure the PromptLab server with API keys and other settings

  • Enables version control and contribution workflows for the PromptLab project

  • Hosts the repository and provides collaboration features for contributing to PromptLab

PromptLab:AI查询增强引擎

PromptLab 将用户的基本查询转换为针对 AI 系统优化的提示。它会自动检测内容类型(论文、电子邮件、技术说明、创意写作),应用定制的模板,并验证增强的提示是否符合原始意图。

🔍 概述

PromptLab 采用模块化架构,并配备基于 YAML 的模板系统,任何人都无需任何编程知识即可创建和管理提示模板。该系统最终通过结构更完善的输入生成更高质量的 AI 响应。

🏗️ 建筑

PromptLab 由三个主要组件组成:

  1. 模板系统prompt_templates.yaml )- 针对不同内容类型的结构化模板
  2. MCP 服务器( promptlab_server.py ) - 通过 LangGraph Workflow 的标准化协议提供模板
  3. 处理客户端promptlab_client.py )- 处理用户查询的瘦客户端

工作流程

  1. 查询输入:用户提交自然语言查询
  2. 分类:系统确定内容类型(文章、电子邮件等)
  3. 参数提取:识别关键参数(主题、受众等)
  4. 模板应用:检索并填充适当的模板
  5. 验证:根据原始意图检查增强提示
  6. 调整:任何需要的改进都会自动进行
  7. 响应生成:优化的提示产生高质量的响应

📋 功能

  • 内容类型检测——自动将用户查询分类为文章、电子邮件、技术或创意写作请求
  • 参数提取——智能提取主题、收件人和受众级别等关键参数
  • 模板库——预先配置的常见内容类型的模板,并带有结构化的指导
  • 验证系统——确保增强的提示保持原始的用户意图
  • 反馈循环- 当验证发现错位时调整提示
  • 模块化设计- MCP 服务器可以插入任何 LLM 系统
  • 非技术管理——无需编码知识即可更新模板

🚀 入门

先决条件

  • Python 3.8+
  • 依赖项:
    • mcp[cli]
    • langchain-openai
    • langgraph>=0.0.20
    • python-dotenv
    • pyyaml

安装

# Clone the repository git clone https://github.com/iRahulPandey/PromptLab.git cd PromptLab # Install dependencies pip install -r requirements.txt # Set up environment variables cp .env # Edit .env to add your OpenAI API key

用法

  1. 首先运行服务器:
# The server loads templates from prompt_templates.yaml python promptlab_server.py
  1. 使用您的查询运行客户端:
python promptlab_client.py "Write an essay about climate change"
  1. 系统将输出:
    • 原始查询
    • 分类内容类型
    • 增强提示
    • 验证结果
    • 最终回应

📝 模板系统

模板在prompt_templates.yaml中使用结构化格式定义:

templates: essay_prompt: description: "Generate an optimized prompt template for writing essays." template: | Write a well-structured essay on {topic} that includes: - A compelling introduction that provides context and states your thesis ... parameters: - name: topic type: string description: The topic of the essay required: true

添加新模板

  1. 打开prompt_templates.yaml
  2. 按照现有格式添加新模板
  3. 定义参数和转换
  4. 在服务器端定义一个工具并加载模板
  5. 服务器将在重启时自动加载新模板

🛠️高级配置

环境变量

  • TEMPLATES_FILE - 模板 YAML 文件的路径(默认值: prompt_templates.yaml
  • OPENAI_API_KEY - 用于 LLM 访问的 OpenAI API 密钥
  • MODEL_NAME - 要使用的 OpenAI 模型(默认值: gpt-3.5-turbo
  • PERSONA_SERVER_SCRIPT - 服务器脚本的路径(默认值: promptlab_server.py

自定义转换

模板可以包括动态调整参数的转换:

transformations: - name: formality value: "formal if recipient_type.lower() in ['boss', 'client'] else 'semi-formal'"

📊 示例输出

输入查询

“为我的教授写一些关于可再生能源的东西”

增强提示

Write a well-structured essay on renewable energy that includes: - A compelling introduction that provides context and states your thesis - 2-3 body paragraphs, each with a clear topic sentence and supporting evidence - Logical transitions between paragraphs that guide the reader - A conclusion that synthesizes your main points and offers final thoughts The essay should be informative, well-reasoned, and demonstrate critical thinking.

📄 许可证

MIT 许可证 - 详情请参阅许可证文件

🤝 贡献

欢迎贡献代码!欢迎提交 Pull 请求。

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/amazing-feature
  3. 提交您的更改( git commit -m 'Add some amazing feature'
  4. 推送到分支( git push origin feature/amazing-feature
  5. 打开拉取请求
-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

通过标准化协议提供提示模板,将基本的用户查询转换为针对 AI 系统的优化提示。

  1. 🔍 Overview
    1. 🏗️ Architecture
      1. Workflow Process
    2. 📋 Features
      1. 🚀 Getting Started
        1. Prerequisites
        2. Installation
        3. Usage
      2. 📝 Template System
        1. Adding New Templates
      3. 🛠️ Advanced Configuration
        1. Environment Variables
        2. Custom Transformations
      4. 📊 Example Outputs
        1. Input Query
        2. Enhanced Prompt
      5. 📄 License
        1. 🤝 Contributing
          ID: i3tad94sjm