From 4ae2f4d03695b9562820b174009fa1aa580f75e5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 11 Feb 2024 11:45:32 +0700 Subject: [PATCH] update --- src/interface.jl | 51 +++++++++++++++++++++++++--------------------- src/llmfunction.jl | 8 ++++++-- src/type.jl | 17 ++++++++-------- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index 56bef54..a5a8e8e 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -350,27 +350,30 @@ function selfAwareness(a::agentReflex) Use the following format strictly: - Info extraction: repeat all important info from the latest observed result thoroughly + Info extraction: from the latest observed result, breakdown all info into smaller one and repeat every important info thoroughly Info mapping: based on extracted info, explicitly state what each info could match which keyword memory's key - Info matching: using JSON format, what key in my memory matches which info + Info matching: using JSON format, what key in my memory matches which info (Donot use nested JSON) - The user wants to buy an electric SUV car under 20000 dollars. + The user wants to buy an 4WD electric SUV car under 20000 dollars. - {\"car type\": null, \"engine type\": null, \"price\": null, \"color\": null, \"financing\": null} + {\"car type\": null, \"powertrain type\": null, \"price\": null, \"color\": null, \"financing\": null, \"drive type\": null} <|assistant|> Info extraction: - - The user is buying an electric SUV car. + - The user is buying a SUV car. + - The user prefers 4WD drive type + - The user prefers electric powertrain - price is under 20000 dollars Info mapping: - "SUV" could matches "car type" key - - "electric" could matches "engine type" key + - "electric" could matches "powertrain type" key - "under 20000 dollars" could match "price" key - Info matching: {\"car type\": \"SUV\", \"engine type\": \"electric motor\", \"price\": \"under 20000\", \"color\": null, \"financing\": null} + - "4WD" could matches "drive type" key + Info matching: {\"car type\": \"SUV\", \"powertrain type\": \"electric\", \"price\": \"under 20000\", \"color\": null, \"financing\": null, \"drive type\": "4WD"} @@ -903,7 +906,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing) keywordmemory = "" for (k, v) in a.memory[:keyword] if v === nothing - keywordmemory *= "- I didn't know about the user preferred $k yet.\n" + keywordmemory *= "- The user preferred $k is null \n" else keywordmemory *= "- The user preferred $k is $v \n" end @@ -918,6 +921,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing) - Luxury level is high {\"car type\": "SUV",\"brand\":\"Lexus\",\"price\":\"200000\",\"color\": null,\"financing method\": null, \"luxury level\":\"high\"} Thought: Based on the recall, you must address what you don't know first if you have one. Otherwise, you must think about what is the immediate next step to do according to the plan + Recall: repeat each of the user info, if you didn't know (indicate by null) say, which info I didn't know """ #WORKING actor donot call final reapond after found matched wines because the current prompt @@ -936,8 +940,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing) Use the following format: - Recall: repeat each of the user info, if you didn't know say, which info I didn't know - Thought: based on the recall, you must address what you don't know first if you have one. Otherwise, you must think about what is the immediate next step to do according to the plan (PS. 1. pay attention to correct numeral calculation and commonsense.) + Thought: check the user info thoroughly, if you don't know some info (indicates by null keyword) you must address it first. Otherwise, you must think about what is the immediate next step to do according to the plan (PS. 1. pay attention to correct numeral calculation and commonsense 2. you must assume nothing) Act: based on your thought what action to choose?, must be one of [{toolnames}]. Actinput: your input to the action using JSON format (pay attention to the tool's input) Obs: observed result of the action @@ -952,7 +955,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing) $winestocksearchresult <|assistant|> - Recall: + Thought: """ prompt_2 = @@ -981,7 +984,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing) """ prompt = prompt_1 - if winestocksearchresult + if nothing ∉ values(a.memory[:keyword]) prompt = prompt_2 end @@ -1250,21 +1253,23 @@ function work(a::agentReflex) response = formulateUserResponse(a) - println("") - formulatedresponse = response - @show formulatedresponse + # println("") + # formulatedresponse = response + # @show formulatedresponse - a.memory[:shortterm]["response $(a.attempt):"] = response - a.memory[:log]["response $(a.attempt):"] = response + # a.memory[:shortterm]["response $(a.attempt):"] = response + # a.memory[:log]["response $(a.attempt):"] = response - # evaluate. if score > 6/10 good enough. - guideline = writeEvaluationGuideline(a) + # # evaluate. if score > 6/10 good enough. + # guideline = writeEvaluationGuideline(a) - println("") - @show guideline + # println("") + # @show guideline - score = grading(a, guideline, response) - @show score + # score = grading(a, guideline, response) + # @show score + + score = 9 #TODO let grading() make a score if score > 5 # good enough answer println("") formulatedresponse_final = response diff --git a/src/llmfunction.jl b/src/llmfunction.jl index d631147..260bce8 100644 --- a/src/llmfunction.jl +++ b/src/llmfunction.jl @@ -79,15 +79,19 @@ end function winestock(a::agentReflex, input::NamedTuple) println("") @show input - wineSearchCriteria = GeneralUtils.JSON3read_stringKey(input[:toolinput]) + wineSearchCriteria = GeneralUtils.JSON3read_stringKey(input[:toolinput]) newDict = Dict{String,Any}() for (k,v) in wineSearchCriteria println("k $k v $v") newDict[string(k)] = v end - query = JSON3.write(a.memory[:keyword]) + #TODO temporary delete key "food pairing from a dict + newDict = deepcopy(a.memory[:keyword]) + delete!(newDict, "food pairing") + + query = JSON3.write(newDict) println("") @show query diff --git a/src/type.jl b/src/type.jl index 2af9d96..505bfa9 100644 --- a/src/type.jl +++ b/src/type.jl @@ -150,14 +150,15 @@ function agentReflex( # """ :sommelier => """ - You need to know all of the following info before searching your wine stock, and use alternative sources of information only if the user is unable to provide it: - - wine budget - - wine type (rose, white, red, sparkling, dessert) - - paring food that will be served with wine - - wine sweetness level (dry to very sweet) - - wine intensity level (light to full bodied) - - wine tannin level (low to high) - - wine acidity level (low to high) + You need to gather all of the following info sequentially before you can recommend wine: + 1. wine budget + 2. wine type (rose, white, red, sparkling, dessert) + 3. paring food that will be served with wine + 4. wine sweetness level (dry to very sweet) + 5. wine intensity level (light to full bodied) + 6. wine tannin level (low to high) + 7. wine acidity level (low to high) + 8. wine you have in stock that match the user preferences """ ),