跳到主要内容

优化提示词(实验性)

持续改进您的 AI 代理和提示词的简单方法。

MLflow 的提示词优化让您只需进行最少的代码更改,就能系统地增强您的 AI 应用。无论您是使用 LangChain、OpenAI 代理、CrewAI 还是自定义实现进行构建,MLflow 都提供了一条从初步原型设计到持续改进的通用路径。

最少重写,无锁定,只为更好的提示词。

MLflow 支持多种优化算法来改进您的提示词

  • GEPA (GepaPromptOptimizer): 利用 LLM 驱动的内省和自动化反馈迭代地改进提示词,通过试错学习实现系统性改进。
  • 元提示词(Metaprompting) (MetaPromptOptimizer): 重构提示词使其更系统、更有效,支持零样本模式(无需训练数据)和少样本模式(从您的示例中学习)。

请参阅选择您的优化器以获取关于为您特定需求选择哪个优化器的指导。

为什么使用 MLflow 提示词优化?
  • 零框架锁定:适用于任何代理框架——LangChain、OpenAI 代理、CrewAI 或自定义解决方案
  • 最少代码更改:添加几行代码即可开始优化;无需架构重写
  • 数据驱动改进:自动从您的评估数据和自定义指标中学习
  • 多提示词优化:联合优化多个提示词以实现复杂的代理工作流程
  • 精细控制:优化单个提示词或整个多提示词工作流程——由您决定改进什么
  • 生产就绪:内置版本控制和注册表,实现无缝部署
  • 可扩展:通过简单的基类扩展,引入您自己的优化算法
版本要求

optimize_prompts API 要求 MLflow >= 3.5.0

快速入门

这是一个优化医学论文部分分类提示词的实际示例

python
import mlflow
import openai
from mlflow.genai.optimize import GepaPromptOptimizer
from mlflow.genai.scorers import Correctness

# Register initial prompt for classifying medical paper sections
prompt = mlflow.genai.register_prompt(
name="medical_section_classifier",
template="Classify this medical research paper sentence into one of these sections: CONCLUSIONS, RESULTS, METHODS, OBJECTIVE, BACKGROUND.\n\nSentence: {{sentence}}",
)


# Define your prediction function
def predict_fn(sentence: str) -> str:
prompt = mlflow.genai.load_prompt("prompts:/medical_section_classifier/1")
completion = openai.OpenAI().chat.completions.create(
model="gpt-5-nano",
# load prompt template using PromptVersion.format()
messages=[{"role": "user", "content": prompt.format(sentence=sentence)}],
)
return completion.choices[0].message.content


# Training data with medical paper sentences and ground truth labels
# fmt: off
raw_data = [
("The emergence of HIV as a chronic condition means that people living with HIV are required to take more responsibility for the self-management of their condition , including making physical , emotional and social adjustments .", "BACKGROUND"),
("This paper describes the design and evaluation of Positive Outlook , an online program aiming to enhance the self-management skills of gay men living with HIV .", "BACKGROUND"),
("This study is designed as a randomised controlled trial in which men living with HIV in Australia will be assigned to either an intervention group or usual care control group .", "METHODS"),
("The intervention group will participate in the online group program ` Positive Outlook ' .", "METHODS"),
("The program is based on self-efficacy theory and uses a self-management approach to enhance skills , confidence and abilities to manage the psychosocial issues associated with HIV in daily life .", "METHODS"),
("Participants will access the program for a minimum of 90 minutes per week over seven weeks .", "METHODS"),
("Primary outcomes are domain specific self-efficacy , HIV related quality of life , and outcomes of health education .", "METHODS"),
("Secondary outcomes include : depression , anxiety and stress ; general health and quality of life ; adjustment to HIV ; and social support .", "METHODS"),
("Data collection will take place at baseline , completion of the intervention ( or eight weeks post randomisation ) and at 12 week follow-up .", "METHODS"),
("Results of the Positive Outlook study will provide information regarding the effectiveness of online group programs improving health related outcomes for men living with HIV .", "CONCLUSIONS"),
("The aim of this study was to evaluate the efficacy , safety and complications of orbital steroid injection versus oral steroid therapy in the management of thyroid-related ophthalmopathy .", "OBJECTIVE"),
("A total of 29 patients suffering from thyroid ophthalmopathy were included in this study .", "METHODS"),
("Patients were randomized into two groups : group I included 15 patients treated with oral prednisolone and group II included 14 patients treated with peribulbar triamcinolone orbital injection .", "METHODS"),
("Both groups showed improvement in symptoms and in clinical evidence of inflammation with improvement of eye movement and proptosis in most cases .", "RESULTS"),
("Mean exophthalmometry value before treatment was 22.6 1.98 mm that decreased to 18.6 0.996 mm in group I , compared with 23 1.86 mm that decreased to 19.08 1.16 mm in group II .", "RESULTS"),
("There was no change in the best-corrected visual acuity in both groups .", "RESULTS"),
("There was an increase in body weight , blood sugar , blood pressure and gastritis in group I in 66.7 % , 33.3 % , 50 % and 75 % , respectively , compared with 0 % , 0 % , 8.3 % and 8.3 % in group II .", "RESULTS"),
("Orbital steroid injection for thyroid-related ophthalmopathy is effective and safe .", "CONCLUSIONS"),
("It eliminates the adverse reactions associated with oral corticosteroid use .", "CONCLUSIONS"),
("The aim of this prospective randomized study was to examine whether active counseling and more liberal oral fluid intake decrease postoperative pain , nausea and vomiting in pediatric ambulatory tonsillectomy .", "OBJECTIVE"),
]
# fmt: on

