update
This commit is contained in:
53
src/util.jl
53
src/util.jl
@@ -1,6 +1,6 @@
|
||||
module util
|
||||
|
||||
export clearhistory, addNewMessage, vectorOfDictToText, eventdict, noises
|
||||
export clearhistory, addNewMessage, vectorOfDictToText, eventdict, noises, createTimeline
|
||||
|
||||
using UUIDs, Dates, DataStructures, HTTP, JSON3
|
||||
using GeneralUtils
|
||||
@@ -169,31 +169,6 @@ function vectorOfDictToText(vecd::Vector; withkey=true)::String
|
||||
end
|
||||
|
||||
|
||||
# function eventdict(;
|
||||
# event_description::Union{String, Nothing}=nothing,
|
||||
# timestamp::Union{DateTime, Nothing}=nothing,
|
||||
# subject::Union{String, Nothing}=nothing,
|
||||
# action_or_dialogue::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,
|
||||
# note::Union{String, Nothing}=nothing,
|
||||
# )
|
||||
# return Dict{Symbol, Any}(
|
||||
# :event_description=> event_description,
|
||||
# :timestamp=> timestamp,
|
||||
# :subject=> subject,
|
||||
# :action_or_dialogue=> action_or_dialogue,
|
||||
# :location=> location,
|
||||
# :equipment_used=> equipment_used,
|
||||
# :material_used=> material_used,
|
||||
# :outcome=> outcome,
|
||||
# :note=> note,
|
||||
# )
|
||||
# end
|
||||
|
||||
|
||||
function eventdict(;
|
||||
event_description::Union{String, Nothing}=nothing,
|
||||
timestamp::Union{DateTime, Nothing}=nothing,
|
||||
@@ -222,6 +197,32 @@ function eventdict(;
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
function createTimeline(memory::T1, recent) where {T1<:AbstractVector}
|
||||
totalevents = length(memory)
|
||||
ind =
|
||||
if totalevents > recent
|
||||
start = totalevents - recent
|
||||
start:totalevents
|
||||
else
|
||||
1:totalevents
|
||||
end
|
||||
|
||||
timeline = ""
|
||||
for (i, event) in enumerate(memory[ind])
|
||||
if event[:outcome] === nothing
|
||||
timeline *= "$i) $(event[:subject])> $(event[:actioninput])\n"
|
||||
else
|
||||
timeline *= "$i) $(event[:subject])> $(event[:actioninput]) $(event[:outcome])\n"
|
||||
end
|
||||
end
|
||||
|
||||
return timeline
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
# """ Convert a single chat dictionary into LLM model instruct format.
|
||||
|
||||
# # Llama 3 instruct format example
|
||||
|
||||
Reference in New Issue
Block a user