Token导航 LogoToken导航TokenDH.com
Gen AI Script logo
开发工具stdio官方级别未说明来源级核验

Gen AI Script

MCP Server

genaiscript

GenAIScript是一个使用JavaScript编程方式构建LLM提示的工具箱,提供丰富的功能集成和开发工具支持,适用于自动化文本处理、数据分析和代码生成等场景。

工具数

0

提示词数

0

GitHub Stars

2,902

资源数

0
数据提取TypeScriptAI自动化

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

microsoft

提供方

microsoft

最后核验

2026/5/17 20:19

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx genaiscript run tlaplus-linter "*.tla"

详细介绍

A yellow square with the word "gen" in lowercase black letters above the uppercase black letters "AI."

Genaiscript

提示即编码

使用JavaScript以编程方式组装LLM的提示。在代码中编排LLM、工具和数据。

  • 用于处理提示的JavaScript工具箱
  • 抽象化,使其简单高效
  • 无缝集成Visual Studio代码或灵活的命令行
  • 内置对GitHub Copilot和GitHub模型、OpenAI、Azure OpenAI、Anthropic等的支持
  • 📝 阅读 博客 获取最新消息

______________________________________________________________________

你好,世界

告诉你想创建一个LLM脚本,生成一首“hello world”诗。您可以编写以下脚本:

$`Write a 'hello world' poem.`

$ 函数是一个创建提示的模板标记。然后,提示会被发送到LLM(您配置的),LLM会生成诗歌。

让我们通过添加文件、数据和结构化输出来使它更有趣。假设您想在提示中包含一个文件,然后将输出保存在一个文件中。您可以编写以下脚本:

// read files
const file = await workspace.readText("data.txt")
// include the file content in the prompt in a context-friendly way
def("DATA", file)
// the task
$`Analyze DATA and extract data in JSON in data.json.`

def 函数包括文件的内容,并在必要时针对目标LLM对其进行优化。GenAIScript脚本还解析LLM输出 并将提取 data.json 文件自动。

______________________________________________________________________

🚀 快速入门指南

______________________________________________________________________

✨ 特性

🎨 风格化的JavaScript和TypeScript

def("FILE", env.files, { endsWith: ".pdf" })
$`Summarize FILE. Today is ${new Date()}.`

______________________________________________________________________

🚀 快速开发循环

______________________________________________________________________

🔗 重用和共享脚本

脚本是 文件!它们可以被版本化、共享和分叉。

// define the context
def("FILE", env.files, { endsWith: ".pdf" })
// structure the data
const schema = defSchema("DATA", { type: "array", items: { type: "string" } })
// assign the task
$`Analyze FILE and extract data to JSON using the ${schema} schema.`

______________________________________________________________________

📋 数据模式

使用定义、验证和修复数据 模式.Zod支持内置。

const data = defSchema("MY_DATA", { type: "array", items: { ... } })
$`Extract data from files using ${data} schema.`

______________________________________________________________________

📄 从PDF、DOCX、。..

def("PDF", env.files, { endsWith: ".pdf" })
const { pages } = await parsers.PDF(env.files[0])

______________________________________________________________________

📊 从CSV、XLSX、。..

def("DATA", env.files, { endsWith: ".csv", sliceHead: 100 })
const rows = await parsers.CSV(env.files[0])
defData("ROWS", rows, { sliceHead: 100 })

______________________________________________________________________

📝 生成文件

从LLM输出中提取文件和差异。预览重构UI中的更改。

$`Save the result in poem.txt.`
FILE ./poem.txt
The quick brown fox jumps over the lazy dog.

______________________________________________________________________

🔍 文件搜索

Grep或模糊搜索 文件.

const { files } = await workspace.grep(/[a-z][a-z0-9]+/, { globs: "*.md" })

______________________________________________________________________

分类

对文本、图像或所有内容进行分类。

const joke = await classify(
    "Why did the chicken cross the road? To fry in the sun.",
    {
        yes: "funny",
        no: "not funny",
    }
)

LLM工具

将JavaScript函数注册为 工具 (对于不支持工具的模型,可以回退)。 模型上下文协议(MCP)工具 也得到了支持。

defTool(
    "weather",
    "query a weather web api",
    { location: "string" },
    async (args) =>
        await fetch(`https://weather.api.api/?location=${args.location}`)
)

