This commit is contained in:
2024-01-14 01:27:52 +00:00
parent ee4da59867
commit 745e9e85fc
2 changed files with 36 additions and 19 deletions

View File

@@ -114,7 +114,8 @@ end
julia> score = grading(agent, guideline, shorttermMemory)
```
"""
function winestock(a::agentReflex, query::T) where {T<:AbstractString}
function winestock(a::agentReflex, query::Dict)
query = JSON3.write(query)
@show query
prompt =
"""
@@ -150,18 +151,21 @@ function winestock(a::agentReflex, query::T) where {T<:AbstractString}
acidity = 5, high acidity
</You have the following wine classification info>
<Your job>
Write SQL command using data from query.
Write a SQL command using data from a JSON-format query.
</Your job>
<Example 1>
query: "{\"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>
<Example 2>
query: {\"wine characteristics\":\"low-bodied | semi-sweet | low tannin\",\"price\":\"22 USD\",\"occasion\":\"anniversary\",\"wine type\":\"Rose\",\"food\":\"American dishes\"}
assistant: SELECT * FROM Rose WHERE intensity = 1 AND sweetness = 3 AND tannin = 1 AND price <= 22;
</Example 2>
</s>
<|query|>
query: $query
$query
</s>
<|assistant|>
"""
println("")
@show db_prompt = prompt
@@ -169,6 +173,19 @@ function winestock(a::agentReflex, query::T) where {T<:AbstractString}
stopword=["/n/n", "END", "End", "Obs", "<|", "</"])
println("")
@show db_response = response
# remove any blank character in front of a string
newresponse = nothing
for i in eachindex(response)
if response[i] != ' '
newresponse = response[i:end]
break
end
end
response = newresponse
error("winestock done")
body =
"""
INSERT INTO $tablename
@@ -179,7 +196,7 @@ function winestock(a::agentReflex, query::T) where {T<:AbstractString}
println("")
@show r.body
error("winestockDB done")
return result
end