update
This commit is contained in:
@@ -288,9 +288,9 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
response = a.func[: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)
|
||||
|
||||
response = String(split(response, ", observation")[1]) # in case LLM generate observation key which it isn't supposed to
|
||||
response = strip(response)
|
||||
responsedict = nothing
|
||||
try
|
||||
responsedict = copy(JSON3.read(response))
|
||||
@@ -316,76 +316,12 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
continue
|
||||
end
|
||||
|
||||
# # check if response contain more than one functions from ["CHATBOX", "CHECKINVENTORY", "ENDCONVERSATION"]
|
||||
# count = 0
|
||||
# for i ∈ ["CHATBOX", "CHECKINVENTORY", "PRESENTBOX", "ENDCONVERSATION"]
|
||||
# if occursin(i, response)
|
||||
# count += 1
|
||||
# end
|
||||
# end
|
||||
# if count > 1
|
||||
# errornote = "You must use only one function"
|
||||
# println("\nERROR YiemAgent decisionMaker() $errornote\n$response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# continue
|
||||
# end
|
||||
|
||||
# # check whether response has all header
|
||||
# detected_kw = GeneralUtils.detect_keyword(header, response)
|
||||
# kwvalue = [i for i in values(detected_kw)]
|
||||
# zeroind = findall(x -> x == 0, kwvalue)
|
||||
# missingkeys = [header[i] for i in zeroind]
|
||||
# if 0 ∈ values(detected_kw)
|
||||
# errornote = "$missingkeys are missing from your previous response"
|
||||
# println("\nERROR YiemAgent decisionMaker() $errornote:\n$response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# continue
|
||||
# elseif sum(values(detected_kw)) > length(header)
|
||||
# errornote = "Your previous attempt has duplicated points"
|
||||
# println("\nERROR YiemAgent decisionMaker() $errornote:\n$response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# continue
|
||||
# end
|
||||
|
||||
# responsedict = GeneralUtils.textToDict(response, header;
|
||||
# dictKey=dictkey, symbolkey=true)
|
||||
|
||||
if responsedict[:actionname] ∉ ["CHATBOX", "CHECKWINE", "PRESENTBOX", "ENDCONVERSATION"]
|
||||
errornote = "Your previous attempt didn't use the given functions"
|
||||
println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict[:actionname])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
|
||||
# checkFlag = false
|
||||
# for i ∈ Symbol.(dictkey)
|
||||
# if length(responsedict[i]) == 0
|
||||
# errornote = "$i is empty"
|
||||
# println("\nERROR YiemAgent decisionMaker() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# checkFlag = true
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# checkFlag == true ? continue : nothing
|
||||
|
||||
# # check if there are more than 1 key per categories
|
||||
# checkFlag = false
|
||||
# for i ∈ Symbol.(dictkey)
|
||||
# matchkeys = GeneralUtils.findMatchingDictKey(responsedict, i)
|
||||
# if length(matchkeys) > 1
|
||||
# errornote = "Your previous attempt has more than one key per categories"
|
||||
# println("\nERROR YiemAgent decisionMaker() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# checkFlag = true
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# checkFlag == true ? continue : nothing
|
||||
|
||||
# # check if actionname = CHECKINVENTORY and actioninput has the words "pairs well" or
|
||||
# # "pair well" in it because it is not a valid query.
|
||||
# detected_kw = GeneralUtils.detect_keyword(["pair", "pairs", "pairing", "well"], responsedict[:actioninput])
|
||||
# if responsedict[:actionname] == "CHECKINVENTORY" && sum(values(detected_kw)) != 0
|
||||
# errornote = "In your previous attempt, actioninput for CHECKINVENTORY function was $(responsedict[:actionname]). It was not specific enough."
|
||||
# println("\nERROR YiemAgent decisionMaker() $errornote => $(responsedict[:actioninput]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# continue
|
||||
# end
|
||||
|
||||
println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
pprintln(Dict(responsedict))
|
||||
|
||||
@@ -435,7 +371,6 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
# store for later training
|
||||
responsedict[:system] = systemmsg
|
||||
responsedict[:unformatPrompt] = unformatPrompt
|
||||
# responsedict[:recentchat] = recentchat
|
||||
responsedict[:prompt] = prompt
|
||||
responsedict[:context] = context
|
||||
responsedict[:think] = think
|
||||
|
||||
@@ -2,11 +2,16 @@ module type
|
||||
|
||||
export agent, sommelier, companion, virtualcustomer
|
||||
|
||||
using Dates, UUIDs, DataStructures, JSON3
|
||||
using Dates, UUIDs, DataStructures, JSON3, NATS
|
||||
using GeneralUtils
|
||||
|
||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
||||
|
||||
#[WORKING]
|
||||
# struct appcontext
|
||||
# connection::
|
||||
# end
|
||||
|
||||
abstract type agent end
|
||||
|
||||
mutable struct companion <: agent
|
||||
|
||||
Reference in New Issue
Block a user