# Format dataset for optimization
dataset = [
{
"inputs": {"sentence": sentence},
"expectations": {"expected_response": label},
}
for sentence, label in raw_data
]

# Optimize the prompt
result = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[prompt.uri],
optimizer=GepaPromptOptimizer(
reflection_model="openai:/gpt-5", max_metric_calls=300
),
scorers=[Correctness(model="openai:/gpt-5-mini")],
)

# Use the optimized prompt
optimized_prompt = result.optimized_prompts[0]
print(f"Optimized template: {optimized_prompt.template}")

API 将通过学习训练示例,自动改进提示词,使其能更好地对医学论文部分进行分类。

选择您的优化器

MLflow 目前支持两种优化算法:GEPAMetaprompting。每种算法都使用不同的策略来改进您的提示词。

GEPA(遗传-帕累托)

GEPA 是一种提示词优化技术,它利用自然语言内省,通过试错学习来迭代地提高 LLM 性能。它特别擅长通过分析自然语言中的失败情况,从系统行为中提取丰富的学习信号。

主要特性

  • 自然语言内省:利用可解释的语言从执行跟踪、推理链和工具交互中提取学习信号
  • 高效率:通过更少的迭代(与 GRPO 等传统方法相比,部署次数少 35 倍)实现卓越的结果
  • 帕累托合成:智能地选择过去要变异和改进的提示词
  • 强大性能:在一系列任务上展示出可靠的提升,例如上下文压缩、问答代理等。

最适合

  • 您拥有明确评估指标和足够大小数据集(例如 100+ 条记录)的任务
  • 对系统质量至关重要的任务(例如医疗代理、金融代理等),因此 GEPA 带来的优化成本和更长的提示词是值得的
降低 GEPA 优化成本

GEPA 优化的成本与您使用的内省模型和允许的最大指标调用次数密切相关。您可以通过使用更便宜的内省模型或减少最大指标调用次数来降低成本。

了解更多: GEPA 研究论文 | GEPA GitHub 仓库

元提示词(Metaprompting)

元提示词是一种提示词优化技术,它利用元提示词来调用语言模型,以重构您的提示词,使其更系统、更有效。它有两种模式:

零样本模式

  • 分析您的初始提示词并将其重构为遵循最佳实践
  • 在不需要训练数据的情况下使提示词更系统
  • 运行快速,无需示例

少样本模式

  • 根据您的训练数据评估初始提示词,以了解任务特定的模式
  • 利用评估结果以及通用最佳实践来重构提示词,使其更系统、更有效

