This commit is contained in:
narawat lamaiin
2025-01-20 18:19:38 +07:00
parent 4197625e57
commit bb81b973d3
3 changed files with 71 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
module util
export clearhistory, addNewMessage, vectorOfDictToText, eventdict, noises, createTimeline
export clearhistory, addNewMessage, chatHistoryToText, eventdict, noises, createTimeline,
availableWineToText
using UUIDs, Dates, DataStructures, HTTP, JSON3
using GeneralUtils
@@ -138,7 +139,7 @@ julia> GeneralUtils.vectorOfDictToText(vecd, withkey=true)
```
# Signature
"""
function vectorOfDictToText(vecd::Vector; withkey=true)::String
function chatHistoryToText(vecd::Vector; withkey=true)::String
# Initialize an empty string to hold the final text
text = ""
@@ -169,6 +170,27 @@ function vectorOfDictToText(vecd::Vector; withkey=true)::String
end
function availableWineToText(vecd::Vector)::String
# Initialize an empty string to hold the final text
rowtext = ""
# Loop through each dictionary in the input vector
for (i, d) in enumerate(vecd)
# Iterate over all key-value pairs in the dictionary
temp = []
for (k, v) in d
# Append the formatted string to the text variable
t = "$k:$v"
push!(temp, t)
end
_rowtext = join(temp, ',')
rowtext *= "$i) $_rowtext "
end
return rowtext
end
function eventdict(;
event_description::Union{String, Nothing}=nothing,
timestamp::Union{DateTime, Nothing}=nothing,