Compare commits
103 Commits
f6eaf4751b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6e53f57707 | |||
| 1eea6c66b6 | |||
| 37ff68c963 | |||
| e5fc800c83 | |||
| 4397ec5fb3 | |||
| 9e3f5a0967 | |||
| 30b79a3b34 | |||
| e5b8518c00 | |||
| d115e60ddf | |||
| e0e6aced33 | |||
| c803238f86 | |||
| 4d6cdbcf4a | |||
| 206c0d2c62 | |||
| 597319a147 | |||
| abfe6f45fb | |||
| f8b3150c17 | |||
| caed2a82d6 | |||
| 7ec3edfd77 | |||
| d7adfaffa8 | |||
| 5bde0ca1f2 | |||
| a3ab288cfe | |||
| 17b0974d82 | |||
| 8fed0b5e8f | |||
| 567d6b79d7 | |||
| 74be3e5717 | |||
| 402b6fcadd | |||
| ef523aaa48 | |||
| ddbb135b6b | |||
| afda364484 | |||
| af73d955eb | |||
| 39cf9a72a1 | |||
| 1c829ad854 | |||
| da98baddb6 | |||
| c5fbaabf42 | |||
| 8080905bad | |||
| b349c3a8b6 | |||
| 0148e03d6a | |||
| e718cc4a5c | |||
| 87bc6a46a1 | |||
| 44bb8baf7c | |||
| 18b2d54ba7 | |||
| b3c3bb9b75 | |||
| d004193b19 | |||
| 8898226825 | |||
| 686b9b2e92 | |||
| 3acf46964b | |||
| 5c7caf0b49 | |||
| ad917ea8d0 | |||
| edeef4ed2a | |||
| 31daa805f3 | |||
| c9937ab5d7 | |||
| 4610137f04 | |||
| 9d7eed7cde | |||
| aedc53bf86 | |||
| 286da3cf2c | |||
| 7fa988313d | |||
| e5b19dd268 | |||
| 0df4159261 | |||
| 45e8ded111 | |||
| 9167ece0c0 | |||
| a6a9395ecc | |||
| a503d4d759 | |||
| f45a036971 | |||
| 24b85be58b | |||
| a798cd119e | |||
| fa338dd0f8 | |||
| 8d4bf5f01f | |||
| cd6f6ef961 | |||
| fdec34832d | |||
| 3c72373b85 | |||
| 688a8c4df2 | |||
| 8bd4986be2 | |||
| 6e5809fc9b | |||
| 2b7c0041e5 | |||
| 9ff0b48eec | |||
| afeb4c7aef | |||
| 2942a89730 | |||
| 6a66f58e63 | |||
| 1d0353d793 | |||
| 0f6aa7c79f | |||
| 0320fd321f | |||
| c29dccf597 | |||
| 70cf04b0db | |||
| 4d57f0146b | |||
| d33aa14dc8 | |||
| 0ed3edd48a | |||
| fb91b51573 | |||
| 0bbd227920 | |||
| 3487770f77 | |||
| 7d27f9e567 | |||
| 511b4d682d | |||
| 5ba91d8acc | |||
| 709f7e7115 | |||
| 3529384cdb | |||
| d1921fa403 | |||
| b4f2a6185b | |||
| d076d5f912 | |||
| e63dd7d898 | |||
| 299a485e4e | |||
| 57dd6df942 | |||
| 9c22cf2e31 | |||
| de20764610 | |||
| 906afc6422 |
+240
-35
@@ -2,7 +2,31 @@
|
|||||||
|
|
||||||
julia_version = "1.12.6"
|
julia_version = "1.12.6"
|
||||||
manifest_format = "2.0"
|
manifest_format = "2.0"
|
||||||
project_hash = "e6bd85ad2679c39ab370f878253f2eeb45c1b6ae"
|
project_hash = "1c1379a2cec320abc347f3acb5ee815ba9855aa6"
|
||||||
|
|
||||||
|
[[deps.Accessors]]
|
||||||
|
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
||||||
|
git-tree-sha1 = "7063ad1083578215c7c4bf410368150abe8d5524"
|
||||||
|
uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
|
||||||
|
version = "0.1.45"
|
||||||
|
|
||||||
|
[deps.Accessors.extensions]
|
||||||
|
AxisKeysExt = "AxisKeys"
|
||||||
|
IntervalSetsExt = "IntervalSets"
|
||||||
|
LinearAlgebraExt = "LinearAlgebra"
|
||||||
|
StaticArraysExt = "StaticArrays"
|
||||||
|
StructArraysExt = "StructArrays"
|
||||||
|
TestExt = "Test"
|
||||||
|
UnitfulExt = "Unitful"
|
||||||
|
|
||||||
|
[deps.Accessors.weakdeps]
|
||||||
|
AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
|
||||||
|
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
|
||||||
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
|
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
|
||||||
|
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
|
||||||
|
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||||
|
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
|
||||||
|
|
||||||
[[deps.AliasTables]]
|
[[deps.AliasTables]]
|
||||||
deps = ["PtrArrays", "Random"]
|
deps = ["PtrArrays", "Random"]
|
||||||
@@ -14,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"
|
||||||
@@ -66,6 +96,11 @@ git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9"
|
|||||||
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
|
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
|
||||||
version = "0.7.8"
|
version = "0.7.8"
|
||||||
|
|
||||||
|
[[deps.CommonSolve]]
|
||||||
|
git-tree-sha1 = "eeaad7cef88554c2fa56b5a3f71cfd5cb708c662"
|
||||||
|
uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
|
||||||
|
version = "0.2.11"
|
||||||
|
|
||||||
[[deps.Compat]]
|
[[deps.Compat]]
|
||||||
deps = ["TOML", "UUIDs"]
|
deps = ["TOML", "UUIDs"]
|
||||||
git-tree-sha1 = "9d8a54ce4b17aa5bdce0ea5c34bc5e7c340d16ad"
|
git-tree-sha1 = "9d8a54ce4b17aa5bdce0ea5c34bc5e7c340d16ad"
|
||||||
@@ -86,6 +121,30 @@ deps = ["Artifacts", "Libdl"]
|
|||||||
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
|
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
|
||||||
version = "1.3.0+1"
|
version = "1.3.0+1"
|
||||||
|
|
||||||
|
[[deps.CompositionsBase]]
|
||||||
|
git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad"
|
||||||
|
uuid = "a33af91c-f02d-484b-be07-31d278c5ca2b"
|
||||||
|
version = "0.1.2"
|
||||||
|
weakdeps = ["InverseFunctions"]
|
||||||
|
|
||||||
|
[deps.CompositionsBase.extensions]
|
||||||
|
CompositionsBaseInverseFunctionsExt = "InverseFunctions"
|
||||||
|
|
||||||
|
[[deps.ConstructionBase]]
|
||||||
|
git-tree-sha1 = "b4b092499347b18a015186eae3042f72267106cb"
|
||||||
|
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
|
||||||
|
version = "1.6.0"
|
||||||
|
|
||||||
|
[deps.ConstructionBase.extensions]
|
||||||
|
ConstructionBaseIntervalSetsExt = "IntervalSets"
|
||||||
|
ConstructionBaseLinearAlgebraExt = "LinearAlgebra"
|
||||||
|
ConstructionBaseStaticArraysExt = "StaticArrays"
|
||||||
|
|
||||||
|
[deps.ConstructionBase.weakdeps]
|
||||||
|
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
|
||||||
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
|
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
|
||||||
|
|
||||||
[[deps.Crayons]]
|
[[deps.Crayons]]
|
||||||
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
|
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
|
||||||
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
|
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
|
||||||
@@ -128,16 +187,30 @@ 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"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
|
||||||
[[deps.Distributions]]
|
[[deps.Distributions]]
|
||||||
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
|
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "Roots", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
|
||||||
git-tree-sha1 = "3c8a0a9a6d4a10bdfb6b751bd2b6051ed3e25fd4"
|
git-tree-sha1 = "cd3c5ac74cd3923c8945c6a81518c46abd0e73a3"
|
||||||
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
||||||
version = "0.25.127"
|
version = "0.25.129"
|
||||||
|
|
||||||
[deps.Distributions.extensions]
|
[deps.Distributions.extensions]
|
||||||
DistributionsChainRulesCoreExt = "ChainRulesCore"
|
DistributionsChainRulesCoreExt = "ChainRulesCore"
|
||||||
@@ -171,11 +244,21 @@ git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec"
|
|||||||
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
|
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
|
|
||||||
|
[[deps.EzXML]]
|
||||||
|
deps = ["Printf", "XML2_jll"]
|
||||||
|
git-tree-sha1 = "7ea1aa5869e2626ccae84480e4f37185bc6f41d3"
|
||||||
|
uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
|
||||||
|
version = "1.2.3"
|
||||||
|
|
||||||
[[deps.FileIO]]
|
[[deps.FileIO]]
|
||||||
deps = ["Pkg", "Requires", "UUIDs"]
|
deps = ["Pkg", "Requires", "UUIDs"]
|
||||||
git-tree-sha1 = "91e0e5c68d02bcdaae76d3c8ceb4361e8f28d2e9"
|
git-tree-sha1 = "6621fef488e496356c9c9625d0562c12a6070819"
|
||||||
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
|
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
|
||||||
version = "1.16.5"
|
version = "1.20.0"
|
||||||
|
weakdeps = ["HTTP"]
|
||||||
|
|
||||||
|
[deps.FileIO.extensions]
|
||||||
|
HTTPExt = "HTTP"
|
||||||
|
|
||||||
[[deps.FilePathsBase]]
|
[[deps.FilePathsBase]]
|
||||||
deps = ["Compat", "Dates"]
|
deps = ["Compat", "Dates"]
|
||||||
@@ -197,6 +280,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"
|
||||||
@@ -204,30 +288,42 @@ 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"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.Gamma]]
|
||||||
|
git-tree-sha1 = "86f86b6168a016ed88e4ae4e64577b98c3b59e8e"
|
||||||
|
uuid = "a0844989-3bd2-4988-8bea-c9407ab0941b"
|
||||||
|
version = "1.1.0"
|
||||||
|
|
||||||
[[deps.GeneralUtils]]
|
[[deps.GeneralUtils]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "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 = "8720a31344bc85ad610ae12f7e1247de22070765"
|
git-tree-sha1 = "93293126d24d3929ef6a5067f347bc28c6582c71"
|
||||||
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.3.2"
|
version = "0.5.10"
|
||||||
|
|
||||||
|
[[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"]
|
||||||
git-tree-sha1 = "a95f80749437ffb42948848d2d2ec81a5050ef4b"
|
git-tree-sha1 = "c2c808326222b6dc4bec295a83b55f79aeec98e0"
|
||||||
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
||||||
version = "2.4.0"
|
version = "2.5.5"
|
||||||
|
|
||||||
[[deps.HashArrayMappedTries]]
|
[[deps.HashArrayMappedTries]]
|
||||||
git-tree-sha1 = "2eaa69a7cab70a52b9687c8bf950a5a93ec895ae"
|
git-tree-sha1 = "2eaa69a7cab70a52b9687c8bf950a5a93ec895ae"
|
||||||
@@ -235,10 +331,10 @@ uuid = "076d061b-32b6-4027-95e0-9a2c6f6d7e74"
|
|||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
[[deps.HypergeometricFunctions]]
|
[[deps.HypergeometricFunctions]]
|
||||||
deps = ["LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
|
deps = ["Gamma", "LinearAlgebra"]
|
||||||
git-tree-sha1 = "68c173f4f449de5b438ee67ed0c9c748dc31a2ec"
|
git-tree-sha1 = "18d7deab5fb0440dc6a7b6993c5c27b25420de10"
|
||||||
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
|
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
|
||||||
version = "0.3.28"
|
version = "0.3.29"
|
||||||
|
|
||||||
[[deps.ICU_jll]]
|
[[deps.ICU_jll]]
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
||||||
@@ -252,6 +348,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"
|
||||||
@@ -273,6 +374,16 @@ git-tree-sha1 = "d6fe00b123e32ddd17231b35d69a6394e696fd5a"
|
|||||||
uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
|
uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.InverseFunctions]]
|
||||||
|
git-tree-sha1 = "a779299d77cd080bf77b97535acecd73e1c5e5cb"
|
||||||
|
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
|
||||||
|
version = "0.1.17"
|
||||||
|
weakdeps = ["Dates", "Test"]
|
||||||
|
|
||||||
|
[deps.InverseFunctions.extensions]
|
||||||
|
InverseFunctionsDatesExt = "Dates"
|
||||||
|
InverseFunctionsTestExt = "Test"
|
||||||
|
|
||||||
[[deps.InvertedIndices]]
|
[[deps.InvertedIndices]]
|
||||||
git-tree-sha1 = "6da3c4316095de0f5ee2ebd875df8721e7e0bdbe"
|
git-tree-sha1 = "6da3c4316095de0f5ee2ebd875df8721e7e0bdbe"
|
||||||
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
|
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
|
||||||
@@ -338,9 +449,11 @@ version = "1.21.3+0"
|
|||||||
|
|
||||||
[[deps.LLMMCTS]]
|
[[deps.LLMMCTS]]
|
||||||
deps = ["GeneralUtils", "JSON", "PrettyPrinting"]
|
deps = ["GeneralUtils", "JSON", "PrettyPrinting"]
|
||||||
path = "../LLMMCTS"
|
git-tree-sha1 = "3dff98131dfa79be8c9bd84fc51cb0ba1832c472"
|
||||||
|
repo-rev = "main"
|
||||||
|
repo-url = "https://git.yiem.cc/ton/LLMMCTS"
|
||||||
uuid = "d76c5a4d-449e-4835-8cc4-dd86ec44f241"
|
uuid = "d76c5a4d-449e-4835-8cc4-dd86ec44f241"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
|
|
||||||
[[deps.LaTeXStrings]]
|
[[deps.LaTeXStrings]]
|
||||||
git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c"
|
git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c"
|
||||||
@@ -393,6 +506,12 @@ version = "1.11.3+1"
|
|||||||
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
|
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.Libiconv_jll]]
|
||||||
|
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
||||||
|
git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809"
|
||||||
|
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
|
||||||
|
version = "1.18.0+0"
|
||||||
|
|
||||||
[[deps.LinearAlgebra]]
|
[[deps.LinearAlgebra]]
|
||||||
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
|
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
|
||||||
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
@@ -420,9 +539,14 @@ version = "1.11.0"
|
|||||||
|
|
||||||
[[deps.LoweredCodeUtils]]
|
[[deps.LoweredCodeUtils]]
|
||||||
deps = ["CodeTracking", "Compiler", "JuliaInterpreter"]
|
deps = ["CodeTracking", "Compiler", "JuliaInterpreter"]
|
||||||
git-tree-sha1 = "0aad96d7b987a5600e260eec50147b254d5ff7e6"
|
git-tree-sha1 = "3733419e9a71156b389f3e331672d2e95436783f"
|
||||||
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
|
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
|
||||||
version = "3.6.0"
|
version = "3.6.2"
|
||||||
|
|
||||||
|
[[deps.MacroTools]]
|
||||||
|
git-tree-sha1 = "1e0228a030642014fe5cfe68c2c0a818f9e3f522"
|
||||||
|
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
|
||||||
|
version = "0.5.16"
|
||||||
|
|
||||||
[[deps.Markdown]]
|
[[deps.Markdown]]
|
||||||
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
|
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
|
||||||
@@ -522,9 +646,9 @@ version = "1.8.2"
|
|||||||
|
|
||||||
[[deps.PDMats]]
|
[[deps.PDMats]]
|
||||||
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
|
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
|
||||||
git-tree-sha1 = "e4cff168707d441cd6bf3ff7e4832bdf34278e4a"
|
git-tree-sha1 = "26766d4b5f1a410c218a19b85a672c6edb693c65"
|
||||||
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
||||||
version = "0.11.37"
|
version = "0.11.40"
|
||||||
weakdeps = ["StatsBase"]
|
weakdeps = ["StatsBase"]
|
||||||
|
|
||||||
[deps.PDMats.extensions]
|
[deps.PDMats.extensions]
|
||||||
@@ -570,15 +694,17 @@ version = "0.4.2"
|
|||||||
|
|
||||||
[[deps.PrettyTables]]
|
[[deps.PrettyTables]]
|
||||||
deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "REPL", "Reexport", "StringManipulation", "Tables"]
|
deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "REPL", "Reexport", "StringManipulation", "Tables"]
|
||||||
git-tree-sha1 = "624de6279ab7d94fc9f672f0068107eb6619732c"
|
git-tree-sha1 = "ebf455bb866ee6737030e3d3816bb6a0683c4325"
|
||||||
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
|
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
|
||||||
version = "3.3.2"
|
version = "3.4.0"
|
||||||
|
|
||||||
[deps.PrettyTables.extensions]
|
[deps.PrettyTables.extensions]
|
||||||
|
PrettyTablesExcelExt = "XLSX"
|
||||||
PrettyTablesTypstryExt = "Typstry"
|
PrettyTablesTypstryExt = "Typstry"
|
||||||
|
|
||||||
[deps.PrettyTables.weakdeps]
|
[deps.PrettyTables.weakdeps]
|
||||||
Typstry = "f0ed7684-a786-439e-b1e3-3b82803b501e"
|
Typstry = "f0ed7684-a786-439e-b1e3-3b82803b501e"
|
||||||
|
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"
|
||||||
|
|
||||||
[[deps.Printf]]
|
[[deps.Printf]]
|
||||||
deps = ["Unicode"]
|
deps = ["Unicode"]
|
||||||
@@ -657,15 +783,39 @@ git-tree-sha1 = "58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8"
|
|||||||
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
|
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
|
||||||
version = "0.5.1+0"
|
version = "0.5.1+0"
|
||||||
|
|
||||||
|
[[deps.Roots]]
|
||||||
|
deps = ["Accessors", "CommonSolve", "Printf"]
|
||||||
|
git-tree-sha1 = "a7caaf7ba8cf307112ca443784d1b56b4a591455"
|
||||||
|
uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
|
||||||
|
version = "3.0.5"
|
||||||
|
|
||||||
|
[deps.Roots.extensions]
|
||||||
|
RootsChainRulesCoreExt = "ChainRulesCore"
|
||||||
|
RootsForwardDiffExt = "ForwardDiff"
|
||||||
|
RootsIntervalRootFindingExt = "IntervalRootFinding"
|
||||||
|
RootsSymPyExt = "SymPy"
|
||||||
|
RootsSymPyPythonCallExt = "SymPyPythonCall"
|
||||||
|
RootsUnitfulExt = "Unitful"
|
||||||
|
|
||||||
|
[deps.Roots.weakdeps]
|
||||||
|
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
||||||
|
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
|
||||||
|
IntervalRootFinding = "d2bf35a9-74e0-55ec-b149-d360ff49b807"
|
||||||
|
SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
|
||||||
|
SymPyPythonCall = "bc8888f7-b21e-4b7c-a06a-5d9c9496438c"
|
||||||
|
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
|
||||||
|
|
||||||
[[deps.SHA]]
|
[[deps.SHA]]
|
||||||
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
|
||||||
[[deps.SQLLLM]]
|
[[deps.SQLLLM]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON3", "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"]
|
||||||
path = "../SQLLLM"
|
git-tree-sha1 = "bae2fd2e2b087753fbb3415896be41df1ae0eb90"
|
||||||
|
repo-rev = "main"
|
||||||
|
repo-url = "https://git.yiem.cc/ton/SQLLLM"
|
||||||
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
||||||
version = "0.2.4"
|
version = "0.2.8"
|
||||||
|
|
||||||
[[deps.SQLStrings]]
|
[[deps.SQLStrings]]
|
||||||
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
||||||
@@ -690,10 +840,22 @@ git-tree-sha1 = "084c47c7c5ce5cfecefa0a98dff69eb3646b5a80"
|
|||||||
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
|
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
|
||||||
version = "1.4.10"
|
version = "1.4.10"
|
||||||
|
|
||||||
|
[[deps.Serde]]
|
||||||
|
deps = ["CSV", "Dates", "EzXML", "JSON", "TOML", "UUIDs", "YAML"]
|
||||||
|
git-tree-sha1 = "f397fc8779cc53e4677c2708f3802c6996f28d00"
|
||||||
|
uuid = "db9b398d-9517-45f8-9a95-92af99003e0e"
|
||||||
|
version = "3.7.2"
|
||||||
|
|
||||||
[[deps.Serialization]]
|
[[deps.Serialization]]
|
||||||
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"
|
||||||
@@ -727,6 +889,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"
|
||||||
@@ -763,6 +944,18 @@ 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.StringEncodings]]
|
||||||
|
deps = ["Libiconv_jll"]
|
||||||
|
git-tree-sha1 = "b765e46ba27ecf6b44faf70df40c57aa3a547dcb"
|
||||||
|
uuid = "69024149-9ee7-55f6-a4c4-859efe599b68"
|
||||||
|
version = "0.3.7"
|
||||||
|
|
||||||
[[deps.StringManipulation]]
|
[[deps.StringManipulation]]
|
||||||
deps = ["PrecompileTools"]
|
deps = ["PrecompileTools"]
|
||||||
git-tree-sha1 = "d05693d339e37d6ab134c5ab53c29fce5ee5d7d5"
|
git-tree-sha1 = "d05693d339e37d6ab134c5ab53c29fce5ee5d7d5"
|
||||||
@@ -823,9 +1016,9 @@ version = "1.0.1"
|
|||||||
|
|
||||||
[[deps.Tables]]
|
[[deps.Tables]]
|
||||||
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"]
|
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"]
|
||||||
git-tree-sha1 = "f2c1efbc8f3a609aadf318094f8fc5204bdaf344"
|
git-tree-sha1 = "0f38a06c83f0007bbab3cf911262841c9a0f07e0"
|
||||||
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
|
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
|
||||||
version = "1.12.1"
|
version = "1.13.0"
|
||||||
|
|
||||||
[[deps.Tar]]
|
[[deps.Tar]]
|
||||||
deps = ["ArgTools", "SHA"]
|
deps = ["ArgTools", "SHA"]
|
||||||
@@ -883,11 +1076,23 @@ git-tree-sha1 = "cd1659ba0d57b71a464a29e64dbc67cfe83d54e7"
|
|||||||
uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60"
|
uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60"
|
||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
|
|
||||||
|
[[deps.XML2_jll]]
|
||||||
|
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"]
|
||||||
|
git-tree-sha1 = "3f3315d89fc954a28f5b471bce698ed6e27481be"
|
||||||
|
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
|
||||||
|
version = "2.15.3+0"
|
||||||
|
|
||||||
|
[[deps.YAML]]
|
||||||
|
deps = ["Base64", "Dates", "Printf", "StringEncodings"]
|
||||||
|
git-tree-sha1 = "a1c0c7585346251353cddede21f180b96388c403"
|
||||||
|
uuid = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
|
||||||
|
version = "0.4.16"
|
||||||
|
|
||||||
[[deps.YiemAgent]]
|
[[deps.YiemAgent]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SQLLLM", "Serialization", "URIs", "UUIDs"]
|
deps = ["Base64", "CSV", "DataFrames", "DataStructures", "Dates", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SQLLLM", "Serde", "Serialization", "URIs", "UUIDs"]
|
||||||
path = "."
|
path = "."
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
version = "0.4.0"
|
version = "0.7.4"
|
||||||
|
|
||||||
[[deps.Zlib_jll]]
|
[[deps.Zlib_jll]]
|
||||||
deps = ["Libdl"]
|
deps = ["Libdl"]
|
||||||
|
|||||||
+8
-2
@@ -1,9 +1,10 @@
|
|||||||
name = "YiemAgent"
|
name = "YiemAgent"
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
version = "0.4.0"
|
version = "0.7.4"
|
||||||
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
||||||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
||||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||||
@@ -18,14 +19,19 @@ PrettyPrinting = "54e16d92-306c-5ea0-a30b-337be88ac337"
|
|||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
||||||
SQLLLM = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
SQLLLM = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
||||||
|
Serde = "db9b398d-9517-45f8-9a95-92af99003e0e"
|
||||||
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
||||||
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
||||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||||
|
|
||||||
[compat]
|
[compat]
|
||||||
|
Base64 = "1.11.0"
|
||||||
CSV = "0.10.15"
|
CSV = "0.10.15"
|
||||||
DataFrames = "1.7.0"
|
DataFrames = "1.7.0"
|
||||||
GeneralUtils = "0.3.2"
|
GeneralUtils = "0.5.10"
|
||||||
HTTP = "2.4.0"
|
HTTP = "2.4.0"
|
||||||
JSON = "1.6.1"
|
JSON = "1.6.1"
|
||||||
|
LLMMCTS = "0.1.5"
|
||||||
NATS = "0.1.0"
|
NATS = "0.1.0"
|
||||||
|
SQLLLM = "0.2.8"
|
||||||
|
Serde = "3.7.2"
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# Store Policy
|
||||||
|
|
||||||
|
- Generally speaking, the store inventory has some wines from France, the United States, Australia, Spain, and Italy, but you won't know exactly until you check your inventory.
|
||||||
|
- If you found wines in the store's database, they are in stock.
|
||||||
|
- You can only recommend wines that are currently in our inventory
|
||||||
|
- Before searching the database for wine, ensure you have at least the following information: 1) budget, 2) wine type, and 3) occasion. Additional details are always helpful. If the user is unsure, provide relevant information and gather insights to make reasonable inferences.
|
||||||
|
- Ask the user one question at a time.
|
||||||
|
- Do not ask the user about wine's flavor e.g. floral, citrusy, nutty or some thing similar as these terms cannot be used to search the database.
|
||||||
|
- Once the user has selected their wine, if you haven't already, ask the user whether they need any further assistance. Do not offer any additional services.
|
||||||
|
- Only end the conversation when the user explicitly intends to do so. When ending, ensure a polite farewell and an invitation to return in the future.
|
||||||
|
- Spicy foods should be paired only with light red wines.
|
||||||
|
- We do not sell organic, sustainable, gluten-free, and sulfite-free wine. Inform the user imediately if they are looking for these types of wines. Do not sell our wines as such.
|
||||||
|
- Gift box, gift card, and custom messages are available. Inform the user to contact our sales team.
|
||||||
|
|
||||||
|
# Store Guidelines
|
||||||
|
|
||||||
|
- Greeting the customer warmly by ask them how could you help. Do not ask any other questions during this greeting.
|
||||||
|
- Customer may provide images for you to look up.
|
||||||
|
- Encourage the customer to explore different options and try new things.
|
||||||
|
- If you are unable to locate the desired item in the database after 2 attempts, it may not be available in your inventory. In such cases, inform the user that the item is unavailable and suggest an alternative instead.
|
||||||
|
- Your store carries only wine.
|
||||||
|
- Vintage 0 means non-vintage.
|
||||||
|
- Start searching the database as broadly as possible within the given information boundary to maximize the chances of finding. Avoid unnecessary parameters unless specified by the user. Refine the search subsequently.
|
||||||
|
|
||||||
|
# Prompt
|
||||||
|
|
||||||
|
Search the database as broad as possible under the informantion you have will increase the chance to find wine. Avoid uneccessary parameter such as region, country, tasting notes unless the user specify
|
||||||
|
|
||||||
|
# Situation
|
||||||
|
|
||||||
|
Your customer is coming into the store
|
||||||
|
|
||||||
|
# Role
|
||||||
|
|
||||||
|
Your name is $(newAgent.name). You are a helpful sommelier for website-based $(newAgent.retailername)'s wine store. You are working under your mentor supervision.
|
||||||
|
|
||||||
|
# Objective
|
||||||
|
|
||||||
|
1. Establish a connection with the customer by talking to them politely and showing your enthusiasm for their wine preferences.
|
||||||
|
2. Provide relevant information and guide them to select the best wines only from your store's inventory that align with their preferences.
|
||||||
|
|
||||||
|
# Responsibility Includes
|
||||||
|
|
||||||
|
1. According to the store's policy and guidelines, make an informed decision about what you need to do to achieve the objective
|
||||||
|
2. Keep the conversation with the customer going smoothly
|
||||||
|
3. Obey your mentor's suggestions.
|
||||||
|
|
||||||
|
# Responsibility Does NOT Include
|
||||||
|
|
||||||
|
1. Requesting the user to place an order, make a purchase, or confirm the order. These are the job of our sales team at the store.
|
||||||
|
2. Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store.
|
||||||
|
3. Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store.
|
||||||
|
|
||||||
|
# Available Actions
|
||||||
|
|
||||||
|
- **CHAT_BOX** which you can use to talk with the user.
|
||||||
|
- **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 2: "Red or white wine, medium tannin, price under 700 USD"
|
||||||
|
- Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
||||||
|
- **PRESENT_WINE_GUIDELINE** which you can use to check the store guidelines about how to present wines you have found to the user. The input is "nothing" keyword. The output is the guidelines that you can follow.
|
||||||
|
- **END_CONVER_GUIDELINE** which you can use to check the store guidelines about how to end the conversation with the user. The input is "nothing" keyword. The output is the guidelines that you can follow.
|
||||||
|
|
||||||
|
# Response Format
|
||||||
|
|
||||||
|
You should respond to the user with interleaving plan, action_name, action_input:
|
||||||
|
|
||||||
|
1. **plan**: Based on the current situation, state a complete action plan to complete the task and rationale. Be specific.
|
||||||
|
2. **action_name**: (Typically corresponds to the execution of the first step in your plan) Can be one of the available_actions name
|
||||||
|
3. **action_input**: The input to the action you are about to perform according to your plan.
|
||||||
|
|
||||||
|
After the action is executed you gets "action_result". It is the output from the action you selected.
|
||||||
|
|
||||||
|
Assistant should only respond in JSON format as described below:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"plan": "...",
|
||||||
|
"action_name": "...",
|
||||||
|
"action_input": "..."
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"nats_server_info": {
|
||||||
|
"description": "nats server",
|
||||||
|
"url": "nats.yiem.cc"
|
||||||
|
},
|
||||||
|
"testingOrProduction": "testing",
|
||||||
|
"agentId": "2b74b87a-5413-4fe2-a4d3-405891051680",
|
||||||
|
"agentCentralConfigSubject": "/yiem/hq/agent/sommelier/backend/config/api/v1.1",
|
||||||
|
"this_service_name": "agent_backend",
|
||||||
|
"this_service_input_channel": {
|
||||||
|
"mqtt": [
|
||||||
|
"/yiem/hq/agent/sommpanion/backend/db/api_v1"
|
||||||
|
],
|
||||||
|
"nats": [
|
||||||
|
"sommpanion.backend.agentbackend.v1.inbox"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"agentRole": "sommelier",
|
||||||
|
"organization": "yiem_hq",
|
||||||
|
"externalservice": {
|
||||||
|
"servicesloadbalancer": {
|
||||||
|
"nats": "sommpanion.backend.servicesloadbalancer.v1.inbox"
|
||||||
|
},
|
||||||
|
"textembedding": {
|
||||||
|
"url": "textembedding.api.v1"
|
||||||
|
},
|
||||||
|
"textimage_to_text_llm": {
|
||||||
|
"url": "https://llmcoder.yiem.cc/v1/chat/completions",
|
||||||
|
"modelname": "Qwen3.6-35B-A3B-UD-Q4_K_M"
|
||||||
|
},
|
||||||
|
"virtualWineCustomer_1": {
|
||||||
|
"serviceSubject": "",
|
||||||
|
"modelName": "qwen3:8b"
|
||||||
|
},
|
||||||
|
"sommpanion_db" : {
|
||||||
|
"description": "A database connection info for LibPQ client",
|
||||||
|
"url": "192.168.88.106:5432",
|
||||||
|
"dbname": "winedb",
|
||||||
|
"user": "admin",
|
||||||
|
"password": "admin@Sommpanion_0.0"
|
||||||
|
},
|
||||||
|
"sommpanion_vectordb" : {
|
||||||
|
"description": "A wine database connection info for LibPQ client",
|
||||||
|
"url": "192.168.88.106:5433",
|
||||||
|
"dbname": "vectordb",
|
||||||
|
"user": "admin",
|
||||||
|
"password": "admin@Sommpanion_0.0"
|
||||||
|
},
|
||||||
|
"fileserver": {
|
||||||
|
"description": "temporary file server",
|
||||||
|
"url": "https://fileserver.yiem.cc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# check if this column has vector embedding. if there is one, seach vector version instead
|
||||||
|
column_name_embedding = column_name * "_embedding"
|
||||||
|
if occursin(column_name_embedding, tables_schema[column_name_embedding])
|
||||||
|
vector_column = Dict(
|
||||||
|
"table_name"=> table_name,
|
||||||
|
"column_name"=> column_name_embedding,
|
||||||
|
"operator"=> "vector_similarity",
|
||||||
|
"value"=> column_obj["value"]
|
||||||
|
)
|
||||||
|
end
|
||||||
@@ -426,7 +426,7 @@ function main()
|
|||||||
# event_description="the assistant talks to the user.",
|
# event_description="the assistant talks to the user.",
|
||||||
# timestamp=Dates.now(),
|
# timestamp=Dates.now(),
|
||||||
# subject="assistant",
|
# subject="assistant",
|
||||||
# actionname="CHATBOX",
|
# action_name="CHAT_BOX",
|
||||||
# action_input=customer_chat,
|
# action_input=customer_chat,
|
||||||
# )
|
# )
|
||||||
# )
|
# )
|
||||||
@@ -453,8 +453,8 @@ function main()
|
|||||||
println("\nagent respond:\n $agent_response")
|
println("\nagent respond:\n $agent_response")
|
||||||
|
|
||||||
if haskey(agent.memory[:events][end], :thought)
|
if haskey(agent.memory[:events][end], :thought)
|
||||||
lastAssistantAction = agent.memory[:events][end][:thought][:actionname]
|
lastAssistantAction = agent.memory[:events][end][:thought][:action_name]
|
||||||
if lastAssistantAction == "ENDCONVERSATION" # store thoughtDict
|
if lastAssistantAction == "END_CONVER_GUIDELINE" # store thoughtDict
|
||||||
|
|
||||||
# save a.memory[:shortmem][:decisionlog] to disk using JSON
|
# save a.memory[:shortmem][:decisionlog] to disk using JSON
|
||||||
println("\nsaving agent.memory[:shortmem][:decisionlog] to disk")
|
println("\nsaving agent.memory[:shortmem][:decisionlog] to disk")
|
||||||
|
|||||||
+1
-1
@@ -429,7 +429,7 @@ function runAgentInstance(
|
|||||||
|
|
||||||
if haskey(agent.memory[:events][end], :thought)
|
if haskey(agent.memory[:events][end], :thought)
|
||||||
lastAssistantAction = agent.memory[:events][end][:thought][:action_name]
|
lastAssistantAction = agent.memory[:events][end][:thought][:action_name]
|
||||||
if lastAssistantAction == "ENDCONVERSATION" # store thoughtDict
|
if lastAssistantAction == "END_CONVER_GUIDELINE" # store thoughtDict
|
||||||
|
|
||||||
# save a.memory[:shortmem][:decisionlog] to disk using JSON
|
# save a.memory[:shortmem][:decisionlog] to disk using JSON
|
||||||
println("\nsaving agent.memory[:shortmem][:decisionlog] to disk")
|
println("\nsaving agent.memory[:shortmem][:decisionlog] to disk")
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAtGVYSWZJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAgAAAAAOgBAABAAAAgAAAAAAAAABKviP0AAANMElEQVR4nO2de3BU1R3Hv7+zu9nNO9mQTQIJzxAeQkKI5MFjAgJJrEiSVmZqq2L/UdvOVO34Xx9WWzvTTutjHMdHrVbb6UyLDqC0jQ9s66ABLaIiCAgmQEhIYh6bBLLPezpnIZDdvQs3mMfde+5n5s5kz97du9nzu79zft/z+50FTExMTExMTExMTExMTExMTExMTEwMTeWWLYnigMRYITODvrsv/vU4JIUgKdXVWx0eh/s4gVv8tuC8/bt2nYeEMEiKN7H/HiLMAFGuLWC5C5JCUt/9hBmhBs7PyuoFmNR3/wgSewHpPEDU3T+CpF5AOg/gcbgfiOp8AVGu1W/9MSRDGg9QWbt5A8B+BULFlc/knxDYI81N218RD2BwDG8A2jteTkMwrAFce8fLZQgWGJCqmvqVYOxFEJZ8/XejXADXF8xd8GHbiaOnYTAMOQlsfnPn+/5u1wKQshXgX1zr+3DOT3KO+zLgWSTeEwbEsEPACGVld9lsrrO3gtNPAZqvteMBeiyTPM80NTV5YWAMbwBhhpDdeQdADwIoiHHaaYA/5O/OeXn//uf8kABpDGD0/IAzek/tOWJKdfM/X3sXEmHIOcCVEGM559gd2c45dsvW+VIagIBx/vOoNovyMCRESgOI9AJc0rtfWgOI9AJM0rtfeipqG94WByRG6pxADv4QJEdqAwDxHFLIcPr+WJBOBxihvK4ujbjjMBFndjsW/3fnzn5IiLSTQIL9kQuJIZTn8ZC0k0ApPUBVXeMKhSvNRHRhNZRzhYFWv//GjmZIhnQeoLq62qpw/uylzhcQMQV4RqwXQDKkM4DhxIz7iFAa9QSh2JrV+SNIhlRDwKoNm2YGrJZDBEpRPYHjvKIEl3zw1ustkASpPEDQan0yZucLCEmMsacgEdIYQHnd5lsAbL7qiUQ3VtTUfwuSQHLF/Cr1AKrwDlm0ASZXzB9O7uz+0KHyCmm0ASZDzA+O70e2W6wKSta3YtmGFlhtStTrCPyHK2sbqmBwmHQx/0UWVbUhOd2DpDQvFlSciX6xJNoAkzHmT5t2HoXLz156XHR9O9KzVWpCJdAGmJFjfgJEBnAYBI7lG1pEEggutTGO5Ru/DD0XdT7Rw+Ubb54Dg8Jki/nnlHTBOX0w6vzM3CHMLumSThtgMsX8jmQfrlt9Kubrlqw5BUeKTyptgBkz5mequ34VrzsJmz0Y87W2hCCWVqsbCDE8WV1fnwGDwWSJ+V2z3cgv6rnq6wsWfIXcuX3SaANMlpi/dL329Z1lN7RKow0wmWJ+rSRJpA0w2WJ+rRRJog0w2WJ+rZAk2gCTMebXSqYE2gCTNebXyhKDawNM1phfKzaDawNMtpg/rc+G6a1JsA9r/9eNrA2QYXL7R8X8G7Z+qhr2LdvjxJIPnKHN3nx2Bf9pbEfXDG3h4fkBO95+qQQBf4ThxHlNAZMl5hd3/kjnCxK8DCveyR6TNrCwss1w2gCTJeZP6bdFbfOY7B5bbez8sg7DaQNMlpi/J9cTcvuj6Zg1DNm1ASZLzO9NvDDm97m88NmDOLlgCB9s6L4mbUBcyyjaAMVbzM/AtqnF/Bvv/GRcwj4t+H0WvP2nZRgeih72ucJv2ffmzlcRJzBDxPxrxyfmH5M2sLbVENoAi/eYP2dOP/IXXH2df7zJL+oxhDbA4n2dX6zdTxXLDJA3wGRa5x9vkgygDVjjIeZniI75iYCe9lTs23V5A/CsGUMoLO0Y8zUK04PIT1Yw4Gc42GOB/wqrx8cP5KHnzOUgRAmy0GfhPKY28HvoGIrrev5RMAvH+ts/RapzbLH98uwgKlyXNwbvGmbY3pIAJcbeYYN9Duz+czGUgAbnGQf7DbC4rucfhXDFY+18wVJn+K7wrkQldMQiNdODBeUq6WJqxIE2wOK+nv+iBFy0on3SHOPCcpEudk7jW+k7b4DFW8wfiZBlS4UEzK5tv8eDveHzNDEEdA3TVSXh0o0tII17TOpZG9DlJJAhYT0n/v7I10ucCMTrAYqaVc8p7USWigTMSLhzHpqcdXso5pj+UbcFAz5CQUoQbi/hYJ815rmjcYYk4U58+bH4TalIuB+cdnK6PDX0evk6ANuhM3Q9CRyhorb+TiJ6MbJdpGpt3BotAdsswOZZvktjeecw4bVWOwJjzw3VIAmXYHgoQe3pO/c27XgJOkeXQ8BoyjZtmgbgt2rPiWIPNQm42BkIm8jlJHIsdQYnRBJetkF9gs/BH63a2OiCztG9AVgD1ieIKCpzY0ZRL/LmqUmxQFpCtA9PTxjn2/8ieXP7MH1+LyIhkFNhyqPQObo2gMqaxjoCvqN25xWvjR1atw1F/x7m6SE2oZKwTcUTEdF3q2oaNkHH6PaXQ8s2bUqyKLQLRJmRz5Wsa0V2Qey1/17vhZSNTDsPqXoffWXD4b6J+1etCUEk2IM425KpNhSsKswvfv7kycMqueVTjy6jAIEtYPkliOZGtjvzBjG7+OqJHPu7raHjWln8YSYWHkgPpZEdLXXjULn6cDOCKCA5dWQaes6khrUT0Sxvov8XAB6ADtGlByivaSwB4Y8UMUSJWH/lN4/AkTSxv+k461gKKt9yweZjoSPvVBLcWT64p/muGE5NmzGIls9c4Ep4cMU5r8ift+gfZ04cGftChWxzALH6R0x5gVS8k6jYTcsau9w7VvJaE6PaRC3B1UgRMrGKIilWMonwgh5XB3VnAF5H5v0EWq71y50IhtIC0W0Z2rxOTCMlFFuyO++FztCVAVTU1s8GqWT8ElBWcwLMOjGhXCRHy9zozbn8m9G9Li+OlLqhBTFMLa9RzxxmnB5aWdcwDzpCV5NAAp4V6fpqs+zjB3JDx2gdQMuWL6PhfhvOHShDwJ0Ox+wWOOYfUz3Pb1PQdGsbsjscocfdeR4oltj6cNuxLJw55gz/zHYFfm/EFIuQpAB/ALA+FCDoAN1IweW19bczope1nHtNWcAKw1d/vQ2+jumXmtLW/hspK/bh6+L3WkNlY2pZwmpw4PZ9TTv+Ah2giyFgxfqGLCL8Tuv5QgcYaxawr316WOcLzu1fgfHAZg+geJ32nA8Cf3x13RbtdWlGNwCLDY8RSJNuLjJxhfsfF1+nYNyYMb8X0wv7tH6YLD/3azZ4QxtAec1msUx6m5ZzhQQs1v6vBVtuB2yuzrC25OUfYTwpibE4pQYR7iiva6iB7EJQQeGiezhxIZAcvnBQGwGFaueW3CAk4IGodpuHwdV+IXb3OZSYSRxJiz4HWQOwpA0gtWIfkkvHbgABdwb8XTlgdg/IGrEMLSRhRwBnv4yWhAUceAPgB0b+V8Ypo+3EkSn97WLdTAJHqKirf5pA90S2T8sfwJoth0Mh4WhcZxxYu2M6EjwsNK3+ZFUPPqvU6orHxmDzKgzuWR362pjDA2fjK0jID08LFykge15dhO5T6dFvwPnTe9/Y+QPoiCkfAkYjiimI4y61jF/h+iM7X1C+OzvU+QLxdMl7WUgVpeDjTKAv81LnCxSPA+7d0R5cfMbS9a2hohUV7i6vrV8DHaEbA6irqxPF28+Logq1ApBYGb+huv9RiO5Jdo+/AQQHREofRRmF6mfKHMaiSvWNJhnwfHX11gsCgw7QjQH0c/vPQFgc2S42ZBAbM8Ti7MxwwxB7APTmjn+1kC2nA8xxWR0U2GfFLkubf307MlwqmcNERd7E/p9AJ0z5JFBQeWP9UgAvA+HlX2LiVtVwFEmpsVfhOgs8SO+zIXnQBrfTh+ZvdGEgItd/PCBrALa8dgQ6c8H9djjmnkBGTRMoQf1aYihw5p3DyUPZ4DxidRC0cmZh0a6240fHvoWp4SaBDz7IKvZ9vIdAUcWUItdf7NMXzxx8dya++F+4ACXgnH84My2hatu2bZNX167HIaCi+eP71To/OT1G4WWcsXhlG5IzoockIlpxasB/r9RDQGj1j+HvBEqIdJ/lN32BVOfUVf6OF2J1MH3aeZz+PFr5JWDNzPkL/3b6+JGJiVv17gHE6p9a7d+s67rgmqVt+TUeyC4YwMzF6vsKXVwdJOkMoKJm8/dAVKO20re0+iSMRvHaU0hMUZ0wrquord+KKYKmqtjD5rd+DoIo+ojK/NFceBlnuLuTMdQXLQFw8F74lMX73nk9fLHCqAkh1oDlKbXOF4gvSO1LMjIEcsJmeQLAtyf/2pNMeW3jTYz4rsm+bjxAxBub/7Vzx6Rec7LLvhm3HwJR/mReN37gk/6z9ZM6CSTYf2N2/pWgPK8Hv4YRPUDFDTfnkM3yBCc+4UZHHFWRhpZoZciwa5vy9HsDGI6sJee8jRMmfEt44qRwf/DeyZoQTr0UPAFU1jW8AiBsW5b81ARU5mrabgh7zw6hbTBq/eHVvU07xLY1hmLKpWCTqcU0AMkxDUByTAOQHF2Vhk0kZwZ92D6kbdFNidr31bhIYwCiS4MSdaxWzCFAckwDkBzTACTHkHMArtCzYPzNcX1ThXS75buJiYmJiYmJiYmJiYmJiYmJiYmJCa7I/wEjf8WA9CzV0gAAAABJRU5ErkJggg==
|
||||||
+645
-1086
File diff suppressed because it is too large
Load Diff
+1156
-709
File diff suppressed because it is too large
Load Diff
+196
-186
@@ -1,6 +1,6 @@
|
|||||||
module type
|
module type
|
||||||
|
|
||||||
export agent, sommelier, companion, virtualcustomer, appcontext
|
export agent, sommelier, companion, virtualcustomer, agentcontext
|
||||||
|
|
||||||
using Dates, UUIDs, DataStructures, JSON, NATS
|
using Dates, UUIDs, DataStructures, JSON, NATS
|
||||||
using GeneralUtils
|
using GeneralUtils
|
||||||
@@ -8,218 +8,147 @@ using GeneralUtils
|
|||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
# ---------------------------------------------- 100 --------------------------------------------- #
|
||||||
|
|
||||||
|
|
||||||
mutable struct appcontext
|
mutable struct agentcontext
|
||||||
const connection::NATS.Connection
|
|
||||||
const text2textInstructLLMServiceSubject::String
|
|
||||||
getTextEmbedding::Function
|
|
||||||
text2textInstructLLM::Function
|
text2textInstructLLM::Function
|
||||||
|
getTextEmbedding::Function
|
||||||
executeSQL::Function
|
executeSQL::Function
|
||||||
similarSQLVectorDB::Function
|
similarSQLVectorDB::Function
|
||||||
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
|
||||||
|
|
||||||
mutable struct companion <: agent
|
|
||||||
name::String # agent name
|
|
||||||
id::String # agent id
|
|
||||||
systemmsg::String # system message
|
|
||||||
tools::Dict # tools
|
|
||||||
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}}
|
|
||||||
memory::Dict{Symbol, Any}
|
|
||||||
context::NamedTuple # NamedTuple of functions
|
|
||||||
llmFormatName::String
|
|
||||||
end
|
|
||||||
|
|
||||||
function companion(
|
|
||||||
context::appcontext # NamedTuple of functions
|
|
||||||
;
|
|
||||||
name::String= "Assistant",
|
|
||||||
id::String= GeneralUtils.uuid4snakecase(),
|
|
||||||
maxHistoryMsg::Integer= 20,
|
|
||||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
|
||||||
llmFormatName::String= "granite3",
|
|
||||||
systemmsg::String=
|
|
||||||
"""
|
|
||||||
Your name: $name
|
|
||||||
Your sex: Female
|
|
||||||
Your role: You are a helpful assistant.
|
|
||||||
You should follow the following guidelines:
|
|
||||||
- Focus on the latest conversation.
|
|
||||||
- Your like to be short and concise.
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
|
|
||||||
tools = Dict( # update input format
|
|
||||||
"CHATBOX"=> Dict(
|
|
||||||
:description => "- CHATBOX which you can use to talk with the user. The input is your intentions for the dialogue. Be specific.",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
""" Memory
|
|
||||||
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
|
||||||
NO "system" message in chathistory because I want to add it at the inference time
|
|
||||||
chathistory= [
|
|
||||||
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
|
||||||
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
|
||||||
]
|
|
||||||
"""
|
|
||||||
memory = Dict{Symbol, Any}(
|
|
||||||
:events=> Vector{Dict{Symbol, Any}}(),
|
|
||||||
:state=> Dict{Symbol, Any}(), # state of the agent
|
|
||||||
:recap=> OrderedDict{Symbol, Any}(), # recap summary of the conversation
|
|
||||||
)
|
|
||||||
|
|
||||||
newAgent = companion(
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
systemmsg,
|
|
||||||
tools,
|
|
||||||
maxHistoryMsg,
|
|
||||||
chathistory,
|
|
||||||
memory,
|
|
||||||
context,
|
|
||||||
llmFormatName
|
|
||||||
)
|
|
||||||
|
|
||||||
return newAgent
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" A sommelier agent.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `mqttClient::Client`
|
|
||||||
MQTTClient's client
|
|
||||||
- `msgMeta::Dict{Symbol, Any}`
|
|
||||||
A dict contain info about a message.
|
|
||||||
- `config::Dict{Symbol, Any}`
|
|
||||||
Config info for an agent. Contain mqtt topic for internal use and other info.
|
|
||||||
|
|
||||||
# Keyword Arguments
|
|
||||||
- `name::String`
|
|
||||||
Agent's name
|
|
||||||
- `id::String`
|
|
||||||
Agent's ID
|
|
||||||
- `tools::Dict{Symbol, Any}`
|
|
||||||
Agent's tools
|
|
||||||
- `maxHistoryMsg::Integer`
|
|
||||||
max history message
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `nothing`
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> using YiemAgent, MQTTClient, GeneralUtils
|
|
||||||
julia> msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
"N/A",
|
|
||||||
replyTopic = "/testtopic/prompt"
|
|
||||||
)
|
|
||||||
julia> tools= Dict(
|
|
||||||
:chatbox=>Dict(
|
|
||||||
:name => "chatbox",
|
|
||||||
:description => "Useful only for when you need to ask the user for more info or context. Do not ask the user their own question.",
|
|
||||||
:input => "Input should be a text.",
|
|
||||||
:output => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
julia> agentConfig = Dict(
|
|
||||||
:receiveprompt=>Dict(
|
|
||||||
:mqtttopic=> "/testtopic/prompt", # topic to receive prompt i.e. frontend send msg to this topic
|
|
||||||
),
|
|
||||||
:receiveinternal=>Dict(
|
|
||||||
:mqtttopic=> "/testtopic/internal", # receive topic for model's internal
|
|
||||||
),
|
|
||||||
:text2text=>Dict(
|
|
||||||
:mqtttopic=> "/text2text/receive",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
julia> client, connection = MakeConnection("test.mosquitto.org", 1883)
|
|
||||||
julia> agent = YiemAgent.bsommelier(
|
|
||||||
client,
|
|
||||||
msgMeta,
|
|
||||||
agentConfig,
|
|
||||||
name= "assistant",
|
|
||||||
id= "555", # agent instance id
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docstring
|
|
||||||
- [x] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
mutable struct sommelier <: agent
|
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{Symbol, Any}}
|
chathistory::Vector{Dict{String, Any}}
|
||||||
memory::Dict{Symbol, Any}
|
memory::Dict{String, Any}
|
||||||
context # NamedTuple of functions
|
context::agentcontext
|
||||||
llmFormatName::String
|
llmFormatName::String
|
||||||
end
|
end
|
||||||
|
|
||||||
|
""" A sommelier agent.
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
- `context::agentcontext`
|
||||||
|
Application context containing shared functions for LLM, SQL, and vector database operations.
|
||||||
|
|
||||||
|
# Keyword Arguments
|
||||||
|
- `name::String`
|
||||||
|
Agent's name. Default: `"Assistant"`
|
||||||
|
- `id::String`
|
||||||
|
Agent's ID. Default: generated UUID string.
|
||||||
|
- `retailername::String`
|
||||||
|
Retailer name associated with the sommelier. Default: `"retailer_name"`
|
||||||
|
- `maxHistoryMsg::Integer`
|
||||||
|
Maximum history messages. Default: `20`
|
||||||
|
- `chathistory::Vector{Dict{String, String}}`
|
||||||
|
Chat history. Default: empty vector.
|
||||||
|
- `llmFormatName::String`
|
||||||
|
LLM format name. Default: `"granite3"`
|
||||||
|
|
||||||
|
# Return
|
||||||
|
- `sommelier`: An instantiated sommelier agent.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
```julia
|
||||||
|
julia> using YiemAgent
|
||||||
|
julia> context = agentcontext(
|
||||||
|
text2textInstructLLM,
|
||||||
|
getTextEmbedding,
|
||||||
|
executeSQL,
|
||||||
|
similarSQLVectorDB,
|
||||||
|
insertSQLVectorDB,
|
||||||
|
similarSommelierDecision,
|
||||||
|
insertSommelierDecision
|
||||||
|
)
|
||||||
|
julia> agent = sommelier(context, name="WineExpert", id="123", retailername="MyWineShop")
|
||||||
|
```
|
||||||
|
"""
|
||||||
function sommelier(
|
function sommelier(
|
||||||
context::appcontext, # 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{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
chathistory::Vector{Dict{String, Any}} = Vector{Dict{String, Any}}(),
|
||||||
llmFormatName::String= "granite3"
|
llmFormatName::String= "granite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
tools = Dict( # update input format
|
tools = Dict( # update input format
|
||||||
"chatbox"=> Dict(
|
"chatbox"=> Dict(
|
||||||
:description => "<askbox tool description>Useful for when you need to ask the user for more context. Do not ask the user their own question.</askbox tool description>",
|
"description" => "<askbox tool description>Useful for when you need to ask the user for more context. Do not ask the user their own question.</askbox tool description>",
|
||||||
:input => """<input>Input is a text in JSON format.</input><input example>{\"Q1\": \"How are you doing?\", \"Q2\": \"How may I help you?\"}</input example>""",
|
"input" => """<input>Input is a text in JSON format.</input><input example>{\"Q1\": \"How are you doing?\", \"Q2\": \"How may I help you?\"}</input example>""",
|
||||||
:output => "" ,
|
"output" => "" ,
|
||||||
),
|
),
|
||||||
"winestock"=> Dict(
|
"winestock"=> Dict(
|
||||||
:description => "<winestock tool description>A handy tool for searching wine in your inventory that match the user preferences.</winestock tool description>",
|
"description" => "<winestock tool description>A handy tool for searching wine in your inventory that match the user preferences.</winestock tool description>",
|
||||||
:input => """<input>Input is a JSON-formatted string that contains a detailed and precise search query.</input><input example>{\"wine type\": \"rose\", \"price\": \"max 35\", \"sweetness level\": \"sweet\", \"intensity level\": \"light bodied\", \"Tannin level\": \"low\", \"Acidity level\": \"low\"}</input example>""",
|
"input" => """<input>Input is a JSON-formatted string that contains a detailed and precise search query.</input><input example>{\"wine type\": \"rose\", \"price\": \"max 35\", \"sweetness level\": \"sweet\", \"intensity level\": \"light bodied\", \"Tannin level\": \"low\", \"Acidity level\": \"low\"}</input example>""",
|
||||||
:output => """<output>Output are wines that match the search query in JSON format.""",
|
"output" => """<output>Output are wines that match the search query in JSON format.""",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
""" Memory
|
""" Memory
|
||||||
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
|
||||||
NO "system" message in chathistory because I want to add it at the inference time
|
Chat history use openai format as follow:
|
||||||
|
|
||||||
|
image1_path = "test/large_image.png" ---
|
||||||
|
image1_bytes = read(image1_path) | this part must be done
|
||||||
|
image1_base64_string = base64encode(image1_bytes) | in frontend
|
||||||
|
mime_type = "image/png" | not in agent code
|
||||||
|
data1_uri = "data:<mime_type>;base64,<image1_base64_string>" ---
|
||||||
|
|
||||||
chathistory= [
|
chathistory= [
|
||||||
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
Dict(
|
||||||
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
"role" => "system",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "You are a helpful assistant"),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
Dict(
|
||||||
|
"role" => "user",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "<internal_context_for_assistant>
|
||||||
|
LLM context here...
|
||||||
|
</internal_context_for_assistant>
|
||||||
|
Do you know this wine? Just give me brief intro."
|
||||||
|
),
|
||||||
|
Dict(
|
||||||
|
"type" => "image_url",
|
||||||
|
"image_url" => Dict("url" => data1_uri)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
shortmem = Dict(
|
||||||
|
"1"=> Dict("plan"=> "...", "action_name"=> "...", "action_input"=> "...", "action_result"=> "..."),
|
||||||
|
"2"=> Dict("plan"=> "...", "action_name"=> "...", "action_input"=> "...", "action_result"=> "..."),
|
||||||
|
...
|
||||||
|
)
|
||||||
"""
|
"""
|
||||||
memory = Dict{Symbol, Any}(
|
memory = Dict{String, Any}(
|
||||||
:shortmem=> OrderedDict{Symbol, Any}(
|
"shortmem"=> OrderedDict{String, Any}(),
|
||||||
:db_search_result=> Any[],
|
"scratchpad"=> "",
|
||||||
:scratchpad=> "", #[PENDING] should be a dict e.g. Dict(:database_search_result=>Dict(:wines=> "", :search_query=> ""))
|
"recap"=> OrderedDict{String, Any}(),
|
||||||
),
|
|
||||||
:events=> Vector{Dict{Symbol, Any}}(),
|
|
||||||
:state=> Dict{Symbol, Any}(
|
|
||||||
),
|
|
||||||
:recap=> OrderedDict{Symbol, Any}(),
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
newAgent = sommelier(
|
newAgent = sommelier(
|
||||||
name,
|
name,
|
||||||
id,
|
id,
|
||||||
retailername,
|
retailername,
|
||||||
|
retailerid,
|
||||||
tools,
|
tools,
|
||||||
maxHistoryMsg,
|
maxHistoryMsg,
|
||||||
chathistory,
|
chathistory,
|
||||||
@@ -227,10 +156,77 @@ function sommelier(
|
|||||||
context,
|
context,
|
||||||
llmFormatName
|
llmFormatName
|
||||||
)
|
)
|
||||||
|
systemmsg =
|
||||||
|
"""
|
||||||
|
# store_policy
|
||||||
|
- Generally speaking, the store inventory has some wines from France, the United States, Australia, Spain, and Italy, but you won't know exactly until you check your inventory.
|
||||||
|
- If you found wines in the store's database, they are in stock.
|
||||||
|
- You can only recommend wines that are currently in our inventory
|
||||||
|
- Before searching the database for wine, ensure you have at least the following information: 1) budget, 2) wine type, and 3) occasion. Additional details are always helpful. If the user is unsure, provide relevant information and gather insights to make reasonable inferences.
|
||||||
|
- Ask the user one question at a time.
|
||||||
|
- Once the user has selected their wine, if you haven't already, ask the user whether they need any further assistance. Do not offer any additional services.
|
||||||
|
- Only end the conversation when the user explicitly intends to do so. When ending, ensure a polite farewell and an invitation to return in the future.
|
||||||
|
- Spicy foods should be paired only with light red wines.
|
||||||
|
- We do not sell organic, sustainable, gluten-free, and sulfite-free wine. Inform the user imediately if they are looking for these types of wines. Do not sell our wines as such.
|
||||||
|
- Gift box, gift card, and custom messages are available. Inform the user to contact our sales team.
|
||||||
|
|
||||||
|
# store_guidelines
|
||||||
|
- Greeting the customer warmly by ask them how could you help. Do not ask any other questions during this greeting.
|
||||||
|
- Customer may provide images for you to look up.
|
||||||
|
- Encourage the customer to explore different options and try new things.
|
||||||
|
- If you are unable to locate the desired item in the database after 2 attempts, it may not be available in your inventory. In such cases, inform the user that the item is unavailable and suggest an alternative instead.
|
||||||
|
- Your store carries only wine.
|
||||||
|
- Vintage 0 means non-vintage.
|
||||||
|
- Start searching the database as broadly as possible within the given information boundary to maximize the chances of finding. Avoid unnecessary parameters unless specified by the user. Refine the search subsequently.
|
||||||
|
- User usually ask for something similar. This means you should use the search term based on the profile they like.
|
||||||
|
|
||||||
|
# situation
|
||||||
|
You are having conversation with a customer.
|
||||||
|
|
||||||
|
# your role
|
||||||
|
Your name is $(newAgent.name). You are a helpful sommelier for website-based $(newAgent.retailername)'s wine store.
|
||||||
|
|
||||||
|
# objective
|
||||||
|
- Establish a connection with the customer by talking to them politely and showing your enthusiasm for their wine preferences.
|
||||||
|
- Provide relevant information and guide them to select the best wines only from your store's inventory that align with their preferences.
|
||||||
|
|
||||||
|
# your responsibility includes
|
||||||
|
- According to the store's policy and guidelines, and make an informed decision about what available_actions you need to use to achieve the objective.
|
||||||
|
- Keep the conversation with the customer going smoothly
|
||||||
|
|
||||||
|
# your responsibility does NOT includes
|
||||||
|
- Requesting the user to place an order, make a purchase, or confirm the order. These are the job of our sales team at the store.
|
||||||
|
- Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store.
|
||||||
|
- Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store.
|
||||||
|
|
||||||
|
# you should then respond to the user with interleaving think, action_name, action_input in JSON format
|
||||||
|
1) "think", Your step-by-step reasoning process. Explain why you are choosing this action.
|
||||||
|
2) "action_name", Can be one of the available actions. Typically corresponds to the execution of the first step in your thought
|
||||||
|
3) "action_input", The input to the action you are about to perform.
|
||||||
|
After the action is executed you gets "action_result". It is the output from the action you selected.
|
||||||
|
|
||||||
|
# available actions
|
||||||
|
"CHAT_BOX", which you can use to talk with the user. The input is dialogue you want to say with the user.
|
||||||
|
"SEARCH_WINE_DATABASE", allows you to search information about wines you want in your inventory's database. The input is strictly supported search term including: retailer_name, wine price, winery, name, vintage, region, country, type of wine, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.
|
||||||
|
Example query 1: "Dry, full-bodied red wine from Burgundy, France. Grape varietal could be Merlot or Syrah. price 100 to 1000 USD."
|
||||||
|
Example query 2: "Red or white wine, medium tannin, price under 700 USD"
|
||||||
|
Example query 3: "white wine from Tuscany, Italy or Bordeaux, France
|
||||||
|
"WINE_PRESENTATION_GUIDELINE", store guidelines about how to present wines to the user appropriately. The input is "null" keyword.
|
||||||
|
"END_CONVER_GUIDELINE", store guidelines about how to end the conversation with the user appropriately. The input is "null" keyword.
|
||||||
|
"""
|
||||||
|
|
||||||
|
system_msg = Dict(
|
||||||
|
"role" => "system",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => systemmsg),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
push!(newAgent.chathistory, system_msg)
|
||||||
|
|
||||||
return newAgent
|
return newAgent
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
mutable struct virtualcustomer <: agent
|
mutable struct virtualcustomer <: agent
|
||||||
name::String # agent name
|
name::String # agent name
|
||||||
@@ -238,8 +234,8 @@ mutable struct virtualcustomer <: agent
|
|||||||
systemmsg::String # system message
|
systemmsg::String # system message
|
||||||
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{Symbol, Any}}
|
chathistory::Vector{Dict{String, Any}}
|
||||||
memory::Dict{Symbol, Any}
|
memory::Dict{String, Any}
|
||||||
context # NamedTuple of functions
|
context # NamedTuple of functions
|
||||||
llmFormatName::String
|
llmFormatName::String
|
||||||
end
|
end
|
||||||
@@ -250,7 +246,7 @@ function virtualcustomer(
|
|||||||
name::String= "Assistant",
|
name::String= "Assistant",
|
||||||
id::String= string(uuid4()),
|
id::String= string(uuid4()),
|
||||||
maxHistoryMsg::Integer= 20,
|
maxHistoryMsg::Integer= 20,
|
||||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
chathistory::Vector{Dict{String, String}} = Vector{Dict{String, String}}(),
|
||||||
llmFormatName::String= "granite3",
|
llmFormatName::String= "granite3",
|
||||||
systemmsg::String=
|
systemmsg::String=
|
||||||
"""
|
"""
|
||||||
@@ -267,27 +263,41 @@ function virtualcustomer(
|
|||||||
|
|
||||||
tools = Dict( # update input format
|
tools = Dict( # update input format
|
||||||
"chatbox"=> Dict(
|
"chatbox"=> Dict(
|
||||||
:description => "<askbox tool description>Useful for when you need to ask the user for more context. Do not ask the user their own question.</askbox tool description>",
|
"description" => "<askbox tool description>Useful for when you need to ask the user for more context. Do not ask the user their own question.</askbox tool description>",
|
||||||
:input => """<input>Input is a text in JSON format.</input><input example>{\"Q1\": \"How are you doing?\", \"Q2\": \"How may I help you?\"}</input example>""",
|
"input" => """<input>Input is a text in JSON format.</input><input example>{\"Q1\": \"How are you doing?\", \"Q2\": \"How may I help you?\"}</input example>""",
|
||||||
:output => "" ,
|
"output" => "" ,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
""" Memory
|
""" Memory
|
||||||
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
Ref: Chat prompt format is openai
|
||||||
NO "system" message in chathistory because I want to add it at the inference time
|
chathistory = [
|
||||||
chathistory= [
|
Dict(
|
||||||
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
"role" => "system",
|
||||||
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => system_msg),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
Dict(
|
||||||
|
"role" => "user",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "Do you know this wine? Just give me brief intro."),
|
||||||
|
Dict(
|
||||||
|
"type" => "image_url",
|
||||||
|
"image_url" => Dict("url" => data1_uri)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
memory = Dict{Symbol, Any}(
|
memory = Dict{String, Any}(
|
||||||
:shortmem=> OrderedDict{Symbol, Any}(
|
"shortmem"=> OrderedDict{String, Any}(
|
||||||
),
|
),
|
||||||
:events=> Vector{Dict{Symbol, Any}}(),
|
"scratchpad"=> "",
|
||||||
:state=> Dict{Symbol, Any}(
|
"events"=> Vector{Dict{String, Any}}(),
|
||||||
|
"state"=> Dict{String, Any}(
|
||||||
),
|
),
|
||||||
:recap=> OrderedDict{Symbol, Any}(),
|
"recap"=> OrderedDict{String, Any}(),
|
||||||
)
|
)
|
||||||
|
|
||||||
newAgent = virtualcustomer(
|
newAgent = virtualcustomer(
|
||||||
|
|||||||
+109
-138
@@ -26,16 +26,16 @@ julia> client, connection = MakeConnection("test.mosquitto.org", 1883)
|
|||||||
julia> connect(client, connection)
|
julia> connect(client, connection)
|
||||||
julia> msgMeta = GeneralUtils.generate_msgMeta("testtopic")
|
julia> msgMeta = GeneralUtils.generate_msgMeta("testtopic")
|
||||||
julia> agentConfig = Dict(
|
julia> agentConfig = Dict(
|
||||||
:receiveprompt=>Dict(
|
"receiveprompt"=>Dict(
|
||||||
:mqtttopic=> "testtopic/receive",
|
"mqtttopic"=> "testtopic/receive",
|
||||||
),
|
),
|
||||||
:receiveinternal=>Dict(
|
"receiveinternal"=>Dict(
|
||||||
:mqtttopic=> "testtopic/internal",
|
"mqtttopic"=> "testtopic/internal",
|
||||||
),
|
),
|
||||||
:text2text=>Dict(
|
"text2text"=>Dict(
|
||||||
:mqtttopic=> "testtopic/text2text",
|
"mqtttopic"=> "testtopic/text2text",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
julia> a = YiemAgent.sommelier(
|
julia> a = YiemAgent.sommelier(
|
||||||
client,
|
client,
|
||||||
msgMeta,
|
msgMeta,
|
||||||
@@ -52,14 +52,25 @@ julia> YiemAgent.clearhistory(a)
|
|||||||
"""
|
"""
|
||||||
function clearhistory(a::T) where {T<:agent}
|
function clearhistory(a::T) where {T<:agent}
|
||||||
empty!(a.chathistory)
|
empty!(a.chathistory)
|
||||||
empty!(a.memory[:shortmem])
|
empty!(a.memory["shortmem"])
|
||||||
empty!(a.memory[:events])
|
empty!(a.memory["events"])
|
||||||
a.memory[:chatbox] = ""
|
a.memory["chatbox"] = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
""" Add new message to agent.
|
""" Add new message to agent.
|
||||||
|
|
||||||
|
messages => Dict(
|
||||||
|
"role" => "user",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "Describe this image for me"),
|
||||||
|
Dict(
|
||||||
|
"type" => "image_url",
|
||||||
|
"image_url" => Dict("url" => data_uri)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
Arguments\n
|
Arguments\n
|
||||||
-----
|
-----
|
||||||
a::agent
|
a::agent
|
||||||
@@ -76,44 +87,24 @@ end
|
|||||||
Example\n
|
Example\n
|
||||||
-----
|
-----
|
||||||
```jldoctest
|
```jldoctest
|
||||||
julia> using YiemAgent, MQTTClient, GeneralUtils
|
|
||||||
julia> client, connection = MakeConnection("test.mosquitto.org", 1883)
|
|
||||||
julia> connect(client, connection)
|
|
||||||
julia> msgMeta = GeneralUtils.generate_msgMeta("testtopic")
|
|
||||||
julia> agentConfig = Dict(
|
|
||||||
:receiveprompt=>Dict(
|
|
||||||
:mqtttopic=> "testtopic/receive",
|
|
||||||
),
|
|
||||||
:receiveinternal=>Dict(
|
|
||||||
:mqtttopic=> "testtopic/internal",
|
|
||||||
),
|
|
||||||
:text2text=>Dict(
|
|
||||||
:mqtttopic=> "testtopic/text2text",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
julia> a = YiemAgent.sommelier(
|
|
||||||
client,
|
|
||||||
msgMeta,
|
|
||||||
agentConfig,
|
|
||||||
)
|
|
||||||
julia> YiemAgent.addNewMessage(a, "user", "hello")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Signature\n
|
Signature\n
|
||||||
-----
|
-----
|
||||||
"""
|
"""
|
||||||
function addNewMessage(a::T1, name::String, text::T2;
|
function addNewMessage(a::T1, name::String, userinput::T2;
|
||||||
maximumMsg::Integer=30) where {T1<:agent, T2<:AbstractString}
|
maximumMsg::Integer=30) where {T1<:agent, T2<:AbstractDict}
|
||||||
if name ∉ ["system", "user", "assistant"] # guard against typo
|
# if name ∉ ["system", "user", "assistant"] # guard against typo
|
||||||
error("name is not in agent.availableRole $(@__LINE__)")
|
# error("name is not in agent.availableRole $(@__LINE__)")
|
||||||
end
|
# end
|
||||||
|
|
||||||
#[PENDING] summarize the oldest 10 message
|
#TODO summarize the oldest 10 message
|
||||||
if length(a.chathistory) > maximumMsg
|
if length(a.chathistory) > maximumMsg
|
||||||
summarize(a.chathistory)
|
summarize(a.chathistory)
|
||||||
else
|
else
|
||||||
d = Dict(:name=> name, :text=> text, :timestamp=> Dates.now())
|
# userinput["timestamp"] = Dates.now()
|
||||||
push!(a.chathistory, d)
|
push!(a.chathistory, userinput)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -138,7 +129,7 @@ This function takes in a vector of dictionaries and outputs a single string wher
|
|||||||
|
|
||||||
julia> using Revise
|
julia> using Revise
|
||||||
julia> using GeneralUtils
|
julia> using GeneralUtils
|
||||||
julia> vecd = [Dict(:name => "John", :text => "Hello"), Dict(:name => "Jane", :text => "Goodbye")]
|
julia> vecd = [Dict("name" => "John", "text" => "Hello"), Dict("name" => "Jane", "text" => "Goodbye")]
|
||||||
julia> GeneralUtils.vectorOfDictToText(vecd, withkey=true)
|
julia> GeneralUtils.vectorOfDictToText(vecd, withkey=true)
|
||||||
"John> Hello\nJane> Goodbye\n"
|
"John> Hello\nJane> Goodbye\n"
|
||||||
```
|
```
|
||||||
@@ -209,9 +200,9 @@ end
|
|||||||
The subject or entity associated with the event
|
The subject or entity associated with the event
|
||||||
- `thought::Union{AbstractDict, Nothing}`
|
- `thought::Union{AbstractDict, Nothing}`
|
||||||
Any associated thoughts or metadata
|
Any associated thoughts or metadata
|
||||||
- `actionname::Union{String, Nothing}`
|
- `action_name::Union{String, Nothing}`
|
||||||
The name of the action performed (e.g., "CHAT", "CHECKINVENTORY")
|
The name of the action performed (e.g., "CHAT", "CHECKINVENTORY")
|
||||||
- `actioninput::Union{String, Nothing}`
|
- `action_input::Union{String, Nothing}`
|
||||||
Input or parameters for the action
|
Input or parameters for the action
|
||||||
- `location::Union{String, Nothing}`
|
- `location::Union{String, Nothing}`
|
||||||
Where the event took place
|
Where the event took place
|
||||||
@@ -232,8 +223,8 @@ function eventdict(;
|
|||||||
timestamp::Union{DateTime, Nothing}=nothing,
|
timestamp::Union{DateTime, Nothing}=nothing,
|
||||||
subject::Union{String, Nothing}=nothing,
|
subject::Union{String, Nothing}=nothing,
|
||||||
thought::Union{AbstractDict, Nothing}=nothing,
|
thought::Union{AbstractDict, Nothing}=nothing,
|
||||||
actionname::Union{String, Nothing}=nothing, # "CHAT", "CHECKINVENTORY", "PRESENTBOX", etc
|
action_name::Union{String, Nothing}=nothing, # "CHAT", "CHECKINVENTORY", "PRESENT_WINE_GUIDELINE", etc
|
||||||
actioninput::Union{String, Nothing}=nothing,
|
action_input::Union{String, Nothing}=nothing,
|
||||||
location::Union{String, Nothing}=nothing,
|
location::Union{String, Nothing}=nothing,
|
||||||
equipment_used::Union{String, Nothing}=nothing,
|
equipment_used::Union{String, Nothing}=nothing,
|
||||||
material_used::Union{String, Nothing}=nothing,
|
material_used::Union{String, Nothing}=nothing,
|
||||||
@@ -241,18 +232,18 @@ function eventdict(;
|
|||||||
note::Union{String, Nothing}=nothing,
|
note::Union{String, Nothing}=nothing,
|
||||||
)
|
)
|
||||||
|
|
||||||
d = Dict{Symbol, Any}(
|
d = Dict{String, Any}(
|
||||||
:event_description=> event_description,
|
"event_description"=> event_description,
|
||||||
:timestamp=> timestamp,
|
"timestamp"=> timestamp,
|
||||||
:subject=> subject,
|
"subject"=> subject,
|
||||||
:thought=> thought,
|
"thought"=> thought,
|
||||||
:actionname=> actionname,
|
"action_name"=> action_name,
|
||||||
:actioninput=> actioninput,
|
"action_input"=> action_input,
|
||||||
:location=> location,
|
"location"=> location,
|
||||||
:equipment_used=> equipment_used,
|
"equipment_used"=> equipment_used,
|
||||||
:material_used=> material_used,
|
"material_used"=> material_used,
|
||||||
:observation=> observation,
|
"observation"=> observation,
|
||||||
:note=> note,
|
"note"=> note,
|
||||||
)
|
)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
@@ -263,22 +254,22 @@ end
|
|||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
- `events::T1`
|
- `events::T1`
|
||||||
Vector of event dictionaries containing subject, actioninput and optional outcome fields
|
Vector of event dictionaries containing subject, action_input and optional outcome fields
|
||||||
Each event dictionary should have the following keys:
|
Each event dictionary should have the following keys:
|
||||||
- :subject - The subject or entity performing the action
|
- :subject - The subject or entity performing the action
|
||||||
- :actioninput - The action or input performed by the subject
|
- :action_input - The action or input performed by the subject
|
||||||
- :observation - (Optional) The result or outcome of the action
|
- :observation - (Optional) The result or outcome of the action
|
||||||
|
|
||||||
# Returns
|
# Returns
|
||||||
- `timeline::String`
|
- `timeline::String`
|
||||||
A formatted string representing the events with their subjects, actions, and optional outcomes
|
A formatted string representing the events with their subjects, actions, and optional outcomes
|
||||||
Format: "{index}) {subject}> {actioninput} {outcome}\n" for each event
|
Format: "{index}) {subject}> {action_input} {outcome}\n" for each event
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
events = [
|
events = [
|
||||||
Dict(:subject => "User", :actioninput => "Hello", :observation => nothing),
|
Dict("subject" => "User", "action_input" => "Hello", "observation" => nothing),
|
||||||
Dict(:subject => "Assistant", :actioninput => "Hi there!", :observation => "with a smile")
|
Dict("subject" => "Assistant", "action_input" => "Hi there!", "observation" => "with a smile")
|
||||||
]
|
]
|
||||||
timeline = createTimeline(events)
|
timeline = createTimeline(events)
|
||||||
# 1) User> Hello
|
# 1) User> Hello
|
||||||
@@ -302,55 +293,25 @@ function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothin
|
|||||||
for i in ind
|
for i in ind
|
||||||
event = events[i]
|
event = events[i]
|
||||||
# If no outcome exists, format without outcome
|
# If no outcome exists, format without outcome
|
||||||
# if event[:actionname] == "CHATBOX"
|
# if event["action_name"] == "CHAT_BOX"
|
||||||
# timeline *= "Event_$i $(event[:subject])> actionname: $(event[:actionname]), actioninput: $(event[:actioninput])\n"
|
# timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"])\n"
|
||||||
# elseif event[:actionname] == "CHECKINVENTORY" && event[:observation] === nothing
|
# elseif event["action_name"] == "CHECKINVENTORY" && event["observation"] === nothing
|
||||||
# timeline *= "Event_$i $(event[:subject])> actionname: $(event[:actionname]), actioninput: $(event[:actioninput]), 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 outcome exists, include it in formatting
|
if event["action_name"] == "SEARCH_WINE_DATABASE"
|
||||||
if event[:actionname] == "CHECKWINE"
|
timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"]), observation: $(event["observation"])\\n"
|
||||||
timeline *= "Event_$i $(event[:subject])> actionname: $(event[:actionname]), actioninput: $(event[:actioninput]), observation: $(event[:observation])\n"
|
|
||||||
else
|
else
|
||||||
timeline *= "Event_$i $(event[:subject])> actionname: $(event[:actionname]), actioninput: $(event[:actioninput])\n"
|
timeline *= "Event_$i $(event["subject"])> action_name: $(event["action_name"]), action_input: $(event["action_input"])\\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return formatted timeline string
|
# Return formatted timeline string
|
||||||
return timeline
|
return timeline
|
||||||
end
|
end
|
||||||
# function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothing
|
|
||||||
# ) where {T1<:AbstractVector}
|
|
||||||
# # Initialize empty timeline string
|
|
||||||
# timeline = ""
|
|
||||||
|
|
||||||
# # Determine which indices to use - either provided range or full length
|
|
||||||
# ind =
|
|
||||||
# if eventindex !== nothing
|
|
||||||
# [eventindex...]
|
|
||||||
# else
|
|
||||||
# 1:length(events)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# # Iterate through events and format each one
|
|
||||||
# for i in ind
|
|
||||||
# event = events[i]
|
|
||||||
# # If no outcome exists, format without outcome
|
|
||||||
# if event[:observation] === nothing
|
|
||||||
# timeline *= "Event_$i $(event[:subject])> actionname: $(event[:actionname]), actioninput: $(event[:actioninput]), observation: Not done yet.\n"
|
|
||||||
# # If outcome exists, include it in formatting
|
|
||||||
# else
|
|
||||||
# timeline *= "Event_$i $(event[:subject])> actionname: $(event[:actionname]), actioninput: $(event[:actioninput]), observation: $(event[:observation])\n"
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# # Return formatted timeline string
|
|
||||||
# return timeline
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
function createEventsLog(events::T1; index::Union{UnitRange, Nothing}=nothing
|
function createEventsLog(events::T1; index::Union{UnitRange, Nothing}=nothing
|
||||||
) where {T1<:AbstractVector}
|
) where {T1<:AbstractVector}
|
||||||
# Initialize empty log array
|
# Initialize empty log array
|
||||||
log = Dict{Symbol, String}[]
|
log = Dict{String, String}[]
|
||||||
|
|
||||||
# Determine which indices to use - either provided range or full length
|
# Determine which indices to use - either provided range or full length
|
||||||
ind =
|
ind =
|
||||||
@@ -364,20 +325,20 @@ function createEventsLog(events::T1; index::Union{UnitRange, Nothing}=nothing
|
|||||||
for i in ind
|
for i in ind
|
||||||
event = events[i]
|
event = events[i]
|
||||||
# If no outcome exists, format without outcome
|
# If no outcome exists, format without outcome
|
||||||
if event[:observation] === nothing
|
if event["observation"] === nothing
|
||||||
subject = event[:subject]
|
subject = event["subject"]
|
||||||
actionname = event[:actionname]
|
action_name = event["action_name"]
|
||||||
actioninput = event[:actioninput]
|
action_input = event["action_input"]
|
||||||
str = "actionname: $actionname, actioninput: $actioninput"
|
str = "action_name: $action_name, action_input: $action_input"
|
||||||
d = Dict{Symbol, String}(:name=>subject, :text=>str)
|
d = Dict{String, String}("name"=>subject, "text"=>str)
|
||||||
push!(log, d)
|
push!(log, d)
|
||||||
else
|
else
|
||||||
subject = event[:subject]
|
subject = event["subject"]
|
||||||
actionname = event[:actionname]
|
action_name = event["action_name"]
|
||||||
actioninput = event[:actioninput]
|
action_input = event["action_input"]
|
||||||
observation = event[:observation]
|
observation = event["observation"]
|
||||||
str = "actionname: $actionname, actioninput: $actioninput, observation: $observation"
|
str = "action_name: $action_name, action_input: $action_input, observation: $observation"
|
||||||
d = Dict{Symbol, String}(:name=>subject, :text=>str)
|
d = Dict{String, String}("name"=>subject, "text"=>str)
|
||||||
push!(log, d)
|
push!(log, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -389,7 +350,7 @@ end
|
|||||||
function createChatLog(chatdict::T1; index::Union{UnitRange, Nothing}=nothing
|
function createChatLog(chatdict::T1; index::Union{UnitRange, Nothing}=nothing
|
||||||
) where {T1<:AbstractVector}
|
) where {T1<:AbstractVector}
|
||||||
# Initialize empty log array
|
# Initialize empty log array
|
||||||
log = Dict{Symbol, String}[]
|
log = Dict{String, String}[]
|
||||||
|
|
||||||
# Determine which indices to use - either provided range or full length
|
# Determine which indices to use - either provided range or full length
|
||||||
ind =
|
ind =
|
||||||
@@ -402,9 +363,9 @@ function createChatLog(chatdict::T1; index::Union{UnitRange, Nothing}=nothing
|
|||||||
# Iterate through events and format each one
|
# Iterate through events and format each one
|
||||||
for i in ind
|
for i in ind
|
||||||
event = chatdict[i]
|
event = chatdict[i]
|
||||||
subject = event[:name]
|
subject = event["name"]
|
||||||
text = event[:text]
|
text = event["text"]
|
||||||
d = Dict{Symbol, String}(:name=>subject, :text=>text)
|
d = Dict{String, String}("name"=>subject, "text"=>text)
|
||||||
push!(log, d)
|
push!(log, d)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -431,26 +392,36 @@ function checkAgentResponse_text(response::String, requiredHeader::T
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function checkAgentResponse_JSON(responsedict::Dict, requiredKeys::T
|
|
||||||
)::Tuple where {T<:Array{Symbol}}
|
|
||||||
_responsedictKey = keys(responsedict)
|
|
||||||
responsedictKey = [i for i in _responsedictKey] # convert into a list
|
|
||||||
is_requiredKeys_in_responsedictKey = [i ∈ responsedictKey for i in requiredKeys]
|
|
||||||
ispass = false
|
|
||||||
errormsg = nothing
|
|
||||||
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
|
||||||
errormsg = "Your previous attempt has duplicated points according to the required response format"
|
|
||||||
ispass = false
|
|
||||||
elseif !all(is_requiredKeys_in_responsedictKey)
|
|
||||||
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
|
||||||
missingkeys = [requiredKeys[i] for i in zeroind]
|
|
||||||
errormsg = "$missingkeys are missing from your previous response"
|
|
||||||
ispass = false
|
|
||||||
else
|
|
||||||
ispass = true
|
|
||||||
end
|
|
||||||
return (ispass, errormsg)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
{
|
|
||||||
"mqttServerInfo": {
|
|
||||||
"description": "mqtt server info",
|
|
||||||
"port": 1883,
|
|
||||||
"broker": "mqtt.yiem.cc"
|
|
||||||
},
|
|
||||||
"testingOrProduction": {
|
|
||||||
"value": "testing",
|
|
||||||
"description": "agent status, couldbe testing or production"
|
|
||||||
},
|
|
||||||
"agentid": {
|
|
||||||
"value": "2b74b87a-5413-4fe2-a4d3-405891051680",
|
|
||||||
"description": "a unique id for this agent"
|
|
||||||
},
|
|
||||||
"agentCentralConfigTopic": {
|
|
||||||
"mqtttopic": "/yiem_branch_1/agent/sommelier/backend/config/api/v1.1",
|
|
||||||
"description": "a central agent server's topic to get this agent config"
|
|
||||||
},
|
|
||||||
"servicetopic": {
|
|
||||||
"mqtttopic": [
|
|
||||||
"/yiem/hq/agent/sommelier/backend/prompt/api_v1/testing"
|
|
||||||
],
|
|
||||||
"description": "a topic this agent are waiting for service request"
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
"value": "sommelier",
|
|
||||||
"description": "agent role"
|
|
||||||
},
|
|
||||||
"organization": {
|
|
||||||
"value": "yiem_branch_1",
|
|
||||||
"description": "organization name"
|
|
||||||
},
|
|
||||||
"externalservice": {
|
|
||||||
"loadbalancer": {
|
|
||||||
"mqtttopic": "/loadbalancer/requestingservice",
|
|
||||||
"description": "text to text service with instruct LLM"
|
|
||||||
},
|
|
||||||
"text2textinstruct": {
|
|
||||||
"mqtttopic": "/loadbalancer/requestingservice",
|
|
||||||
"description": "text to text service with instruct LLM",
|
|
||||||
"llminfo": {
|
|
||||||
"name": "llama3instruct"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"virtualWineCustomer_1": {
|
|
||||||
"mqtttopic": "/virtualenvironment/winecustomer",
|
|
||||||
"description": "text to text service with instruct LLM that act as wine customer",
|
|
||||||
"llminfo": {
|
|
||||||
"name": "llama3instruct"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"text2textchat": {
|
|
||||||
"mqtttopic": "/loadbalancer/requestingservice",
|
|
||||||
"description": "text to text service with instruct LLM",
|
|
||||||
"llminfo": {
|
|
||||||
"name": "llama3instruct"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"wineDB" : {
|
|
||||||
"description": "A wine database connection info for LibPQ client",
|
|
||||||
"host": "192.168.88.12",
|
|
||||||
"port": 10201,
|
|
||||||
"dbname": "wineDB",
|
|
||||||
"user": "yiemtechnologies",
|
|
||||||
"password": "yiemtechnologies@Postgres_0.0"
|
|
||||||
},
|
|
||||||
"SQLVectorDB" : {
|
|
||||||
"description": "A wine database connection info for LibPQ client",
|
|
||||||
"host": "192.168.88.12",
|
|
||||||
"port": 10203,
|
|
||||||
"dbname": "SQLVectorDB",
|
|
||||||
"user": "yiemtechnologies",
|
|
||||||
"password": "yiemtechnologies@Postgres_0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -66,7 +66,7 @@ tools=Dict( # update input format
|
|||||||
|
|
||||||
|
|
||||||
input =
|
input =
|
||||||
OrderedDict{Symbol, Any}(:question => "Hello, I would like a get a bottle of wine", :thought_1 => "It's great that the user is looking for a bottle of wine. To give them a personalized recommendation, I need to know more about their preferences.", :action_1 => Dict{Symbol, Any}(:name => "chatbox", :input => "What occasion are you planning to use this wine for?"), :observation_1 => "We are holding a wedding party", :thought_2 => "A wedding party is a great occasion for a special bottle of wine. I need to know what type of food will be served, and how much the user is willing to spend.", :action_2 => Dict{Symbol, Any}(:name => "chatbox", :input => "What type of food will you be serving at the wedding?"), :observation_2 => "It will be Thai dishes.", :thought_3 => "The type of wine that pairs well with Thai dishes is usually a crisp and refreshing white wine, but I also need to consider the budget and personal preferences.", :action_3 => Dict{Symbol, Any}(:name => "chatbox", :input => "How much are you willing to spend on this bottle of wine?"), :observation_3 => "I would spend up to 50 bucks.", :thought_4 => "I have a good idea of the occasion, food, and budget. Now I need to know what type of wine the user is looking for.", :action_4 => Dict{Symbol, Any}(:name => "chatbox", :input => "What type of wine are you usually looking for? Red, White, Sparkling, Rose, Dessert or Fortified?"), :observation_4 => "I like full-bodied Red wine with low tannin.", :thought_5 => "Now that I have all the necessary information, I can start searching for a suitable wine in our inventory.", :action_5 => Dict{Symbol, Any}(:name => "winestock", :input => "red wine with low tannins"), :observation_5 => "I found the following wines in our stock: \n{\n 1: El Enemigo Cabernet Franc 2019\n2: Tantara Chardonnay 2017\n\n}\n", :thought_6 => "Now that I have the information about the wine, it's time to make a recommendation.", :action_6 => Dict{Symbol, Any}(:name => "recommendbox", :input => "El Enemigo Cabernet Franc 2019"), :observation_6 => "I don't like the one you recommend. I want dry wine.")
|
OrderedDict{String, Any}(:question => "Hello, I would like a get a bottle of wine", :thought_1 => "It's great that the user is looking for a bottle of wine. To give them a personalized recommendation, I need to know more about their preferences.", :action_1 => Dict{String, Any}(:name => "chatbox", :input => "What occasion are you planning to use this wine for?"), :observation_1 => "We are holding a wedding party", :thought_2 => "A wedding party is a great occasion for a special bottle of wine. I need to know what type of food will be served, and how much the user is willing to spend.", :action_2 => Dict{String, Any}(:name => "chatbox", :input => "What type of food will you be serving at the wedding?"), :observation_2 => "It will be Thai dishes.", :thought_3 => "The type of wine that pairs well with Thai dishes is usually a crisp and refreshing white wine, but I also need to consider the budget and personal preferences.", :action_3 => Dict{String, Any}(:name => "chatbox", :input => "How much are you willing to spend on this bottle of wine?"), :observation_3 => "I would spend up to 50 bucks.", :thought_4 => "I have a good idea of the occasion, food, and budget. Now I need to know what type of wine the user is looking for.", :action_4 => Dict{String, Any}(:name => "chatbox", :input => "What type of wine are you usually looking for? Red, White, Sparkling, Rose, Dessert or Fortified?"), :observation_4 => "I like full-bodied Red wine with low tannin.", :thought_5 => "Now that I have all the necessary information, I can start searching for a suitable wine in our inventory.", :action_5 => Dict{String, Any}(:name => "winestock", :input => "red wine with low tannins"), :observation_5 => "I found the following wines in our stock: \n{\n 1: El Enemigo Cabernet Franc 2019\n2: Tantara Chardonnay 2017\n\n}\n", :thought_6 => "Now that I have the information about the wine, it's time to make a recommendation.", :action_6 => Dict{String, Any}(:name => "recommendbox", :input => "El Enemigo Cabernet Franc 2019"), :observation_6 => "I don't like the one you recommend. I want dry wine.")
|
||||||
|
|
||||||
|
|
||||||
result = YiemAgent.jsoncorrection(a, input)
|
result = YiemAgent.jsoncorrection(a, input)
|
||||||
|
|||||||
@@ -0,0 +1,223 @@
|
|||||||
|
|
||||||
|
using JSON, Dates, UUIDs, PrettyPrinting, Base64, NATS, HTTP
|
||||||
|
using GeneralUtils, msghandler
|
||||||
|
|
||||||
|
config = JSON.parsefile("./appconfig.json")
|
||||||
|
|
||||||
|
agent_conn = NATS.connect(config["nats_server_info"]["url"])
|
||||||
|
|
||||||
|
function text2text_instruct_llm(sender_id::String, openai_msg::Dict{String, Any})
|
||||||
|
payloads = [("msg", openai_msg, "dictionary")] # List of tuples
|
||||||
|
_, msg_envelope_json_str = msghandler.smartpack(
|
||||||
|
config["externalservice"]["servicesloadbalancer"]["nats"],
|
||||||
|
payloads;
|
||||||
|
sender_id=sender_id,
|
||||||
|
msg_purpose="text2text",
|
||||||
|
broker_url=config["nats_server_info"]["url"],
|
||||||
|
fileserver_url=config["externalservice"]["fileserver"]["url"])
|
||||||
|
|
||||||
|
reply = NATS.request(agent_conn,
|
||||||
|
config["externalservice"]["servicesloadbalancer"]["nats"],
|
||||||
|
msg_envelope_json_str, timeout=120)
|
||||||
|
|
||||||
|
incoming_env_json_str = String(reply.payload)
|
||||||
|
incoming_env = msghandler.smartunpack(incoming_env_json_str)
|
||||||
|
_llm_response = incoming_env["payloads"][1][2]
|
||||||
|
llm_response = _llm_response["choices"][1]["message"]["content"]
|
||||||
|
return llm_response
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 1. Read local file and encode to base64 string
|
||||||
|
image1_path = "test/large_image.png"
|
||||||
|
image1_bytes = read(image1_path)
|
||||||
|
image1_base64_string = base64encode(image1_bytes)
|
||||||
|
|
||||||
|
# 2. Match the MIME type according to your file extension (e.g., png, jpeg)
|
||||||
|
mime_type = "image/png"
|
||||||
|
data1_uri = "data:$(mime_type);base64,$(image1_base64_string)"
|
||||||
|
|
||||||
|
# 3. Construct payload with the Data URI
|
||||||
|
openai_msg = Dict(
|
||||||
|
"model" => "gemma-4-E4B-it-UD-Q4_K_XL",
|
||||||
|
"messages" => [
|
||||||
|
Dict(
|
||||||
|
"role" => "user",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "Do you know this wine? Just give me brief intro."),
|
||||||
|
Dict(
|
||||||
|
"type" => "image_url",
|
||||||
|
"image_url" => Dict("url" => data1_uri)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
],
|
||||||
|
"temperature" => 0.7
|
||||||
|
)
|
||||||
|
|
||||||
|
llm_response = text2text_instruct_llm(openai_msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 1. Read local file and encode to base64 string
|
||||||
|
image2_path = "test/large_image.png"
|
||||||
|
image2_bytes = read(image2_path)
|
||||||
|
image2_base64_string = base64encode(image2_bytes)
|
||||||
|
|
||||||
|
# 2. Match the MIME type according to your file extension (e.g., png, jpeg)
|
||||||
|
mime_type = "image/png"
|
||||||
|
data2_uri = "data:$(mime_type);base64,$(image2_base64_string)"
|
||||||
|
|
||||||
|
systemmsg =
|
||||||
|
"""
|
||||||
|
# Store Policy
|
||||||
|
- Generally speaking, the store inventory has some wines from France, the United States, Australia, Spain, and Italy, but you won't know exactly until you check your inventory.
|
||||||
|
- If you found wines in the store's database, they are in stock.
|
||||||
|
- You can only recommend wines that are currently in our inventory
|
||||||
|
- Before searching the database for wine, ensure you have at least the following information: 1) budget, 2) wine type, and 3) occasion. Additional details are always helpful. If the user is unsure, provide relevant information and gather insights to make reasonable inferences.
|
||||||
|
- Ask the user one question at a time.
|
||||||
|
- Do not ask the user about wine's flavor e.g. floral, citrusy, nutty or some thing similar as these terms cannot be used to search the database.
|
||||||
|
- Once the user has selected their wine, if you haven't already, ask the user whether they need any further assistance. Do not offer any additional services.
|
||||||
|
- Only end the conversation when the user explicitly intends to do so. When ending, ensure a polite farewell and an invitation to return in the future.
|
||||||
|
- Spicy foods should be paired only with light red wines.
|
||||||
|
- We do not sell organic, sustainable, gluten-free, and sulfite-free wine. Inform the user imediately if they are looking for these types of wines. Do not sell our wines as such.
|
||||||
|
- Gift box, gift card, and custom messages are available. Inform the user to contact our sales team.
|
||||||
|
|
||||||
|
# Store Guidelines
|
||||||
|
- Greeting the customer warmly by ask them how could you help. Do not ask any other questions during this greeting.
|
||||||
|
- Customer may provide images for you to look up.
|
||||||
|
- Encourage the customer to explore different options and try new things.
|
||||||
|
- If you are unable to locate the desired item in the database after 2 attempts, it may not be available in your inventory. In such cases, inform the user that the item is unavailable and suggest an alternative instead.
|
||||||
|
- Your store carries only wine.
|
||||||
|
- Vintage 0 means non-vintage.
|
||||||
|
- Start searching the database as broadly as possible within the given information boundary to maximize the chances of finding. Avoid unnecessary parameters unless specified by the user. Refine the search subsequently.
|
||||||
|
|
||||||
|
# Situation
|
||||||
|
Your customer is coming into the store
|
||||||
|
|
||||||
|
# Role
|
||||||
|
Your name is Janie. You are a helpful sommelier for website-based Yiem Wine's wine store. You are working under your mentor supervision.
|
||||||
|
|
||||||
|
# Objective
|
||||||
|
1. Establish a connection with the customer by talking to them politely and showing your enthusiasm for their wine preferences.
|
||||||
|
2. Provide relevant information and guide them to select the best wines only from your store's inventory that align with their preferences.
|
||||||
|
|
||||||
|
# Responsibility Includes
|
||||||
|
1. According to the store's policy and guidelines, make an informed decision about what you need to do to achieve the objective
|
||||||
|
2. Keep the conversation with the customer going smoothly
|
||||||
|
3. Obey your mentor's suggestions.
|
||||||
|
|
||||||
|
# Responsibility Does NOT Include
|
||||||
|
|
||||||
|
1. Requesting the user to place an order, make a purchase, or confirm the order. These are the job of our sales team at the store.
|
||||||
|
2. Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store.
|
||||||
|
3. Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store.
|
||||||
|
|
||||||
|
# You should then respond to the user with interleaving plan, action_name, action_input
|
||||||
|
1) plan: Based on the current situation, state a complete action plan to complete the task and rationale. Be specific.
|
||||||
|
2) action_name: (Typically corresponds to the execution of the first step in your plan) Can be one of the available_actions name
|
||||||
|
3) action_input: The input to the action you are about to perform according to your plan.
|
||||||
|
After the action is executed you gets "action_result". It is the output from the action you selected.
|
||||||
|
|
||||||
|
# You should only respond in JSON format as described below
|
||||||
|
"plan": "...",
|
||||||
|
"action_name": "...",
|
||||||
|
"action_input": "..."
|
||||||
|
|
||||||
|
# Available Actions
|
||||||
|
- **CHAT_BOX** which you can use to talk with the user.
|
||||||
|
- **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 2: "Red or white wine, medium tannin, price under 700 USD"
|
||||||
|
- Example query 3: "white wine, region: Tuscany or Bordeaux, country: Italy or France
|
||||||
|
- **PRESENT_WINE_GUIDELINE** which you can use to check the store guidelines about how to present wines you have found to the user. The input is "nothing" keyword. The output is the guidelines that you can follow.
|
||||||
|
- **END_CONVER_GUIDELINE** which you can use to check the store guidelines about how to end the conversation with the user. The input is "nothing" keyword. The output is the guidelines that you can follow.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
openai_msg = Dict(
|
||||||
|
"model" => "gemma-4-E4B-it-UD-Q4_K_XL",
|
||||||
|
"messages" => [
|
||||||
|
Dict(
|
||||||
|
"role" => "system",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => systemmsg),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
Dict(
|
||||||
|
"role" => "user",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "Do you know this wine? Just give me brief intro."),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
Dict(
|
||||||
|
"role" => "assistant",
|
||||||
|
"content" => [
|
||||||
|
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 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>"
|
||||||
|
"""
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
Dict(
|
||||||
|
"role" => "user",
|
||||||
|
"content" => [
|
||||||
|
Dict("type" => "text", "text" => "ok"),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
],
|
||||||
|
"temperature" => 0.7
|
||||||
|
)
|
||||||
|
|
||||||
|
llm_response = text2text_instruct_llm(openai_msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------- 100 --------------------------------------------- #
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
+401
@@ -0,0 +1,401 @@
|
|||||||
|
using JSON, Dates, UUIDs, PrettyPrinting, LibPQ, Base64, DataFrames, DataStructures, HTTP, Base64,
|
||||||
|
NATS, Base.Threads
|
||||||
|
using YiemAgent, GeneralUtils, msghandler
|
||||||
|
|
||||||
|
function text2text_instruct_llm(sender_id::String, openai_msg::Dict{String, Any})
|
||||||
|
payloads = [("msg", openai_msg, "dictionary")] # List of tuples
|
||||||
|
_, msg_envelope_json_str = msghandler.smartpack(
|
||||||
|
config["externalservice"]["servicesloadbalancer"]["nats"],
|
||||||
|
payloads;
|
||||||
|
sender_id=sender_id,
|
||||||
|
msg_purpose="text2text",
|
||||||
|
broker_url=config["nats_server_info"]["url"],
|
||||||
|
fileserver_url=config["externalservice"]["fileserver"]["url"])
|
||||||
|
|
||||||
|
reply = NATS.request(agent_conn,
|
||||||
|
config["externalservice"]["servicesloadbalancer"]["nats"],
|
||||||
|
msg_envelope_json_str, timeout=120)
|
||||||
|
|
||||||
|
incoming_env_json_str = String(reply.payload)
|
||||||
|
incoming_env = msghandler.smartunpack(incoming_env_json_str)
|
||||||
|
_llm_response = incoming_env["payloads"][1][2]
|
||||||
|
llm_response = _llm_response["choices"][1]["message"]["content"]
|
||||||
|
return llm_response
|
||||||
|
end
|
||||||
|
|
||||||
|
""" get a single text embedding from a LLM service
|
||||||
|
Example
|
||||||
|
text = ["hello"]
|
||||||
|
embedding = get_embedding(text)
|
||||||
|
"""
|
||||||
|
function get_embedding(text::AbstractArray{String})
|
||||||
|
documents_dict = Dict("documents" => text)
|
||||||
|
payloads = [("documents", documents_dict, "dictionary")]
|
||||||
|
_, msg_envelope_json_str = msghandler.smartpack(
|
||||||
|
config["externalservice"]["servicesloadbalancer"]["nats"],
|
||||||
|
payloads;
|
||||||
|
msg_purpose="embedding",
|
||||||
|
broker_url=config["nats_server_info"]["url"],
|
||||||
|
fileserver_url=config["externalservice"]["fileserver"]["url"])
|
||||||
|
|
||||||
|
reply = NATS.request(agent_conn,
|
||||||
|
config["externalservice"]["servicesloadbalancer"]["nats"],
|
||||||
|
msg_envelope_json_str, timeout=120)
|
||||||
|
incoming_env_json_str = String(reply.payload)
|
||||||
|
incoming_env = msghandler.smartunpack(incoming_env_json_str)
|
||||||
|
embedding_response = incoming_env["payloads"][1][2]
|
||||||
|
|
||||||
|
return embedding_response
|
||||||
|
end
|
||||||
|
|
||||||
|
""" sql = "SELECT * FROM wine;"
|
||||||
|
result = execute_sql_winedb(sql)
|
||||||
|
"""
|
||||||
|
function execute_sql_winedb(sql::T) where {T<:AbstractString}
|
||||||
|
host_url, _port = split(config["externalservice"]["sommpanion_db"]["url"], ':')
|
||||||
|
port = parse(Int, _port)
|
||||||
|
dbname = "winedb"
|
||||||
|
user = config["externalservice"]["sommpanion_db"]["user"]
|
||||||
|
password = config["externalservice"]["sommpanion_db"]["password"]
|
||||||
|
db_connection = LibPQ.Connection("host=$host_url port=$port dbname=$dbname user=$user password=$password")
|
||||||
|
result = nothing
|
||||||
|
try
|
||||||
|
result = LibPQ.execute(db_connection, sql)
|
||||||
|
catch e
|
||||||
|
LibPQ.close(db_connection)
|
||||||
|
end
|
||||||
|
|
||||||
|
LibPQ.close(db_connection)
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
""" find similar sql from vector database
|
||||||
|
sql = "SELECT * FROM wine;"
|
||||||
|
result, distance = similar_sql_vectordb(sql)
|
||||||
|
"""
|
||||||
|
function similar_sql_vectordb(sql::T; maxdistance::Number=0.2) where {T<:AbstractString}
|
||||||
|
tablename = "sqlllm_decision_repository"
|
||||||
|
# get embedding of the query
|
||||||
|
df = find_similar_text_from_vectordb(sql, tablename,
|
||||||
|
"function_input_embedding", execute_sql_vectordb)
|
||||||
|
# println(df[1, [:id, :function_output]])
|
||||||
|
row, col = size(df)
|
||||||
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
|
if row != 0 && distance < maxdistance
|
||||||
|
# if there is usable SQL, return it.
|
||||||
|
output_b64 = df[1, :function_output_base64] # pick the closest match
|
||||||
|
output_str = String(base64decode(output_b64))
|
||||||
|
rowid = df[1, :id]
|
||||||
|
println("\n--| similar sql found. row id $rowid, distance $distance ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
|
pprintln(output_str)
|
||||||
|
return (result=output_str, distance=distance)
|
||||||
|
else
|
||||||
|
println("\n--| similar sql not found, max distance $maxdistance ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
|
return (result=nothing, distance=nothing)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
""" insert query and sql into vector database
|
||||||
|
query = "get all wines from wine table"
|
||||||
|
sql = "SELECT * FROM wine;"
|
||||||
|
insert_sql_vectordb(query, sql)
|
||||||
|
"""
|
||||||
|
function insert_sql_vectordb(query::T1, SQL::T2; maxdistance::Number=3
|
||||||
|
) where {T1<:AbstractString, T2<:AbstractString}
|
||||||
|
|
||||||
|
tablename = "sqlllm_decision_repository"
|
||||||
|
# get embedding of the query
|
||||||
|
# query = state[:thoughtHistory][:question]
|
||||||
|
df = find_similar_text_from_vectordb(query, tablename,
|
||||||
|
"function_input_embedding", execute_sql_vectordb)
|
||||||
|
row, col = size(df)
|
||||||
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
|
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
|
||||||
|
_query_embedding = get_embedding([query])
|
||||||
|
_query_embedding = GeneralUtils.dictify(_query_embedding)
|
||||||
|
# println("\n--- _query_embedding() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
|
# println(_query_embedding)
|
||||||
|
# println("---\n")
|
||||||
|
query_embedding = _query_embedding["data"][1]["embedding"]
|
||||||
|
query = replace(query, "'" => "")
|
||||||
|
sql_base64 = base64encode(SQL)
|
||||||
|
sql_ = replace(SQL, "'" => "")
|
||||||
|
|
||||||
|
sql =
|
||||||
|
"""
|
||||||
|
INSERT INTO $tablename (function_input, function_output, function_output_base64, function_input_embedding) VALUES ('$query', '$sql_', '$sql_base64', '$query_embedding');
|
||||||
|
"""
|
||||||
|
# println("\n--| added new decision to vectorDB ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
|
# println(sql)
|
||||||
|
_ = execute_sql_vectordb(sql)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
""" execute sql against vectordb
|
||||||
|
sql = "SELECT * FROM wine;"
|
||||||
|
result = execute_sql_vectordb(sql)
|
||||||
|
"""
|
||||||
|
function execute_sql_vectordb(sql::T) where {T<:AbstractString}
|
||||||
|
host_url, _port = split(config["externalservice"]["sommpanion_vectordb"]["url"], ':')
|
||||||
|
port = parse(Int, _port)
|
||||||
|
dbname = config["externalservice"]["sommpanion_vectordb"]["dbname"]
|
||||||
|
user = config["externalservice"]["sommpanion_vectordb"]["user"]
|
||||||
|
password = config["externalservice"]["sommpanion_vectordb"]["password"]
|
||||||
|
DBconnection = LibPQ.Connection("host=$host_url port=$port dbname=$dbname user=$user password=$password")
|
||||||
|
result = LibPQ.execute(DBconnection, sql)
|
||||||
|
close(DBconnection)
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
""" search similar decision llm made from vectordb
|
||||||
|
"""
|
||||||
|
function similar_sommelier_decision(recentevents::T1; maxdistance::Integer=3
|
||||||
|
)::Union{AbstractDict, Nothing} where {T1<:AbstractString}
|
||||||
|
|
||||||
|
tablename = "sommelier_decision_repository"
|
||||||
|
# find similar
|
||||||
|
df = find_similar_text_from_vectordb(recentevents, tablename,
|
||||||
|
"function_input_embedding", execute_sql_vectordb)
|
||||||
|
row, col = size(df)
|
||||||
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
|
if row != 0 && distance < maxdistance
|
||||||
|
# if there is usable decision, return it.
|
||||||
|
rowid = df[1, :id]
|
||||||
|
println("\n--| found similar decision. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__)
|
||||||
|
output_b64 = df[1, :function_output_base64] # pick the closest match
|
||||||
|
_output_str = String(base64decode(output_b64))
|
||||||
|
output = copy(JSON.read(_output_str))
|
||||||
|
return output
|
||||||
|
else
|
||||||
|
println("\n--| similar decision not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__)
|
||||||
|
return nothing
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
""" search similar text from vectordb
|
||||||
|
"""
|
||||||
|
function find_similar_text_from_vectordb(text::T1, tablename::T2, embeddingColumnName::T3,
|
||||||
|
vectorDB::Function; limit::Integer=1
|
||||||
|
)::DataFrame where {T1<:AbstractString, T2<:AbstractString, T3<:AbstractString}
|
||||||
|
# get embedding from LLM service
|
||||||
|
_embedding = get_embedding([text])
|
||||||
|
_embedding = _embedding["data"][1]["embedding"]
|
||||||
|
_embedding = "$_embedding"
|
||||||
|
|
||||||
|
embedding = _embedding[4:end]
|
||||||
|
|
||||||
|
# check whether there is close enough vector already store in vectorDB. if no, add, else skip
|
||||||
|
sql = """
|
||||||
|
SELECT *, $embeddingColumnName <-> '$embedding' as distance
|
||||||
|
FROM $tablename
|
||||||
|
ORDER BY distance LIMIT $limit;
|
||||||
|
"""
|
||||||
|
response = vectorDB(sql)
|
||||||
|
df = DataFrame(response)
|
||||||
|
|
||||||
|
return df
|
||||||
|
end
|
||||||
|
|
||||||
|
""" insert decision llm made to vectordb
|
||||||
|
"""
|
||||||
|
function insert_sommelier_decision(recentevents::T1, decision::T2; maxdistance::Integer=5
|
||||||
|
) where {T1<:AbstractString, T2<:AbstractDict}
|
||||||
|
tablename = "sommelier_decision_repository"
|
||||||
|
# find similar
|
||||||
|
df = find_similar_text_from_vectordb(recentevents, tablename,
|
||||||
|
"function_input_embedding", execute_sql_vectordb)
|
||||||
|
row, col = size(df)
|
||||||
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
|
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
|
||||||
|
_embedding = get_embedding([recentevents])[1]
|
||||||
|
recentevents_embedding = _embedding["data"][1]["embedding"]
|
||||||
|
recentevents = replace(recentevents, "'" => "")
|
||||||
|
decision_json = JSON.json(decision)
|
||||||
|
decision_base64 = base64encode(decision_json)
|
||||||
|
decision = replace(decision_json, "'" => "")
|
||||||
|
|
||||||
|
sql =
|
||||||
|
"""
|
||||||
|
INSERT INTO $tablename (function_input, function_output, function_output_base64, function_input_embedding) VALUES ('$recentevents', '$decision', '$decision_base64', '$recentevents_embedding');
|
||||||
|
"""
|
||||||
|
println("\n--| added new decision to vectorDB ", @__FILE__, " ", @__LINE__)
|
||||||
|
println(sql)
|
||||||
|
_ = execute_sql_vectordb(sql)
|
||||||
|
else
|
||||||
|
println("--| similar decision previously cached, distance $distance ", @__FILE__, " ", @__LINE__)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config = JSON.parsefile("./appconfig.json")
|
||||||
|
sessionId = "0"
|
||||||
|
backend_session_topic = "sommpanion.testsubject"
|
||||||
|
agent_ch = Channel(8)
|
||||||
|
agent_conn = NATS.connect(config["nats_server_info"]["url"])
|
||||||
|
|
||||||
|
sub2 = NATS.subscribe(agent_conn, backend_session_topic) do msg
|
||||||
|
put!(agent_ch, msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
agent_context = YiemAgent.agentcontext(
|
||||||
|
text2text_instruct_llm,
|
||||||
|
get_embedding,
|
||||||
|
execute_sql_winedb,
|
||||||
|
similar_sql_vectordb,
|
||||||
|
insert_sql_vectordb,
|
||||||
|
similar_sommelier_decision,
|
||||||
|
insert_sommelier_decision
|
||||||
|
)
|
||||||
|
|
||||||
|
# can't instantiate
|
||||||
|
agent = YiemAgent.sommelier(
|
||||||
|
agent_context;
|
||||||
|
name="Janie",
|
||||||
|
id=sessionId, # agent instance id
|
||||||
|
retailername="Yiem Wine Ltd.",
|
||||||
|
llmFormatName=""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
image1_path = "test/large_image.png"
|
||||||
|
image1_bytes = read(image1_path)
|
||||||
|
image1_base64_string = base64encode(image1_bytes)
|
||||||
|
mime_type = "image/png"
|
||||||
|
data1_uri = "data:$(mime_type);base64,$(image1_base64_string)"
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
result = YiemAgent.conversation(agent; userinput=message)
|
||||||
|
println("\n$result")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# message = Dict(
|
||||||
|
# "role" => "user",
|
||||||
|
# "content" => [
|
||||||
|
# Dict("type" => "text", "text" =>
|
||||||
|
# "
|
||||||
|
# เป็นงานเลี้ยงทั่วไป
|
||||||
|
# "),
|
||||||
|
# ]
|
||||||
|
# )
|
||||||
|
|
||||||
|
# result = YiemAgent.conversation(agent; userinput=message)
|
||||||
|
# println("\n$result")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# message = Dict(
|
||||||
|
# "role" => "user",
|
||||||
|
# "content" => [
|
||||||
|
# Dict("type" => "text", "text" => "no thanks. that's all"),
|
||||||
|
# ]
|
||||||
|
# )
|
||||||
|
|
||||||
|
# result = YiemAgent.conversation(agent; userinput=message)
|
||||||
|
# println("\n$result")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# message = Dict(
|
||||||
|
# "role" => "user",
|
||||||
|
# "content" => [
|
||||||
|
# Dict("type" => "text", "text" => "What about this wine?"),
|
||||||
|
# Dict(
|
||||||
|
# "type" => "image_url",
|
||||||
|
# "image_url" => Dict("url" => data2_uri)
|
||||||
|
# )
|
||||||
|
# ]
|
||||||
|
# )
|
||||||
|
|
||||||
|
# result = YiemAgent.conversation(agent; userinput=message)
|
||||||
|
# println("\n$result")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Reference in New Issue
Block a user