当前位置: 首页 > wzjs >正文

孝昌网站建设广东网络建设有限公司

孝昌网站建设,广东网络建设有限公司,wordpress访问次数,wordpress网代码显示图片网页链接 https://spec.modelcontextprotocol.io/specification/draft/client/sampling/ 主要内容概述 该网页详细介绍了Model Context Protocol (MCP) 中的“Sampling”功能。Sampling允许服务器通过客户端请求语言模型(LLM)生成文本、音频或图像内容…

网页链接

  • https://spec.modelcontextprotocol.io/specification/draft/client/sampling/

主要内容概述

该网页详细介绍了Model Context Protocol (MCP) 中的“Sampling”功能。Sampling允许服务器通过客户端请求语言模型(LLM)生成文本、音频或图像内容,而无需服务器直接使用API密钥访问模型。客户端在模型访问、选择和权限方面保持控制权,同时为服务器提供AI能力。

核心内容笔记

1. 用户交互模型 (User Interaction Model)
  • Sampling允许服务器实现代理行为,通过在其他MCP服务器功能中嵌套LLM调用。
  • 协议本身不强制规定具体的用户交互模式,但建议:
    • 提供易于使用的界面,方便用户审查Sampling请求。
    • 允许用户在发送前查看和编辑提示。
    • 在交付前让用户审查生成的响应。
2. 功能声明 (Capabilities)
  • 支持Sampling的客户端必须在初始化时声明sampling能力:
    {"capabilities": {"sampling": {}}
    }
    
3. 协议消息 (Protocol Messages)
  • 创建消息 (Creating Messages)
    • 服务器通过发送sampling/createMessage请求来请求语言模型生成内容。
    • 请求示例:
      {"jsonrpc": "2.0","id": 1,"method": "sampling/createMessage","params": {"messages": [{"role": "user","content": {"type": "text","text": "What is the capital of France?"}}],"modelPreferences": {"hints": [{"name": "claude-3-sonnet"}],"intelligencePriority": 0.8,"speedPriority": 0.5},"systemPrompt": "You are a helpful assistant.","maxTokens": 100}
      }
      
    • 响应示例:
      {"jsonrpc": "2.0","id": 1,"result": {"role": "assistant","content": {"type": "text","text": "The capital of France is Paris."},"model": "claude-3-sonnet-20240307","stopReason": "endTurn"}
      }
      
4. 消息流 (Message Flow)
  • 服务器发起Sampling请求,用户在客户端审查并批准请求,客户端与模型交互并返回生成结果。
  • 流程图:
    LLMUserClientServerLLMUserClientServer
    Server initiates sampling
    Human-in-the-loop review
    Model interaction
    Response review
    Complete request
    sampling/createMessage
    Present request for approval
    Review and approve/modify
    Forward approved request
    Return generation
    Present response for approval
    Review and approve/modify
    Return approved response
    
5. 数据类型 (Data Types)
  • 消息 (Messages)
    • Sampling消息可以包含以下内容类型:
      • 文本内容 (Text Content)
        {"type": "text","text": "The message content"
        }
        
      • 图像内容 (Image Content)
        {"type": "image","data": "base64-encoded-image-data","mimeType": "image/jpeg"
        }
        
      • 音频内容 (Audio Content)
        {"type": "audio","data": "base64-encoded-audio-data","mimeType": "audio/wav"
        }
        
6. 模型偏好 (Model Preferences)
  • 由于服务器和客户端可能使用不同的AI提供商,MCP通过偏好系统抽象化模型选择。
    • 能力优先级 (Capability Priorities)
      • 服务器通过以下三个归一化优先级值(0-1)表达需求:
        • costPriority:成本优先级,值越高表示越偏好低成本模型。
        • speedPriority:速度优先级,值越高表示越偏好低延迟模型。
        • intelligencePriority:智能优先级,值越高表示越偏好高级功能模型。
    • 模型提示 (Model Hints)
      • 提示允许服务器建议特定模型或模型家族:
        • 提示被视为模型名称的子字符串,可以灵活匹配。
        • 客户端可以根据提示将请求映射到其他提供商的等效模型。
        • 示例:
          {"hints": [{"name": "claude-3-sonnet"},{"name": "claude"}],"costPriority": 0.3,"speedPriority": 0.8,"intelligencePriority": 0.5
          }
          
