You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为LiteLLM提示提供程序配置生效的系统提示?

解决LiteLLM系统提示不生效的问题

原因说明

LiteLLM与OpenAI原生提供程序的配置参数映射规则不同,instructions并非LiteLLM识别的系统提示参数,直接沿用该配置会被忽略。

解决方案

方案1:改用system_prompt配置项

LiteLLM支持通过system_prompt参数传递系统指令,修改后的YAML配置如下:

description: "instructions_test_2025-04-30_005"
prompts:
  - "Hi, how are you?"
providers:
  - id: "litellm:gpt-4o-mini"
    config:
      system_prompt: "Reply in Spanish."

方案2:使用标准多轮消息结构

将系统提示与用户提问组合成OpenAI格式的消息数组,兼容性更强,适用于所有LiteLLM支持的模型:

description: "instructions_test_2025-04-30_005"
prompts:
  - messages:
      - role: "system"
        content: "Reply in Spanish."
      - role: "user"
        content: "Hi, how are you?"
providers:
  - id: "litellm:gpt-4o-mini"

补充说明

对于OpenAI系列模型(如gpt-4o-mini),上述两种方案均能正确传递系统指令,确保模型输出西班牙语。LiteLLM的参数设计更贴近底层模型API规范,不同模型的系统提示参数可能存在差异,但以上两种方式是通用的解决思路。

内容的提问来源于stack exchange,提问作者Tobias Hermann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 07:18:20