This commit is contained in:
2024-01-13 12:44:41 +00:00
parent 6567523ac6
commit ee4da59867
2 changed files with 43 additions and 33 deletions

View File

@@ -502,6 +502,15 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
@show iskey_Thought = haskey(chunkedtext, "Thought $latestTask:")
@show iskey_Act = haskey(chunkedtext, "Act $latestTask:")
@show iskey_Actinput = haskey(chunkedtext, "Actinput $latestTask:")
# check whether the act has valid json
isJsonReadable = false
try
act = GeneralUtils.getStringBetweenCharacters(response, '{', '}', endCharLocation="end")
act = Dict(JSON3.read(act))
isJsonReadable = true
catch
end
if iskey_Thought && iskey_Act && iskey_Actinput
istoolnameValid = false
@@ -513,8 +522,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
end
if length(chunkedtext["Thought $latestTask:"]) > 5 && istoolnameValid &&
length(chunkedtext["Actinput $latestTask:"]) > 5 &&
occursin('{', response) && occursin('}', response)
length(chunkedtext["Actinput $latestTask:"]) > 5 && isJsonReadable
break
end
end
@@ -547,6 +555,8 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
chunkedtext["Act $latestTask:"] = toolname
chunkedtext["Actinput $latestTask:"] = act[Symbol(toolname)]
toolinput = chunkedtext["Actinput $latestTask:"]
@show toolinput
println(typeof(toolinput))
return toolname, toolinput, chunkedtext
end

View File

@@ -59,36 +59,36 @@ end
function winestock(a::agentReflex, phrase::T) where {T<:AbstractString}
result =
"""
I found the following wines
{
1: {
Chateau: Louis Latou,
name: Corton-Charlamagne,
grape variety: chardonnay,
year: 2014,
price: 55 USD,
stock ID: ws-114,
Description: Corton-Charlemagne 2018 is a powerful, complex wine. Its nose is intense, with notes of white stone fruits such as white peach, fresh hazelnut, vanilla, and almond paste. The wine is full-bodied for the palate, and the vanilla is complemented by aromas of fresh almond and lime blossom. The experience ends with a very fine aromatic aftertaste that has subtle saline notes.,
},
2: {
Chateau: Beaucastel,
name: Malbec Argentino,
grape variety: riesling,
year: 2016,
price: 39 USD,
stock ID: ed-23,
Description: The quintessence of Château de Beaucastel, Hommage à Jacques Perrin delights us every year, and the 2019 vintage is no exception. To the eye it offers a splendid deep red color, verging on black. Full of power and supremely elegant, the nose is of magnificent aromatic complexity with notes of black fruit and spices that offer all the characteristic expression of Mourvèdre. Perfectly balanced by an incredible freshness, the mouth is eminently elegant with intense and complex aromas of great subtlety, a full, refined texture, subtle tannins of great finesse, and infinite length. A great classic Hommage à Jacques Perrin.,
}
}
"""
return result
end
# function winestock(a::agentReflex, phrase::T) where {T<:AbstractString}
# result =
# """
# I found the following wines
# {
# 1: {
# Chateau: Louis Latou,
# name: Corton-Charlamagne,
# grape variety: chardonnay,
# year: 2014,
# price: 55 USD,
# stock ID: ws-114,
# Description: Corton-Charlemagne 2018 is a powerful, complex wine. Its nose is intense, with notes of white stone fruits such as white peach, fresh hazelnut, vanilla, and almond paste. The wine is full-bodied for the palate, and the vanilla is complemented by aromas of fresh almond and lime blossom. The experience ends with a very fine aromatic aftertaste that has subtle saline notes.,
# },
# 2: {
# Chateau: Beaucastel,
# name: Malbec Argentino,
# grape variety: riesling,
# year: 2016,
# price: 39 USD,
# stock ID: ed-23,
# Description: The quintessence of Château de Beaucastel, Hommage à Jacques Perrin delights us every year, and the 2019 vintage is no exception. To the eye it offers a splendid deep red color, verging on black. Full of power and supremely elegant, the nose is of magnificent aromatic complexity with notes of black fruit and spices that offer all the characteristic expression of Mourvèdre. Perfectly balanced by an incredible freshness, the mouth is eminently elegant with intense and complex aromas of great subtlety, a full, refined texture, subtle tannins of great finesse, and infinite length. A great classic Hommage à Jacques Perrin.,
# }
# }
# """
# return result
# end
#WORKING
"""
Arguments:
@@ -114,7 +114,7 @@ end
julia> score = grading(agent, guideline, shorttermMemory)
```
"""
function winestockDB(a::agentReflex, query::T) where {T<:AbstractString}
function winestock(a::agentReflex, query::T) where {T<:AbstractString}
@show query
prompt =
"""
@@ -153,7 +153,7 @@ function winestockDB(a::agentReflex, query::T) where {T<:AbstractString}
Write SQL command using data from query.
</Your job>
<Example 1>
query: "{\"winestock\": {\"wine type\": \"white\", \"wine characteristics\": \"full-bodied | off-dry | low acidity | medium tannin\", \"price\": {\"max\": \"50\"}}}"
query: "{\"wine type\": \"white\", \"wine characteristics\": \"full-bodied | off-dry | low acidity | medium tannin\", \"price\": {\"max\": \"50\"}}"
assistant: SELECT * FROM White WHERE intensity = 5 AND sweetness = 2 AND acidity = 1 AND tannin = 3 AND price <= 50;
</Example 1>
</s>
@@ -165,7 +165,7 @@ function winestockDB(a::agentReflex, query::T) where {T<:AbstractString}
"""
println("")
@show db_prompt = prompt
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=0.4,
response = sendReceivePrompt(a, prompt, max_tokens=256, temperature=0.4,
stopword=["/n/n", "END", "End", "Obs", "<|", "</"])
println("")
@show db_response = response