微信扫码
添加专属顾问
 
                        我要投稿
快速构建AI应用,Higress是您的不二选择。 核心内容: 1. AI时代对API网关的新要求 2. Higress的AI原生功能与开源优势 3. 实战演示:基于Higress搭建完整的LLM应用
 
                                一、前言
二、AI 代理
官方文档:https://help.aliyun.com/zh/mse/user-guide/ai-agent?spm=a2c4g.11186623.0.0.2927178eciPER4
应用架构
provider:type: qwenapiTokens:- sk-xxxxxxxxxxxxxxxxxxxxxxtimeout: 1200000modelMapping:'gpt-3.5-turbo': qwen-turbo'gpt-4': qwen-max'*': qwen-max
三、AI 可观测
enable: true
配置 AI 内容安全插件后,应用架构如下图所示:
serviceSource: dnsserviceName: green-cipservicePort: 443domain: green-cip.cn-hangzhou.aliyuncs.comak: xxxxxxxxxxxxxxxxxsk: xxxxxxxxxxxxxxxxx
创建一个 redis 服务并且在网关进行配置:
rule_name: default_rulerule_items:- limit_by_per_ip: from-remote-addrlimit_keys:- key: 0.0.0.0/0token_per_minute: 100redis:service_name: redis.staticservice_port: 6379username: xxxxxxpassword: xxxxxxrejected_code: 429rejected_msg: 您的请求频率过高,请稍后再试。
redis:serviceName: redis.staticservicePort: 6379timeout: 2000username: xxxxxx password: xxxxxx
dashscope:apiKey: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxserviceName: qwenservicePort: 443domain: dashscope.aliyuncs.comdashvector:apiKey: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxserviceName: dashvectorservicePort: 443domain: vrs-cn-xxxxxxxxxxxxxx.dashvector.cn-hangzhou.aliyuncs.comcollection: xxxxxxxxxxxxxx
prompt 模板[3]
templates:- name: "developer-chat"template:model: gpt-3.5-turbomessages:- role: systemcontent: "你是一个 {{program}} 专家, 你平时使用的编程语言为 {{language}}"- role: user      content: "帮我写一个 {{program}} 程序, 你的返回结果里面应该只包含python代码"请求 body 示例如下:
{"template": "developer-chat","properties": {"program": "冒泡排序","language": "python"}}Prompt 装饰器允许用户在网关定义对 prompt 的修改操作,包括在原始请求之前和之后插入 message,配置示例如下,请求 body 与 openai 的请求一致。
prepend:- role: systemcontent: "请使用英语回答问题."append:- role: usercontent: "每次回答完问题,尝试进行反问"
response: enable: trueprompt: "帮我修改以下HTTP应答信息,要求:1. content-type修改为application/json;2. body由xml转化为json;3. 移除content-length。"provider: serviceName: qwendomain: dashscope.aliyuncs.com apiKey: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx
<?xml version='1.0' encoding='us-ascii'?><!--A SAMPLE set of slides--><slideshowtitle="Sample Slide Show"date="Date of publication"author="Yours Truly"><!-- TITLE SLIDE --><slide type="all"><title>Wake up to WonderWidgets!</title></slide><!-- OVERVIEW --><slide type="all"><title>Overview</title><item>Why <em>WonderWidgets</em> are great</item><item/><item>Who <em>buys</em> WonderWidgets</item></slide></slideshow>
使用以上配置,通过网关访问 httpbin 的 /xml 接口,结果为:
{"slideshow": {"title": "Sample Slide Show","date": "Date of publication","author": "Yours Truly","slides": [{"type": "all","title": "Wake up to WonderWidgets!"},{"type": "all","title": "Overview","items": ["Why <em>WonderWidgets</em> are great","","Who <em>buys</em> WonderWidgets"]}]}}53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-10-31
Google DeepMind揭秘:开源AI模型如何泄露训练秘方
2025-10-31
有人问我会不会用 AI,我直接拿出这个 Ollama + FastGPT 项目给他看
2025-10-30
开源可信MCP,AICC机密计算新升级!
2025-10-30
OpenAI 开源了推理安全模型-gpt-oss-safeguard-120b 和 gpt-oss-safeguard-20b
2025-10-29
刚刚,OpenAI 再次开源!安全分类模型 gpt-oss-safeguard 准确率超越 GPT-5
2025-10-29
AI本地知识库+智能体系列:手把手教你本地部署 n8n,一键实现自动采集+智能处理!
2025-10-29
n8n如何调用最近爆火的deepseek OCR?
2025-10-29
OpenAI终于快要上市了,也直面了这23个灵魂拷问。
 
            2025-08-20
2025-09-07
2025-08-05
2025-08-20
2025-08-26
2025-08-22
2025-09-06
2025-08-06
2025-10-20
2025-08-22
2025-10-29
2025-10-28
2025-10-13
2025-09-29
2025-09-17
2025-09-09
2025-09-08
2025-09-07