update
This commit is contained in:
@@ -43,7 +43,7 @@ julia> formattedtext = YiemAgent.formatLLMtext_llama3instruct(d[:name], d[:text]
|
|||||||
Signature
|
Signature
|
||||||
"""
|
"""
|
||||||
function formatLLMtext_llama3instruct(name::T, text::T;
|
function formatLLMtext_llama3instruct(name::T, text::T;
|
||||||
assistantStarter::Bool=true) where {T<:AbstractString}
|
assistantStarter::Bool=false) where {T<:AbstractString}
|
||||||
formattedtext =
|
formattedtext =
|
||||||
if name == "system"
|
if name == "system"
|
||||||
"""
|
"""
|
||||||
@@ -71,7 +71,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function formatLLMtext_qwen(name::T, text::T;
|
function formatLLMtext_qwen(name::T, text::T;
|
||||||
assistantStarter::Bool=true) where {T<:AbstractString}
|
assistantStarter::Bool=false) where {T<:AbstractString}
|
||||||
formattedtext =
|
formattedtext =
|
||||||
if name == "system"
|
if name == "system"
|
||||||
"""
|
"""
|
||||||
@@ -99,7 +99,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function formatLLMtext_phi4(name::T, text::T;
|
function formatLLMtext_phi4(name::T, text::T;
|
||||||
assistantStarter::Bool=true) where {T<:AbstractString}
|
assistantStarter::Bool=false) where {T<:AbstractString}
|
||||||
formattedtext =
|
formattedtext =
|
||||||
if name == "system"
|
if name == "system"
|
||||||
"""
|
"""
|
||||||
@@ -155,7 +155,7 @@ julia> formattedtext = YiemAgent.formatLLMtext(chatmessage, "llama3instruct")
|
|||||||
# Signature
|
# Signature
|
||||||
"""
|
"""
|
||||||
function formatLLMtext(messages::Vector{Dict{Symbol, T}}; formatname::String="llama3instruct"
|
function formatLLMtext(messages::Vector{Dict{Symbol, T}}; formatname::String="llama3instruct"
|
||||||
)::String where {T<:Any}
|
)::String where {T<:AbstractString}
|
||||||
f = if formatname == "llama3instruct"
|
f = if formatname == "llama3instruct"
|
||||||
formatLLMtext_llama3instruct
|
formatLLMtext_llama3instruct
|
||||||
elseif formatname == "mistral"
|
elseif formatname == "mistral"
|
||||||
@@ -171,8 +171,12 @@ function formatLLMtext(messages::Vector{Dict{Symbol, T}}; formatname::String="ll
|
|||||||
end
|
end
|
||||||
|
|
||||||
str = ""
|
str = ""
|
||||||
for t in messages
|
for (i, t) in enumerate(messages)
|
||||||
|
if i < length(messages)
|
||||||
str *= f(t[:name], t[:text])
|
str *= f(t[:name], t[:text])
|
||||||
|
else
|
||||||
|
str *= f(t[:name], t[:text]; assistantStarter=true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return str
|
return str
|
||||||
|
|||||||
Reference in New Issue
Block a user