Concierge Agentic Web Interfaces
Expose your service to Agents
Concierge is a declarative framework that allows LLMs to interact with your applications and navigate through complex service hierarchies. Build applications for AI/LLM use exposed over the web to guide agents towards domain specific goals.
礼宾令牌在任务难度不断增加的情况下提高效率。
快速开始
1.ChatGPT应用程序
# Install MCP SDK
pip install openmcp-sdk
# Initialize with ChatGPT Apps support
openmcp init --chatgpt
# Deploy your service
openmcp deployExample: Interactive Applications rendering in ChatGPT
from openmcp import OpenMCP
mcp = OpenMCP("my-app", stateless_http=True)
@mcp.widget(uri="widget://chart", html="
Chart Widget
")
def show_chart(data: str):
"""Display a chart widget."""
return {"data": data}Concierge OpenMCP提供了自己的抽象,如 widgets 以及模拟 window.openai 在检查器中,可以在几秒钟内创建应用程序。 使用https://getconcierge.app/docs开始吧。
2.MCP服务器
# Install MCP Core
pip install openmcp-sdk
# Initialize your MCP project
openmcp init
# Deploy your service
openmcp deployExample: Convert your existing MCPs to OpenMCP
from mcp.server.fastmcp import FastMCP
from openmcp import OpenMCP
# Enable OpenMCP on FastMCP
mcp = OpenMCP(FastMCP("my-server")) # 1 line replacement
@mcp.tool()
def get_user(user_id: int):
"""Get user by ID."""
return {"id": user_id, "name": "John"}
if __name__ == "__main__":
mcp.run()您现有的MCP工具工作不变。OpenMCP增加了小部件支持、检查器调试和ChatGPT应用程序兼容性。 使用https://getconcierge.app/docs开始吧。
3.礼宾部多级工作流程
# Install MCP Core with all features
pip install openmcp-sdk[all]
# Initialize concierge project
openmcp init
# Deploy with enhanced capabilities
openmcp deployExample: Enable OpenMCP Search Backend
from openmcp import OpenMCP, Config, ProviderType
mcp = OpenMCP("my-app", config=Config(provider_type=ProviderType.SEARCH))
@mcp.tool()
def add(a: int, b: int):
"""Add two numbers together."""
return a + b
@mcp.tool()
def subtract(a: int, b: int):
"""Subtract b from a."""
return a - b
# Automatically adds search_tools and call_tool!支持的协议
| 协议 | 状态 | 描述 |
|---|---|---|
| AIP(代理交互协议) | ✅ 支持 | Concierge本机实现了代理交互协议(AIP),用于将代理连接到web公开的服务。工具是动态提供的,可以防止模型上下文膨胀,节省成本和延迟。 |
| MCP(模型上下文协议) | ✅ 支持 | 现在通过MCP快速完成礼宾工作流程 |
核心概念
开发人员使用明确的规则和先决条件定义工作流。您可以通过在每个阶段指定合法任务和阶段之间的有效转换来控制代理自主性。例如:代理商在将商品添加到购物车之前无法结账。Concierge执行这些规则,在执行任务之前验证先决条件,并确保代理在应用程序中遵循您定义的路径。
任务
任务是可调用业务逻辑的最小粒度。在一个阶段内可以定义多个任务。确保这些任务在该阶段是可用的或可调用的。
@task(description="Add product to shopping cart")
def add_to_cart(self, state: State, product_id: str, quantity: int) -> dict:
"""Adds item to cart and updates state"""
cart_items = state.get("cart.items", [])
cart_items.append({"product_id": product_id, "quantity": quantity})
state.set("cart.items", cart_items)
return {"success": True, "cart_size": len(cart_items)}阶段
阶段是实现目标的逻辑子步骤,阶段可以将多个任务组合在一起,代理可以在给定点调用这些任务。
@stage(name="product")
class ProductStage:
@task(description="Add product to shopping cart")
def add_to_cart(self, state: State, product_id: str, quantity: int) -> dict:
"""Adds item to cart"""
@task(description="Save product to wishlist")
def add_to_wishlist(self, state: State, product_id: str) -> dict:
"""Saves item for later"""
状态
状态是由Concierge维护的全局上下文,当代理在各个阶段转换和导航时,其部分内容可以传播到其他阶段。
# State persists across stages and tasks
state.set("cart.items", [{"product_id": "123", "quantity": 2}])
state.set("user.email", "user@example.com")
state.set("cart.total", 99.99)
# Retrieve state values
items = state.get("cart.items", [])
user_email = state.get("user.email")工作流程
工作流是几个阶段的逻辑分组,您可以定义阶段图,这些阶段图表示工作流中其他阶段的合法移动。
@workflow(name="shopping")
class ShoppingWorkflow:
discovery = DiscoveryStage # Search and filter products
product = ProductStage # View product details
selection = SelectionStage # Add to cart/wishlist
cart = CartStage # Manage cart items
checkout = CheckoutStage # Complete purchase
transitions = {
discovery: [product, selection],
product: [selection, discovery],
selection: [cart, discovery, product],
cart: [checkout, selection, discovery],
checkout: []
}仪表盘
例子
多阶段工作流
@workflow(name="amazon_shopping")
class AmazonShoppingWorkflow:
browse = BrowseStage # Search and filter products
select = SelectStage # Add items to cart
checkout = CheckoutStage # Complete transaction
transitions = {
browse: [select],
select: [browse, checkout],
checkout: []
}有任务的阶段
@stage(name="browse")
class BrowseStage:
@task(description="Search for products by keyword")
def search_products(self, state: State, query: str) -> dict:
"""Returns matching products"""
@task(description="Filter products by price range")
def filter_by_price(self, state: State, min_price: float, max_price: float) -> dict:
"""Filters current results by price"""
@task(description="Sort products by rating or price")
def sort_products(self, state: State, sort_by: str) -> dict:
"""Sorts: 'rating', 'price_low', 'price_high'"""
@stage(name="select")
class SelectStage:
@task(description="Add product to shopping cart")
def add_to_cart(self, state: State, product_id: str, quantity: int) -> dict:
"""Adds item to cart"""
@task(description="Save product to wishlist")
def add_to_wishlist(self, state: State, product_id: str) -> dict:
"""Saves item for later"""
@task(description="Star product for quick access")
def star_product(self, state: State, product_id: str) -> dict:
"""Stars item as favorite"""
@task(description="View product details")
def view_details(self, state: State, product_id: str) -> dict:
"""Shows full product information"""先决条件
@stage(name="checkout", prerequisites=["cart.items", "user.payment_method"])
class CheckoutStage:
@task(description="Apply discount code")
def apply_discount(self, state: State, code: str) -> dict:
"""Validates and applies discount"""
@task(description="Complete purchase")
def complete_purchase(self, state: State) -> dict:
"""Processes payment and creates order"""我们正在构建代理网络。来加入我们吧。
有兴趣与礼宾部合作或建立联系吗? 联系.
贡献
欢迎捐款。请打开问题或提交拉取请求。
