A tool to export AI chat history to HTML with syntax highlighting
Project description
中文 | English
AI Chat HTML 导出器
一个专业的 AI 对话历史导出工具,将您与 AI 的对话智能转换为精美 HTML 文件,助力开发调试与 Prompt 观察。
✨ 核心亮点
- 🚀 极简集成 - 仅需一行代码,轻松收集 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 框架集成
🤝 参与贡献
我们欢迎各种形式的贡献!
- Fork 本仓库
- 创建您的特性分支 (
git checkout -b feature/amazing-feature) - 提交您的更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 打开一个 Pull Request
也欢迎提交 Issue 反馈问题或建议!
📄 许可证
本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件
🔗 相关链接
如果这个项目对您有帮助,请给它一个⭐️!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_chat_html_exporter-1.0.3.post1.tar.gz.
File metadata
- Download URL: ai_chat_html_exporter-1.0.3.post1.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dab81636f6745f9616d98403b379e43df6e32d151b8ffaaf4bbe283cfa06dea
|
|
| MD5 |
f061fad180f49d8c8005b03f54791a18
|
|
| BLAKE2b-256 |
ec1b093d08fd7e9d9da5046f8bd5a68425890a9ccc162f565f15ca7143a4380c
|
Provenance
The following attestation bundles were made for ai_chat_html_exporter-1.0.3.post1.tar.gz:
Publisher:
python-publish.yml on fishisnow/ai_chat_html_exporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_chat_html_exporter-1.0.3.post1.tar.gz -
Subject digest:
1dab81636f6745f9616d98403b379e43df6e32d151b8ffaaf4bbe283cfa06dea - Sigstore transparency entry: 203559770
- Sigstore integration time:
-
Permalink:
fishisnow/ai_chat_html_exporter@3534543ffcf5b3b12da05a027c7eb1128f1f42b8 -
Branch / Tag:
refs/tags/v1.0.3.post1 - Owner: https://github.com/fishisnow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3534543ffcf5b3b12da05a027c7eb1128f1f42b8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl.
File metadata
- Download URL: ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8a7283d45709cbc875d70be7790d547a978de85ea5b6f00f377a9592cbd4de7
|
|
| MD5 |
afb66d2589001b620da04dc3b2b1c809
|
|
| BLAKE2b-256 |
0295ddc4e1ebcefc83e7368df6d47306b4519105681390ae9ae0615e1880a7d7
|
Provenance
The following attestation bundles were made for ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl:
Publisher:
python-publish.yml on fishisnow/ai_chat_html_exporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_chat_html_exporter-1.0.3.post1-py3-none-any.whl -
Subject digest:
d8a7283d45709cbc875d70be7790d547a978de85ea5b6f00f377a9592cbd4de7 - Sigstore transparency entry: 203559772
- Sigstore integration time:
-
Permalink:
fishisnow/ai_chat_html_exporter@3534543ffcf5b3b12da05a027c7eb1128f1f42b8 -
Branch / Tag:
refs/tags/v1.0.3.post1 - Owner: https://github.com/fishisnow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3534543ffcf5b3b12da05a027c7eb1128f1f42b8 -
Trigger Event:
release
-
Statement type: