在其中创建一个名为 pdf-parsing 的文件夹。该文件夹用于存放 PDF 解析相关的全部文件。
在 pdf-parsing 文件夹中,新建一个 SKILL.md 文件,内容如下:
---name: pdf-processingdescription: Extracts textfromPDF filesusingPyPDF2.--- # PDF Processing Skill ## When to use this skillUsethisskillwhena user needs to extract textfroma PDFfile. ## How to Use this SkillThis skill provides the `extract_text()` functionfromthe `parse_pdf.py` script. Import itintoyour agent script: pythonfromskills.pdf_parsing.parse_pdf import extract_text result = extract_text( file_path="/path/to/document.pdf", pages="all"# or "1-3" or "1,2,3") ### Parameters- `file_path` (str): Path to the PDFfile- `pages` (str): Pages to extract -"all","1-3"(range),or"1,2,3"(specific pages) ### ReturnsJSONobjectwith:- `success` (bool): Whether extraction succeeded- `file_path` (str): Path to the processedfile- `total_pages` (int): Total pagesinPDF- `extracted_pages` (int): Number of pages extracted- `pages` (list): Array of {page: number, text:string} objects Alternatively, you can call the script directlyfromthe command line:commandpython skills/pdf-parsing/parse_pdf.py extract_text --file_path /path/to/file.pdf --pages all
本教程不涉及从零开始构建一个支持 SKill 的智能体,但你可以使用我们提供的这个智能体脚本。该脚本通过 DigitalOcean Gradient AI 平台的无服务器推理(Serverless Inference)功能调用 Llama 3.3 70B 模型。你需要先获取一个模型访问密钥,才能在 DigitalOcean Gradient AI 平台上使用无服务器推理服务。请将你的模型访问密钥添加到脚本的 main() 函数中。
在这里我们简单先介绍一下DigitalOcean Gradient AI平台的无服务推理。
DigitalOcean Gradient AI 平台的无服务器推理(Serverless Inference)是一种让开发者无需管理任何底层基础设施,就能调用强大 AI 模型进行推理计算的服务。这种模式通过简洁的 API 让你直接访问包括开源模型和主流大模型提供者的能力,无需自行部署或维护服务器集群。它由 DigitalOcean 平台自动处理扩容、可用性和资源调度等复杂工作,使开发者可以集中精力构建应用逻辑,而不必担心底层算力的管理和运维。