Skip to main content

中文 | English

License: MIT  

AI Chat HTML 导出器

一个专业的 AI 对话历史导出工具,将您与 AI 的对话智能转换为精美 HTML 文件,助力开发调试与 Prompt 观察。

版本 构建状态 许可证 Python

✨ 核心亮点

  • 🚀 极简集成 - 仅需一行代码,轻松收集 AI 对话日志
  • 🔍 透明调试 - 直观了解 AI Agent 的行为过程,无需繁琐的 langsmith 配置
  • 💎 精美展示 - 响应式界面设计,代码语法高亮,JSON 数据格式化
  • 🌐 即时预览 - 支持浏览器中实时查看对话历史
  • 🎨 图片支持 - 自动识别对话中的 base64 和 URL 图片,展示图像内容
  • 🛠 多框架支持 - 完美兼容 LangChain 和 OpenAI API

📋 应用场景

  • AI 应用开发调试过程中快速记录对话历史
  • 收集和展示 AI 交互示例
  • 保存重要的 AI 对话以供日后参考
  • 分享 AI 对话成果给团队成员

🔧 安装方法

从 PyPI 安装

pip install ai-chat-html-exporter

本地开发安装

git clone https://github.com/yourusername/ai-chat-html-exporter.git
cd ai-chat-html-exporter
pip install -e .

🚀 快速上手

LangChain 集成示例

from ai_chat_html_exporter import HtmlExportCallbackHandler
from langchain_openai import AzureChatOpenAI

# 创建导出器实例
llm = AzureChatOpenAI(
    model="gpt-4",
    callbacks=[HtmlExportCallbackHandler()]  # 只需添加这一行
)

# 对话内容会自动保存到 logs 目录下的精美 HTML 文件中

OpenAI API 集成示例

支持 AsyncOpenAI, OpenAI, AsyncAzureOpenAI, AzureOpenAI 客户端

from ai_chat_html_exporter.openai_chat_html_exporter import with_html_logger
from openai import AsyncOpenAI

@with_html_logger  # 只需添加这个装饰器
def get_openai_client(self):
    return AsyncOpenAI(api_key=self.api_key, base_url=self.base_url)
<script src="https://cdn.jsdelivr.net/gh/fishisnow/ai_chat_html_exporter@main/frontend/openai-chat-html-exporter.js"></script>

// 你的 script
import OpenAI from 'openai';

// 配置 OpenAI 客户端
const openaiConfig = {
  apiKey: 'your-api-key',
  baseUrl: 'https://api.openai.com/v1',
};

// 创建带拦截器的 OpenAI 客户端, nodejs 环境测试的时候会自动生成 html 文件
const openaiClient = createChatExporterOpenAI(OpenAI, openaiConfig);
// copy openai-chat-html-exporter.ts to your project
import { createChatExporterOpenAI } from 'openai-chat-html-exporter';
const openaiConfig = {
  apiKey: 'your-api-key',
  baseUrl: 'https://api.openai.com/v1',
};
const openaiClient = createChatExporterOpenAI(OpenAI, openaiConfig);

⚙️ 自定义配置

# 自定义输出目录
from ai_chat_html_exporter import HtmlExportCallbackHandler
exporter = HtmlExportCallbackHandler(output_dir="my_chat_logs")

# 更多配置选项即将推出...

📊 输出效果展示

对话历史展示

📦 系统要求

  • Python >= 3.12
  • langchain-core >= 0.1.0
  • python-dotenv >= 1.0.0
  • openai >= 1.6.1

🔜 未来规划

  • 支持更多的 AI 框架集成

🤝 参与贡献

我们欢迎各种形式的贡献!

  1. Fork 本仓库
  2. 创建您的特性分支 (git checkout -b feature/amazing-feature)
  3. 提交您的更改 (git commit -m 'Add some amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 打开一个 Pull Request

也欢迎提交 Issue 反馈问题或建议!

📄 许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件

🔗 相关链接


如果这个项目对您有帮助,请给它一个⭐️!

Metadata

Release files for ai-chat-html-exporter 1.0.3.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-chat-html-exporter 1.0.3.post1
File Size Uploaded Provenance
ai_chat_html_exporter-1.0.3.post1.tar.gz 18.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-chat-html-exporter 1.0.3.post1
File Interpreter ABI Platform
ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl Python 3 none any Details

Total release size: 37.2 kB

Release files / ai_chat_html_exporter-1.0.3.post1.tar.gz

Download URL ai_chat_html_exporter-1.0.3.post1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1dab81636f6745f9616d98403b379e43df6e32d151b8ffaaf4bbe283cfa06dea
BLAKE2b-256 checksum
How to use checksums
ec1b093d08fd7e9d9da5046f8bd5a68425890a9ccc162f565f15ca7143a4380c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Release files / ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl

Download URL ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8a7283d45709cbc875d70be7790d547a978de85ea5b6f00f377a9592cbd4de7
BLAKE2b-256 checksum
How to use checksums
0295ddc4e1ebcefc83e7368df6d47306b4519105681390ae9ae0615e1880a7d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Security for ai-chat-html-exporter 1.0.3.post1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ai_chat_html_exporter-1.0.3.post1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page