主要特性

  • 快速优化:运行速度快,因为它在少样本模式下只进行一次评估轮次,在零样本模式下只进行一次对语言模型的调用
  • 最小数据要求:在零样本或只有少量示例(少于 10 个)的情况下效果良好
  • 系统性改进:重构提示词以遵循清晰的模式和最佳实践
  • 数据感知:在少样本模式下,从您的特定数据中学习以定制改进
  • 自定义指南:您可以向优化器提供自定义指南,以根据您的特定需求定制优化

最适合: 想要基于提示词工程最佳实践快速改进的任务,或者数据有限但希望利用数据进行有针对性改进的任务。

使用示例

python
from mlflow.genai.optimize import MetaPromptOptimizer

# Zero-shot mode: No training data or scorers required
# The optimizer automatically uses zero-shot mode when train_data is empty and scorers is empty
results = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=[],
prompt_uris=[prompt.uri],
optimizer=MetaPromptOptimizer(
reflection_model="openai:/gpt-5",
guidelines="This prompt is used in a finance agent to project tax situations.",
),
scorers=[],
)

# Few-shot mode: Learn from training data
# The optimizer automatically uses few-shot mode when train_data and scorers are provided
results = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[prompt.uri],
optimizer=MetaPromptOptimizer(
reflection_model="openai:/gpt-5",
guidelines="This prompt is used in a finance agent to project tax situations.",
),
scorers=[Correctness(model="openai:/gpt-5-mini")],
)

比较摘要

特征GEPA元提示词(零样本)元提示词(少样本)
需要训练数据
优化速度中等快-中等
学习方法带有内省的迭代试错系统性重构数据驱动的重构
最佳用例具有明确指标的复杂任务无数据快速改进带有有限数据的有针对性的改进

选择最符合您的任务要求、可用数据和优化预算的优化器。

示例:简单提示词 → 优化后的提示词

优化前

text
Classify this medical research paper sentence
into one of these sections: CONCLUSIONS, RESULTS,
METHODS, OBJECTIVE, BACKGROUND.

Sentence: {{sentence}}

优化后

text
You are a single-sentence classifier for medical research abstracts. For each input sentence, decide which abstract section it belongs to and output exactly one label in UPPERCASE with no extra words, punctuation, or explanation.

Allowed labels: CONCLUSIONS, RESULTS, METHODS, OBJECTIVE, BACKGROUND

Input format:
- The prompt will be:
"Classify this medical research paper sentence into one of these sections: CONCLUSIONS, RESULTS, METHODS, OBJECTIVE, BACKGROUND.

Sentence: {{sentence}}"

Core rules:
- Use only the information in the single sentence.
- Classify by the sentence's function: context-setting vs aim vs procedure vs findings vs interpretation.
- Return exactly one uppercase label from the allowed set.

Decision guide and lexical cues:

1) RESULTS
- Reports observed findings/outcomes tied to data.
- Common cues: past-tense result verbs and outcome terms: "showed," "was/were associated with," "increased/decreased," "improved," "reduced," "significant," "p < …," "odds ratio," "risk ratio," "95% CI," percentages, rates, counts or numbers tied to effects/adverse events.
- If it explicitly states changes, associations, statistical significance, or quantified outcomes, choose RESULTS.

2) CONCLUSIONS
- Interpretation, implications, recommendations, or high-level takeaways.
- Common cues: "In conclusion," "These findings suggest/indicate," "We conclude," statements about practice/policy/clinical implications, benefit–risk judgments, feasibility statements.
- Sentences that forecast the significance/utility of the study's results ("Results will provide insight/information," "Findings will inform/guide practice") are CONCLUSIONS.
- Tie-break with RESULTS: If a sentence describes an outcome as a general claim without specific observed data/statistics, prefer CONCLUSIONS over RESULTS.

3) METHODS
- How the study was conducted: design, participants, interventions/programs, measurements/outcomes lists, timelines, procedures, or analyses.
- Common cues: design terms ("randomized," "double-blind," "cross-sectional," "cohort," "case-control"), "participants," "n =," inclusion/exclusion criteria, instruments/scales, dosing/protocols, schedules/timelines, statistical tests/analysis plans ("multivariate regression," "Kaplan–Meier," "ANOVA," "we will compare"), trial registration, ethics approval.
- Measurement/outcome lists are METHODS (e.g., "Secondary outcomes include: …"; "Primary outcome was …").
- Numbers specifying sample size (e.g., "n = 200") → METHODS; numbers tied to effects → RESULTS.
- Program/intervention descriptions, components, theoretical basis, and mechanisms are METHODS, even if written in present tense and even if they contain purpose phrases. Examples: "The program is based on self-efficacy theory…," "The intervention uses a self-management approach to enhance skills…," "The device is designed to…"
- Important: An infinitive "to [verb] …" inside a program/intervention description (e.g., "uses X to improve Y") is METHODS, not OBJECTIVE, because it describes how the intervention works, not the study's aim.

