diff --git a/Manifest.toml b/Manifest.toml
index 3469f0b..b7ca320 100644
--- a/Manifest.toml
+++ b/Manifest.toml
@@ -2,7 +2,7 @@
julia_version = "1.12.6"
manifest_format = "2.0"
-project_hash = "09bd5c43d6ad954d8be233d27fc343ea1149c0b0"
+project_hash = "d8b83d09e35f3ba09b54977607be02d80ec68613"
[[deps.Accessors]]
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
@@ -760,9 +760,7 @@ version = "0.7.0"
[[deps.SQLLLM]]
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
-git-tree-sha1 = "93cc1ae6202279a2eb4e1dbfff706c5bc158609d"
-repo-rev = "main"
-repo-url = "https://git.yiem.cc/ton/SQLLLM"
+path = "../SQLLLM"
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
version = "0.2.5"
@@ -983,10 +981,10 @@ uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60"
version = "1.6.1"
[[deps.YiemAgent]]
-deps = ["CSV", "DataFrames", "DataStructures", "Dates", "GeneralUtils", "HTTP", "JSON", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SQLLLM", "Serialization", "URIs", "UUIDs"]
+deps = ["CSV", "DataFrames", "DataStructures", "Dates", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "Serialization", "URIs", "UUIDs"]
path = "."
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
-version = "0.4.0"
+version = "0.4.1"
[[deps.Zlib_jll]]
deps = ["Libdl"]
diff --git a/Project.toml b/Project.toml
index 11bd808..889d30f 100644
--- a/Project.toml
+++ b/Project.toml
@@ -30,4 +30,3 @@ HTTP = "2.4.0"
JSON = "1.6.1"
LLMMCTS = "0.1.5"
NATS = "0.1.0"
-SQLLLM = "0.2.5"
diff --git a/src/interface.jl b/src/interface.jl
index cc00f16..382684a 100644
--- a/src/interface.jl
+++ b/src/interface.jl
@@ -75,7 +75,7 @@ OrderedDict{String, Any} with 4 entries:
"""
function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
) where {T<:agent}
- println("\nExecuting YiemAgent decisionMaker()")
+
# lessonDict = copy(JSON.parsefile("lesson.json"))
# lesson =
@@ -108,9 +108,9 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
context =
"""
-
+
$(GeneralUtils.dict_to_string_html(a.memory["shortmem"]))
-
+
"""
@@ -269,9 +269,9 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
context =
"""
-
+
$timeline
-
+
$evaluateecontext
@@ -320,177 +320,10 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
println("\nEvaluator() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
pprintln(Dict(responsedict))
-
- # # read sessionId
- # sessionid = a.id
- # # save to filename ./log/decisionlog.txt
- # println("saving SQLLLM evaluator() to disk")
- # filename = "agent_evaluator_log_$(sessionid[:id]).json"
- # filepath = "/appfolder/app/log/$filename"
- # # check whether there is a file path exists before writing to it
- # if !isfile(filepath)
- # decisionlist = [responsedict]
- # println("Creating file $filepath")
- # open(filepath, "w") do io
- # JSON.pretty(io, decisionlist)
- # end
- # else
- # # read the file and append new data
- # decisionlist = copy(JSON.parsefile(filepath))
- # push!(decisionlist, responsedict)
- # println("Appending new data to file $filepath")
- # open(filepath, "w") do io
- # JSON.pretty(io, decisionlist)
- # end
- # end
-
- return responsedict
+ return responsedict
end
error("Evaluator failed to generate an evaluation, Response: \n$response\n<|End of error|>")
end
-# function evaluator(a::T1, timeline, decisiondict, evaluateecontext
-# ) where {T1<:agent}
-
-# systemmsg =
-# """
-#
-# - You are a master sommelier of an online wine store.
-#
-#
-# - Under your supervision, a trainee sommelier is engaging with a store customer. Each time the customer speaks, the trainee will assess the situation, determine the next course of action, and pause to await your guidance before proceeding.
-#
-#
-# - Improve a trainee sommelier decision based on the store policy and guidelines while ensuring seamless interactions between the trainee and customers.
-#
-#
-# - trajectory: A conversation between your trainee and the customer that have occurred up until now
-# - evaluatee_context: The context that evaluatee use to make a decision
-# - evaluatee_decision: The decision made by the evaluatee, consists of the following elements:
-# "plan" is the trainee's plan
-# "action_name" is the name of the action taken, which can be one of the available tool name.
-# "action_input" is the input to the action.
-#
-#
-# - Use only infomation provided by the store policy and guidelines as a bedrocks for your response.
-#
-#
-# - The trainee's plan, action_name, and action_input must be logically consistent
-# - The trainee's action_input should be in a proper format as specified by the tools.
-# - The trainee's action name and action input should make sense. For example, if the trainee isn't finished talking, he shouldn't use the END_CONVER_GUIDELINE tool.
-#
-#
-# 1) trajectory_evaluation: Analyze the trajectory of a solution to answer the user's original question.
-# - Evaluate the correctness of each section and the overall trajectory based on the given question.
-# - Provide detailed reasoning and analysis, focusing on the latest thought, action, and observation.
-# - Incomplete trajectory are acceptable if the thoughts and actions up to that point are correct, even if the final answer isn't reached.
-# - Do not generate additional thoughts or actions.
-# 2) decision_evaluation:
-# - Examine how the trainee's decisions align with the store's policies and guidelines before proceeding.
-# 3) suggestion: Based store policy and guidelines, provide a suggestion for the immediate decision step only.
-# 4) approval: Can be "yes" or "no". "no" if the suggestion contradict the trainee's decision; otherwise, it is "yes".
-
-#
-#
-# {
-# "trajectory_evaluation": "...",
-# "decision_evaluation": "...",
-# "suggestion": "...",
-# "approval": "...",
-# }
-#
-
-# Let's begin!
-# """
-# requiredKeys = [:trajectory_evaluation, :decision_evaluation, :approval, :suggestion]
-# errornote = "N/A"
-
-# for attempt in 1:10
-# evaluateecontext = replace(evaluateecontext, "" => "")
-# evaluateecontext = replace(evaluateecontext, "" => "")
-
-# context =
-# """
-#
-#
-# $timeline
-#
-#
-# $evaluateecontext
-#
-#
-# {plan: $(decisiondict["plan"]), action_name: $(decisiondict["action_name"]), action_input: $(decisiondict["action_input"])}
-#
-# P.S. $errornote
-#
-# """
-
-# unformatPrompt =
-# [
-# Dict("name" => "system", "text" => systemmsg),
-# ]
-
-# # put in model format
-# prompt = GeneralUtils.formatLLMtext(unformatPrompt, a.llmFormatName)
-# # add info
-# prompt = prompt * context
-
-# response = a.context.text2textInstructLLM(prompt; senderId=a.id)
-# response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
-# response = GeneralUtils.remove_french_accents(response)
-# # response = replace(response, '$'=>"USD")
-# think, response = GeneralUtils.extractthink(response)
-
-# responsedict = nothing
-# try
-# responsedict = copy(JSON.parsefile(response))
-# catch
-# println("\nERROR YiemAgent generatechat() failed to parse response: $response", @__FILE__, ":", @__LINE__, " $(Dates.now())")
-# continue
-# end
-
-# # check whether all answer's key points are in responsedict
-# ispass, errormsg = checkAgentResponse_JSON(responsedict, requiredKeys)
-# if !ispass
-# errornote = errormsg
-# println("\nERROR YiemAgent evaluator() $errornote --(not qualify response)> $responsedict", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
-# continue
-# end
-
-# # if accepted_as_answer ∉ ["yes", "no"] # [PENDING] add errornote into the prompt
-# # error("generated accepted_as_answer has wrong format")
-# # end
-
-# println("\nEvaluator() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
-# pprintln(Dict(responsedict))
-
-# # # read sessionId
-# # sessionid = a.id
-# # # save to filename ./log/decisionlog.txt
-# # println("saving SQLLLM evaluator() to disk")
-# # filename = "agent_evaluator_log_$(sessionid[:id]).json"
-# # filepath = "/appfolder/app/log/$filename"
-# # # check whether there is a file path exists before writing to it
-# # if !isfile(filepath)
-# # decisionlist = [responsedict]
-# # println("Creating file $filepath")
-# # open(filepath, "w") do io
-# # JSON.pretty(io, decisionlist)
-# # end
-# # else
-# # # read the file and append new data
-# # decisionlist = copy(JSON.parsefile(filepath))
-# # push!(decisionlist, responsedict)
-# # println("Appending new data to file $filepath")
-# # open(filepath, "w") do io
-# # JSON.pretty(io, decisionlist)
-# # end
-# # end
-
-# return responsedict
-# end
-# error("Evaluator failed to generate an evaluation, Response: \n$response\n<|End of error|>")
-# end
-
""" Chat with llm.
@@ -543,8 +376,8 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
# thinking loop until AI wants to communicate with the user
loopcount = 0
while true
- @info "YiemAgent conversation() 2-0 count $loopcount" @__LINE__
loopcount += 1
+ @info "YiemAgent conversation() 2-0 count $loopcount" @__LINE__
thoughtdict, _ = think(a)
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
@info "YiemAgent conversation() 2-1" @__LINE__
@@ -566,45 +399,6 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
end
end
-# function conversation(a::Union{companion, virtualcustomer}, userinput::Dict;
-# converPartnerName::Union{String, Nothing}=nothing,
-# maximumMsg=50)
-
-# chatresponse = nothing
-
-# if userinput["text"] == "newtopic"
-# clearhistory(a)
-# return "Okay. What shall we talk about?"
-# else
-# # add usermsg to a.chathistory
-# addNewMessage(a, "user", userinput["text"]; maximumMsg=maximumMsg)
-
-# # add user activity to events memory
-# push!(a.memory["events"],
-# eventdict(;
-# event_description="the user talks to the assistant.",
-# timestamp=Dates.now(),
-# subject="user",
-# action_name="CHAT_BOX",
-# action_input=userinput["text"],
-# )
-# )
-# chatresponse = generatechat(a; converPartnerName=converPartnerName, recentEventNum=20)
-
-# addNewMessage(a, "assistant", chatresponse; maximumMsg=maximumMsg)
-
-# push!(a.memory["events"],
-# eventdict(;
-# event_description="the assistant talks to the user.",
-# timestamp=Dates.now(),
-# subject="assistant",
-# action_name="CHAT_BOX",
-# action_input=chatresponse,
-# )
-# )
-# return chatresponse
-# end
-# end
"""
# Arguments
@@ -831,9 +625,9 @@ function generatechat(a::T; recentevents::Integer=20, maxattempt=10
context =
"""
-
+
$(GeneralUtils.dict_to_string_html(a.memory["shortmem"]))
-
+
"""