当前位置: 首页 > Skill >

Filechat

Filechat

Filechat

在任意 Google Drive 文件夹中安全存储的文档上,使用语义向量搜索(RAG)进行搜索、检索和聊天。适用时机:①用户请求保存...

1.0.4 2026.11.27 672
获取Skill文件查看使用说明
作 者:沈言 许可证: 更新时间:2026.11.27
本文目录收起

FileChat RAG Skill

Your personal RAG (Retrieval-Augmented Generation) document library backed by Google Drive. Supports multiple Google Drive folders dynamically, interactive folder routing, incremental sync, choosing between Gemini or OpenAI for embeddings, and connecting to Qdrant.

Setup & Bootstrap

FIRST verify that the required environment variables are set in /workspace/skills/filechat/.env:

  1. EMBEDDING_PROVIDER (either gemini or openai)
  2. GEMINI_API_KEY or OPENAI_API_KEY
  3. Optional: QDRANT_URL and QDRANT_API_KEY (If absent, it uses local disk-based JSON).

Create the .env file like this:

echo "EMBEDDING_PROVIDER=gemini" > ./skills/filechat/.env
echo "GEMINI_API_KEY=your_key_here" >> ./skills/filechat/.env

Google Workspace Authentication: Before running any commands, check if the system is authenticated by running:

npx @googleworkspace/cli auth status

If it returns an auth error or indicates no token, you MUST prompt the user to authenticate. Trigger the interactive login flow:

npx @googleworkspace/cli auth login --services drive

Wait for the user to complete the browser OAuth flow before proceeding.

Folder Management

The user can have infinite folders synced. You manage them using folders.js.

  • List Folders: cd ./skills/filechat && node folders.js list
  • Add a Folder: node folders.js add "Taxes 2026" <FOLDER_ID> (Auto-discovers the ID via gws drive files list if you don't know it!)
  • Set Default Folder: node folders.js default "Taxes 2026"

If the user asks to do something with a file/folder but doesn't specify which one, run node folders.js get-default to find the default ID. If no folders exist, ask them to set one up!

How to Sync the Library

When the user asks to "sync", "flush", or "update", you must run the ingestion script.

To sync a specific folder:

cd ./skills/filechat && node sync.js <FOLDER_ID>

To sync EVERYTHING (all folders in the registry):

cd ./skills/filechat && node sync-all.js

Note: Syncs are highly incremental and use a local cache! If a file hasn't been modified in Drive, the script will skip it instantly and output "0 chunks" embedded. This is NORMAL behavior. If you are debugging, testing, or the user specifically requests a hard flush, you MUST delete the cache files first:

rm ./skills/filechat/meta_<FOLDER_ID>.json
rm ./skills/filechat/vector_db_<FOLDER_ID>.json

How to Answer User Questions (RAG)

Query the local vector store or Qdrant for the target Folder ID to fetch relevant text chunks:

cd ./skills/filechat && node query.js <FOLDER_ID> "What does my medical discharge say?"

Use the snippets returned to answer the user.

How to Retrieve and Send a Physical File

Find the File ID using the query script, then download it:

gws drive files get --params '{"fileId": "<FILE_ID>", "alt": "media"}' --output /workspace/discharge.pdf

Reply using the media tag: MEDIA:/workspace/discharge.pdf.

How to Store a New File for the User

If the user uploads a file and asks you to save it (or implicitly sends a file per your automatic processing rules):

  1. Check their folders (node folders.js list).
  2. If they didn't specify which folder, use the default folder. If no default is set, ask them!
  3. Notify the user exactly which folder the file is being saved to.
  4. Tell the user that you are now extracting the information and saving it in a vectordb.
  5. If the file is an image or scanned document, make sure to extract the text using a vision model or OCR before it is embedded. (The sync script handles this natively).
  6. Upload it to the correct folder using gws:
    gws drive files create --json '{"name": "filename.pdf", "parents": ["<FOLDER_ID>"]}' --upload /path/to/uploaded/file.pdf
    
  7. Trigger node sync.js <FOLDER_ID> so the vector database chunks and embeds the file into the corresponding vectordb.

How to Test & Validate the Skill

If the user asks you to verify the skill is working, or if you just set it up and want to ensure end-to-end functionality, follow these exact steps:

  1. Verify Auth: Run npx @googleworkspace/cli auth status. Ensure it shows a valid token.
  2. Verify Drive Access: Do a dry-run fetch of the target folder to ensure GWS can see the files.
    npx @googleworkspace/cli drive files list --params '{"q": "'''<FOLDER_ID>''' in parents and trashed = false"}'
    
    (If this fails, check folder permissions or GWS credentials.)
  3. Force a Clean Sync: Clear the cache for the test folder to guarantee a fresh run, then sync.
    rm -f ./skills/filechat/meta_<FOLDER_ID>.json ./skills/filechat/vector_db_<FOLDER_ID>.json
    node ./skills/filechat/sync.js <FOLDER_ID>
    
    (You should see files being downloaded, OCR'd, and chunks being embedded. If it says "0 chunks", verify the folder isn't empty.)
  4. Test the Vector Query: Run a generic query to verify the embeddings were saved and cosine similarity works.
    node ./skills/filechat/query.js <FOLDER_ID> "hello"
    
    (You should see a list of "Top matches" with similarity scores and text snippets. If you do, the RAG pipeline is 100% operational!)

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,040
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,033
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,021
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,021
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,019
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,016
Skill 文件
  • SKILL.md
    • FileChat RAG Skill
    • Setup & Bootstrap
    • Folder Management
    • How to Sync the Library
    • How to Answer User Questions (RAG)
    • How to Retrieve and Send a Physical File
    • How to Store a New File for the User
    • How to Test & Validate the Skill
  • 项目或源文件

相关 Skill

更多
Cloud Cloud 选择、整理、同步、共享并备份个人文件至 iCloud、Google Drive、Dropbox 和 OneDrive。
Workspace Sync & Backup Workspace Sync & Backup 使用 rclone 同步代理工作区与云存储(Dropbox、Google Drive、S3 等)
GDrive Owncloud sync GDrive Owncloud sync 检查 Google Drive 中的新文件是否已同步到 OwnCloud 并发送邮件报告
Backup & Recovery Automation Backup & Recovery Automation 使用 rClone 实现 OpenClaw 备份与恢复自动化。每日备份至 Google Drive,保留 20 天轮换。
Todo4google Todo4google 管理待办事项,记录工作日志,与 Google Tasks 同步。根据本地待办创建 Google 任务并更新状态。将待办文件上传至 Google Drive 归档。