This commit is contained in:
narawat lamaiin
2024-07-29 15:28:47 +07:00
parent 7e0f8fa6f0
commit 689bca3805
3 changed files with 30 additions and 31 deletions

View File

@@ -197,7 +197,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
# - plan: Based on the current situation, what would you do to complete the task? Be specific.
# - action (Must be aligned with your plan): Can be one of the following functions:
# 1) CHATBOX[text], which you can use to talk with the user. "text" is in verbal English.
# 2) WINESTOCK[query], which you can use to find info about wine in your inventory. "query" is a search term in verbal English.
# 2) CHECKINVENTORY[query], which you can use to find info about wine in your inventory. "query" is a search term in verbal English.
# - observation: result of the action.
# You should only respond in format as described below:
@@ -222,23 +222,20 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
You must follow the following DO guidelines:
- If the user interrupts, prioritize the user then get back to the guidelines.
- Check your inventory before mentioning any specific wine.
- Get to know how much the user willing to spend
- Get to know type of wine the user is looking for e.g. red, white, sparkling, rose, dessert, fortified
- Get to know what occasion the user is buying wine for
- Get to know what characteristics of wine the user is looking for e.g. tannin, sweetness, intensity, acidity
- Get to know what food will be served with wine
You must follow the following DON'T guidelines:
- Don't mention any specific wine until you've checked your inventory.
- Check your inventory before recommending any specific wine.
You should then respond to the user with interleaving Thought, Plan, Action and Observation:
- thought:
1) State your reasoning about the current situation.
- plan: Based on the current situation, state a complete plan to complete the task. Be specific.
- action_name (Must be aligned with your plan): Can be one of the following functions:
1) CHATBOX[text], which you can use to talk with the user. "text" is in verbal English.
2) WINESTOCK[query], which you can use to find info about wine in your inventory. "query" is a search term in verbal English.
2) CHECKINVENTORY[query], which you can use to find info about wine in your inventory. "query" is a search term in verbal English.
Good query example: black car with a stereo, 200 mile range and an electric motor.
Good query example: How many car brand are from Asia?
- action_input: input to the action
@@ -280,7 +277,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
["thought", "plan", "action_name", "action_input", "observation"],
rightmarker=":", symbolkey=true)
if responsedict[:action_name] ["CHATBOX", "WINESTOCK"]
if responsedict[:action_name] ["CHATBOX", "CHECKINVENTORY"]
error("decisionMaker didn't use the given functions ", @__LINE__)
end
@@ -493,9 +490,8 @@ function evaluator(config::T1, state::T2
Analyze the trajectories of a solution to a question answering task. The trajectories are
labeled by environmental observations about the situation, thoughts that can reason about
the current situation and actions that can be three types:
1) winestock[query], which you can use to find wine in your inventory.
2) chatbox[text], which you can use to interact with the user.
3) recommendbox[answer], which returns your wine recommendation to the user.
1) CHECKINVENTORY[query], which you can use to find wine in your inventory.
2) CHATBOX[text], which you can use to interact with the user.
Given a question and a trajectory, evaluate its correctness and provide your reasoning and
analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories
@@ -1056,8 +1052,8 @@ function think(a::T) where {T<:agent}
response =
if actionname == "CHATBOX"
(result=actioninput, errormsg=nothing, success=true)
elseif actionname == "WINESTOCK"
winestock(a, actioninput)
elseif actionname == "CHECKINVENTORY"
checkinventory(a, actioninput)
else
error("undefined LLM function. Requesting $actionname")
end

View File

@@ -1,7 +1,7 @@
module llmfunction
export virtualWineUserChatbox, jsoncorrection, winestock,
virtualWineUserRecommendbox, userChatbox, userRecommendbox
export virtualWineUserChatbox, jsoncorrection, checkinventory,
virtualWineUserRecommendbox, userChatbox, userRecommendbox, extractWineAttributes
using HTTP, JSON3, URIs, Random, PrettyPrinting, UUIDs
using GeneralUtils, SQLLLM
@@ -352,7 +352,7 @@ end
julia> using ChatAgent
julia> agent = ChatAgent.agentReflex("Jene")
julia> input = "{\"food\": \"pizza\", \"occasion\": \"anniversary\"}"
julia> result = winestock(agent, input)
julia> result = checkinventory(agent, input)
"{"wine 1": {\"Winery\": \"Pichon Baron\", \"wine name\": \"Pauillac (Grand Cru Classé)\", \"grape variety\": \"Cabernet Sauvignon\", \"year\": 2010, \"price\": \"125 USD\", \"stock ID\": \"ar-17\"}, }"
```
@@ -362,7 +362,7 @@ julia> result = winestock(agent, input)
# Signature
"""
function winestock(a::T1, input::T2
function checkinventory(a::T1, input::T2
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:agent, T2<:AbstractString}
wineattributes = extractWineAttributes(a, input)

View File

@@ -62,6 +62,9 @@ function text2textInstructLLM(prompt::String)
return response
end
# Instantiate an agent
a = YiemAgent.sommelier(
text2textInstructLLM,
@@ -70,22 +73,22 @@ end
id="testingSessionID", # agent instance id
)
function main()
userinput = "Hello, I would like a get a bottle of wine."
for i in 1:10
response = YiemAgent.conversation(a, Dict(:text=> userinput))
println("")
println("--> assistant response: \n", response)
println("")
println("--> user input:")
userinput = readline()
end
end
# function main()
# userinput = "Hello, I would like a get a bottle of wine."
# for i in 1:10
# response = YiemAgent.conversation(a, Dict(:text=> userinput))
# println("")
# println("--> assistant response: \n", response)
# println("")
# println("--> user input:")
# userinput = readline()
# end
# end
main()
# main()
# """
# I'm having a graduation party this evening. So I think a bottle of wine would be nice.
# I'm having a graduation party this evening. I have no budget limit.
# I have no idea. The party will be formal. What type of wine people usually get for this occasion?
# What about sparkling Rose?
@@ -116,7 +119,7 @@ main()
input = "query=\"medium-bodied dry white wine\""
result = YiemAgent.extractWineAttributes(a, input)