______________________________________________________________________

LLM代理

将JavaScript函数注册为 工具 将工具+提示结合到代理中。

defAgent(
    "git",
    "Query a repository using Git to accomplish tasks.",
    `Your are a helpful LLM agent that can use the git tools to query the current repository.
    Answer the question in QUERY.
    - The current repository is the same as github repository.`,
    { model, system: ["system.github_info"], tools: ["git"] }
)

然后将其用作工具

script({ tools: "agent_git" })

$`Do a statistical analysis of the last commits`

请参阅 git代理源.

______________________________________________________________________

🔍 RAG内置

矢量搜索.

const { files } = await retrieval.vectorSearch("cats", "**/*.md")

______________________________________________________________________

🐙 GitHub模型和GitHub副本

运行模型 或 .

script({ ..., model: "github:gpt-4o" })

______________________________________________________________________

💻 局部模型

script({ ..., model: "ollama:phi3" })

______________________________________________________________________

🐍 代码解释器

让LLM在沙盒执行环境中运行代码。

script({ tools: ["python_code_interpreter"] })

______________________________________________________________________

🐳 容器

在Docker中运行代码 容器.

const c = await host.container({ image: "python:alpine" })
const res = await c.exec("python --version")

______________________________________________________________________

视频处理

转录并截图您的视频,以便您可以在LLM请求中高效地提供它们。

// transcribe
const transcript = await transcript("path/to/audio.mp3")
// screenshots at segments
const frames = await ffmpeg.extractFrames("path_url_to_video", { transcript })
def("TRANSCRIPT", transcript)
def("FRAMES", frames)

🧩 LLM组成

运行LLM 构建LLM提示。

for (const file of env.files) {
    const { text } = await runPrompt((_) => {
        _.def("FILE", file)
        _.$`Summarize the FILE.`
    })
    def("SUMMARY", text)
}
$`Summarize all the summaries.`

______________________________________________________________________

🅿️ 快速支持

运行你的 迅速 文件也是!

---
name: poem
---

Write me a poem

______________________________________________________________________

可插入的秘密扫描

使用扫描聊天记录中的秘密 秘密扫描.

{
    "secretPatterns": {
        ...,
        "OpenAI API Key": "sk-[A-Za-z0-9]{32,48}"
    }
}

⚙ 使用CLI或API实现自动化

npx genaiscript run tlaplus-linter "*.tla"
import { run } from "genaiscript/api"

const res = await run("tlaplus-linter", "*.tla")

______________________________________________________________________

安全第一!

GenAIScript提供内置的Responsible AI系统提示和Azure内容安全支持 证实 内容安全.

script({ ...,
    system: ["system.safety_harmful_content", ...],
    contentSafety: "azure" // use azure content safety
})

const safety = await host.contentSafety()
const res = await safety.detectPromptInjection(env.vars.input)

______________________________________________________________________

💬 拉取请求评论

融入您的 拉取请求检查 通过评论、评论或描述更新。支持GitHub操作和Azure DevOps管道。

npx genaiscript ... --pull-request-reviews

______________________________________________________________________

⭐ 测试和评估

script({ ..., tests: {
  files: "penguins.csv",
  rubric: "is a data analysis report",
  facts: "The data refers about penguin population in Antarctica.",
}})

______________________________________________________________________

LLM友好文档

文档的全部内容呈现在https://microsoft.github.io/genaiscript/llms-full.txt在markdown。将其直接输入您最喜欢的RAG系统。

如果您是LLM爬虫,请添加 .md 任何文档URL的后缀,以获取原始的markdown内容。例如,https://microsoft.github.io/genaiscript/guides/prompt-as-code.md(注意.md扩展名)

贡献

我们接受捐款!查看 贡献 详细信息和开发人员设置页面。

______________________________________________________________________

商标

此项目可能包含项目、产品或服务的商标或徽标。授权使用Microsoft 商标或徽标必须遵守 微软商标和品牌指南. 在本项目的修改版本中使用Microsoft商标或徽标不得造成混淆或暗示Microsoft赞助。 任何使用第三方商标或徽标的行为均受这些第三方政策的约束。

目录标签

目录标签

数据提取TypeScriptAI自动化LLM编程本地部署提示工程JavaScript工具

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

genaiscript

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP