update
This commit is contained in:
52
src/type.jl
52
src/type.jl
@@ -1,6 +1,6 @@
|
||||
module type
|
||||
|
||||
export agent, sommelier
|
||||
export agent, sommelier, companion
|
||||
|
||||
using Dates, UUIDs, DataStructures, JSON3
|
||||
using GeneralUtils
|
||||
@@ -10,6 +10,56 @@ using GeneralUtils
|
||||
abstract type agent end
|
||||
|
||||
|
||||
mutable struct companion <: agent
|
||||
name::String # agent name
|
||||
id::String # agent id
|
||||
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
||||
|
||||
""" Memory
|
||||
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
||||
NO "system" message in chathistory because I want to add it at the inference time
|
||||
chathistory= [
|
||||
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
||||
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
||||
]
|
||||
|
||||
"""
|
||||
chathistory::Vector{Dict{Symbol, Any}}
|
||||
memory::Dict{Symbol, Any}
|
||||
|
||||
# communication function
|
||||
text2textInstructLLM::Function
|
||||
end
|
||||
|
||||
function companion(
|
||||
text2textInstructLLM::Function
|
||||
;
|
||||
name::String= "Assistant",
|
||||
id::String= string(uuid4()),
|
||||
maxHistoryMsg::Integer= 20,
|
||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
||||
)
|
||||
|
||||
memory = Dict{Symbol, Any}(
|
||||
:chatbox=> "",
|
||||
:shortmem=> Vector{Dict{Symbol, String}}(),
|
||||
:events=> Vector{Dict{Symbol, Any}}()
|
||||
)
|
||||
|
||||
newAgent = companion(
|
||||
name,
|
||||
id,
|
||||
maxHistoryMsg,
|
||||
chathistory,
|
||||
memory,
|
||||
text2textInstructLLM
|
||||
)
|
||||
|
||||
return newAgent
|
||||
end
|
||||
|
||||
|
||||
|
||||
""" A sommelier agent.
|
||||
|
||||
# Arguments
|
||||
|
||||
Reference in New Issue
Block a user