4) OBJECTIVE
- The aim/purpose/hypothesis of the study.
- Common cues: "Objective(s):" "Aim/Purpose was," "We aimed/sought/intended to," "We hypothesized that …"
- Infinitive purpose phrases indicating the study's aim without procedures or results: "To determine/evaluate/assess/investigate whether …" → OBJECTIVE.
- Phrases like "The aim of this study was to evaluate the efficacy/safety of X vs Y …" → OBJECTIVE.
- If "We evaluated/assessed …" is clearly used as a purpose statement (not describing methods or results), label OBJECTIVE.

5) BACKGROUND
- Context, rationale, prior knowledge, unmet need; introduces topic without specific aims, procedures, or results.
- Common cues: burden/prevalence statements, "X is common," "X remains poorly understood," prior work summaries, general descriptions.
- If a sentence merely states that a paper describes/reports a program/design/evaluation without concrete procedures/analyses, label as BACKGROUND.

Important tie-break rules:
- RESULTS vs CONCLUSIONS: Observed data/findings → RESULTS; interpretation/generalization/recommendation → CONCLUSIONS.
- OBJECTIVE vs METHODS: Purpose/aim of the study → OBJECTIVE; concrete design/intervention details/measurements/analysis steps → METHODS.
- BACKGROUND vs OBJECTIVE: Context/motivation without an explicit study aim → BACKGROUND.
- BACKGROUND vs METHODS: General description without concrete procedures/analyses → BACKGROUND.
- The word "Results" at the start does not guarantee RESULTS; e.g., "Results will provide information …" → CONCLUSIONS.

Output constraint:
- Return exactly one uppercase label: CONCLUSIONS, RESULTS, METHODS, OBJECTIVE, or BACKGROUND. No extra text or punctuation.

组件

mlflow.genai.optimize_prompts API 需要以下组件

