This commit is contained in:
narawat lamaiin
2024-05-09 13:04:54 +07:00
parent ed63c19e66
commit 78d69194e9
4 changed files with 47 additions and 33 deletions

View File

@@ -74,7 +74,7 @@ julia> output_thoughtDict = Dict(
- [] implement RAG to pull similar experience
- [] use customerinfo
- [] user storeinfo
- [PENDING] add try block. check result that it is expected before returning
- [x] add try block. check result that it is expected before returning
# Signature
"""
@@ -91,18 +91,23 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
$(JSON3.write(state[:storeinfo]))
"""
reflect = ""
# """
# You have attempted to answer the following question before and failed. The following
# reflection(s) give a plan to avoid failing to answer the question in the same way you did
# previously. Use them to improve your strategy of correctly answering the given question.
# (trajectories)
# """
lesson =
if isempty(a.lesson)
""
else
"""
You have attempted to answer the following question before and failed, either because your reasoning for the answer was incorrect or the phrasing of your response did not exactly match what the user want. The following lesson(s) give a plan to avoid failing to answer the question in the same way you did previously. Use them to improve your strategy of correctly answering the given question.
$(JSON3.write(a.lesson[:lesson_1][:lesson]))
When providing the thought and action for the current trial, that into account these failed trajectories and make sure not to repeat the same mistakes and incorrect answers.
"""
end
_prompt =
"""
You are a helpful sommelier working for a wine store.
Your goal is to reccommend the best wine from your inventory that match the user preferences.
You are also an advanced reasoning agent that can improve based on self refection.
You must follow the following criteria:
1) Get to know what occasion the user is buying wine for
@@ -119,6 +124,7 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
1) winestock[query], which you can use to find wine in your inventory. The more input data the better.
2) chatbox[text], which you can use to interact with the user.
3) recommendbox[answer], which returns your wine reccommendation to the user.
After each observation, provide the next Thought and next Action.
You should only respond in JSON format as describe below:
{
@@ -140,6 +146,8 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
"observation": "I'll take black."
}
$lesson
Let's begin!
$(JSON3.write(state[:thoughtHistory]))
@@ -236,9 +244,6 @@ serving as a heuristic to steer the search algorithm towards the most promising
julia>
```
# TODO
- [PENDING] add try block. check result that it is expected before returning
# Signature
"""
function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where {T1<:agent, T2<:AbstractDict}
@@ -325,7 +330,7 @@ function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where
# check if dict has all required value
dummya::AbstractString = evaluationDict[:evaluation]
dummyb::AbstractString = evaluationDict[:score]
dummyb::Integer = evaluationDict[:score]
return (evaluationDict[:evaluation], evaluationDict[:score])
catch e
@@ -339,7 +344,7 @@ function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where
end
if attempt > 5
error("progressValueEstimator failed to generate a thought")
error("progressValueEstimator failed to generate an evaluation")
end
end
end
@@ -603,7 +608,7 @@ function conversation(a::T, userinput::Dict) where {T<:agent}
:reward=> 0,
:isterminal=> false,
:evaluation=> nothing,
:feedback=> nothing,
:lesson=> nothing,
:thoughtHistory=> OrderedDict{Symbol, Any}( # contain question, thought_1, action_1, observation_1, thought_2, ...
# :recap=>,
:question=> userinput[:text],