hughhuangandClaude Sonnet 4.5 45c3ab606e docs: 添加伪流式接口使用指南
- 详细说明伪流式接口的技术架构和工作原理
- 提供完整的 API 使用示例和前端集成代码
- 包含多个实际使用场景的步骤展示
- 说明性能优化和故障排查方法
- 对比三种接口类型的优缺点

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 16:17:02 +08:00
2026-01-29 20:58:16 +08:00
2026-01-29 20:58:16 +08:00

Skills Demo

A focused demonstration of the SkillsTool system for building custom AI agent capabilities.

Overview

This demo shows how to create and use AI agent skills - specialized capabilities defined in Markdown files that can include helper scripts, reference documentation, and custom tool restrictions.

Features

  • ai-tutor skill - Creates educational PDF tutorials explaining technical concepts
  • pdf skill - Generates PDF documents from content
  • YouTube transcript integration for research-based content
  • Classpath-based skill loading for packaged applications
  • Python helper scripts for extended functionality

Quick Start

Prerequisites

  • Java 17+
  • Maven 3.6+
  • AI provider API key (Anthropic, OpenAI, or Google)
  • Python 3.9+ (for YouTube transcript fetching)

Setup

  1. Set your API key:
export ANTHROPIC_API_KEY=your-key-here
# Or use OpenAI: export OPENAI_API_KEY=your-key-here
# Or use Google: export GOOGLE_CLOUD_PROJECT=your-project-id
  1. Optional - for web search:
export BRAVE_API_KEY=your-brave-key
  1. Run the demo:
mvn spring-boot:run

How It Works

The demo executes a single prompt that:

  1. Requests an explanation of a technical concept (reinforcement learning)
  2. References a YouTube video for supporting content
  3. Automatically invokes the ai-tutor skill
  4. Fetches the YouTube transcript using Python
  5. Generates an educational explanation
  6. Can create a PDF tutorial

Example Code

var answer = chatClient.prompt("""
    Explain reinforcement learning in simple terms and use.
    Use required skills.
    Then use the Youtube video https://youtu.be/vXtfdGphr3c transcript
    to support your answer.
    """).call().content();

Skills Configuration

Skills are loaded from classpath resources in src/main/resources/.claude/skills/:

src/main/resources/.claude/skills/
├── ai-tutor/
│   ├── SKILL.md                    # Skill definition
│   ├── REFERENCE.md                # Supporting documentation
│   └── scripts/
│       └── get_youtube_transcript.py
└── pdf/
    ├── SKILL.md
    └── scripts/

Configure in application.properties:

agent.skills.dirs=classpath:/.claude/skills

Creating Your Own Skills

  1. Create a directory under .claude/skills/
  2. Add a SKILL.md with YAML frontmatter:
---
name: my-skill
description: What the skill does and when to use it
allowed-tools: Read, Bash, Grep
model: claude-sonnet-4-5-20250929
---

# Skill Instructions
Your detailed prompt for the AI agent...
  1. Optionally add helper scripts and reference files

Architecture

The demo uses:

  • SkillsTool - Loads and manages agent skills
  • ShellTools - Executes shell commands (for running Python scripts)
  • FileSystemTools - Reads/writes files (for PDF generation)
  • SmartWebFetchTool - Fetches web content
  • BraveWebSearchTool - Web search capabilities

Switching AI Providers

Update pom.xml and application.properties to use different providers:

Anthropic Claude (default):

spring.ai.anthropic.api-key=${ANTHROPIC_API_KEY}
spring.ai.anthropic.chat.options.model=claude-sonnet-4-5-20250929

OpenAI:

spring.ai.openai-sdk.api-key=${OPENAI_API_KEY}
spring.ai.openai-sdk.chat.options.model=gpt-5-mini-2025-08-07

Google Gemini:

spring.ai.google.genai.project-id=${GOOGLE_CLOUD_PROJECT}
spring.ai.google.genai.chat.options.model=gemini-3-pro-preview

Learn More

License

Apache License 2.0

S
Description
No description provided
Readme
355 KiB
0 Stars 1 Watchers 0 Forks
Languages
Java 42.3%
JavaScript 27.6%
CSS 15.9%
HTML 10.1%
Python 4.1%