组件描述
目标提示词 URI要优化的提示词 URI 列表(例如 ["prompts:/qa/1"]
预测函数一个可调用对象,它接受关键字参数作为输入并返回输出。必须从 MLflow 提示词版本中加载模板(例如调用 PromptVersion.format())。
训练数据包含 inputs(字典)和 expectations(预期结果)的数据集。支持 pandas DataFrame、字典列表或 MLflow EvaluationDataset。
优化器提示词优化器实例(例如 GepaPromptOptimizerMetaPromptOptimizer)。请参阅选择您的优化器获取指导。

1. 目标提示词 URI

使用 MLflow 提示词注册表中提示词的 URI 指定要优化的提示词

python
prompt_uris = [
"prompts:/qa/1", # Specific version
"prompts:/instruction@latest", # Latest version
]

您可以通过以下方式引用提示词:

  • 特定版本"prompts:/qa/1" - 优化特定版本
  • 最新版本"prompts:/qa@latest" - 优化最新版本
  • 别名"prompts:/qa@champion" - 优化具有特定别名的版本

2. 预测函数

您的 predict_fn 必须

python
def predict_fn(question: str) -> str:
# Load prompt from registry
prompt = mlflow.genai.load_prompt("prompts:/qa/1")

# Format the prompt with input variables
formatted_prompt = prompt.format(question=question)

# Call your LLM
response = your_llm_call(formatted_prompt)

return response

3. 训练数据

提供一个包含 inputsexpectations 的数据集。这两个列的值都应该是字典。inputs 的值将作为关键字参数传递给预测函数。有关每个内置评分器的预期格式,请参阅预定义 LLM 评分器

python
# List of dictionaries - Example: Medical paper classification
dataset = [
{
"inputs": {
"sentence": "The emergence of HIV as a chronic condition means that people living with HIV are required to take more responsibility..."
},
"expectations": {"expected_response": "BACKGROUND"},
},
{
"inputs": {
"sentence": "This study is designed as a randomised controlled trial in which men living with HIV..."
},
"expectations": {"expected_response": "METHODS"},
},
{
"inputs": {
"sentence": "Both groups showed improvement in symptoms and in clinical evidence of inflammation..."
},
"expectations": {"expected_response": "RESULTS"},
},
{
"inputs": {
"sentence": "Orbital steroid injection for thyroid-related ophthalmopathy is effective and safe."
},
"expectations": {"expected_response": "CONCLUSIONS"},
},
{
"inputs": {
"sentence": "The aim of this study was to evaluate the efficacy, safety and complications..."
},
"expectations": {"expected_response": "OBJECTIVE"},
},
]

# Or pandas DataFrame
import pandas as pd

dataset = pd.DataFrame(
{
"inputs": [
{"sentence": "The emergence of HIV as a chronic condition..."},
{"sentence": "This study is designed as a randomised controlled trial..."},
{"sentence": "Both groups showed improvement in symptoms..."},
],
"expectations": [
{"expected_response": "BACKGROUND"},
{"expected_response": "METHODS"},
{"expected_response": "RESULTS"},
],
}
)

4. 优化器

为优化算法创建一个优化器实例。MLflow 支持 GepaPromptOptimizerMetaPromptOptimizer。请参阅选择您的优化器以获取关于使用哪个优化器的详细指导。

python
from mlflow.genai.optimize import GepaPromptOptimizer, MetaPromptOptimizer

# Option 1: GEPA optimizer
optimizer = GepaPromptOptimizer(
reflection_model="openai:/gpt-5", # Powerful model for optimization
max_metric_calls=100,
display_progress_bar=False,
)

# Option 2: Metaprompting optimizer
# Note: Zero-shot vs few-shot is determined by whether you provide
# scorers and train_data to optimize_prompts()
optimizer = MetaPromptOptimizer(
reflection_model="openai:/gpt-5",
guidelines="Optional custom guidelines for optimization",
)

高级用法

适用于任何代理框架

MLflow 的优化是框架无关的——它与 LangChain、LangGraph、OpenAI 代理、Pydantic AI、CrewAI、AutoGen 或任何自定义框架无缝协作。无需重写您现有的代理或更换框架。

有关详细示例,请参阅这些特定于框架的指南

LangChain Logo
LangGraph Logo
OpenAI Agent Logo
Pydantic AI Logo

使用自定义评分器

定义自定义评估指标来指导优化

python
from typing import Any
from mlflow.genai.scorers import scorer


@scorer
def accuracy_scorer(outputs: Any, expectations: dict[str, Any]):
"""Check if output matches expected value."""
return 1.0 if outputs.lower() == expectations.lower() else 0.0


@scorer
def brevity_scorer(outputs: Any):
"""Prefer shorter outputs (max 50 chars)."""
return min(1.0, 50 / max(len(outputs), 1))


# Combine scorers with a weighted objective
def weighted_objective(scores: dict[str, Any]):
return 0.7 * scores["accuracy_scorer"] + 0.3 * scores["brevity_scorer"]


# Use custom scorers
result = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[prompt.uri],
optimizer=GepaPromptOptimizer(reflection_model="openai:/gpt-5"),
scorers=[accuracy_scorer, brevity_scorer],
aggregation=weighted_objective,
)

自定义优化算法

通过扩展 BasePromptOptimizer 实现您自己的优化器

python
from mlflow.genai.optimize import BasePromptOptimizer, PromptOptimizerOutput
from mlflow.genai.scorers import Correctness


class MyCustomOptimizer(BasePromptOptimizer):
def __init__(self, model_name: str):
self.model_name = model_name

def optimize(self, eval_fn, train_data, target_prompts, enable_tracking):
# Your custom optimization logic
optimized_prompts = {}
for prompt_name, prompt_template in target_prompts.items():
# Implement your algorithm
optimized_prompts[prompt_name] = your_optimization_algorithm(
prompt_template, train_data, self.model_name
)

return PromptOptimizerOutput(optimized_prompts=optimized_prompts)


