update
This commit is contained in:
@@ -2,7 +2,7 @@ module interface
|
||||
|
||||
export addNewMessage, conversation, decisionMaker, progressValueEstimator, isterminal
|
||||
|
||||
using JSON3, DataStructures, Dates, UUIDs, HTTP, Random, MQTTClient
|
||||
using JSON3, DataStructures, Dates, UUIDs, HTTP, Random, MQTTClient, PrettyPrinting
|
||||
using GeneralUtils
|
||||
using ..type, ..util, ..llmfunction, ..mcts
|
||||
|
||||
@@ -98,6 +98,16 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
|
||||
# (trajectories)
|
||||
# """
|
||||
|
||||
responseformat =
|
||||
"""
|
||||
You should only respond in JSON format as describe below:
|
||||
{
|
||||
"Thought": "your reasoning",
|
||||
"Action": {"name": "action to take", "input": "Action input"},
|
||||
"Observation": "result of the action"
|
||||
}
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
"""
|
||||
You are a helpful sommelier working for a wine store.
|
||||
@@ -119,12 +129,7 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
|
||||
2) chatbox[text], which you can use to interact with the user.
|
||||
3) recommendation[answer], which returns your wine reccommendation to the user.
|
||||
|
||||
You should only respond in JSON format as describe below:
|
||||
{
|
||||
"Thought": "your reasoning",
|
||||
"Action": {"name": "action to take", "input": "Action input"},
|
||||
"Observation": "result of the action"
|
||||
}
|
||||
$responseformat
|
||||
|
||||
Here are some examples:
|
||||
{
|
||||
@@ -164,12 +169,18 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
|
||||
:msgMeta=> msgMeta,
|
||||
:payload=> Dict(
|
||||
:text=> prompt,
|
||||
:kwargs=> Dict(
|
||||
:max_tokens=> 512,
|
||||
:stop=> ["<|eot_id|>"],
|
||||
)
|
||||
)
|
||||
)
|
||||
@show outgoingMsg
|
||||
|
||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
||||
thoughtJsonStr = _response[:response][:text]
|
||||
_thoughtJsonStr = _response[:response][:text]
|
||||
thoughtJsonStr = jsoncorrection(a, _thoughtJsonStr, "")
|
||||
thoughtDict = copy(JSON3.read(thoughtJsonStr))
|
||||
pprint(thoughtDict)
|
||||
return thoughtDict
|
||||
end
|
||||
|
||||
@@ -196,6 +207,17 @@ julia>
|
||||
# Signature
|
||||
"""
|
||||
function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where {T1<:agent, T2<:AbstractDict}
|
||||
responseformat =
|
||||
"""
|
||||
You should only respond in JSON format as describe below:
|
||||
{
|
||||
"Thought_1": "reasoning 1",
|
||||
"Action_1": {"name": "action to take", "input": "Action input"},
|
||||
"Observation_1": "result of the action",
|
||||
"Evaluation_1": {"evaluation": "your evaluation", "score": your evaluation score}
|
||||
}
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
"""
|
||||
Analyze the trajectories of a solution to a question answering task. The trajectories are
|
||||
@@ -211,13 +233,7 @@ function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where
|
||||
yet. Do not generate additional thoughts or actions. Then ending with the correctness score s
|
||||
where s is an integer from 1 to 10.
|
||||
|
||||
You should only respond in JSON format as describe below:
|
||||
{
|
||||
"Thought_1": "reasoning 1",
|
||||
"Action_1": {"name": "action to take", "input": "Action input"},
|
||||
"Observation_1": "result of the action",
|
||||
"Evaluation_1": {"evaluation": "your evaluation", "score": your evaluation score}
|
||||
}
|
||||
$responseformat
|
||||
|
||||
Here are some examples:
|
||||
{
|
||||
@@ -232,6 +248,7 @@ function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where
|
||||
"score": 10}
|
||||
}
|
||||
|
||||
Let's begin!:
|
||||
$(JSON3.write(state[:thoughtHistory]))
|
||||
"""
|
||||
|
||||
@@ -254,7 +271,8 @@ function progressValueEstimator(a::T1, state::T2)::Tuple{String, Integer} where
|
||||
)
|
||||
|
||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
||||
thoughtJsonStr = _response[:response][:text]
|
||||
_thoughtJsonStr = _response[:response][:text]
|
||||
thoughtJsonStr = jsoncorrection(a, _thoughtJsonStr, responseformat)
|
||||
thoughtDict = copy(JSON3.read(thoughtJsonStr))
|
||||
latestEvaluationKey, _ =
|
||||
GeneralUtils.findHighestIndexKey(thoughtDict, "Evaluation")
|
||||
|
||||
Reference in New Issue
Block a user