元数据
提示使用script({ ... })函数调用来配置标题和其他用户界面元素。
调用script是可选的,如果不需要配置提示词可以省略。
但script参数应该是一个有效的JSON5字面量,因为在提取元数据时脚本会被解析而不会被执行。
标题、描述、分组
title、description 和 group 在用户界面中用于(可选)显示提示信息。
script({ title: "Shorten", // displayed in UI // also displayed but grayed out: description: "A prompt that shrinks the size of text without losing meaning", group: "shorten", // see Inline prompts later})系统
覆盖脚本中包含的系统提示。默认的系统提示集是从脚本内容动态推断出来的。
script({ ... system: ["system.files"],})model
您可以在脚本中指定LLM model标识符。
genaiscript.g.ts提供的智能感知功能将帮助发现支持的模型列表。
使用large和small别名来选择默认模型,无论配置如何。
script({ ..., model: "openai:gpt-4o",})maxTokens
您可以在脚本中指定LLM的最大完成标记数。默认为未指定。
script({ ..., maxTokens: 2000,})最大工具调用次数
限制在生成过程中允许的函数/工具调用次数。这有助于防止无限循环。
script({ ..., maxToolCalls: 100,})温度
您可以在脚本中指定LLM的temperature参数,取值范围在0到2之间。默认值为0.8。
script({ ..., temperature: 0.8,})top_p
您可以在脚本中指定LLM的top_p参数。默认情况下不指定该参数
script({ ..., top_p: 0.5,})种子
对于某些模型,您可以在脚本中指定LLM的seed参数(适用于支持该功能的模型)。默认情况下不指定此参数。
script({ ..., seed: 12345678,})其他参数
unlisted: true,不在列表中向用户显示。模板system.*会自动被隐藏。
详情请参阅源代码中的genaiscript.d.ts文件。
env.meta
您可以在env.meta对象中查阅顶层脚本的元数据。
const { model } = env.meta模型分辨率
使用host.resolveModel函数将模型名称或别名解析为其提供商和模型名称。
const info = await host.resolveModel("large")console.log(info){ "provider": "openai", "model": "gpt-4o"}