界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
文档与办公 · SKILL.md

sap-cloud-sdk-ai

sap-cloud-sdk-ai

【文档与办公】SAP Cloud SDK for AI — generative AI hub SDK, LLM orchestration, prompt templating, model selection, orchestration service for multi-step AI workflows, document grounding, retrieval augmented generation (RAG). Use when building AI agents with SAP Cloud SDK, calling LLMs via SAP BTP GenAI Hub, or implementing RAG patterns with SAP data.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: sap-cloud-sdk-ai description: SAP Cloud SDK for AI — generative AI hub SDK, LLM orchestration, prompt templating, model selection, orchestration service for multi-step AI workflows, document grounding, retrieval augmented generation (RAG). Use when building AI agents with SAP Cloud SDK, calling LLMs via SAP BTP GenAI Hub, or implementing RAG patterns with SAP data. trigger: keywords: [ai, sdk, generative, llm, orchestration, rag, prompt, btp, genai, models] intent: >- Build AI agents and orchestrate LLMs on SAP BTP using the Cloud SDK for AI, including prompt templating, RAG, and model selection.

SAP Cloud SDK for AI

Generative AI development on SAP BTP — LLM orchestration, prompt management, RAG.

Python SDK

from gen_ai_hub.orchestration import OrchestrationService

# Orchestration with templating and grounding
service = OrchestrationService(
    api_url="https://api.ai.core.prod.<region>.aws.cloud.sap/v2",
    client_id="...", client_secret="..."
)

# Define a prompt template
template = '''
System: You are an SAP procurement expert. Answer using only provided context.

Context: {{?grounding_context}}

User: {{?user_input}}
'''

result = service.invoke(
    template=template,
    grounding={"type": "document", "source": "sap-procurement-docs"},
    model={"name": "gpt-4"},
    input={"user_input": "How do I create a purchase order?"}
)
print(result.content)

Document Grounding

# Upload SAP documents for RAG
service.upload_document(
    name="sap-procurement-docs",
    content=open("procurement_guide.pdf", "rb"),
    metadata={"category": "SAP_MM", "language": "EN"}
)

# Query with grounding
response = service.query_with_grounding(
    question="What BAPI creates a purchase order?",
    document_names=["sap-procurement-docs"],
    top_k=3
)

Model Selection

ModelProviderBest For
GPT-4 / GPT-4oOpenAIComplex reasoning, code generation
Codex Opus / SonnetAnthropicAnalysis, structured output
Llama 3Meta (self-hosted)Cost-sensitive, offline scenarios
Gemini ProGoogleMultimodal, long context

Multi-Step Orchestration

# Chain: classify → route → generate → validate
orchestrator = OrchestrationService()

steps = [
    {"name": "classify", "template": classify_template, "model": "gpt-4o-mini"},
    {"name": "generate", "template": generate_template, "model": "gpt-4"},
    {"name": "validate", "template": validate_template, "model": "gpt-4o-mini"}
]

result = orchestrator.run_pipeline(steps=steps, input={"question": user_input})

Gotchas

  • GenAI Hub requires AI Core entitlement on BTP subaccount
  • Rate limits vary by model provider (OpenAI vs Anthropic vs Meta)
  • Document grounding documents must be in supported format (PDF, TXT, MD)
  • Always validate LLM output — hallucination risk with SAP technical content
我的收藏