update
This commit is contained in:
@@ -586,10 +586,13 @@ function sendReceiveMqttMsg(mqttInstance::mqttClientInstance_v2, receivechannel:
|
||||
)::NamedTuple where {T<:Any}
|
||||
|
||||
timepass = nothing
|
||||
attempts = 1
|
||||
attempts = 0
|
||||
while attempts <= maxattempt
|
||||
attempts += 1
|
||||
if attempts > 1
|
||||
println("attempts $attempts ", @__FILE__, " ", @__LINE__)
|
||||
println("\nsendReceiveMqttMsg() attempts $attempts ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
pprintln(outgoingMsg)
|
||||
println("--------------\n")
|
||||
end
|
||||
|
||||
sendMqttMsg(mqttInstance, outgoingMsg)
|
||||
@@ -616,8 +619,6 @@ function sendReceiveMqttMsg(mqttInstance::mqttClientInstance_v2, receivechannel:
|
||||
end
|
||||
sleep(1)
|
||||
end
|
||||
|
||||
attempts += 1
|
||||
end
|
||||
|
||||
return (success=false,
|
||||
|
||||
@@ -42,7 +42,8 @@ julia> formattedtext = YiemAgent.formatLLMtext_llama3instruct(d[:name], d[:text]
|
||||
|
||||
Signature
|
||||
"""
|
||||
function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString}
|
||||
function formatLLMtext_llama3instruct(name::T, text::T;
|
||||
assistantStarter::Bool=true) where {T<:AbstractString}
|
||||
formattedtext =
|
||||
if name == "system"
|
||||
"""
|
||||
@@ -58,6 +59,13 @@ function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString
|
||||
"""
|
||||
end
|
||||
|
||||
if assistantStarter
|
||||
formattedtext *=
|
||||
"""
|
||||
<|start_header_id|>assistant<|end_header_id|>
|
||||
"""
|
||||
end
|
||||
|
||||
return formattedtext
|
||||
end
|
||||
# function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString}
|
||||
@@ -80,6 +88,32 @@ end
|
||||
# return formattedtext
|
||||
# end
|
||||
|
||||
function formatLLMtext_qwen(name::T, text::T;
|
||||
assistantStarter::Bool=true) where {T<:AbstractString}
|
||||
formattedtext =
|
||||
if name == "system"
|
||||
"""
|
||||
<|im_start|>$name
|
||||
$text
|
||||
<|im_end|>
|
||||
"""
|
||||
else
|
||||
"""
|
||||
<|im_start|>$name
|
||||
$text
|
||||
<|im_end|>
|
||||
"""
|
||||
end
|
||||
|
||||
if assistantStarter
|
||||
formattedtext *=
|
||||
"""
|
||||
<|im_start|>assistant
|
||||
"""
|
||||
end
|
||||
|
||||
return formattedtext
|
||||
end
|
||||
|
||||
|
||||
""" Convert a chat messages in vector of dictionary into LLM model instruct format.
|
||||
@@ -116,7 +150,9 @@ function formatLLMtext(messages::Vector{Dict{Symbol, T}}; formatname::String="ll
|
||||
elseif formatname == "mistral"
|
||||
# not define yet
|
||||
elseif formatname == "phi3instruct"
|
||||
formatLLMtext_phi3instruct
|
||||
# not define yet
|
||||
elseif formatname == "qwen"
|
||||
formatLLMtext_qwen
|
||||
else
|
||||
error("$formatname template not define yet")
|
||||
end
|
||||
@@ -126,11 +162,6 @@ function formatLLMtext(messages::Vector{Dict{Symbol, T}}; formatname::String="ll
|
||||
str *= f(t[:name], t[:text])
|
||||
end
|
||||
|
||||
# add <|assistant|> so that the model don't generate it and I don't need to clean it up later
|
||||
if formatname == "phi3instruct"
|
||||
str *= "<|assistant|>\n"
|
||||
end
|
||||
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ function textToDict(text::String, detectKeywords::Vector{String};
|
||||
od1[key] = str
|
||||
remainingtext = remainingtext[1:keywordidx[1]-1]
|
||||
else
|
||||
error("""keyword "$keyword" not found in the provided text""")
|
||||
error("""keyword "$keyword" not found in the provided text: $text </end of error note>""")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user