update
This commit is contained in:
47
src/util.jl
47
src/util.jl
@@ -1,6 +1,6 @@
|
||||
module util
|
||||
|
||||
export clearhistory, addNewMessage, chatHistoryToString
|
||||
export clearhistory, addNewMessage, vectorOfDictToText
|
||||
|
||||
using UUIDs, Dates, DataStructures, HTTP, MQTTClient, JSON3
|
||||
using GeneralUtils
|
||||
@@ -113,15 +113,43 @@ function addNewMessage(a::T1, name::String, text::T2;
|
||||
end
|
||||
|
||||
|
||||
function chatHistoryToString(a)
|
||||
chatHistoryStr = ""
|
||||
for i in a.chathistory
|
||||
name = i[:name]
|
||||
text = i[:text]
|
||||
chatHistoryStr *= "$name> $text"
|
||||
"""
|
||||
|
||||
# Arguments
|
||||
- `v::Integer`
|
||||
dummy variable
|
||||
|
||||
# Return
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [x] implement the function
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function vectorOfDictToText(vecd::Vector; withkey=true)
|
||||
text = ""
|
||||
|
||||
if withkey
|
||||
for d in vecd
|
||||
name = d[:name]
|
||||
_text = d[:text]
|
||||
text *= "$name> $_text \n"
|
||||
end
|
||||
else
|
||||
for d in vecd
|
||||
for (k, v) in d
|
||||
text *= "$v \n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return chatHistoryStr
|
||||
return text
|
||||
end
|
||||
|
||||
|
||||
@@ -131,9 +159,6 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# """ Convert a single chat dictionary into LLM model instruct format.
|
||||
|
||||
# # Llama 3 instruct format example
|
||||
|
||||
Reference in New Issue
Block a user