Skip to content

AI & LLM

AI model integration, text generation, embeddings, and autonomous agents.

18 modules

ModuleDescription
自主代理具備記憶和目標導向行為的自主 AI 代理
鏈式代理具有多步驟的循序 AI 處理鏈
工具使用代理可以調用工具/功能的 AI 代理
文字嵌入使用 AI 模型從文字生成向量嵌入
AI 提取使用 AI 從文字提取結構化資料
本機 Ollama 對話透過 Ollama 與本機 LLM 對話(完全離線)
AI 記憶AI Agent 的對話記憶
實體記憶從對話中擷取並追蹤實體(人物、地點、概念)
Redis 記憶使用 Redis 儲存的持久對話記憶
向量記憶使用向量嵌入的語意記憶,用於擷取相關上下文
AI 模型AI Agent 的 LLM 模型配置
AI ToolExpose a module as a tool for AI Agent
視覺分析使用 AI 視覺模型分析影像
Claude 對話傳送聊天訊息給 Anthropic Claude AI 並取得回應
Google Gemini 對話傳送聊天訊息給 Google Gemini AI 並取得回應
OpenAI 對話傳送聊天訊息給 OpenAI GPT 模型
DALL-E 圖片產生使用 DALL-E 產生圖片
AI 代理自主 AI 代理,支援多埠連接(模型、記憶、工具)

Modules

自主代理

agent.autonomous

具備記憶和目標導向行為的自主 AI 代理

Parameters:

NameTypeRequiredDefaultDescription
goalstringYes-代理要達成的目標
contextstringNo-額外的上下文或限制條件
max_iterationsnumberNo5最大推理步驟數
llm_providerselect (openai, ollama)NoopenaiLLM 提供者(openai 或 ollama)
modelstringNogpt-4-turbo-preview模型名稱(例如 gpt-4、llama2、mistral)
ollama_urlstringNohttp://localhost:11434Ollama 伺服器網址(僅限 ollama 提供者)
temperaturenumberNo0.7創造力等級(0-2)

Output:

FieldTypeDescription
resultstring操作結果
thoughtsarray代理推理步驟
iterationsnumber執行的迭代次數
goal_achievedboolean是否達成目標

Example: Research task

yaml
goal: Research the latest trends in AI and summarize the top 3
max_iterations: 5
model: gpt-4

Example: Problem solving

yaml
goal: Find the best approach to optimize database queries
context: PostgreSQL database with 10M records
max_iterations: 10

鏈式代理

agent.chain

具有多步驟的循序 AI 處理鏈

Parameters:

NameTypeRequiredDefaultDescription
inputstringYes-鏈式處理的初始輸入
chain_stepsarrayYes-處理步驟陣列(每個都是提示詞範本)
llm_providerselect (openai, ollama)NoopenaiLLM 提供者(openai 或 ollama)
modelstringNogpt-4-turbo-preview模型名稱(例如 gpt-4、llama2、mistral)
ollama_urlstringNohttp://localhost:11434Ollama 伺服器網址(僅限 ollama 提供者)
temperaturenumberNo0.7創造力等級(0-2)

Output:

FieldTypeDescription
resultstring最終結果
intermediate_resultsarray中間結果
steps_completednumber已完成的步驟數

Example: Content pipeline

yaml
input: AI and machine learning trends
chain_steps: ["Generate 5 blog post ideas about: {input}", "Take the first idea and write a detailed outline: {previous}", "Write an introduction paragraph based on: {previous}"]
model: gpt-4

Example: Data analysis chain

yaml
input: User behavior data shows 60% bounce rate
chain_steps: ["Analyze what might cause this issue: {input}", "Suggest 3 solutions based on: {previous}", "Create an action plan from: {previous}"]

工具使用代理

agent.tool_use

可以調用工具/功能的 AI 代理

Parameters:

NameTypeRequiredDefaultDescription
promptstringYes-代理的目標或任務
toolsarrayYes-工具定義列表 [{name, description, parameters}]
providerselect (openai, anthropic)Noopenai代理的 LLM 提供者
modelstringNogpt-4o要使用的模型
api_keystringNo-API 金鑰(可回退到環境變數)
max_iterationsnumberNo10工具調用回合的最大次數
system_promptstringNo-可選的系統提示以引導代理