7. 错误处理 (Error Handling)
  • 客户端应为常见失败情况返回错误。
  • 示例错误:
    {"jsonrpc": "2.0","id": 1,"error": {"code": -1,"message": "User rejected sampling request"}
    }
    
8. 安全考虑 (Security Considerations)
  • 客户端应实现用户审批控制。
  • 双方应验证消息内容。
  • 客户端应尊重模型偏好提示。
  • 客户端应实现速率限制。
  • 双方必须妥善处理敏感数据。

文章转载自:

http://MFUPaA9V.fprhg.cn
http://HCOFYrGf.fprhg.cn
http://iCXfeyxx.fprhg.cn
http://bsQG2XMe.fprhg.cn
http://XkM6j4fS.fprhg.cn
http://wyRG30bL.fprhg.cn
http://6vpSUTNg.fprhg.cn
http://LKlj8bKg.fprhg.cn
http://CA7GYT6d.fprhg.cn
http://PleMxz5f.fprhg.cn
http://BCYdUgg1.fprhg.cn
http://UjcxVtBM.fprhg.cn
http://nf46mONs.fprhg.cn
http://lC8mDUCS.fprhg.cn
http://12jBUleF.fprhg.cn
http://dJoGppBT.fprhg.cn
http://4Xx8I6B9.fprhg.cn
http://zBY1ml5M.fprhg.cn
http://B6yXkWOh.fprhg.cn
http://ERlz70KS.fprhg.cn
http://nPSofJDd.fprhg.cn
http://hYoYbaDK.fprhg.cn
http://UDIKZEo4.fprhg.cn
http://x8V9n6DN.fprhg.cn
http://r3n8Bmud.fprhg.cn
http://OoLQ9JLY.fprhg.cn
http://3jZOhRQL.fprhg.cn
http://ESvj28ch.fprhg.cn
http://CAZygyC7.fprhg.cn
http://FtM31HQ5.fprhg.cn
http://www.dtcms.com/wzjs/645789.html

相关文章:

  • 出售域名的网站全国最新实时大数据
  • 四川平昌县建设局网站哪个好用?
  • 百度网站提交中国工程预算网
  • 营销型网站四大元素xampp网站后台
  • 宣传中心网站建设wordpress更新提示ftp
  • 手机wap网站开发与设计设计工作室简介怎么写
  • 做360手机网站优化快建设仿优酷视频网站
  • 聊城网站建设有限公司wordpress后台是什么样的
  • 建设专业网站公司外贸网站建设维护
  • 网站开发合同付款比例厦门建设网站企业
  • 搜狐做app的网站百度指数是什么意思
  • 高新网站建设网络营销推广方案怎么做
  • 做网站对企业有什么好处ps网站子页怎么做
  • php网站的开发背景家居企业网站建设渠道
  • 专业的集团网站开发开发电子商务网站建设与管理期末
  • 科技建筑公司网站模仿别人的网站
  • 在智联招聘网站做销售企业网站 实名认证
  • 二级网站建设情况说明二级建造师注册查询官网入口
  • 做博客网站赚钱优质高等职业院校建设网站
  • 湘西网站建设花垣奋进新征程
  • 昆明网站建设wang.cd网上推广怎么收费
  • 网站标题字体网站建设伍际网络
  • 电子商务网站策划书网页设计模板图片
  • discuz网站名称做个网站多少钱 百度能查到的
  • 网站icp备案wordpress 插件启用钩子
  • 汕头模板做网站最值得购买 wordpress
  • 怎么测网站流量吗亚马逊跨境电商官方网站
  • 建设网站费用评估wordpress 评论双击
  • 宁津 做网站wordpress hsts
  • 自媒体短视频制作教程seo引擎