#include <prompt_builder.h>
Public Member Functions | |
PromptBuilder () | |
void | SetRom (Rom *rom) |
absl::Status | LoadResourceCatalogue (const std::string &yaml_path) |
std::string | BuildSystemInstruction () |
std::string | BuildSystemInstructionWithExamples () |
std::string | BuildContextualPrompt (const std::string &user_prompt, const RomContext &context) |
std::string | BuildPromptFromHistory (const std::vector< agent::ChatMessage > &history) |
void | AddFewShotExample (const FewShotExample &example) |
std::vector< FewShotExample > | GetExamplesForCategory (const std::string &category) |
std::string | LookupTileId (const std::string &alias) const |
const std::map< std::string, std::string > & | tile_reference () const |
std::string | BuildFunctionCallSchemas () const |
void | SetVerbosity (int level) |
Private Member Functions | |
std::string | BuildCommandReference () const |
std::string | BuildFewShotExamplesSection () const |
std::string | BuildToolReference () const |
std::string | BuildContextSection (const RomContext &context) |
std::string | BuildConstraintsSection () const |
std::string | BuildTileReferenceSection () const |
absl::StatusOr< std::string > | ResolveCataloguePath (const std::string &yaml_path) const |
void | ClearCatalogData () |
absl::Status | ParseCommands (const nlohmann::json &commands) |
absl::Status | ParseTools (const nlohmann::json &tools) |
absl::Status | ParseExamples (const nlohmann::json &examples) |
void | ParseTileReference (const nlohmann::json &tile_reference) |
Private Attributes | |
Rom * | rom_ = nullptr |
std::unique_ptr< ResourceContextBuilder > | resource_context_builder_ |
std::map< std::string, std::string > | command_docs_ |
std::vector< FewShotExample > | examples_ |
std::vector< ToolSpecification > | tool_specs_ |
std::map< std::string, std::string > | tile_reference_ |
int | verbosity_ = 1 |
bool | catalogue_loaded_ = false |
Definition at line 64 of file prompt_builder.h.
|
default |
|
inline |
Definition at line 68 of file prompt_builder.h.
References rom_.
Referenced by yaze::cli::GeminiAIService::SetRomContext(), and yaze::cli::OllamaAIService::SetRomContext().
absl::Status yaze::cli::PromptBuilder::LoadResourceCatalogue | ( | const std::string & | yaml_path | ) |
Definition at line 111 of file prompt_builder.cc.
References catalogue_loaded_, ClearCatalogData(), ParseCommands(), ParseExamples(), ParseTileReference(), ParseTools(), and ResolveCataloguePath().
Referenced by yaze::cli::GeminiAIService::GeminiAIService(), and yaze::cli::OllamaAIService::OllamaAIService().
std::string yaze::cli::PromptBuilder::BuildSystemInstruction | ( | ) |
Definition at line 625 of file prompt_builder.cc.
Referenced by yaze::cli::GeminiAIService::BuildSystemInstruction(), and yaze::cli::OllamaAIService::BuildSystemPrompt().
std::string yaze::cli::PromptBuilder::BuildSystemInstructionWithExamples | ( | ) |
Definition at line 680 of file prompt_builder.cc.
Referenced by yaze::cli::GeminiAIService::GeminiAIService(), and yaze::cli::OllamaAIService::OllamaAIService().
std::string yaze::cli::PromptBuilder::BuildContextualPrompt | ( | const std::string & | user_prompt, |
const RomContext & | context | ||
) |
Definition at line 690 of file prompt_builder.cc.
std::string yaze::cli::PromptBuilder::BuildPromptFromHistory | ( | const std::vector< agent::ChatMessage > & | history | ) |
Definition at line 706 of file prompt_builder.cc.
References BuildCommandReference(), BuildToolReference(), catalogue_loaded_, command_docs_, and tool_specs_.
Referenced by yaze::cli::GeminiAIService::GenerateResponse(), and yaze::cli::OllamaAIService::GenerateResponse().
void yaze::cli::PromptBuilder::AddFewShotExample | ( | const FewShotExample & | example | ) |
Definition at line 724 of file prompt_builder.cc.
std::vector< FewShotExample > yaze::cli::PromptBuilder::GetExamplesForCategory | ( | const std::string & | category | ) |
Definition at line 728 of file prompt_builder.cc.
References BuildCommandReference(), BuildToolReference(), command_docs_, and tool_specs_.
std::string yaze::cli::PromptBuilder::LookupTileId | ( | const std::string & | alias | ) | const |
Definition at line 364 of file prompt_builder.cc.
References tile_reference_.
|
inline |
Definition at line 95 of file prompt_builder.h.
References tile_reference_.
Referenced by ParseTileReference().
std::string yaze::cli::PromptBuilder::BuildFunctionCallSchemas | ( | ) | const |
Definition at line 419 of file prompt_builder.cc.
References tool_specs_.
Referenced by BuildConstraintsSection(), BuildContextSection(), and yaze::cli::GeminiAIService::BuildFunctionCallSchemas().
|
inline |
Definition at line 103 of file prompt_builder.h.
References verbosity_.
|
private |
Definition at line 372 of file prompt_builder.cc.
References command_docs_.
Referenced by BuildPromptFromHistory(), and GetExamplesForCategory().
|
private |
Definition at line 470 of file prompt_builder.cc.
References examples_.
|
private |
Definition at line 385 of file prompt_builder.cc.
References tool_specs_.
Referenced by BuildPromptFromHistory(), and GetExamplesForCategory().
|
private |
Definition at line 588 of file prompt_builder.cc.
References BuildFunctionCallSchemas().
|
private |
Definition at line 511 of file prompt_builder.cc.
References BuildFunctionCallSchemas(), BuildTileReferenceSection(), yaze::util::PlatformPaths::FindAsset(), tile_reference_, and tool_specs_.
|
private |
Definition at line 576 of file prompt_builder.cc.
Referenced by BuildConstraintsSection().
|
private |
Definition at line 78 of file prompt_builder.cc.
References yaze::util::PlatformPaths::FindAsset().
Referenced by LoadResourceCatalogue().
|
private |
Definition at line 70 of file prompt_builder.cc.
References catalogue_loaded_, command_docs_, examples_, tile_reference_, and tool_specs_.
Referenced by LoadResourceCatalogue().
|
private |
Definition at line 172 of file prompt_builder.cc.
References command_docs_.
Referenced by LoadResourceCatalogue().
|
private |
Definition at line 189 of file prompt_builder.cc.
References yaze::cli::ToolSpecification::arguments, yaze::cli::ToolArgument::description, yaze::cli::ToolSpecification::description, yaze::cli::ToolArgument::example, yaze::cli::ToolArgument::name, yaze::cli::ToolSpecification::name, yaze::cli::ToolArgument::required, tool_specs_, and yaze::cli::ToolSpecification::usage_notes.
Referenced by LoadResourceCatalogue().
|
private |
Definition at line 259 of file prompt_builder.cc.
References yaze::cli::ToolCall::args, examples_, yaze::cli::FewShotExample::expected_commands, yaze::cli::FewShotExample::explanation, yaze::cli::FewShotExample::text_response, yaze::cli::FewShotExample::tool_calls, yaze::cli::ToolCall::tool_name, and yaze::cli::FewShotExample::user_prompt.
Referenced by LoadResourceCatalogue().
|
private |
Definition at line 352 of file prompt_builder.cc.
References tile_reference(), and tile_reference_.
Referenced by LoadResourceCatalogue().
|
private |
Definition at line 119 of file prompt_builder.h.
Referenced by SetRom().
|
private |
Definition at line 120 of file prompt_builder.h.
|
private |
Definition at line 121 of file prompt_builder.h.
Referenced by BuildCommandReference(), BuildPromptFromHistory(), ClearCatalogData(), GetExamplesForCategory(), and ParseCommands().
|
private |
Definition at line 122 of file prompt_builder.h.
Referenced by BuildFewShotExamplesSection(), ClearCatalogData(), and ParseExamples().
|
private |
Definition at line 123 of file prompt_builder.h.
Referenced by BuildConstraintsSection(), BuildFunctionCallSchemas(), BuildPromptFromHistory(), BuildToolReference(), ClearCatalogData(), GetExamplesForCategory(), and ParseTools().
|
private |
Definition at line 124 of file prompt_builder.h.
Referenced by BuildConstraintsSection(), ClearCatalogData(), LookupTileId(), ParseTileReference(), and tile_reference().
|
private |
Definition at line 125 of file prompt_builder.h.
Referenced by SetVerbosity().
|
private |
Definition at line 126 of file prompt_builder.h.
Referenced by BuildPromptFromHistory(), ClearCatalogData(), and LoadResourceCatalogue().