Output:

FieldTypeDescription
resultstring代理的最終回應
tool_callsarray執行期間所有的工具調用
iterationsnumber已完成的回合數
modelstring使用的模型

Example: File Processing Agent

yaml
prompt: Read the config file and update the version number
tools: [{"name": "read_file", "description": "Read contents of a file", "parameters": {"type": "object", "properties": {"path": {"type": "string", "description": "File path"}}, "required": ["path"]}}, {"name": "write_file", "description": "Write contents to a file", "parameters": {"type": "object", "properties": {"path": {"type": "string", "description": "File path"}, "content": {"type": "string", "description": "File content"}}, "required": ["path", "content"]}}]
provider: openai
model: gpt-4o
max_iterations: 5

文字嵌入

ai.embed

使用 AI 模型從文字生成向量嵌入

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-要嵌入的文字
providerselect (openai, local)Noopenai嵌入的 AI 提供者
modelstringNotext-embedding-3-small要使用的嵌入模型
api_keystringNo-API 金鑰(可回退至環境變數)
dimensionsnumberNo-嵌入維度(適用於支援的模型)

Output:

FieldTypeDescription
embeddingsarray向量嵌入陣列
modelstring用於嵌入的模型
dimensionsnumber嵌入向量的維度數
token_countnumber處理的標記數量

Example: Single Text Embedding

yaml
text: The quick brown fox jumps over the lazy dog
provider: openai
model: text-embedding-3-small

Example: Reduced Dimensions

yaml
text: Semantic search query
provider: openai
model: text-embedding-3-small
dimensions: 256

AI 提取

ai.extract

使用 AI 從文字提取結構化資料

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-從中提取資料的文字
schemaobjectYes-定義要提取欄位的 JSON 架構
instructionsstringNo-額外的提取指示
providerselect (openai, anthropic)Noopenai要使用的 AI 提供者
modelstringNogpt-4o-mini用於提取的模型
api_keystringNo-API 金鑰(可回退至環境變數)
temperaturenumberNo0取樣溫度(0-2)

Output:

FieldTypeDescription
extractedobject提取的結構化資料
modelstring用於提取的模型
raw_responsestring模型的原始回應

Example: Extract Contact Info

yaml
text: John Smith is a senior engineer at Acme Corp. Email: john@acme.com
schema: {"type": "object", "properties": {"name": {"type": "string"}, "title": {"type": "string"}, "company": {"type": "string"}, "email": {"type": "string"}}}
provider: openai
model: gpt-4o-mini

Example: Extract Invoice Data

yaml
text: Invoice #1234 from Acme Corp. Total: $500.00. Due: 2024-03-01
schema: {"type": "object", "properties": {"invoice_number": {"type": "string"}, "vendor": {"type": "string"}, "total": {"type": "number"}, "due_date": {"type": "string"}}}
instructions: Extract all invoice fields. Parse amounts as numbers.

本機 Ollama 對話

ai.local_ollama.chat

透過 Ollama 與本機 LLM 對話(完全離線)

Parameters:

NameTypeRequiredDefaultDescription
promptstringYes-傳送給本機 LLM 的訊息
modelselect (llama2, llama2:13b, llama2:70b, mistral, mixtral, codellama, codellama:13b, phi, neural-chat, starling-lm)Nollama2要使用的模型名稱
temperaturenumberNo0.7取樣溫度(0-2)
system_messagestringNo-系統角色訊息(選填)
ollama_urlstringNohttp://localhost:11434Ollama 伺服器網址
max_tokensnumberNo-回應的最大 Token 數量

Output:

FieldTypeDescription
responsestring模型回應內容
modelstring使用的模型
contextarray對話上下文
total_durationnumber總處理時間
load_durationnumber模型載入時間
prompt_eval_countnumber提示詞評估數量
eval_countnumber評估 Token 數量

Example: Simple local chat

yaml
prompt: Explain quantum computing in 3 sentences
model: llama2

Example: Code generation with local model

