Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18b2d54ba7 | |||
| d004193b19 | |||
| 686b9b2e92 | |||
| 3acf46964b | |||
| ad917ea8d0 | |||
| 31daa805f3 | |||
| c9937ab5d7 | |||
| 9d7eed7cde | |||
| 286da3cf2c | |||
| e5b19dd268 | |||
| 45e8ded111 | |||
| a503d4d759 | |||
| a798cd119e | |||
| fa338dd0f8 | |||
| 8d4bf5f01f |
+78
-14
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
julia_version = "1.12.6"
|
julia_version = "1.12.6"
|
||||||
manifest_format = "2.0"
|
manifest_format = "2.0"
|
||||||
project_hash = "a2c996ffe370e277cbff80af974d2701698f1b6c"
|
project_hash = "a5128932115e2d3aa9658af105ac712db061d523"
|
||||||
|
|
||||||
[[deps.Accessors]]
|
[[deps.Accessors]]
|
||||||
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
||||||
@@ -38,6 +38,12 @@ version = "1.1.3"
|
|||||||
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
|
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
|
||||||
version = "1.1.2"
|
version = "1.1.2"
|
||||||
|
|
||||||
|
[[deps.ArnoldiMethod]]
|
||||||
|
deps = ["LinearAlgebra", "Random", "StaticArrays"]
|
||||||
|
git-tree-sha1 = "d57bd3762d308bded22c3b82d033bff85f6195c6"
|
||||||
|
uuid = "ec485272-7323-5ecc-a04f-4719b315124d"
|
||||||
|
version = "0.4.0"
|
||||||
|
|
||||||
[[deps.ArrowTypes]]
|
[[deps.ArrowTypes]]
|
||||||
deps = ["Sockets", "UUIDs"]
|
deps = ["Sockets", "UUIDs"]
|
||||||
git-tree-sha1 = "404265cd8128a2515a81d5eae16de90fdef05101"
|
git-tree-sha1 = "404265cd8128a2515a81d5eae16de90fdef05101"
|
||||||
@@ -181,6 +187,20 @@ git-tree-sha1 = "e98abef36d02a0ec385d68cd7dadbce9b28cbd88"
|
|||||||
uuid = "abce61dc-4473-55a0-ba07-351d65e31d42"
|
uuid = "abce61dc-4473-55a0-ba07-351d65e31d42"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
|
||||||
|
[[deps.Distances]]
|
||||||
|
deps = ["LinearAlgebra", "Statistics", "StatsAPI"]
|
||||||
|
git-tree-sha1 = "c7e3a542b999843086e2f29dac96a618c105be1d"
|
||||||
|
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
|
||||||
|
version = "0.10.12"
|
||||||
|
|
||||||
|
[deps.Distances.extensions]
|
||||||
|
DistancesChainRulesCoreExt = "ChainRulesCore"
|
||||||
|
DistancesSparseArraysExt = "SparseArrays"
|
||||||
|
|
||||||
|
[deps.Distances.weakdeps]
|
||||||
|
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
||||||
|
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
||||||
|
|
||||||
[[deps.Distributed]]
|
[[deps.Distributed]]
|
||||||
deps = ["Random", "Serialization", "Sockets"]
|
deps = ["Random", "Serialization", "Sockets"]
|
||||||
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
|
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
|
||||||
@@ -250,6 +270,7 @@ deps = ["LinearAlgebra"]
|
|||||||
git-tree-sha1 = "2f979084d1e13948a3352cf64a25df6bd3b4dca3"
|
git-tree-sha1 = "2f979084d1e13948a3352cf64a25df6bd3b4dca3"
|
||||||
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
|
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
|
||||||
version = "1.16.0"
|
version = "1.16.0"
|
||||||
|
weakdeps = ["PDMats", "SparseArrays", "StaticArrays", "Statistics"]
|
||||||
|
|
||||||
[deps.FillArrays.extensions]
|
[deps.FillArrays.extensions]
|
||||||
FillArraysPDMatsExt = "PDMats"
|
FillArraysPDMatsExt = "PDMats"
|
||||||
@@ -257,12 +278,6 @@ version = "1.16.0"
|
|||||||
FillArraysStaticArraysExt = "StaticArrays"
|
FillArraysStaticArraysExt = "StaticArrays"
|
||||||
FillArraysStatisticsExt = "Statistics"
|
FillArraysStatisticsExt = "Statistics"
|
||||||
|
|
||||||
[deps.FillArrays.weakdeps]
|
|
||||||
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
|
||||||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
|
||||||
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
|
|
||||||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
|
|
||||||
|
|
||||||
[[deps.Future]]
|
[[deps.Future]]
|
||||||
deps = ["Random"]
|
deps = ["Random"]
|
||||||
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
|
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
|
||||||
@@ -274,12 +289,25 @@ uuid = "a0844989-3bd2-4988-8bea-c9407ab0941b"
|
|||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
||||||
[[deps.GeneralUtils]]
|
[[deps.GeneralUtils]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "HTTP", "JSON", "NATS", "PrettyPrinting", "Random", "Revise", "SHA", "UUIDs"]
|
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "Graphs", "HTTP", "JSON", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SHA", "StringDistances", "UUIDs"]
|
||||||
git-tree-sha1 = "7c0600c166a5deb2c607018a491c04eb25969c2e"
|
git-tree-sha1 = "a75a088ee8e5faf10f554ca00748e0e6ca58d1ca"
|
||||||
repo-rev = "main"
|
repo-rev = "main"
|
||||||
repo-url = "https://git.yiem.cc/ton/GeneralUtils"
|
repo-url = "https://git.yiem.cc/ton/GeneralUtils"
|
||||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
||||||
version = "0.4.9"
|
version = "0.5.1"
|
||||||
|
|
||||||
|
[[deps.Graphs]]
|
||||||
|
deps = ["ArnoldiMethod", "DataStructures", "Inflate", "LinearAlgebra", "Random", "SimpleTraits", "SparseArrays", "Statistics"]
|
||||||
|
git-tree-sha1 = "7eb45fe833a5b7c51cf6d89c5a841d5967e44be3"
|
||||||
|
uuid = "86223c79-3864-5bf0-83f7-82e725a168b6"
|
||||||
|
version = "1.14.0"
|
||||||
|
|
||||||
|
[deps.Graphs.extensions]
|
||||||
|
GraphsSharedArraysExt = "SharedArrays"
|
||||||
|
|
||||||
|
[deps.Graphs.weakdeps]
|
||||||
|
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
|
||||||
|
SharedArrays = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
|
||||||
|
|
||||||
[[deps.HTTP]]
|
[[deps.HTTP]]
|
||||||
deps = ["Base64", "CodecZlib", "Dates", "EnumX", "PrecompileTools", "Random", "Reseau", "SHA", "URIs", "UUIDs", "Zlib_jll"]
|
deps = ["Base64", "CodecZlib", "Dates", "EnumX", "PrecompileTools", "Random", "Reseau", "SHA", "URIs", "UUIDs", "Zlib_jll"]
|
||||||
@@ -310,6 +338,11 @@ git-tree-sha1 = "cf8234411cbeb98676c173f930951ea29dca3b23"
|
|||||||
uuid = "a303e19e-6eb4-11e9-3b09-cd9505f79100"
|
uuid = "a303e19e-6eb4-11e9-3b09-cd9505f79100"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
|
|
||||||
|
[[deps.Inflate]]
|
||||||
|
git-tree-sha1 = "d1b1b796e47d94588b3757fe84fbf65a5ec4a80d"
|
||||||
|
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
|
||||||
|
version = "0.1.5"
|
||||||
|
|
||||||
[[deps.InlineStrings]]
|
[[deps.InlineStrings]]
|
||||||
git-tree-sha1 = "8f3d257792a522b4601c24a577954b0a8cd7334d"
|
git-tree-sha1 = "8f3d257792a522b4601c24a577954b0a8cd7334d"
|
||||||
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
|
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
|
||||||
@@ -760,11 +793,11 @@ version = "0.7.0"
|
|||||||
|
|
||||||
[[deps.SQLLLM]]
|
[[deps.SQLLLM]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
|
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
|
||||||
git-tree-sha1 = "2807a768907f59308d8d71ece599037b0a66b0a5"
|
git-tree-sha1 = "bae2fd2e2b087753fbb3415896be41df1ae0eb90"
|
||||||
repo-rev = "main"
|
repo-rev = "main"
|
||||||
repo-url = "https://git.yiem.cc/ton/SQLLLM"
|
repo-url = "https://git.yiem.cc/ton/SQLLLM"
|
||||||
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
||||||
version = "0.2.7"
|
version = "0.2.8"
|
||||||
|
|
||||||
[[deps.SQLStrings]]
|
[[deps.SQLStrings]]
|
||||||
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
||||||
@@ -793,6 +826,12 @@ version = "1.4.10"
|
|||||||
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.SimpleTraits]]
|
||||||
|
deps = ["InteractiveUtils", "MacroTools"]
|
||||||
|
git-tree-sha1 = "7ddb0b49c109481b046972c0e4ab02b2127d6a75"
|
||||||
|
uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
|
||||||
|
version = "0.9.6"
|
||||||
|
|
||||||
[[deps.Sockets]]
|
[[deps.Sockets]]
|
||||||
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
|
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
@@ -826,6 +865,25 @@ version = "2.8.0"
|
|||||||
[deps.SpecialFunctions.weakdeps]
|
[deps.SpecialFunctions.weakdeps]
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
||||||
|
|
||||||
|
[[deps.StaticArrays]]
|
||||||
|
deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"]
|
||||||
|
git-tree-sha1 = "246a8bb2e6667f832eea063c3a56aef96429a3db"
|
||||||
|
uuid = "90137ffa-7385-5640-81b9-e52037218182"
|
||||||
|
version = "1.9.18"
|
||||||
|
|
||||||
|
[deps.StaticArrays.extensions]
|
||||||
|
StaticArraysChainRulesCoreExt = "ChainRulesCore"
|
||||||
|
StaticArraysStatisticsExt = "Statistics"
|
||||||
|
|
||||||
|
[deps.StaticArrays.weakdeps]
|
||||||
|
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
||||||
|
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
|
||||||
|
|
||||||
|
[[deps.StaticArraysCore]]
|
||||||
|
git-tree-sha1 = "6ab403037779dae8c514bad259f32a447262455a"
|
||||||
|
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
|
||||||
|
version = "1.4.4"
|
||||||
|
|
||||||
[[deps.Statistics]]
|
[[deps.Statistics]]
|
||||||
deps = ["LinearAlgebra"]
|
deps = ["LinearAlgebra"]
|
||||||
git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0"
|
git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0"
|
||||||
@@ -862,6 +920,12 @@ version = "2.2.0"
|
|||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
||||||
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
|
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
|
||||||
|
|
||||||
|
[[deps.StringDistances]]
|
||||||
|
deps = ["Distances", "StatsAPI"]
|
||||||
|
git-tree-sha1 = "cd83a04baf746e3b43b83c61b7de77ab0409b80a"
|
||||||
|
uuid = "88034a9c-02f8-509d-84a9-84ec65e18404"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
[[deps.StringManipulation]]
|
[[deps.StringManipulation]]
|
||||||
deps = ["PrecompileTools"]
|
deps = ["PrecompileTools"]
|
||||||
git-tree-sha1 = "d05693d339e37d6ab134c5ab53c29fce5ee5d7d5"
|
git-tree-sha1 = "d05693d339e37d6ab134c5ab53c29fce5ee5d7d5"
|
||||||
@@ -983,10 +1047,10 @@ uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60"
|
|||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
|
|
||||||
[[deps.YiemAgent]]
|
[[deps.YiemAgent]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "Serialization", "URIs", "UUIDs"]
|
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SQLLLM", "Serialization", "URIs", "UUIDs"]
|
||||||
path = "."
|
path = "."
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
version = "0.5.0"
|
version = "0.6.4"
|
||||||
|
|
||||||
[[deps.Zlib_jll]]
|
[[deps.Zlib_jll]]
|
||||||
deps = ["Libdl"]
|
deps = ["Libdl"]
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
name = "YiemAgent"
|
name = "YiemAgent"
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
version = "0.5.0"
|
version = "0.6.4"
|
||||||
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
@@ -25,9 +25,9 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|||||||
[compat]
|
[compat]
|
||||||
CSV = "0.10.15"
|
CSV = "0.10.15"
|
||||||
DataFrames = "1.7.0"
|
DataFrames = "1.7.0"
|
||||||
GeneralUtils = "0.4.9"
|
GeneralUtils = "0.5.1"
|
||||||
HTTP = "2.4.0"
|
HTTP = "2.4.0"
|
||||||
JSON = "1.6.1"
|
JSON = "1.6.1"
|
||||||
LLMMCTS = "0.1.5"
|
LLMMCTS = "0.1.5"
|
||||||
NATS = "0.1.0"
|
NATS = "0.1.0"
|
||||||
SQLLLM = "0.2.7"
|
SQLLLM = "0.2.8"
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ Your name is $(newAgent.name). You are a helpful sommelier for website-based $(n
|
|||||||
# Available Actions
|
# Available Actions
|
||||||
|
|
||||||
- **CHAT_BOX** which you can use to talk with the user.
|
- **CHAT_BOX** which you can use to talk with the user.
|
||||||
- **CHECK_WINE** allows you to check information about wines you want in your inventory's database. The input is text that specify supported search criteria includeing: retailer_name, wine price, winery, name, vintage, region, country, type, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
- **SEARCH_WINE_DATABASE** allows you to check information about wines you want in your inventory's database. The input is text that specify supported search criteria includeing: retailer_name, wine price, winery, name, vintage, region, country, type, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
||||||
- Example query 1: "Dry, full-bodied red wine from 1) region: Burgundy, country: France or 2) region: Tuscany, country: Italy. Grape varietal: Merlot or Syrah. price 100 to 1000 USD."
|
- Example query 1: "Dry, full-bodied red wine from 1) region: Burgundy, country: France or 2) region: Tuscany, country: Italy. Grape varietal: Merlot or Syrah. price 100 to 1000 USD."
|
||||||
- Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
- Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
||||||
- Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
- Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
||||||
|
|||||||
+6
-5
@@ -6,6 +6,7 @@
|
|||||||
"testingOrProduction": "testing",
|
"testingOrProduction": "testing",
|
||||||
"agentId": "2b74b87a-5413-4fe2-a4d3-405891051680",
|
"agentId": "2b74b87a-5413-4fe2-a4d3-405891051680",
|
||||||
"agentCentralConfigSubject": "/yiem/hq/agent/sommelier/backend/config/api/v1.1",
|
"agentCentralConfigSubject": "/yiem/hq/agent/sommelier/backend/config/api/v1.1",
|
||||||
|
"this_service_name": "agent_backend",
|
||||||
"this_service_input_channel": {
|
"this_service_input_channel": {
|
||||||
"mqtt": [
|
"mqtt": [
|
||||||
"/yiem/hq/agent/sommpanion/backend/db/api_v1"
|
"/yiem/hq/agent/sommpanion/backend/db/api_v1"
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
"agentRole": "sommelier",
|
"agentRole": "sommelier",
|
||||||
"organization": "yiem_hq",
|
"organization": "yiem_hq",
|
||||||
"externalService": {
|
"externalservice": {
|
||||||
"servicesloadbalancer": {
|
"servicesloadbalancer": {
|
||||||
"nats": "sommpanion.backend.servicesloadbalancer.v1.inbox"
|
"nats": "sommpanion.backend.servicesloadbalancer.v1.inbox"
|
||||||
},
|
},
|
||||||
@@ -35,15 +36,15 @@
|
|||||||
"description": "A database connection info for LibPQ client",
|
"description": "A database connection info for LibPQ client",
|
||||||
"url": "192.168.88.106:5432",
|
"url": "192.168.88.106:5432",
|
||||||
"dbname": "winedb",
|
"dbname": "winedb",
|
||||||
"user": "yiemtechnologies@gmail.com",
|
"user": "admin",
|
||||||
"password": "yiemtechnologies@Postgres_0.0"
|
"password": "admin@Sommpanion_0.0"
|
||||||
},
|
},
|
||||||
"sommpanion_vectordb" : {
|
"sommpanion_vectordb" : {
|
||||||
"description": "A wine database connection info for LibPQ client",
|
"description": "A wine database connection info for LibPQ client",
|
||||||
"url": "192.168.88.106:5433",
|
"url": "192.168.88.106:5433",
|
||||||
"dbname": "vectordb",
|
"dbname": "vectordb",
|
||||||
"user": "yiemtechnologies@gmail.com",
|
"user": "admin",
|
||||||
"password": "yiemtechnologies@Postgres_0.0"
|
"password": "admin@Sommpanion_0.0"
|
||||||
},
|
},
|
||||||
"fileserver": {
|
"fileserver": {
|
||||||
"description": "temporary file server",
|
"description": "temporary file server",
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
|
"""
|
||||||
|
CREATE TABLE "public"."wine" (
|
||||||
|
"wine_id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||||
d = Dict(
|
"seo_name" character varying(128) NOT NULL,
|
||||||
"hello"=> 555,
|
"wine_name" character varying(128) NOT NULL,
|
||||||
"world"=> Dict(
|
"winery" character varying(128) NOT NULL,
|
||||||
"name"=> "ton"
|
"vintage" integer NOT NULL,
|
||||||
)
|
"region" character varying(128) NOT NULL,
|
||||||
)
|
"country" character varying(128) NOT NULL,
|
||||||
|
"wine_type" character varying(128) NOT NULL,
|
||||||
x = 55
|
"grape" character varying(128) NOT NULL,
|
||||||
|
"serving_temperature" character varying(128) NOT NULL,
|
||||||
@info "YiemAgent think() 1 " d x @__LINE__
|
"intensity" integer NULL,
|
||||||
|
"sweetness" integer NULL,
|
||||||
|
"tannin" integer NULL,
|
||||||
|
"acidity" integer NULL,
|
||||||
|
"fizziness" integer NULL,
|
||||||
|
"tasting_notes" text NULL,
|
||||||
|
"image_url" jsonb NULL,
|
||||||
|
"manufacturer_sku" text NULL,
|
||||||
|
"note" text NULL,
|
||||||
|
"other_attributes" jsonb NULL,
|
||||||
|
"created_time" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NULL,
|
||||||
|
"updated_time" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NULL,
|
||||||
|
"description" text NULL,
|
||||||
|
PRIMARY KEY (wine_id)
|
||||||
|
);
|
||||||
|
"""
|
||||||
+28
-45
@@ -68,7 +68,7 @@ julia> result = decisionMaker(agent)
|
|||||||
|
|
||||||
OrderedDict{String, Any} with 4 entries:
|
OrderedDict{String, Any} with 4 entries:
|
||||||
"plan" => "The user provided an image of a sparkling white wine (Asolo Prosecco Bella Principessa from Italy) and requested a search for similar wines in the inventory. According to store guidelines, I must st…
|
"plan" => "The user provided an image of a sparkling white wine (Asolo Prosecco Bella Principessa from Italy) and requested a search for similar wines in the inventory. According to store guidelines, I must st…
|
||||||
"action_name" => "CHECK_WINE"
|
"action_name" => "SEARCH_WINE_DATABASE"
|
||||||
"action_input" => "Sparkling white wine from Italy"
|
"action_input" => "Sparkling white wine from Italy"
|
||||||
"action_result" => "1) winery: Terrazze dell Etna, wine_name: Rose Brut.
|
"action_result" => "1) winery: Terrazze dell Etna, wine_name: Rose Brut.
|
||||||
```
|
```
|
||||||
@@ -154,19 +154,6 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
println("\nERROR YiemAgent decisionMaker() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent decisionMaker() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
# fall back to normal text because LLM default to natural chat when it didn't use action_call
|
|
||||||
else
|
|
||||||
try
|
|
||||||
responsedict = OrderedDict(
|
|
||||||
"plan"=> "I will talk to the user",
|
|
||||||
"action_name"=> "CHAT_BOX",
|
|
||||||
"action_input"=> response[2:end-1] # remove { } at the front and back that added by clean_json_response
|
|
||||||
)
|
|
||||||
catch e
|
|
||||||
println("\nERROR YiemAgent decisionMaker(). $e --(not qualify response)-> $response", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# check whether all answer's key points are in responsedict
|
# check whether all answer's key points are in responsedict
|
||||||
@@ -177,7 +164,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
# if responsedict["action_name"] ∉ ["CHAT_BOX", "CHECK_WINE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
|
# if responsedict["action_name"] ∉ ["CHAT_BOX", "SEARCH_WINE_DATABASE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
|
||||||
# errornote = "Your previous attempt didn't use the given functions"
|
# errornote = "Your previous attempt didn't use the given functions"
|
||||||
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
# continue
|
# continue
|
||||||
@@ -392,7 +379,7 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
|
|||||||
end
|
end
|
||||||
|
|
||||||
@info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__
|
@info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__
|
||||||
thoughtdict, _ = think(a)
|
thoughtdict, result_raw = think(a)
|
||||||
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
||||||
@info "YiemAgent conversation() 2-4 think count $loopcount " @__LINE__
|
@info "YiemAgent conversation() 2-4 think count $loopcount " @__LINE__
|
||||||
assistant_response = Dict{String, Any}(
|
assistant_response = Dict{String, Any}(
|
||||||
@@ -400,8 +387,27 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
|
|||||||
"content" => [Dict("type" => "text", "text" => thoughtdict["action_input"]),]
|
"content" => [Dict("type" => "text", "text" => thoughtdict["action_input"]),]
|
||||||
)
|
)
|
||||||
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
||||||
|
@info "YiemAgent conversation() 2-5 think count $loopcount " @__LINE__
|
||||||
return thoughtdict["action_input"]
|
return thoughtdict["action_input"]
|
||||||
|
# elseif thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
||||||
|
# @info "YiemAgent conversation() 2-4 think count $loopcount " @__LINE__
|
||||||
|
# assistant_response = Dict{String, Any}(
|
||||||
|
# "role" => "assistant",
|
||||||
|
# "content" => [
|
||||||
|
# Dict("type" => "text", "text" => thoughtdict["action_input"]),
|
||||||
|
# Dict( #WORKING put 1st image here
|
||||||
|
# "type" => "image_url",
|
||||||
|
# "image_url" => Dict("url" => image1_data_uri)
|
||||||
|
# ),
|
||||||
|
# Dict( #WORKING put 2nd image here
|
||||||
|
# "type" => "image_url",
|
||||||
|
# "image_url" => Dict("url" => image2_data_uri)
|
||||||
|
# ),
|
||||||
|
# ]
|
||||||
|
# )
|
||||||
|
# addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
||||||
|
|
||||||
|
# return thoughtdict["action_input"] #XXX change output from string to dict
|
||||||
else
|
else
|
||||||
action_name = thoughtdict["action_name"]
|
action_name = thoughtdict["action_name"]
|
||||||
action_input = thoughtdict["action_input"]
|
action_input = thoughtdict["action_input"]
|
||||||
@@ -452,27 +458,17 @@ function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict,
|
|||||||
elseif thoughtdict["action_name"] ∈ ["WINE_PRESENTATION_GUIDELINE"]
|
elseif thoughtdict["action_name"] ∈ ["WINE_PRESENTATION_GUIDELINE"]
|
||||||
@info "YiemAgent think() 4 " @__LINE__
|
@info "YiemAgent think() 4 " @__LINE__
|
||||||
thoughtdict, result_raw = wine_presentation_guideline!(a, thoughtdict)
|
thoughtdict, result_raw = wine_presentation_guideline!(a, thoughtdict)
|
||||||
|
|
||||||
|
|
||||||
elseif thoughtdict["action_name"] == "CHECK_WINE"
|
elseif thoughtdict["action_name"] == "SEARCH_WINE_DATABASE"
|
||||||
@info "YiemAgent think() 5 " @__LINE__
|
@info "YiemAgent think() 5 " @__LINE__
|
||||||
thoughtdict, result_raw = checkwine!(a, thoughtdict; useSQLLLM=false)
|
thoughtdict, result_raw = search_wine_database!(a, thoughtdict; useSQLLLM=false)
|
||||||
|
#WORKING result_raw will be a df. i need to get images so i can send to frontend
|
||||||
else
|
else
|
||||||
@info "YiemAgent think() 6 " @__LINE__
|
@info "YiemAgent think() 6 " @__LINE__
|
||||||
error("condition is not defined ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
error("condition is not defined ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
end
|
end
|
||||||
|
println("\n")
|
||||||
# max_ind =
|
@show thoughtdict
|
||||||
# if length(a.memory["shortmem"]) == 0
|
|
||||||
# 0
|
|
||||||
# else
|
|
||||||
# k = keys(a.memory["shortmem"])
|
|
||||||
# maximum(parse.(Int, k))
|
|
||||||
# end
|
|
||||||
# a.memory["shortmem"]["$(max_ind + 1)"] = thoughtdict
|
|
||||||
|
|
||||||
pprintln(thoughtdict)
|
|
||||||
@info "YiemAgent think() 7 " @__LINE__
|
@info "YiemAgent think() 7 " @__LINE__
|
||||||
return (thoughtdict=thoughtdict, result_raw=result_raw)
|
return (thoughtdict=thoughtdict, result_raw=result_raw)
|
||||||
end
|
end
|
||||||
@@ -677,19 +673,6 @@ function generatechat!(a::T; maxattempt::Integer=10
|
|||||||
println("\nERROR YiemAgent generatechat() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent generatechat() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
# fall back to normal text because LLM default to natural chat when it didn't use action_call
|
|
||||||
else
|
|
||||||
try
|
|
||||||
responsedict = OrderedDict(
|
|
||||||
"plan"=> "I will talk to the user",
|
|
||||||
"action_name"=> "CHAT_BOX",
|
|
||||||
"action_input"=> response[2:end-1] # remove { } at the front and back that added by clean_json_response
|
|
||||||
)
|
|
||||||
catch e
|
|
||||||
println("\nERROR YiemAgent decisionMaker(). $e --(not qualify response)-> $response", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# check whether all answer's key points are in responsedict
|
# check whether all answer's key points are in responsedict
|
||||||
@@ -700,7 +683,7 @@ function generatechat!(a::T; maxattempt::Integer=10
|
|||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
# if responsedict["action_name"] ∉ ["CHAT_BOX", "CHECK_WINE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
|
# if responsedict["action_name"] ∉ ["CHAT_BOX", "SEARCH_WINE_DATABASE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
|
||||||
# errornote = "Your previous attempt didn't use the given functions"
|
# errornote = "Your previous attempt didn't use the given functions"
|
||||||
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
# continue
|
# continue
|
||||||
|
|||||||
+185
-129
@@ -1,6 +1,6 @@
|
|||||||
module llmfunction
|
module llmfunction
|
||||||
|
|
||||||
export virtualWineUserChatbox, jsoncorrection, checkwine!, # recommendbox,
|
export virtualWineUserChatbox, jsoncorrection, search_wine_database!, # recommendbox,
|
||||||
virtualWineUserRecommendbox, userChatbox, userRecommendbox, extractWineAttributes_1,
|
virtualWineUserRecommendbox, userChatbox, userRecommendbox, extractWineAttributes_1,
|
||||||
extractWineAttributes_2, paraphrase
|
extractWineAttributes_2, paraphrase
|
||||||
|
|
||||||
@@ -282,15 +282,15 @@ 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\"}, }"
|
"{"wine 1": {\"Winery\": \"Pichon Baron\", \"wine name\": \"Pauillac (Grand Cru Classé)\", \"grape variety\": \"Cabernet Sauvignon\", \"year\": 2010, \"price\": \"125 USD\", \"stock ID\": \"ar-17\"}, }"
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function checkwine!(a::T, thoughtdict::AbstractDict; useSQLLLM::Bool=false
|
function search_wine_database!(a::T, thoughtdict::AbstractDict; useSQLLLM::Bool=false
|
||||||
)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict, Any}} where {T<:agent}
|
)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict, Any}} where {T<:agent}
|
||||||
|
|
||||||
println("\ncheckinventory order: $(thoughtdict["action_input"]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\ncheckinventory order: $(thoughtdict["action_input"]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
wineattributes_1 = extractWineAttributes_1(a, thoughtdict["action_input"])
|
wineattributes_1 = extractWineAttributes_1(a, thoughtdict["action_input"])
|
||||||
wineattributes_2 = extractWineAttributes_2(a, thoughtdict["action_input"])
|
wineattributes_2 = extractWineAttributes_2(a, thoughtdict["action_input"])
|
||||||
|
|
||||||
retrieve_attributes = ["winery", "wine_name", "wine_id", "vintage", "region", "country", "wine_type", "grape", "serving_temperature", "sweetness", "intensity", "tannin", "acidity", "tasting_notes", "price", "currency"]
|
retrieve_attributes = ["winery", "wine_name", "wine_id", "vintage", "region", "country", "wine_type", "grape", "serving_temperature", "sweetness", "intensity", "tannin", "acidity", "tasting_notes", "price", "currency", "image_url", "retailer_name", "retailer_id"]
|
||||||
_inventoryquery = "$wineattributes_1, $wineattributes_2"
|
_inventoryquery = "$wineattributes_1, $wineattributes_2, retailer_name: $(a.retailername), retailerid: $(a.retailerid)"
|
||||||
inventoryquery = "Retrieves $retrieve_attributes of wines that match the following criteria - {$_inventoryquery}"
|
inventoryquery = "Retrieves $retrieve_attributes of wines that match the following criteria - {$_inventoryquery}"
|
||||||
println("\ncheckinventory input: $inventoryquery ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\ncheckinventory input: $inventoryquery ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
|
|
||||||
@@ -308,7 +308,44 @@ function checkwine!(a::T, thoughtdict::AbstractDict; useSQLLLM::Bool=false
|
|||||||
|
|
||||||
# direct query with possible sql instead of SQLLLM.
|
# direct query with possible sql instead of SQLLLM.
|
||||||
sql = generatesql(a, inventoryquery)
|
sql = generatesql(a, inventoryquery)
|
||||||
|
println("\nSQL: $sql ", @__FILE__, ":", @__LINE__, " $(Dates.now()) \n")
|
||||||
textresult, result_raw, _, _ = SQLexecution(a.context.executeSQL, sql)
|
textresult, result_raw, _, _ = SQLexecution(a.context.executeSQL, sql)
|
||||||
|
#WORKING if result_raw != nothing, get image from image_url column of a df.
|
||||||
|
# then store in a.memory["shortmem]["image"] = OrderedDict(
|
||||||
|
# Dict(
|
||||||
|
# "wine_id"=> "wine_id,
|
||||||
|
# "name"=> "wine name",
|
||||||
|
# "image_url" => Dict("url" => data1_uri)
|
||||||
|
# )
|
||||||
|
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
# # 1. Read local file and encode to base64 string
|
||||||
|
# image2_path = "test/small_image.png"
|
||||||
|
# image2_bytes = read(image2_path)
|
||||||
|
# image2_base64_string = base64encode(image2_bytes)
|
||||||
|
# mime_type = "image/png"
|
||||||
|
# data2_uri = "data:$(mime_type);base64,$(image2_base64_string)"
|
||||||
|
|
||||||
|
# # 3. Construct payload with the Data URI
|
||||||
|
# message = Dict(
|
||||||
|
# "role" => "user",
|
||||||
|
# "content" => [
|
||||||
|
# Dict("type" => "text", "text" => "Do you know type of wine in the image?"),
|
||||||
|
# Dict(
|
||||||
|
# "type" => "image_url",
|
||||||
|
# "image_url" => Dict("url" => data1_uri)
|
||||||
|
# )
|
||||||
|
# ]
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
thoughtdict["action_result"] = textresult
|
thoughtdict["action_result"] = textresult
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -324,7 +361,8 @@ function generatesql(a::T, searchterm::String,
|
|||||||
"""
|
"""
|
||||||
# database_search_guidelines
|
# database_search_guidelines
|
||||||
- Keep SQL queries focused only on the provided information.
|
- Keep SQL queries focused only on the provided information.
|
||||||
- Do not create any table in the database
|
- Use wildcard character (%) to search more effectively.
|
||||||
|
- Do not create any table in the database.
|
||||||
- A junction table can be used to link tables together. Another use case is for filtering data.
|
- A junction table can be used to link tables together. Another use case is for filtering data.
|
||||||
- If you can't find a single table that can be used to answer the user's search term, try joining multiple tables to see if you can obtain the answer.
|
- If you can't find a single table that can be used to answer the user's search term, try joining multiple tables to see if you can obtain the answer.
|
||||||
- Text information in the database usually stored in lower case. If your search returns empty, try using lower case to search.
|
- Text information in the database usually stored in lower case. If your search returns empty, try using lower case to search.
|
||||||
@@ -358,133 +396,143 @@ function generatesql(a::T, searchterm::String,
|
|||||||
Do not wrap the SQL as it will be executed against the database directly and SQL must be ended with ';'.
|
Do not wrap the SQL as it will be executed against the database directly and SQL must be ended with ';'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
table_schema =
|
# table_schema =
|
||||||
"""
|
# """
|
||||||
create table customer (
|
# create table customer (
|
||||||
customer_id uuid primary key default gen_random_uuid (),
|
# customer_id uuid primary key default gen_random_uuid (),
|
||||||
customer_firstname varchar(128),
|
# customer_firstname varchar(128),
|
||||||
customer_lastname varchar(128),
|
# customer_lastname varchar(128),
|
||||||
customer_displayname varchar(128) not null,
|
# customer_displayname varchar(128) not null,
|
||||||
customer_username varchar(128),
|
# customer_username varchar(128),
|
||||||
customer_password varchar(128),
|
# customer_password varchar(128),
|
||||||
customer_gender varchar(128),
|
# customer_gender varchar(128),
|
||||||
country varchar(128),
|
# country varchar(128),
|
||||||
telephone varchar(128),
|
# telephone varchar(128),
|
||||||
email varchar(128) not null,
|
# email varchar(128) not null,
|
||||||
customer_birthdate varchar(128),
|
# customer_birthdate varchar(128),
|
||||||
note text,
|
# note text,
|
||||||
|
|
||||||
other_attributes jsonb,
|
# other_attributes jsonb,
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp,
|
# updated_time timestamptz default current_timestamp,
|
||||||
description text
|
# description text
|
||||||
);
|
# );
|
||||||
|
|
||||||
create table retailer (
|
# create table retailer (
|
||||||
retailer_id uuid primary key default gen_random_uuid (),
|
# retailer_id uuid primary key default gen_random_uuid (),
|
||||||
retailer_name varchar(128) not null,
|
# retailer_name varchar(128) not null,
|
||||||
retailer_username varchar(128) not null,
|
# retailer_username varchar(128) not null,
|
||||||
retailer_password varchar(128) not null,
|
# retailer_password varchar(128) not null,
|
||||||
retailer_address text not null,
|
# retailer_address text not null,
|
||||||
country varchar(128) not null,
|
# country varchar(128) not null,
|
||||||
contact_person varchar(128) not null,
|
# contact_person varchar(128) not null,
|
||||||
telephone varchar(128) not null,
|
# telephone varchar(128) not null,
|
||||||
email varchar(128) not null,
|
# email varchar(128) not null,
|
||||||
note text,
|
# note text,
|
||||||
|
|
||||||
other_attributes jsonb,
|
# other_attributes jsonb,
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp,
|
# updated_time timestamptz default current_timestamp,
|
||||||
description text
|
# description text
|
||||||
);
|
# );
|
||||||
|
|
||||||
create table food (
|
# create table food (
|
||||||
food_id uuid primary key default gen_random_uuid (),
|
# food_id uuid primary key default gen_random_uuid (),
|
||||||
food_name varchar(128) not null,
|
# food_name varchar(128) not null,
|
||||||
country varchar(128),
|
# country varchar(128),
|
||||||
spiciness integer,
|
# spiciness integer,
|
||||||
sweetness integer,
|
# sweetness integer,
|
||||||
sourness integer,
|
# sourness integer,
|
||||||
savoriness integer,
|
# savoriness integer,
|
||||||
bitterness integer,
|
# bitterness integer,
|
||||||
serving_temperature integer,
|
# serving_temperature integer,
|
||||||
image_url jsonb,
|
# image_url jsonb,
|
||||||
note text,
|
# note text,
|
||||||
other_attributes jsonb,
|
# other_attributes jsonb,
|
||||||
|
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp,
|
# updated_time timestamptz default current_timestamp,
|
||||||
description text
|
# description text
|
||||||
);
|
# );
|
||||||
|
|
||||||
create table wine (
|
# create table wine (
|
||||||
wine_id uuid primary key default gen_random_uuid (),
|
# wine_id uuid primary key default gen_random_uuid (),
|
||||||
seo_name varchar(128) not null,
|
# seo_name varchar(128) not null,
|
||||||
wine_name varchar(128) not null,
|
# wine_name varchar(128) not null,
|
||||||
winery varchar(128) not null,
|
# winery varchar(128) not null,
|
||||||
vintage integer not null,
|
# vintage integer not null,
|
||||||
region varchar(128) not null,
|
# region varchar(128) not null,
|
||||||
country varchar(128) not null,
|
# country varchar(128) not null,
|
||||||
wine_type varchar(128) not null,
|
# wine_type varchar(128) not null,
|
||||||
grape varchar(128) not null,
|
# grape varchar(128) not null,
|
||||||
serving_temperature varchar(128) not null,
|
# serving_temperature varchar(128) not null,
|
||||||
intensity integer,
|
# intensity integer,
|
||||||
sweetness integer,
|
# sweetness integer,
|
||||||
tannin integer,
|
# tannin integer,
|
||||||
acidity integer,
|
# acidity integer,
|
||||||
fizziness integer,
|
# fizziness integer,
|
||||||
tasting_notes text,
|
# tasting_notes text,
|
||||||
image_url jsonb,
|
# image_url jsonb,
|
||||||
manufacturer_sku text,
|
# manufacturer_sku text,
|
||||||
note text,
|
# note text,
|
||||||
other_attributes jsonb,
|
# other_attributes jsonb,
|
||||||
|
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp,
|
# updated_time timestamptz default current_timestamp,
|
||||||
description text
|
# description text
|
||||||
);
|
# );
|
||||||
|
|
||||||
create table wine_food (
|
# create table wine_food (
|
||||||
wine_id uuid references wine(wine_id),
|
# wine_id uuid references wine(wine_id),
|
||||||
food_id uuid references food(food_id),
|
# food_id uuid references food(food_id),
|
||||||
constraint wine_food_id primary key (wine_id, food_id),
|
# constraint wine_food_id primary key (wine_id, food_id),
|
||||||
|
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp
|
# updated_time timestamptz default current_timestamp
|
||||||
);
|
# );
|
||||||
|
|
||||||
CREATE TABLE retailer_wine (
|
# CREATE TABLE retailer_wine (
|
||||||
retailer_id uuid references retailer(retailer_id),
|
# retailer_id uuid references retailer(retailer_id),
|
||||||
wine_id uuid references wine(wine_id),
|
# wine_id uuid references wine(wine_id),
|
||||||
constraint retailer_wine_id primary key (retailer_id, wine_id),
|
# constraint retailer_wine_id primary key (retailer_id, wine_id),
|
||||||
price NUMERIC(10, 2),
|
# price NUMERIC(10, 2),
|
||||||
currency varchar(3) not null,
|
# currency varchar(3) not null,
|
||||||
|
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp
|
# updated_time timestamptz default current_timestamp
|
||||||
);
|
# );
|
||||||
|
|
||||||
CREATE TABLE retailer_food (
|
# CREATE TABLE retailer_food (
|
||||||
retailer_id uuid references retailer(retailer_id),
|
# retailer_id uuid references retailer(retailer_id),
|
||||||
food_id uuid references food(food_id),
|
# food_id uuid references food(food_id),
|
||||||
constraint retailer_food_id primary key (retailer_id, food_id),
|
# constraint retailer_food_id primary key (retailer_id, food_id),
|
||||||
price NUMERIC(10, 2),
|
# price NUMERIC(10, 2),
|
||||||
currency varchar(3) not null,
|
# currency varchar(3) not null,
|
||||||
|
|
||||||
created_time timestamptz default current_timestamp,
|
# created_time timestamptz default current_timestamp,
|
||||||
updated_time timestamptz default current_timestamp
|
# updated_time timestamptz default current_timestamp
|
||||||
);
|
# );
|
||||||
"""
|
# """
|
||||||
|
|
||||||
requiredKeys = ["plan", "action_name", "action_input"]
|
requiredKeys = ["plan", "action_name", "action_input"]
|
||||||
errornote = ""
|
errornote = ""
|
||||||
# provide similar sql only for the first attempt
|
# provide similar sql only for the first attempt
|
||||||
sql, distance = a.context.similarSQLVectorDB(searchterm)
|
# sql, distance = a.context.similarSQLVectorDB(searchterm)
|
||||||
|
|
||||||
similarSQL_ = sql !== nothing ? sql : "None"
|
# similarSQL_ = sql !== nothing ? sql : "None"
|
||||||
# if sql is really close, just use it
|
# # if sql is really close, just use it
|
||||||
if similarSQL_ != "None" && distance <= 0.1
|
# if similarSQL_ != "None" && distance <= 0.1
|
||||||
return similarSQL_
|
# return similarSQL_
|
||||||
|
# end
|
||||||
|
|
||||||
|
#CHANGE use find_related_tables_for_user_question and inject only related table schema instead
|
||||||
|
# of hard code table schema. CPU embedding is too slow. use embedding service on GPU.
|
||||||
|
related_tables = a.context.find_related_tables_for_user_question(searchterm)
|
||||||
|
table_schema = ""
|
||||||
|
for table in related_tables
|
||||||
|
_table_schema_str = GeneralUtils.get_db_table_schema_simple(a.context.pg_conn_str, table)
|
||||||
|
table_schema_str = sprint(show, _table_schema_str) * "\n"
|
||||||
|
table_schema = table_schema * table_schema_str
|
||||||
end
|
end
|
||||||
|
|
||||||
context =
|
context =
|
||||||
@@ -493,12 +541,6 @@ function generatesql(a::T, searchterm::String,
|
|||||||
<database_table_schema>
|
<database_table_schema>
|
||||||
$table_schema
|
$table_schema
|
||||||
</database_table_schema>
|
</database_table_schema>
|
||||||
<possible SQL for user's search term>
|
|
||||||
$similarSQL_
|
|
||||||
</possible SQL for user's search term>
|
|
||||||
<error_note>
|
|
||||||
$errornote
|
|
||||||
<error_note>
|
|
||||||
</internal_context_for_assistant>
|
</internal_context_for_assistant>
|
||||||
"""
|
"""
|
||||||
input = context * searchterm
|
input = context * searchterm
|
||||||
@@ -603,7 +645,7 @@ function SQLexecution(executeSQL::Function, sql::T
|
|||||||
tablesize = size(df)
|
tablesize = size(df)
|
||||||
row, column = tablesize
|
row, column = tablesize
|
||||||
if row == 0
|
if row == 0
|
||||||
return (result_str="No records found.", result_raw=df, success=true, errormsg=nothing)
|
return (result_str="No records found. Try loosening your search criteria.", result_raw=nothing, success=true, errormsg=nothing)
|
||||||
elseif column > 30
|
elseif column > 30
|
||||||
return (result_str="There are more than 30 columns. Please be more specific.", result_raw=df, success=true, errormsg=nothing)
|
return (result_str="There are more than 30 columns. Please be more specific.", result_raw=df, success=true, errormsg=nothing)
|
||||||
else
|
else
|
||||||
@@ -678,6 +720,7 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
|||||||
wine_price_max: maximum price range of wine. Example: For wine price 20, wine_price_max will be 20. For wine price 10 to 100, wine_price_max will be 100.
|
wine_price_max: maximum price range of wine. Example: For wine price 20, wine_price_max will be 20. For wine price 10 to 100, wine_price_max will be 100.
|
||||||
occasion: the occasion the user is having the wine for
|
occasion: the occasion the user is having the wine for
|
||||||
food_to_be_paired_with_wine: food that the user will be served with the wine such as poultry, fish, steak, etc
|
food_to_be_paired_with_wine: food that the user will be served with the wine such as poultry, fish, steak, etc
|
||||||
|
_keyword suffice is the related keyword that appears in user's query. each keyword can not be used twice.
|
||||||
</you should then respond to the user with>
|
</you should then respond to the user with>
|
||||||
<you should only respond in JSON format as described below>
|
<you should only respond in JSON format as described below>
|
||||||
"wine_name": "...",
|
"wine_name": "...",
|
||||||
@@ -712,11 +755,11 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
|||||||
"wine_name": "Saumur Blanc",
|
"wine_name": "Saumur Blanc",
|
||||||
"winery": "Domaine du Collier",
|
"winery": "Domaine du Collier",
|
||||||
"vintage": "2019",
|
"vintage": "2019",
|
||||||
"region": "Saumur",
|
"region": "N/A",
|
||||||
"country": "France",
|
"country": "France",
|
||||||
"wine_type": "white",
|
"wine_type": "white",
|
||||||
"grape_varietal": "Merlot",
|
"grape_varietal": "Merlot",
|
||||||
"tasting_notes": "plum",
|
"tasting_notes": "N/A",
|
||||||
"wine_price_min": "N/A",
|
"wine_price_min": "N/A",
|
||||||
"wine_price_max": "N/A",
|
"wine_price_max": "N/A",
|
||||||
"occasion": "N/A",
|
"occasion": "N/A",
|
||||||
@@ -756,9 +799,6 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
|||||||
for attempt in 1:maxattempt
|
for attempt in 1:maxattempt
|
||||||
response = a.context.text2textInstructLLM(a.id, msg)
|
response = a.context.text2textInstructLLM(a.id, msg)
|
||||||
response = GeneralUtils.clean_json_response(response)
|
response = GeneralUtils.clean_json_response(response)
|
||||||
println("\n--- extractWineAttributes_1-1()")
|
|
||||||
println(response)
|
|
||||||
println("--- \n")
|
|
||||||
|
|
||||||
response = GeneralUtils.remove_french_accents(response)
|
response = GeneralUtils.remove_french_accents(response)
|
||||||
think, response = GeneralUtils.extractthink(response)
|
think, response = GeneralUtils.extractthink(response)
|
||||||
@@ -786,6 +826,20 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
|||||||
_v = replace(v, r"\(.*?\)" => "")
|
_v = replace(v, r"\(.*?\)" => "")
|
||||||
responsedict[k] = _v
|
responsedict[k] = _v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# println("\n--- extractWineAttributes_1-1()")
|
||||||
|
# @show responsedict
|
||||||
|
# @info "---\n" @__LINE__
|
||||||
|
|
||||||
|
# check each attributes against each column in a database table with BM25
|
||||||
|
for (k, v) in responsedict
|
||||||
|
if k ∉ ["wine_price_min", "wine_price_max"]
|
||||||
|
words_catalog = GeneralUtils.harvest_entity_catalog(a.context.pg_conn_str, "wine", k)
|
||||||
|
resolved_word = GeneralUtils.resolve_entity(v, words_catalog;threshold=0.9)
|
||||||
|
responsedict[k] = resolved_word
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
result = ""
|
result = ""
|
||||||
for (k, v) in responsedict
|
for (k, v) in responsedict
|
||||||
# some time LLM generate text with "(some comment)". this line removes it
|
# some time LLM generate text with "(some comment)". this line removes it
|
||||||
@@ -793,10 +847,12 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
|||||||
result *= "$k: $v, "
|
result *= "$k: $v, "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
result = result[1:end-2] # remove the ending ", "
|
result = result[1:end-2] # remove the ending ", "
|
||||||
println("\n--- extractWineAttributes_1-2()")
|
# println("\n--- extractWineAttributes_1-2()")
|
||||||
println(result)
|
# @show responsedict
|
||||||
println("--- \n")
|
# @show result
|
||||||
|
# @info "---\n" @__LINE__
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
error("extractWineAttributes_1() failed to get a response")
|
error("extractWineAttributes_1() failed to get a response")
|
||||||
|
|||||||
+9
-3
@@ -16,6 +16,9 @@ mutable struct agentcontext
|
|||||||
insertSQLVectorDB::Function
|
insertSQLVectorDB::Function
|
||||||
similarSommelierDecision::Function
|
similarSommelierDecision::Function
|
||||||
insertSommelierDecision::Function
|
insertSommelierDecision::Function
|
||||||
|
find_related_tables_for_user_question::Function
|
||||||
|
pg_conn_str::String
|
||||||
|
agentconfig::AbstractDict
|
||||||
end
|
end
|
||||||
|
|
||||||
abstract type agent end
|
abstract type agent end
|
||||||
@@ -93,6 +96,7 @@ mutable struct sommelier <: agent
|
|||||||
name::String # agent name
|
name::String # agent name
|
||||||
id::String # agent id
|
id::String # agent id
|
||||||
retailername::String
|
retailername::String
|
||||||
|
retailerid::String
|
||||||
tools::Dict
|
tools::Dict
|
||||||
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
||||||
chathistory::Vector{Dict{String, Any}}
|
chathistory::Vector{Dict{String, Any}}
|
||||||
@@ -140,11 +144,12 @@ julia> agent = sommelier(context, name="WineExpert", id="123", retailername="MyW
|
|||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function sommelier(
|
function sommelier(
|
||||||
context::agentcontext, # app context
|
context::agentcontext, # agent functions, db connect and other context
|
||||||
;
|
;
|
||||||
name::String= "Assistant",
|
name::String= "Assistant",
|
||||||
id::String= string(uuid4()),
|
id::String= string(uuid4()),
|
||||||
retailername::String= "retailer_name",
|
retailername::String= "not specified",
|
||||||
|
retailerid::String= "not specified",
|
||||||
maxHistoryMsg::Integer= 20,
|
maxHistoryMsg::Integer= 20,
|
||||||
chathistory::Vector{Dict{String, Any}} = Vector{Dict{String, Any}}(),
|
chathistory::Vector{Dict{String, Any}} = Vector{Dict{String, Any}}(),
|
||||||
llmFormatName::String= "granite3"
|
llmFormatName::String= "granite3"
|
||||||
@@ -216,6 +221,7 @@ function sommelier(
|
|||||||
name,
|
name,
|
||||||
id,
|
id,
|
||||||
retailername,
|
retailername,
|
||||||
|
retailerid,
|
||||||
tools,
|
tools,
|
||||||
maxHistoryMsg,
|
maxHistoryMsg,
|
||||||
chathistory,
|
chathistory,
|
||||||
@@ -279,7 +285,7 @@ function sommelier(
|
|||||||
|
|
||||||
# available actions
|
# available actions
|
||||||
"CHAT_BOX", which you can use to talk with the user. The input is dialogue you want to chat with the user according to your plan.
|
"CHAT_BOX", which you can use to talk with the user. The input is dialogue you want to chat with the user according to your plan.
|
||||||
"CHECK_WINE", allows you to check information about wines you want in your inventory's database. The input is text that specify supported search criteria includeing: retailer_name, wine price, winery, name, vintage, region, country, type, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
"SEARCH_WINE_DATABASE", allows you to search information about wines you want in your inventory's database. The input is supported search criteria including: retailer_name, wine price, winery, name, vintage, region, country, type, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
||||||
Example query 1: "Dry, full-bodied red wine from 1) region: Burgundy, country: France or 2) region: Tuscany, country: Italy. Grape varietal: Merlot or Syrah. price 100 to 1000 USD."
|
Example query 1: "Dry, full-bodied red wine from 1) region: Burgundy, country: France or 2) region: Tuscany, country: Italy. Grape varietal: Merlot or Syrah. price 100 to 1000 USD."
|
||||||
Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
||||||
Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
||||||
|
|||||||
+1
-1
@@ -297,7 +297,7 @@ function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothin
|
|||||||
# timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"])\n"
|
# timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"])\n"
|
||||||
# elseif event["action_name"] == "CHECKINVENTORY" && event["observation"] === nothing
|
# elseif event["action_name"] == "CHECKINVENTORY" && event["observation"] === nothing
|
||||||
# timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"]), observation: Not done yet.\n"
|
# timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"]), observation: Not done yet.\n"
|
||||||
if event["action_name"] == "CHECK_WINE"
|
if event["action_name"] == "SEARCH_WINE_DATABASE"
|
||||||
timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"]), observation: $(event["observation"])\\n"
|
timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"]), observation: $(event["observation"])\\n"
|
||||||
else
|
else
|
||||||
timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"])\\n"
|
timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"])\\n"
|
||||||
|
|||||||
+2
-2
@@ -128,7 +128,7 @@ systemmsg =
|
|||||||
|
|
||||||
# Available Actions
|
# Available Actions
|
||||||
- **CHAT_BOX** which you can use to talk with the user.
|
- **CHAT_BOX** which you can use to talk with the user.
|
||||||
- **CHECK_WINE** allows you to check information about wines you want in your inventory's database. The input is text that specify supported search criteria includeing: retailer_name, wine price, winery, name, vintage, region, country, type, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
- **SEARCH_WINE_DATABASE** allows you to check information about wines you want in your inventory's database. The input is text that specify supported search criteria includeing: retailer_name, wine price, winery, name, vintage, region, country, type, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
||||||
- Example query 1: "Dry, full-bodied red wine from 1) region: Burgundy, country: France or 2) region: Tuscany, country: Italy. Grape varietal: Merlot or Syrah. price 100 to 1000 USD."
|
- Example query 1: "Dry, full-bodied red wine from 1) region: Burgundy, country: France or 2) region: Tuscany, country: Italy. Grape varietal: Merlot or Syrah. price 100 to 1000 USD."
|
||||||
- Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
- Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
||||||
- Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
- Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
||||||
@@ -157,7 +157,7 @@ openai_msg = Dict(
|
|||||||
"content" => [
|
"content" => [
|
||||||
Dict("type" => "text", "text" =>
|
Dict("type" => "text", "text" =>
|
||||||
"""
|
"""
|
||||||
" <plan>I will greet the customer warmly as Janie, acknowledge their request to find a similar wine for their wedding party based on the image, identify the wine type and country (Italian Sparkling Wine), and then use the CHECK_WINE action to search the inventory for suitable options.</plan>\n <action_name>CHAT_BOX</action_name>\n <action_input>Hello! I'm Janie, and I'd be delighted to help you find the perfect wine for your wedding party. That beautiful wine in the image appears to be an Italian sparkling wine, which is wonderful for a celebration like a wedding! Since you have an unlimited budget, I can certainly look for some truly exceptional options. To start, I will check our inventory for similar Italian sparkling wines that are perfect for a wedding celebration.</action_input><action_result> User response in the next message </action_result>"
|
" <plan>I will greet the customer warmly as Janie, acknowledge their request to find a similar wine for their wedding party based on the image, identify the wine type and country (Italian Sparkling Wine), and then use the SEARCH_WINE_DATABASE action to search the inventory for suitable options.</plan>\n <action_name>CHAT_BOX</action_name>\n <action_input>Hello! I'm Janie, and I'd be delighted to help you find the perfect wine for your wedding party. That beautiful wine in the image appears to be an Italian sparkling wine, which is wonderful for a celebration like a wedding! Since you have an unlimited budget, I can certainly look for some truly exceptional options. To start, I will check our inventory for similar Italian sparkling wines that are perfect for a wedding celebration.</action_input><action_result> User response in the next message </action_result>"
|
||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user