This commit is contained in:
narawat lamaiin
2025-04-04 15:04:02 +07:00
parent c21f943b12
commit c0edf7dadf
3 changed files with 247 additions and 204 deletions

View File

@@ -281,18 +281,27 @@ timeline = createTimeline(events)
# 2) Assistant> Hi there! with a smile
"""
function createTimeline(events::T1) where {T1<:AbstractVector}
function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothing
) where {T1<:AbstractVector}
# Initialize empty timeline string
timeline = ""
# Iterate through events with index
for (i, event) in enumerate(events)
# Determine which indices to use - either provided range or full length
ind =
if eventindex !== nothing
[eventindex...]
else
1:length(events)
end
# Iterate through events and format each one
for (i, event) in zip(ind, events)
# If no outcome exists, format without outcome
if event[:outcome] === nothing
timeline *= "Event_$i) $(event[:subject])> $(event[:actioninput])\n"
# If outcome exists, include it in formatting
timeline *= "Event_$i $(event[:subject])> $(event[:actioninput])\n"
# If outcome exists, include it in formatting
else
timeline *= "Event_$i) $(event[:subject])> $(event[:actioninput]) $(event[:outcome])\n"
timeline *= "Event_$i $(event[:subject])> $(event[:actioninput]) $(event[:outcome])\n"
end
end
@@ -302,7 +311,6 @@ end
# """ Convert a single chat dictionary into LLM model instruct format.
# # Llama 3 instruct format example