yaml
prompt: Write a Python function to calculate fibonacci numbers
model: codellama
temperature: 0.2
system_message: You are a Python programming expert. Write clean, efficient code.

Example: Local reasoning task

yaml
prompt: What are the pros and cons of microservices architecture?
model: mistral
temperature: 0.7

AI 記憶

ai.memory

AI Agent 的對話記憶

Parameters:

NameTypeRequiredDefaultDescription
memory_typeselect (buffer, window, summary)Yesbuffer記憶儲存類型
window_sizenumberNo10保留的最近訊息數量(用於視窗記憶)
session_idstringNo-此對話會話的唯一識別碼
initial_messagesarrayNo[]預載的對話歷史

Output:

FieldTypeDescription
memory_typestring記憶類型
session_idstring會話識別碼
messagesarray對話訊息
configobject記憶配置

Example: Simple Buffer Memory

yaml
memory_type: buffer

Example: Window Memory (last 5 messages)

yaml
memory_type: window
window_size: 5

實體記憶

ai.memory.entity

從對話中擷取並追蹤實體(人物、地點、概念)

Parameters:

NameTypeRequiredDefaultDescription
entity_typesmultiselectNo['person', 'organization', 'location']Types of entities to extract and track
extraction_modelselect (llm, spacy, regex)YesllmModel for entity extraction
session_idstringNo-Unique identifier for this memory session
track_relationshipsbooleanNoTrueTrack relationships between entities
max_entitiesnumberNo100Maximum number of entities to remember

Output:

FieldTypeDescription
memory_typestring記憶類型(entity)
session_idstring會話識別碼
entitiesobject追蹤的實體
relationshipsarray實體關係
configobject記憶配置

Example: People & Organizations

yaml
entity_types: ["person", "organization"]
extraction_model: llm

Example: Full Entity Tracking

yaml
entity_types: ["person", "organization", "location", "concept"]
track_relationships: true
max_entities: 200

Redis 記憶

ai.memory.redis

使用 Redis 儲存的持久對話記憶

Parameters:

NameTypeRequiredDefaultDescription
redis_urlstringYesredis://localhost:6379Redis connection URL
key_prefixstringNoflyto:memory:Prefix for all Redis keys
session_idstringYes-Unique identifier for this memory session
ttl_secondsnumberNo86400Time-to-live for memory entries (0 = no expiry)
max_messagesnumberNo100Maximum messages to store per session
load_on_startbooleanNoTrueLoad existing messages from Redis on initialization

Output:

FieldTypeDescription
memory_typestring記憶類型(redis)
session_idstring會話識別碼
messagesarray載入的訊息歷史
connectedboolean連線狀態
configobject記憶配置

Example: Local Redis

yaml
redis_url: redis://localhost:6379
session_id: my-session
ttl_seconds: 3600

Example: Cloud Redis with Auth

yaml
redis_url: redis://:password@redis-cloud.example.com:6379
session_id: user-session
ttl_seconds: 86400
max_messages: 500

向量記憶

ai.memory.vector

使用向量嵌入的語意記憶,用於擷取相關上下文

Parameters:

NameTypeRequiredDefaultDescription
embedding_modelselect (text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002, local)Yestext-embedding-3-smallModel to use for generating embeddings
top_knumberNo5Number of most relevant memories to retrieve
similarity_thresholdnumberNo0.7Minimum similarity score (0-1) for retrieval
session_idstringNo-Unique identifier for this memory session
include_metadatabooleanNoTrueInclude timestamp and other metadata with memories

Output:

FieldTypeDescription
memory_typestring記憶類型(vector)
session_idstring會話識別碼
embedding_modelstring嵌入模型
configobject記憶配置

Example: Default Vector Memory

yaml
embedding_model: text-embedding-3-small
top_k: 5

Example: High Precision Memory

yaml
embedding_model: text-embedding-3-large
top_k: 10
similarity_threshold: 0.85

AI 模型

ai.model

AI Agent 的 LLM 模型配置

Parameters:

