搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.1

dotprompt

Dotprompt for Dart:解析並呈現 .prompt 檔案(YAML 前置資料 + Handlebars 模板),用於生成式 AI。

AndroidiOSLinuxmacOSWebWindows
近 30 天下載
4.3萬
喜歡數
1
Pub 分數
150

安裝套件

flutter pub add dotprompt

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Dotprompt 是一個 Dart 套件,可使用 YAML 前置欄位與 Handlebars 模板解析與呈現 .prompt 檔案,專為生成式 AI 應用設計。它讓開發者能透過元資料與動態內容結構化提示,進而更容易管理與自訂 AI 產生的回應。此套件可無縫整合至跨平台的 Flutter 應用,支援 Android、iOS、Linux、macOS、Web 與 Windows。非常適合建構可重複使用、結構化的提示,打造互動式 AI 經驗。

適用情境

  • AI 驅動的聊天介面
  • 動態提示產生
  • 產生式工作流程中的內容自訂
  • 基於模板的回應系統
  • 多語言AI互動

主要特色

  • YAML 前置元資料支援
  • Handlebars 模板渲染
  • 跨平台相容性
  • 與大語言模型的輕鬆整合
  • 結構化提示管理

適合對象

  • Flutter 開發人員建構 AI 應用
  • 使用生成式模型的團隊
  • 需要可重複使用提示範本的開發人員
  • 需要動態內容產生的專案
  • 針對多個平台的應用程式

使用建議

  • 需要熟悉 Handlebars 語法
  • 限於 .prompt 檔案格式
  • 依賴外部大語言模型 API
  • 不適合非AI使用情境
  • 可能需要對動態輸入進行額外驗證

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

OpenSSF Scorecard codecov License

GitHub stars GitHub forks GitHub watchers GitHub contributors GitHub last commit GitHub commit activity

OSS Insight Discord View Code Wiki Ask DeepWiki

Star History Chart

Dotprompt: Executable GenAI Prompt Templates

Dotprompt is an executable prompt template file format for Generative AI. It is designed to be agnostic to programming language and model provider to allow for maximum flexibility in usage. Dotprompt extends the popular Handlebars templating language with GenAI-specific features.

Package Versions

Package Version Registry
Core Libraries
dotprompt (JS/TS) npm npm
dotpromptz (Python) PyPI PyPI
dotpromptz-handlebars (Python) PyPI PyPI
dotprompt-go (Go) Go pkg.go.dev
dotprompt-rs (Rust) crates.io crates.io
dotprompt-java (Java) Maven Central Maven Central
IDE Extensions
dotprompt-vscode VS Marketplace VS Marketplace
dotprompt-jetbrains JetBrains JetBrains
dotprompt-vim - GitHub
dotprompt-emacs - GitHub
Web Editors
dotprompt-monaco npm npm
dotprompt-codemirror npm npm
Tools
tree-sitter-dotprompt npm npm
promptly npm npm

CI Status

Workflow Status Description
Language Tests
Go Go Go library tests
Python Python Python dotpromptz tests
JavaScript JavaScript JS/TS library tests
Java Java Java library tests
Rust Rust Rust library tests
Bazel Bazel Bazel build & test
IDE & Editor Plugins
VS Code VS Code VS Code extension
IDE Plugins IDE Plugins Vim, Emacs, JetBrains
Web Editors Web Editors Monaco, CodeMirror
Tree-sitter Tree-sitter Grammar & parser
Code Quality
Go Lint Go Lint golangci-lint

What's an executable prompt template?

An executable prompt template is a file that contains not only the text of a prompt but also metadata and instructions for how to use that prompt with a generative AI model. Here's what makes Dotprompt files executable:

  • Metadata Inclusion: Dotprompt files include metadata about model configuration, input requirements, and expected output format. This information is typically stored in a YAML frontmatter section at the beginning of the file.

  • Self-Contained Entity: Because a Dotprompt file contains all the necessary information to execute a prompt, it can be treated as a self-contained entity. This means you can "run" a Dotprompt file directly, without needing additional configuration or setup in your code.

  • Model Configuration: The file specifies which model to use and how to configure it (e.g., temperature, max tokens).

  • Input Schema: It defines the structure of the input data expected by the prompt, allowing for validation and type-checking.

  • Output Format: The file can specify the expected format of the model's output, which can be used for parsing and validation.

  • Templating: The prompt text itself uses Handlebars syntax, allowing for dynamic content insertion based on input variables.

