Class: SolidAgent::AgentManifest::Parsers::DotpromptParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/solid_agent/agent_manifest/parsers/dotprompt_parser.rb

Overview

DotpromptParser handles Google Genkit's .prompt format.

Dotprompt files use YAML frontmatter with Handlebars-style templates. This parser converts them to the unified Manifest format.

Examples:

Basic .prompt file

---
model: googleai/gemini-1.5-pro
input:
  schema:
    text: string
output:
  format: json
---

Extract information from: {{text}}

See Also:

Constant Summary

Constants inherited from BaseParser

BaseParser::FRONTMATTER_REGEX

Class Method Summary collapse

Methods inherited from BaseParser

parse

Class Method Details

.format_nameObject



27
28
29
# File 'lib/solid_agent/agent_manifest/parsers/dotprompt_parser.rb', line 27

def format_name
  :dotprompt
end

.parse_string(content) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/solid_agent/agent_manifest/parsers/dotprompt_parser.rb', line 31

def parse_string(content)
  frontmatter, body = extract_frontmatter(content)

  # Extract name from frontmatter or generate from content
  name = frontmatter["name"] || generate_name_from_content(body)

  Manifest.new(
    name: name,
    version: frontmatter["version"] || "1.0.0",
    description: frontmatter["description"],

    # Model - Dotprompt format
    model: normalize_model(frontmatter["model"]),
    config: parse_dotprompt_config(frontmatter),

    # Schemas
    input_schema: parse_input_schema(frontmatter["input"]),
    output_schema: parse_output_schema(frontmatter["output"]),

    # Tools (Dotprompt can reference tools)
    tools: parse_tools(frontmatter["tools"]),

    # Template
    instructions: body,
    template: body,

    # Store original Dotprompt config in extensions
    extensions: {
      dotprompt: extract_dotprompt_extensions(frontmatter)
    }
  )
end