NameTypeRequiredDefaultDescription
providerselect (openai, anthropic, ollama)NoopenaiAI model provider
modelstringNogpt-4oSpecific model to use
temperaturenumberNo0.7Creativity level (0=deterministic, 1=creative)
api_keystringNo-API key (defaults to provider env var)
base_urlstringNo-Custom API base URL (for Ollama or proxies)
max_tokensnumberNo4096回應的最大 Token 數量

Output:

FieldTypeDescription
providerstringLLM 提供者
modelstring模型名稱
configobject模型配置

Example: OpenAI GPT-4

yaml
provider: openai
model: gpt-4o
temperature: 0.7

Example: Anthropic Claude

yaml
provider: anthropic
model: claude-3-5-sonnet-20241022
temperature: 0.5

AI Tool

ai.tool

Expose a module as a tool for AI Agent

Parameters:

NameTypeRequiredDefaultDescription
module_idstringYes-Module ID to expose as tool (e.g. http.request, data.json_parse)
tool_descriptionstringNo-Custom description for the agent (overrides module default)

Output:

FieldTypeDescription
module_idstringModule ID exposed as tool

Example: HTTP Request Tool

yaml
module_id: http.request

Example: JSON Parse Tool

yaml
module_id: data.json_parse

視覺分析

ai.vision.analyze

使用 AI 視覺模型分析影像

Parameters:

NameTypeRequiredDefaultDescription
image_pathstringNo-影像檔案的本地路徑
image_urlstringNo-要分析的影像 URL
promptstringNoDescribe this image in detail要分析或詢問圖片的內容
providerselect (openai, anthropic)Noopenai視覺分析的 AI 提供者
modelstringNogpt-4o要使用的視覺模型
api_keystringNo-API 金鑰(可回退至環境變數)
max_tokensnumberNo1000回應中的最大標記數量
detailselect (low, high, auto)Noauto影像細節等級(低/高/自動)

Output:

FieldTypeDescription
analysisstring影像的 AI 分析
modelstring用於分析的模型
providerstring用於分析的提供者
tokens_usednumber使用的標記數量

Example: Analyze Screenshot

yaml
image_path: /tmp/screenshot.png
prompt: Describe what you see in this UI screenshot
provider: openai
model: gpt-4o

Example: Analyze from URL

yaml
image_url: https://example.com/photo.jpg
prompt: What objects are in this image?
provider: anthropic
model: claude-sonnet-4-20250514

Claude 對話

api.anthropic.chat

傳送聊天訊息給 Anthropic Claude AI 並取得回應

Parameters:

NameTypeRequiredDefaultDescription
api_keystringNo-Anthropic API 金鑰(預設使用 env.ANTHROPIC_API_KEY)
modelstringNoclaude-3-5-sonnet-20241022要使用的 Claude 模型
messagesarrayYes-包含角色和內容的訊息物件陣列
max_tokensnumberNo1024回應的最大 Token 數
temperaturenumberNo1.0取樣溫度(0-1),較高值使輸出更隨機
systemstringNo-引導 Claude 行為的系統提示詞

Output:

FieldTypeDescription
contentstring回應內容
modelstring使用的模型
stop_reasonstring停止原因
usageobjectToken 使用統計

Example: Simple question

yaml
messages: [{"role": "user", "content": "What is the capital of France?"}]
max_tokens: 100

Example: Text summarization

yaml
system: You are a helpful assistant that summarizes text concisely.
messages: [{"role": "user", "content": "Summarize this article: ${article_text}"}]
max_tokens: 500

Google Gemini 對話

api.google_gemini.chat

傳送聊天訊息給 Google Gemini AI 並取得回應

Parameters:

NameTypeRequiredDefaultDescription
api_keystringNo-Google AI API 金鑰(預設使用 env.GOOGLE_AI_API_KEY)
modelstringNogemini-1.5-pro要使用的 Gemini 模型
promptstringYes-傳送給 Gemini 的文字提示詞
temperaturenumberNo1.0控制隨機性(0-2),較高值使輸出更隨機
max_output_tokensnumberNo2048回應的最大 Token 數

Output:

FieldTypeDescription
textstringGenerated text response from Gemini
modelstringModel used for generation
candidatesarrayAll candidate responses

