add context

This commit is contained in:
2026-06-24 21:02:56 +07:00
parent 9c22cf2e31
commit 57dd6df942
2 changed files with 167 additions and 140 deletions

View File

@@ -93,7 +93,7 @@ julia> output_thoughtDict = Dict(
- [] use customerinfo - [] use customerinfo
- [] user storeinfo - [] user storeinfo
""" #WORKING """
function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10 function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
) where {T<:agent} ) where {T<:agent}
println("\nExecuting YiemAgent decisionMaker()") println("\nExecuting YiemAgent decisionMaker()")
@@ -127,6 +127,20 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
requiredKeys = ["plan", "actionname", "actioninput"] requiredKeys = ["plan", "actionname", "actioninput"]
context =
"""
<internal_context_for_LLM>
$(a.memory["scratchpad"])
</internal_context_for_LLM>
"""
#WORKING add context to the latest message (in the front)
for d in enumerate(a.chathistory[end]["content"])
if d["type"] == "text"
d["text"] = context * d["text"]
break
end
end
errornote = "N/A" errornote = "N/A"
response = nothing # placeholder for show when error msg show up response = nothing # placeholder for show when error msg show up
@@ -279,7 +293,6 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
return responsedict return responsedict
end end
error("DecisionMaker failed to generate a thought ", response) error("DecisionMaker failed to generate a thought ", response)
end
end end

View File

@@ -321,16 +321,30 @@ function virtualcustomer(
) )
""" Memory """ Memory
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3 Ref: Chat prompt format is openai
NO "system" message in chathistory because I want to add it at the inference time chathistory = [
chathistory= [ Dict(
Dict("name"=>"user", "text"=> "Wassup!", "timestamp"=> Dates.now()), "role" => "system",
Dict("name"=>"assistant", "text"=> "Hi I'm your assistant.", "timestamp"=> Dates.now()), "content" => [
Dict("type" => "text", "text" => system_msg),
]
),
Dict(
"role" => "user",
"content" => [
Dict("type" => "text", "text" => "Do you know this wine? Just give me brief intro."),
Dict(
"type" => "image_url",
"image_url" => Dict("url" => data1_uri)
)
]
)
] ]
""" """
memory = Dict{String, Any}( memory = Dict{String, Any}(
"shortmem"=> OrderedDict{String, Any}( "shortmem"=> OrderedDict{String, Any}(
), ),
"scratchpad"=> "",
"events"=> Vector{Dict{String, Any}}(), "events"=> Vector{Dict{String, Any}}(),
"state"=> Dict{String, Any}( "state"=> Dict{String, Any}(
), ),