Dotprompt은 YAML 프론트마터와 Handlebars 템플릿을 사용하여 .prompt 파일을 파싱하고 렌더링할 수 있도록 해주는 Dart 패키지로, 생성형 AI 애플리케이션에 특화되어 있습니다. 개발자가 메타데이터와 동적 콘텐츠를 포함한 프롬프트를 구조화할 수 있게 하여 AI가 생성한 응답을 보다 쉽게 관리하고 맞춤설정할 수 있도록 합니다. 이 패키지는 Android, iOS, Linux, macOS, Web, Windows 등 다양한 플랫폼에서 작동하는 Flutter 앱에 원활하게 통합될 수 있으며, 재사용 가능한 구조화된 프롬프트를 활용해 상호작용형 AI 경험을 구축하는 데 이상적입니다.
사용 사례
AI 기반 채팅 인터페이스
동적 프롬프트 생성
생성 워크플로에서의 콘텐츠 사용자 지정
템플릿 기반 응답 시스템
다국어 AI 상호작용
주요 기능
YAML 프론트마터 지원
Handlebars 템플릿 렌더링
크로스 플랫폼 호환성
LLM과의 간편한 통합
구조화된 프롬프트 관리
적합한 대상
AI 앱을 개발하는 Flutter 개발자
생성 모델을 사용하는 팀
재사용 가능한 프롬프트 템플릿이 필요한 개발자
동적 콘텐츠 생성이 필요한 프로젝트
다중 플랫폼을 대상으로 하는 애플리케이션
고려 사항
Handlebars 구문에 익숙해야 합니다
.prompt 파일 형식에 제한됨
외부 LLM API에 의존합니다
비 AI 사용 사례에는 적합하지 않습니다
동적 입력에 대해 추가 검증이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
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.
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:
Specifies the use of the googleai/gemini-2.5-pro model.
Defines an input schema expecting a text string.
Specifies that the output should be in JSON format.
Provides a schema for the expected output, including fields for name, age,
and occupation.
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 pluginconst 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 } = awaitextractInfo({
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.