Example: Simple question

yaml
prompt: Explain quantum computing in simple terms

Example: Content generation

yaml
prompt: Write a professional email about ${topic}
temperature: 0.7
max_output_tokens: 500

OpenAI 對話

api.openai.chat

傳送聊天訊息給 OpenAI GPT 模型

Parameters:

NameTypeRequiredDefaultDescription
promptstringYes-傳送給 GPT 的訊息
modelselect (gpt-4-turbo-preview, gpt-4, gpt-3.5-turbo)Nogpt-4-turbo-preview要使用的 GPT 模型
temperaturenumberNo0.7取樣溫度(0-2)
max_tokensnumberNo1000回應的最大 Token 數
system_messagestringNo-系統角色訊息(選填)

Output:

FieldTypeDescription
responsestring回應文字
modelstring使用的模型
usageobjectToken 使用統計

Example: Simple chat

yaml
prompt: Explain quantum computing in 3 sentences
model: gpt-3.5-turbo

Example: Code generation

yaml
prompt: Write a Python function to calculate fibonacci numbers
model: gpt-4
temperature: 0.2
system_message: You are a Python programming expert

DALL-E 圖片產生

api.openai.image

使用 DALL-E 產生圖片

Parameters:

NameTypeRequiredDefaultDescription
promptstringYes-要產生的圖片描述
sizeselect (256x256, 512x512, 1024x1024, 1792x1024, 1024x1792)No1024x1024圖片尺寸
modelselect (dall-e-3, dall-e-2)Nodall-e-3DALL-E 模型版本
qualityselect (standard, hd)Nostandard圖片品質(僅限 DALL-E 3)
nnumberNo1要產生的圖片數量(1-10)

Output:

FieldTypeDescription
imagesarrayList of generated images
modelstringModel name or identifier

Example: Generate artwork

yaml
prompt: A serene mountain landscape at sunset, digital art
size: 1024x1024
model: dall-e-3
quality: hd

Example: Create logo

yaml
prompt: Modern tech startup logo with blue and green colors
size: 512x512
model: dall-e-2
n: 3

AI 代理

llm.agent

自主 AI 代理,支援多埠連接(模型、記憶、工具)

Parameters:

NameTypeRequiredDefaultDescription
prompt_sourceselect (manual, auto)Nomanual取得任務提示詞的來源
taskstringNo-代理要完成的任務。使用 {{input}} 參考上游資料。
prompt_pathstringNo{<!-- -->{input}<!-- -->}從輸入擷取提示詞的路徑(例如 {{input.message}})
join_strategyselect (first, newline, separator, json)Nofirst如何處理陣列輸入
join_separatorstringNo`

| 合併陣列項目的分隔符 | |max_input_size| number | No |10000| 提示詞的最大字元數(防止溢位) | |system_prompt| string | No |You are a helpful AI agent. Use the available tools to complete the task. Think step by step.| 代理行為的指示說明 | |tools| array | No |[]| 模組 ID 列表(可替代連接工具節點) | |context| object | No |{}| 提供給代理的額外上下文資料 | |max_iterations| number | No |10| 代理執行的最大迭代次數 | |provider | select (openai, anthropic, ollama) | No | openai| AI model provider | |model| string | No |gpt-4o| Specific model to use | |temperature| number | No |0.3| Creativity level (0=deterministic, 1=creative) | |api_key| string | No | - | API key (defaults to provider env var) | |base_url` | string | No | - | Custom API base URL (for Ollama or proxies) |

Output:

FieldTypeDescription
okboolean代理是否成功完成
resultstring代理的最終結果
stepsarray代理執行的步驟列表
tool_callsnumber工具呼叫記錄
tokens_usednumber使用的 Token 數量

Example: Web Research Agent

yaml
task: Search for the latest news about AI and summarize the top 3 stories
tools: ["http.request", "data.json_parse"]
model: gpt-4o

Example: Data Processing Agent

yaml
task: Read the CSV file, filter rows where status is "active", and count them
tools: ["file.read", "data.csv_parse", "array.filter"]
model: gpt-4o

Released under the Apache 2.0 License.