# Use custom optimizer
result = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[prompt.uri],
optimizer=MyCustomOptimizer(model_name="openai:/gpt-5"),
scorers=[Correctness(model="openai:/gpt-5")],
)

多提示词优化

一起优化多个提示词

python
import mlflow
from mlflow.genai.scorers import Correctness

# Register multiple prompts
plan_prompt = mlflow.genai.register_prompt(
name="plan",
template="Make a plan to answer {{question}}.",
)
answer_prompt = mlflow.genai.register_prompt(
name="answer",
template="Answer {{question}} following the plan: {{plan}}",
)


def predict_fn(question: str) -> str:
plan_prompt = mlflow.genai.load_prompt("prompts:/plan/1")
completion = openai.OpenAI().chat.completions.create(
model="gpt-5", # strong model
messages=[{"role": "user", "content": plan_prompt.format(question=question)}],
)
plan = completion.choices[0].message.content

answer_prompt = mlflow.genai.load_prompt("prompts:/answer/1")
completion = openai.OpenAI().chat.completions.create(
model="gpt-5-mini", # cost efficient model
messages=[
{
"role": "user",
"content": answer_prompt.format(question=question, plan=plan),
}
],
)
return completion.choices[0].message.content


# Optimize both
result = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[plan_prompt.uri, answer_prompt.uri],
optimizer=GepaPromptOptimizer(reflection_model="openai:/gpt-5"),
scorers=[Correctness(model="openai:/gpt-5")],
)

# Access optimized prompts
optimized_plan = result.optimized_prompts[0]
optimized_answer = result.optimized_prompts[1]

结果对象

API 返回一个 PromptOptimizationResult 对象

python
result = mlflow.genai.optimize_prompts(...)

# Access optimized prompts
for prompt in result.optimized_prompts:
print(f"Name: {prompt.name}")
print(f"Version: {prompt.version}")
print(f"Template: {prompt.template}")
print(f"URI: {prompt.uri}")

# Check optimizer used
print(f"Optimizer: {result.optimizer_name}")

# View evaluation scores (if available)
print(f"Initial score: {result.initial_eval_score}")
print(f"Final score: {result.final_eval_score}")

常见用例

提高准确性

优化提示词以产生更准确的输出

python
from mlflow.genai.scorers import Correctness


result = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[prompt.uri],
optimizer=GepaPromptOptimizer(reflection_model="openai:/gpt-5"),
scorers=[Correctness(model="openai:/gpt-5")],
)

优化安全性

确保输出安全

python
from mlflow.genai.scorers import Safety


result = mlflow.genai.optimize_prompts(
predict_fn=predict_fn,
train_data=dataset,
prompt_uris=[prompt.uri],
optimizer=GepaPromptOptimizer(reflection_model="openai:/gpt-5"),
scorers=[Safety(model="openai:/gpt-5")],
)

模型切换和迁移

当您在不同语言模型之间切换时(例如,为了降低成本从 gpt-5 迁移到 gpt-5-mini),您可能需要重写提示词以在保持输出质量的同时适应新模型。mlflow.genai.optimize_prompts() API 可以利用您现有的应用程序输出来自动帮助调整提示词,作为训练数据。

有关完整的模型迁移工作流程,请参阅为新模型自动重写提示词指南。

故障排除

问题:优化耗时过长

解决方案:减小数据集大小或减少优化器预算

python
# Use fewer examples
small_dataset = dataset[:20]

# Use faster model for optimization
optimizer = GepaPromptOptimizer(
reflection_model="openai:/gpt-5-mini", max_metric_calls=100
)

问题:未观察到改进

解决方案:检查您的评估指标并增加数据集多样性

  • 确保评分器准确衡量您关心的内容
  • 增加训练数据量和多样性
  • 尝试修改优化器配置
  • 验证输出格式与期望值匹配

问题:提示词未被使用

解决方案:确保 predict_fn 在执行期间调用 PromptVersion.format()

python
# ✅ Correct - loads from registry
def predict_fn(question: str):
prompt = mlflow.genai.load_prompt("prompts:/qa@latest")
return llm_call(prompt.format(question=question))


# ❌ Incorrect - hardcoded prompt
def predict_fn(question: str):
return llm_call(f"Answer: {question}")

另请参阅