update
This commit is contained in:
49
src/util.jl
49
src/util.jl
@@ -1,7 +1,7 @@
|
|||||||
module util
|
module util
|
||||||
|
|
||||||
export clearhistory, addNewMessage, formatLLMtext, formatLLMtext_llama3instruct,
|
export clearhistory, addNewMessage, formatLLMtext, syntaxcheck_json, iterativeprompting,
|
||||||
syntaxcheck_json, iterativeprompting
|
formatLLMtext_llama3instruct, formatLLMtext_phi3instruct
|
||||||
|
|
||||||
using UUIDs, Dates, DataStructures, HTTP, MQTTClient, JSON3
|
using UUIDs, Dates, DataStructures, HTTP, MQTTClient, JSON3
|
||||||
using GeneralUtils
|
using GeneralUtils
|
||||||
@@ -172,6 +172,51 @@ function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
""" Convert a single chat dictionary into LLM model instruct format.
|
||||||
|
|
||||||
|
# Llama 3 instruct format example
|
||||||
|
<|system|>
|
||||||
|
You are a helpful AI assistant.<|end|>
|
||||||
|
<|user|>
|
||||||
|
I am going to Paris, what should I see?<|end|>
|
||||||
|
<|assistant|>
|
||||||
|
Paris, the capital of France, is known for its stunning architecture, art museums."<|end|>
|
||||||
|
<|user|>
|
||||||
|
What is so great about #1?<|end|>
|
||||||
|
<|assistant|>
|
||||||
|
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
- `name::T`
|
||||||
|
message owner name e.f. "system", "user" or "assistant"
|
||||||
|
- `text::T`
|
||||||
|
|
||||||
|
# Return
|
||||||
|
- `formattedtext::String`
|
||||||
|
text formatted to model format
|
||||||
|
|
||||||
|
# Example
|
||||||
|
```jldoctest
|
||||||
|
julia> using Revise
|
||||||
|
julia> using YiemAgent
|
||||||
|
julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
||||||
|
julia> formattedtext = YiemAgent.formatLLMtext_phi3instruct(d[:name], d[:text])
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Signature
|
||||||
|
"""
|
||||||
|
function formatLLMtext_phi3instruct(name::T, text::T) where {T<:AbstractString}
|
||||||
|
formattedtext =
|
||||||
|
"""
|
||||||
|
<|$name|>
|
||||||
|
$text<|end|>\n
|
||||||
|
"""
|
||||||
|
|
||||||
|
return formattedtext
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" Convert a chat messages in vector of dictionary into LLM model instruct format.
|
""" Convert a chat messages in vector of dictionary into LLM model instruct format.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user