From ee4da598671bff846847ebed44c4b48551a99d17 Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Sat, 13 Jan 2024 12:44:41 +0000 Subject: [PATCH] update --- src/interface.jl | 14 +++++++++-- src/llmfunction.jl | 62 +++++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index dcf5a39..452efe0 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -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 diff --git a/src/llmfunction.jl b/src/llmfunction.jl index 778891e..cd7075f 100644 --- a/src/llmfunction.jl +++ b/src/llmfunction.jl @@ -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. - 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; @@ -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", "<|", "