This combination of features makes it possible to treat a Dotprompt file as an executable unit, streamlining the process of working with AI models and ensuring consistency across different uses of the same prompt.

Example .prompt file

Here's an example of a Dotprompt file that extracts structured data from provided text:

---
model: googleai/gemini-2.5-pro
input:
  schema:
    text: string
output:
  format: json
  schema:
    name?: string, the full name of the person
    age?: number, the age of the person
    occupation?: string, the person's occupation
---

Extract the requested information from the given text. If a piece of information
is not present, omit that field from the output.

Text: {{text}}

This Dotprompt file:

  1. Specifies the use of the googleai/gemini-2.5-pro model.
  2. Defines an input schema expecting a text string.
  3. Specifies that the output should be in JSON format.
  4. Provides a schema for the expected output, including fields for name, age, and occupation.
  5. Uses Handlebars syntax ({{text}}) to insert the input text into the prompt.

When executed, this prompt would take a text input, analyze it using the specified AI model, and return a structured JSON object with the extracted information.

Installation

The remainder of this getting started guide will use the reference Dotprompt implementation included as part of Genkit, the GenAI SDK for app developers. To use other implementations of Dotprompt, see the list of Implementations.

First, install the necessary packages using NPM. Here we'll be using the Gemini API from Google as our model implementation:

npm i genkit @genkit-ai/googleai

After installation, you'll need to set up your environment and initialize the Dotprompt system. Here's a basic setup:

import { genkit } from "genkit";
import { googleAI } from "@genkit-ai/googleai";

// Configure Genkit with the GoogleAI provider and Dotprompt plugin
const ai = genkit({
  plugins: [googleAI()],
  // promptDir: 'prompts', /* this is the default value */
});

// Now you're ready to use Dotprompt!

Note: You will need to set your Google AI API key to the GOOGLE_API_KEY environment variable or pass it as an option to the googleAI() plugin configuration.

With this setup, you can now create .prompt files in your project and use them in your code. For example, if you have a file named extractInfo.prompt with the content from the earlier example, you can use it like this:

const extractInfo = ai.prompt("extractInfo");

const { output } = await extractInfo({
  text: "John Doe is a 35-year-old software engineer living in New York.",
});

console.log(output);
// Output: { "name": "John Doe", "age": 35, "occupation": "software engineer" }

This setup allows you to leverage the power of Dotprompt, making your AI interactions more structured, reusable, and maintainable.

By following these steps, you'll have a basic Dotprompt setup ready to go. From here, you can create more complex prompts, integrate them into your application, and start harnessing the full power of generative AI in a structured, template-driven way.

Contributing

We welcome contributions! Please see our Development Guidelines for:

  • Code style and linting requirements for each language
  • Testing requirements
  • Git commit message conventions
Commit Message Format

We use Conventional Commits with package names as scopes:

feat(dotpromptz): add new helper function
fix(dotprompt-go): resolve parsing edge case
docs(dotprompt-java): update API documentation
Scope Package
dotprompt JavaScript/TypeScript (js/)
dotpromptz Python dotpromptz (python/dotpromptz/)
dotpromptz-handlebars Python Handlebars (python/handlebars/)
dotprompt-go Go (go/)
dotprompt-rs Rust (rs/)
dotprompt-java Java (java/)
dotprompt-vscode VS Code extension
dotprompt-jetbrains JetBrains plugin
tree-sitter-dotprompt Tree-sitter grammar
promptly CLI tool for .prompt files

See GEMINI.md for the complete list of scopes and guidelines.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單