update
This commit is contained in:
+4
-6
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
julia_version = "1.12.6"
|
julia_version = "1.12.6"
|
||||||
manifest_format = "2.0"
|
manifest_format = "2.0"
|
||||||
project_hash = "09bd5c43d6ad954d8be233d27fc343ea1149c0b0"
|
project_hash = "d8b83d09e35f3ba09b54977607be02d80ec68613"
|
||||||
|
|
||||||
[[deps.Accessors]]
|
[[deps.Accessors]]
|
||||||
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
||||||
@@ -760,9 +760,7 @@ version = "0.7.0"
|
|||||||
|
|
||||||
[[deps.SQLLLM]]
|
[[deps.SQLLLM]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
|
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
|
||||||
git-tree-sha1 = "93cc1ae6202279a2eb4e1dbfff706c5bc158609d"
|
path = "../SQLLLM"
|
||||||
repo-rev = "main"
|
|
||||||
repo-url = "https://git.yiem.cc/ton/SQLLLM"
|
|
||||||
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
|
|
||||||
@@ -983,10 +981,10 @@ uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60"
|
|||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
|
|
||||||
[[deps.YiemAgent]]
|
[[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 = "."
|
path = "."
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
|
|
||||||
[[deps.Zlib_jll]]
|
[[deps.Zlib_jll]]
|
||||||
deps = ["Libdl"]
|
deps = ["Libdl"]
|
||||||
|
|||||||
@@ -30,4 +30,3 @@ HTTP = "2.4.0"
|
|||||||
JSON = "1.6.1"
|
JSON = "1.6.1"
|
||||||
LLMMCTS = "0.1.5"
|
LLMMCTS = "0.1.5"
|
||||||
NATS = "0.1.0"
|
NATS = "0.1.0"
|
||||||
SQLLLM = "0.2.5"
|
|
||||||
|
|||||||
+9
-215
@@ -75,7 +75,7 @@ OrderedDict{String, Any} with 4 entries:
|
|||||||
"""
|
"""
|
||||||
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()")
|
|
||||||
# lessonDict = copy(JSON.parsefile("lesson.json"))
|
# lessonDict = copy(JSON.parsefile("lesson.json"))
|
||||||
|
|
||||||
# lesson =
|
# lesson =
|
||||||
@@ -108,9 +108,9 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
context =
|
context =
|
||||||
"""
|
"""
|
||||||
<internal_context_for_assistant>
|
<internal_context_for_assistant>
|
||||||
<thought_history>
|
<assistant_action_history>
|
||||||
$(GeneralUtils.dict_to_string_html(a.memory["shortmem"]))
|
$(GeneralUtils.dict_to_string_html(a.memory["shortmem"]))
|
||||||
</thought_history>
|
</assistant_action_history>
|
||||||
</internal_context_for_assistant>
|
</internal_context_for_assistant>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -269,9 +269,9 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
|||||||
context =
|
context =
|
||||||
"""
|
"""
|
||||||
<context>
|
<context>
|
||||||
<trajectory>
|
<assistant_trajectories>
|
||||||
$timeline
|
$timeline
|
||||||
</trajectory>
|
</assistant_trajectories>
|
||||||
<evaluatee_context>
|
<evaluatee_context>
|
||||||
$evaluateecontext
|
$evaluateecontext
|
||||||
</evaluatee_context>
|
</evaluatee_context>
|
||||||
@@ -320,177 +320,10 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
|||||||
|
|
||||||
println("\nEvaluator() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nEvaluator() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
pprintln(Dict(responsedict))
|
pprintln(Dict(responsedict))
|
||||||
|
return 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
|
end
|
||||||
error("Evaluator failed to generate an evaluation, Response: \n$response\n<|End of error|>")
|
error("Evaluator failed to generate an evaluation, Response: \n$response\n<|End of error|>")
|
||||||
end
|
end
|
||||||
# function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
|
||||||
# ) where {T1<:agent}
|
|
||||||
|
|
||||||
# systemmsg =
|
|
||||||
# """
|
|
||||||
# <Your role>
|
|
||||||
# - You are a master sommelier of an online wine store.
|
|
||||||
# </Your role>
|
|
||||||
# <Situation>
|
|
||||||
# - 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.
|
|
||||||
# </Situation>
|
|
||||||
# <Your mission>
|
|
||||||
# - Improve a trainee sommelier decision based on the store policy and guidelines while ensuring seamless interactions between the trainee and customers.
|
|
||||||
# </Your mission>
|
|
||||||
# <At each round of conversation, you will be given the following information>
|
|
||||||
# - 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.
|
|
||||||
# </At each round of conversation, you will be given the following information>
|
|
||||||
# <You must follow the following policy>
|
|
||||||
# - Use only infomation provided by the store policy and guidelines as a bedrocks for your response.
|
|
||||||
# </You must follow the following policy>
|
|
||||||
# <You should follow the following guidelines>
|
|
||||||
# - 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.
|
|
||||||
# </You should follow the following guidelines>
|
|
||||||
# <You should then respond to the user with>
|
|
||||||
# 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".
|
|
||||||
|
|
||||||
# </You should then respond to the user with>
|
|
||||||
# <You should only respond in JSON format as described below>
|
|
||||||
# {
|
|
||||||
# "trajectory_evaluation": "...",
|
|
||||||
# "decision_evaluation": "...",
|
|
||||||
# "suggestion": "...",
|
|
||||||
# "approval": "...",
|
|
||||||
# }
|
|
||||||
# </You should only respond in format as described below>
|
|
||||||
|
|
||||||
# Let's begin!
|
|
||||||
# """
|
|
||||||
# requiredKeys = [:trajectory_evaluation, :decision_evaluation, :approval, :suggestion]
|
|
||||||
# errornote = "N/A"
|
|
||||||
|
|
||||||
# for attempt in 1:10
|
|
||||||
# evaluateecontext = replace(evaluateecontext, "<context>" => "")
|
|
||||||
# evaluateecontext = replace(evaluateecontext, "</context>" => "")
|
|
||||||
|
|
||||||
# context =
|
|
||||||
# """
|
|
||||||
# <context>
|
|
||||||
# <trajectory>
|
|
||||||
# $timeline
|
|
||||||
# </trajectory>
|
|
||||||
# <evaluatee_context>
|
|
||||||
# $evaluateecontext
|
|
||||||
# </evaluatee_context>
|
|
||||||
# <evaluatee_decision>
|
|
||||||
# {plan: $(decisiondict["plan"]), action_name: $(decisiondict["action_name"]), action_input: $(decisiondict["action_input"])}
|
|
||||||
# </evaluatee_decision>
|
|
||||||
# P.S. $errornote
|
|
||||||
# </context>
|
|
||||||
# """
|
|
||||||
|
|
||||||
# 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.
|
""" 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
|
# thinking loop until AI wants to communicate with the user
|
||||||
loopcount = 0
|
loopcount = 0
|
||||||
while true
|
while true
|
||||||
@info "YiemAgent conversation() 2-0 count $loopcount" @__LINE__
|
|
||||||
loopcount += 1
|
loopcount += 1
|
||||||
|
@info "YiemAgent conversation() 2-0 count $loopcount" @__LINE__
|
||||||
thoughtdict, _ = think(a)
|
thoughtdict, _ = think(a)
|
||||||
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
||||||
@info "YiemAgent conversation() 2-1" @__LINE__
|
@info "YiemAgent conversation() 2-1" @__LINE__
|
||||||
@@ -566,45 +399,6 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
|
|||||||
end
|
end
|
||||||
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
|
# Arguments
|
||||||
@@ -831,9 +625,9 @@ function generatechat(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
context =
|
context =
|
||||||
"""
|
"""
|
||||||
<internal_context_for_assistant>
|
<internal_context_for_assistant>
|
||||||
<thought_history>
|
<assistant_action_history>
|
||||||
$(GeneralUtils.dict_to_string_html(a.memory["shortmem"]))
|
$(GeneralUtils.dict_to_string_html(a.memory["shortmem"]))
|
||||||
</thought_history>
|
</assistant_action_history>
|
||||||
</internal_context_for_assistant>
|
</internal_context_for_assistant>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user