use enriched city in generation functions

This commit is contained in:
Aaron Po
2026-07-17 21:11:23 -04:00
parent 5a8a9f4652
commit 320696fb92
6 changed files with 23 additions and 25 deletions

View File

@@ -20,12 +20,10 @@ class DataGenerator {
/** /**
* @brief Generates brewery data for a location. * @brief Generates brewery data for a location.
* *
* @param location Location data * @param city Enriched city the brewery is associated with.
* @param region_context Additional regional context text.
* @return Brewery generation result. * @return Brewery generation result.
*/ */
virtual BreweryResult GenerateBrewery(const Location& location, virtual BreweryResult GenerateBrewery(const EnrichedCity& city) = 0;
const std::string& region_context) = 0;
/** /**
* @brief Generates a user profile grounded in a sampled name and persona. * @brief Generates a user profile grounded in a sampled name and persona.

View File

@@ -55,8 +55,7 @@ class LlamaGenerator final : public DataGenerator {
* @param region_context Additional regional context. * @param region_context Additional regional context.
* @return Generated brewery result. * @return Generated brewery result.
*/ */
BreweryResult GenerateBrewery(const Location& location, BreweryResult GenerateBrewery(const EnrichedCity&) override;
const std::string& region_context) override;
/** /**
* @brief Generates a user profile grounded in a sampled name and persona. * @brief Generates a user profile grounded in a sampled name and persona.

View File

@@ -20,20 +20,15 @@ class MockGenerator final : public DataGenerator {
/** /**
* @brief Generates deterministic brewery data for a location. * @brief Generates deterministic brewery data for a location.
* *
* @param location City and country names. * @param enriched_city
* @param region_context Unused for mock generation.
* @return Generated brewery result. * @return Generated brewery result.
*/ */
BreweryResult GenerateBrewery(const Location& location,
const std::string& region_context) override;
BreweryResult GenerateBrewery(const EnrichedCity& enriched_city) override;
/** /**
* @brief Generates deterministic user data grounded in a sampled name and * @brief Generates deterministic user data grounded in a sampled name and
* persona. * persona.
*
* @param city Enriched city the user is associated with.
* @param persona Persona archetype.
* @param name Sampled first/last name, copied directly into the result.
* @return Generated user result. * @return Generated user result.
*/ */
UserResult GenerateUser(const EnrichedCity& city, const UserPersona& persona, UserResult GenerateUser(const EnrichedCity& city, const UserPersona& persona,

View File

@@ -22,12 +22,15 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
const auto generate_record = const auto generate_record =
[this, &skipped_count]( [this, &skipped_count](
const Location& location, const EnrichedCity& enriched_city) -> std::optional<BreweryRecord> {
const std::string& region_context) -> std::optional<BreweryRecord> {
try { try {
const BreweryResult brewery = const BreweryResult brewery = generator_->GenerateBrewery(enriched_city);
generator_->GenerateBrewery(location, region_context); const std::string postal_code =
return BreweryRecord{.location = location, .brewery = brewery}; postal_code_service_->GeneratePostalCode(enriched_city.location);
return BreweryRecord{
.address = BreweryAddress{.city = enriched_city.location,
.postal_code = postal_code},
.brewery = brewery};
} catch (const std::exception& e) { } catch (const std::exception& e) {
++skipped_count; ++skipped_count;
@@ -36,7 +39,8 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
.phase = PipelinePhase::BreweryAndBeerGeneration, .phase = PipelinePhase::BreweryAndBeerGeneration,
.message = std::format("[Pipeline] Skipping city '{}' ({}): brewery " .message = std::format("[Pipeline] Skipping city '{}' ({}): brewery "
"generation failed: {}", "generation failed: {}",
location.city, location.country, e.what())}); enriched_city.location.city,
enriched_city.location.country, e.what())});
return std::nullopt; return std::nullopt;
} }
}; };
@@ -57,9 +61,8 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
} }
}; };
for (const auto& [location, region_context] : cities) { for (const EnrichedCity& enriched_city : cities) {
const std::optional<BreweryRecord> record = const std::optional<BreweryRecord> record = generate_record(enriched_city);
generate_record(location, region_context);
if (!record.has_value()) { if (!record.has_value()) {
continue; continue;
} }

View File

@@ -36,7 +36,9 @@ static std::string FormatLocalLanguageCodes(
static constexpr int kBreweryInitialMaxTokens = 2800; static constexpr int kBreweryInitialMaxTokens = 2800;
BreweryResult LlamaGenerator::GenerateBrewery( BreweryResult LlamaGenerator::GenerateBrewery(
const Location& location, const std::string& region_context) { const EnrichedCity& enriched_city) {
const City& location = enriched_city.location;
const std::string& region_context = enriched_city.region_context;
/** /**
* Preprocess and truncate region context to manageable size * Preprocess and truncate region context to manageable size
*/ */

View File

@@ -11,7 +11,8 @@
#include "data_generation/mock_generator.h" #include "data_generation/mock_generator.h"
BreweryResult MockGenerator::GenerateBrewery( BreweryResult MockGenerator::GenerateBrewery(
const Location& location, const std::string& /*region_context*/) { const EnrichedCity& enriched_city) {
const City& location = enriched_city.location;
const size_t hash = DeterministicHash(location); const size_t hash = DeterministicHash(location);
const std::string_view adjective = const std::string_view adjective =