update
This commit is contained in:
47
src/util.jl
47
src/util.jl
@@ -231,12 +231,12 @@ function eventdict(;
|
||||
timestamp::Union{DateTime, Nothing}=nothing,
|
||||
subject::Union{String, Nothing}=nothing,
|
||||
thought::Union{AbstractDict, Nothing}=nothing,
|
||||
actionname::Union{String, Nothing}=nothing, # "CHAT", "CHECKINVENTORY", "PRESENTBOX", etc
|
||||
actioninput::Union{String, Nothing}=nothing,
|
||||
action_name::Union{String, Nothing}=nothing, # "CHAT", "CHECKINVENTORY", "PRESENTBOX", etc
|
||||
action_input::Union{String, Nothing}=nothing,
|
||||
location::Union{String, Nothing}=nothing,
|
||||
equipment_used::Union{String, Nothing}=nothing,
|
||||
material_used::Union{String, Nothing}=nothing,
|
||||
outcome::Union{String, Nothing}=nothing,
|
||||
observation::Union{String, Nothing}=nothing,
|
||||
note::Union{String, Nothing}=nothing,
|
||||
)
|
||||
|
||||
@@ -245,12 +245,12 @@ function eventdict(;
|
||||
:timestamp=> timestamp,
|
||||
:subject=> subject,
|
||||
:thought=> thought,
|
||||
:actionname=> actionname,
|
||||
:actioninput=> actioninput,
|
||||
:action_name=> action_name,
|
||||
:action_input=> action_input,
|
||||
:location=> location,
|
||||
:equipment_used=> equipment_used,
|
||||
:material_used=> material_used,
|
||||
:outcome=> outcome,
|
||||
:observation=> observation,
|
||||
:note=> note,
|
||||
)
|
||||
|
||||
@@ -266,7 +266,7 @@ end
|
||||
Each event dictionary should have the following keys:
|
||||
- :subject - The subject or entity performing the action
|
||||
- :actioninput - The action or input performed by the subject
|
||||
- :outcome - (Optional) The result or outcome of the action
|
||||
- :observation - (Optional) The result or outcome of the action
|
||||
|
||||
# Returns
|
||||
- `timeline::String`
|
||||
@@ -276,8 +276,8 @@ end
|
||||
# Example
|
||||
|
||||
events = [
|
||||
Dict(:subject => "User", :actioninput => "Hello", :outcome => nothing),
|
||||
Dict(:subject => "Assistant", :actioninput => "Hi there!", :outcome => "with a smile")
|
||||
Dict(:subject => "User", :actioninput => "Hello", :observation => nothing),
|
||||
Dict(:subject => "Assistant", :actioninput => "Hi there!", :observation => "with a smile")
|
||||
]
|
||||
timeline = createTimeline(events)
|
||||
# 1) User> Hello
|
||||
@@ -297,19 +297,19 @@ function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothin
|
||||
1:length(events)
|
||||
end
|
||||
|
||||
#[WORKING] Iterate through events and format each one
|
||||
# Iterate through events and format each one
|
||||
for i in ind
|
||||
event = events[i]
|
||||
# If no outcome exists, format without outcome
|
||||
# if event[:actionname] == "CHATBOX"
|
||||
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput])\n"
|
||||
# elseif event[:actionname] == "CHECKINVENTORY" && event[:outcome] === nothing
|
||||
# elseif event[:actionname] == "CHECKINVENTORY" && event[:observation] === nothing
|
||||
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: Not done yet.\n"
|
||||
# If outcome exists, include it in formatting
|
||||
if event[:actionname] == "CHECKWINE"
|
||||
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:outcome])\n"
|
||||
if event[:action_name] == "CHECKWINE"
|
||||
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:action_name]), action_input: $(event[:action_input]), observation: $(event[:observation])\n"
|
||||
else
|
||||
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput])\n"
|
||||
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:action_name]), action_input: $(event[:action_input])\n"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -333,11 +333,11 @@ end
|
||||
# for i in ind
|
||||
# event = events[i]
|
||||
# # If no outcome exists, format without outcome
|
||||
# if event[:outcome] === nothing
|
||||
# if event[:observation] === nothing
|
||||
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: Not done yet.\n"
|
||||
# # If outcome exists, include it in formatting
|
||||
# else
|
||||
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:outcome])\n"
|
||||
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:observation])\n"
|
||||
# end
|
||||
# end
|
||||
|
||||
@@ -363,16 +363,19 @@ function createEventsLog(events::T1; index::Union{UnitRange, Nothing}=nothing
|
||||
for i in ind
|
||||
event = events[i]
|
||||
# If no outcome exists, format without outcome
|
||||
if event[:outcome] === nothing
|
||||
if event[:observation] === nothing
|
||||
subject = event[:subject]
|
||||
actioninput = event[:actioninput]
|
||||
d = Dict{Symbol, String}(:name=>subject, :text=>actioninput)
|
||||
action_name = event[:action_name]
|
||||
action_input = event[:action_input]
|
||||
str = "Action_name: $action_name, Action_input: $action_input"
|
||||
d = Dict{Symbol, String}(:name=>subject, :text=>str)
|
||||
push!(log, d)
|
||||
else
|
||||
subject = event[:subject]
|
||||
actioninput = event[:actioninput]
|
||||
outcome = event[:outcome]
|
||||
str = "Action: $actioninput Outcome: $outcome"
|
||||
action_name = event[:action_name]
|
||||
action_input = event[:action_input]
|
||||
observation = event[:observation]
|
||||
str = "Action_name: $action_name, Action_input: $action_input, Observation: $observation"
|
||||
d = Dict{Symbol, String}(:name=>subject, :text=>str)
|
||||
push!(log, d)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user