Skip to content

Commit

Permalink
Refactor: 테스트 용으로 사용 할 이벤트 스토밍 정보를 얻어오는 코드 통합 작업 및 주석 개선 작업
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinSeongJin2 committed Jan 8, 2025
1 parent e7cdedf commit 6f7c129
Show file tree
Hide file tree
Showing 9 changed files with 5,656 additions and 11,082 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ESActionsUtil from "../../modeling/generators/es-ddl-generators/modules/E
import TokenCounterTest from "../../modeling/generators/utils/TokenCounter/TokenCounterTest";
import ESValueSummaryGeneratorTest from "../../modeling/generators/es-generators/ESValueSummaryGenerator/ESValueSummaryGeneratorTest";
import ESValueSummarizeWithFilterTest from "../../modeling/generators/es-generators/helpers/ESValueSummarizeWithFilter/ESValueSummarizeWithFilterTest";
import { getEsValue } from "../../modeling/generators/es-generators/mocks";

export default {
name: "es-test-terminal",
Expand Down Expand Up @@ -1036,6 +1037,9 @@ export default {
},

async _TempTest() {
console.log(getEsValue("librarySevice"))
console.log(getEsValue("librarySevice", ['remainOnlyBoundedContext']))
console.log(getEsValue("librarySevice", ['remainOnlyAggregate']))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,11 @@ const { TokenCounter } = require("../../utils")
* @description EventStorming 모델의 요약 정보를 생성하고 관리하는 클래스입니다.
* 주어진 컨텍스트에 따라 EventStorming 요소들을 분석하고 토큰 제한에 맞춰 요약된 정보를 생성합니다.
*
* @class
* @extends {FormattedJSONAIGenerator}
*
* @property {string[]} checkInputParamsKeys - 필수 입력 파라미터 키 목록
* @property {string[]} progressCheckStrings - 진행 상태 확인을 위한 문자열 목록
* @property {ESAliasTransManager} esAliasTransManager - ES 별칭 변환 관리자
*
* @constructor
* @param {Object} client - 클라이언트 설정 객체
* @param {Object} client.input - 입력 파라미터
* @param {string} client.input.context - 분석 컨텍스트
* @param {Object} client.input.esValue - EventStorming 모델 데이터
* @param {string[]} client.input.keysToFilter - 필터링할 키 목록
* @param {number} client.input.maxTokens - 최대 토큰 수 제한
* @param {string} client.input.tokenCalcModel - 토큰 계산 모델
*
* @throws {Error} id 속성이 keysToFilter에 포함된 경우
*
* @see FormattedJSONAIGenerator
* @see ESAliasTransManager
* @see ESValueSummarizeWithFilter
*
* @example
* @example 전달된 이벤트 스토밍 모델에 대해서 최대 토큰 이내의 요약정보 얻기
* const generator = new ESValueSummaryGenerator({
* input: {
* context: "도서 관련 커맨드 생성 작업을 수행해야 함",
* esValue: libraryEsValue,
* esValue: getEsValue("librarySevice"),
* keysToFilter: [],
* maxTokens: 800,
* tokenCalcModel: "gpt-4o"
Expand All @@ -52,11 +30,6 @@ const { TokenCounter } = require("../../utils")
* });
*
* generator.generate();
*
* @note
* - id 속성은 정렬에 사용되므로 필터링할 수 없습니다
* - 토큰 제한에 맞춰 자동으로 요약 정보가 조정됩니다
* - 요약된 정보는 JSON 형식으로 제공됩니다
*/
class ESValueSummaryGenerator extends FormattedJSONAIGenerator{
constructor(client){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const ESValueSummaryGenerator = require("./ESValueSummaryGenerator")
const { libraryEsValue } = require("./mocks");
const { ESValueSummarizeWithFilter } = require("../helpers")
const ESAliasTransManager = require("../../es-ddl-generators/modules/ESAliasTransManager")
const { TokenCounter } = require("../../utils")
const { getEsValue } = require("../mocks")

class ESValueSummaryGeneratorTest {
static async test(esValue=null) {
if(!esValue) esValue = JSON.parse(JSON.stringify(libraryEsValue));
if(!esValue) esValue = getEsValue("librarySevice");

const esAliasTransManager = new ESAliasTransManager(esValue)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,30 @@ The approximate structure is as follows.

/**
* 주어진 이벤트스토밍에서 위치 데이터등을 제외한 핵심 정보들만 추출해서 LLM에게 입력 데이터로 제공
* keysToFilter: 일부 경우에는 properties와 같은 구체적인 속성들이 불필요할 수 있음. 이런 경우에 제외시킬 키값을 배열로 전달
* keysToExcludeFilter: 일부 경우에는 properties와 같은 구체적인 속성들이 불필요할 수 있음. 이런 경우에 제외시킬 키값을 배열로 전달
* ex) id: 모든 id 속성을 미포함, boundedContext.id: boundedContext의 id 속성을 미포함
* esAliasTransManager: Id값을 별칭으로 바꿔서 UUID를 제거해서, 패턴 기반의 LLM의 성능을 향상
*/
static getSummarizedESValue(esValue, keysToFilter=[], esAliasTransManager=null){
static getSummarizedESValue(esValue, keysToExcludeFilter=[], esAliasTransManager=null){
const boundedContexts = Object.values(esValue.elements)
.filter(element => element && element._type === 'org.uengine.modeling.model.BoundedContext')

let summarizedBoundedContexts = boundedContexts.map(boundedContext =>
this.getSummarizedBoundedContextValue(
esValue, boundedContext, keysToFilter, esAliasTransManager
esValue, boundedContext, keysToExcludeFilter, esAliasTransManager
)
)

return {
deletedProperties: keysToFilter,
deletedProperties: keysToExcludeFilter,
boundedContexts: summarizedBoundedContexts
}
}


static getSummarizedBoundedContextValue(esValue, boundedContext, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedBoundedContextValue(esValue, boundedContext, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}


Expand All @@ -197,24 +197,24 @@ The approximate structure is as follows.
...getConditionalValue(
["actors", "boundedContext.actors"],
{ actors: this.getSummarizedActorValue(
esValue, boundedContext, keysToFilter, esAliasTransManager
esValue, boundedContext, keysToExcludeFilter, esAliasTransManager
)}
),
...getConditionalValue(
["aggregates", "boundedContext.aggregates"],
{ aggregates: boundedContext.aggregates
.map(aggregate => esValue.elements[aggregate.id])
.map(aggregate => this.getSummarizedAggregateValue(
esValue, boundedContext, aggregate, keysToFilter, esAliasTransManager
esValue, boundedContext, aggregate, keysToExcludeFilter, esAliasTransManager
))
}
)
}
}

static getSummarizedActorValue(esValue, boundedContext, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedActorValue(esValue, boundedContext, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}

const getUniqueActors = (actors, property) => {
Expand Down Expand Up @@ -245,18 +245,18 @@ The approximate structure is as follows.
}


if(!this._checkKeyFilters(keysToFilter, ["name", "actors.name"]))
if(!this._checkKeyFilters(keysToExcludeFilter, ["name", "actors.name"]))
return getUniqueActors(actors, "name")

if(!this._checkKeyFilters(keysToFilter, ["id", "actors.id"]))
if(!this._checkKeyFilters(keysToExcludeFilter, ["id", "actors.id"]))
return getUniqueActors(actors, "id")

return actors
}

static getSummarizedAggregateValue(esValue, boundedContext, aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedAggregateValue(esValue, boundedContext, aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}

return {
Expand All @@ -274,34 +274,34 @@ The approximate structure is as follows.
),
...getConditionalValue(
["entities", "aggregate.entities"],
{ entities: this.getSummarizedEntityValue(aggregate, keysToFilter, esAliasTransManager) }
{ entities: this.getSummarizedEntityValue(aggregate, keysToExcludeFilter, esAliasTransManager) }
),
...getConditionalValue(
["enumerations", "aggregate.enumerations"],
{ enumerations: this.getSummarizedEnumerationValue(aggregate, keysToFilter, esAliasTransManager) }
{ enumerations: this.getSummarizedEnumerationValue(aggregate, keysToExcludeFilter, esAliasTransManager) }
),
...getConditionalValue(
["valueObjects", "aggregate.valueObjects"],
{ valueObjects: this.getSummarizedValueObjectValue(aggregate, keysToFilter, esAliasTransManager) }
{ valueObjects: this.getSummarizedValueObjectValue(aggregate, keysToExcludeFilter, esAliasTransManager) }
),
...getConditionalValue(
["commands", "aggregate.commands"],
{ commands: this.getSummarizedCommandValue(esValue, boundedContext, aggregate, keysToFilter, esAliasTransManager) }
{ commands: this.getSummarizedCommandValue(esValue, boundedContext, aggregate, keysToExcludeFilter, esAliasTransManager) }
),
...getConditionalValue(
["events", "aggregate.events"],
{ events: this.getSummarizedEventValue(esValue, boundedContext, aggregate, keysToFilter, esAliasTransManager) }
{ events: this.getSummarizedEventValue(esValue, boundedContext, aggregate, keysToExcludeFilter, esAliasTransManager) }
),
...getConditionalValue(
["readModels", "aggregate.readModels"],
{ readModels: this.getSummarizedReadModelValue(esValue, boundedContext, aggregate, keysToFilter, esAliasTransManager) }
{ readModels: this.getSummarizedReadModelValue(esValue, boundedContext, aggregate, keysToExcludeFilter, esAliasTransManager) }
)
}
}

static getSummarizedEntityValue(aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedEntityValue(aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}


Expand Down Expand Up @@ -336,9 +336,9 @@ The approximate structure is as follows.
return summarizedEntityValue
}

static getSummarizedEnumerationValue(aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedEnumerationValue(aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}


Expand Down Expand Up @@ -366,9 +366,9 @@ The approximate structure is as follows.
return summarizedEnumerationValue
}

static getSummarizedValueObjectValue(aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedValueObjectValue(aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}

if(!this._isAggregateHaveElements(aggregate)) return []
Expand Down Expand Up @@ -406,9 +406,9 @@ The approximate structure is as follows.
return summarizedValueObjectValue
}

static getSummarizedCommandValue(esValue, boundedContext, aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedCommandValue(esValue, boundedContext, aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}

const getOutputEvents = (element) => {
Expand Down Expand Up @@ -473,9 +473,9 @@ The approximate structure is as follows.
return summarizedCommandValue
}

static getSummarizedEventValue(esValue, boundedContext, aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedEventValue(esValue, boundedContext, aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}

const getRelationsForType = (esValue, sourceElement, targetType) => {
Expand Down Expand Up @@ -544,9 +544,9 @@ The approximate structure is as follows.
return summarizedEventValue
}

static getSummarizedReadModelValue(esValue, boundedContext, aggregate, keysToFilter=[], esAliasTransManager=null) {
static getSummarizedReadModelValue(esValue, boundedContext, aggregate, keysToExcludeFilter=[], esAliasTransManager=null) {
const getConditionalValue = (keys, value) => {
return !this._checkKeyFilters(keysToFilter, keys) ? value : {}
return !this._checkKeyFilters(keysToExcludeFilter, keys) ? value : {}
}

let summarizedReadModelValue = []
Expand Down Expand Up @@ -611,8 +611,8 @@ The approximate structure is as follows.
})
}

static _checkKeyFilters(keysToFilter, valuesToCheck, onNotMatch=null) {
for(let key of keysToFilter)
static _checkKeyFilters(keysToExcludeFilter, valuesToCheck, onNotMatch=null) {
for(let key of keysToExcludeFilter)
if(valuesToCheck.includes(key)) return true

if(onNotMatch) onNotMatch()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const libraryEsValue = require("./mocks")
const { getEsValue } = require("../../mocks")
const ESAliasTransManager = require("../../../es-ddl-generators/modules/ESAliasTransManager")
const ESValueSummarizeWithFilter = require("./ESValueSummarizeWithFilter")

class ESValueSummarizeWithFilterTest {
static async test(esValue=null) {
if(!esValue)
esValue = libraryEsValue
esValue = getEsValue("librarySevice")

const esAliasTransManager = new ESAliasTransManager(esValue)

Expand Down
Loading

0 comments on commit 6f7c129

Please sign in to comment.