Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e524813021 | ||
|
|
3444f00062 | ||
|
|
919d8ec85e | ||
|
|
3a88e0e7d4 | ||
|
|
68c2c2f12b | ||
|
|
3e79c0bfed | ||
|
|
d0c26e52e8 | ||
|
|
a0152a3c29 | ||
|
|
1fc5dfe820 | ||
|
|
4b2575f4a4 | ||
|
|
a01a91e7b9 | ||
|
|
aa8436c0ed | ||
|
|
cccad676db | ||
|
|
03de659c9b | ||
|
|
affb96f0cf | ||
|
|
f19f302bd9 | ||
|
|
7ca4f5276d | ||
|
|
44804041a3 | ||
|
|
48a3704f6d | ||
| 8321a13afc | |||
| b26ae31d4c | |||
|
|
b397bf7bdb | ||
|
|
c0edf7dadf | ||
|
|
c21f943b12 | ||
|
|
b8fd772a28 | ||
|
|
883f581b2a | ||
|
|
5a890860a6 | ||
| 7d5bc14a09 | |||
|
|
37ba3a9d31 | ||
| bfadd53033 | |||
| 8fc3afe348 | |||
| c60037226a | |||
|
|
db6c9c5f2b | ||
|
|
6504099959 | ||
| 724b092bdb | |||
| c56c3d02b0 | |||
|
|
a7f3e29e9c | ||
|
|
b8fc23b41e | ||
|
|
cf4cd13b14 | ||
|
|
29adc077d5 | ||
|
|
d89d425885 | ||
|
|
bb81b973d3 | ||
|
|
4197625e57 | ||
|
|
3fdc0adf99 | ||
|
|
c7000f66b8 | ||
|
|
2206831bab | ||
|
|
a29e8049a7 | ||
|
|
944d9eaf2b | ||
|
|
616c159336 | ||
|
|
022cb5caf0 | ||
| cff0d31ae6 | |||
| 82167fe006 | |||
| 814a0ecc6a | |||
| 795e8a6e31 | |||
| 9768f22019 | |||
| 178750db9a | |||
| 27944a178b | |||
| 00f1a6775b | |||
|
|
becda0b309 | ||
|
|
bc002a3ef4 | ||
|
|
d763727d7d |
@@ -1,8 +1,8 @@
|
|||||||
# This file is machine-generated - editing it directly is not advised
|
# This file is machine-generated - editing it directly is not advised
|
||||||
|
|
||||||
julia_version = "1.11.2"
|
julia_version = "1.11.4"
|
||||||
manifest_format = "2.0"
|
manifest_format = "2.0"
|
||||||
project_hash = "b483014657ef9f0fde60d7258585b291d6f0eeca"
|
project_hash = "cb7f3c57318e927e8ac4dc2dea9acdcace566ed1"
|
||||||
|
|
||||||
[[deps.AliasTables]]
|
[[deps.AliasTables]]
|
||||||
deps = ["PtrArrays", "Random"]
|
deps = ["PtrArrays", "Random"]
|
||||||
@@ -120,9 +120,9 @@ 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", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
|
||||||
git-tree-sha1 = "3101c32aab536e7a27b1763c0797dba151b899ad"
|
git-tree-sha1 = "0b4190661e8a4e51a842070e7dd4fae440ddb7f4"
|
||||||
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
||||||
version = "0.25.113"
|
version = "0.25.118"
|
||||||
|
|
||||||
[deps.Distributions.extensions]
|
[deps.Distributions.extensions]
|
||||||
DistributionsChainRulesCoreExt = "ChainRulesCore"
|
DistributionsChainRulesCoreExt = "ChainRulesCore"
|
||||||
@@ -158,9 +158,9 @@ version = "0.1.10"
|
|||||||
|
|
||||||
[[deps.FileIO]]
|
[[deps.FileIO]]
|
||||||
deps = ["Pkg", "Requires", "UUIDs"]
|
deps = ["Pkg", "Requires", "UUIDs"]
|
||||||
git-tree-sha1 = "2dd20384bf8c6d411b5c7370865b1e9b26cb2ea3"
|
git-tree-sha1 = "b66970a70db13f45b7e57fbda1736e1cf72174ea"
|
||||||
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
|
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
|
||||||
version = "1.16.6"
|
version = "1.17.0"
|
||||||
weakdeps = ["HTTP"]
|
weakdeps = ["HTTP"]
|
||||||
|
|
||||||
[deps.FileIO.extensions]
|
[deps.FileIO.extensions]
|
||||||
@@ -168,9 +168,9 @@ weakdeps = ["HTTP"]
|
|||||||
|
|
||||||
[[deps.FilePathsBase]]
|
[[deps.FilePathsBase]]
|
||||||
deps = ["Compat", "Dates"]
|
deps = ["Compat", "Dates"]
|
||||||
git-tree-sha1 = "7878ff7172a8e6beedd1dea14bd27c3c6340d361"
|
git-tree-sha1 = "3bab2c5aa25e7840a4b065805c0cdfc01f3068d2"
|
||||||
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
|
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
|
||||||
version = "0.9.22"
|
version = "0.9.24"
|
||||||
weakdeps = ["Mmap", "Test"]
|
weakdeps = ["Mmap", "Test"]
|
||||||
|
|
||||||
[deps.FilePathsBase.extensions]
|
[deps.FilePathsBase.extensions]
|
||||||
@@ -200,11 +200,9 @@ version = "1.11.0"
|
|||||||
|
|
||||||
[[deps.GeneralUtils]]
|
[[deps.GeneralUtils]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "JSON3", "MQTTClient", "PrettyPrinting", "Random", "SHA", "UUIDs"]
|
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "JSON3", "MQTTClient", "PrettyPrinting", "Random", "SHA", "UUIDs"]
|
||||||
git-tree-sha1 = "978d9a5c3fc30205dd72d4a2a2ed4fa85ebee5cf"
|
path = "/appfolder/app/dev/GeneralUtils"
|
||||||
repo-rev = "main"
|
|
||||||
repo-url = "https://git.yiem.cc/ton/GeneralUtils"
|
|
||||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
||||||
version = "0.1.0"
|
version = "0.2.3"
|
||||||
|
|
||||||
[[deps.HTTP]]
|
[[deps.HTTP]]
|
||||||
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "PrecompileTools", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
|
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "PrecompileTools", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
|
||||||
@@ -214,9 +212,9 @@ version = "1.10.13"
|
|||||||
|
|
||||||
[[deps.HypergeometricFunctions]]
|
[[deps.HypergeometricFunctions]]
|
||||||
deps = ["LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
|
deps = ["LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
|
||||||
git-tree-sha1 = "b1c2585431c382e3fe5805874bda6aea90a95de9"
|
git-tree-sha1 = "68c173f4f449de5b438ee67ed0c9c748dc31a2ec"
|
||||||
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
|
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
|
||||||
version = "0.3.25"
|
version = "0.3.28"
|
||||||
|
|
||||||
[[deps.ICU_jll]]
|
[[deps.ICU_jll]]
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
|
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
|
||||||
@@ -260,9 +258,9 @@ uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
|
|||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
|
||||||
[[deps.IrrationalConstants]]
|
[[deps.IrrationalConstants]]
|
||||||
git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2"
|
git-tree-sha1 = "e2222959fbc6c19554dc15174c81bf7bf3aa691c"
|
||||||
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
|
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
|
||||||
version = "0.2.2"
|
version = "0.2.4"
|
||||||
|
|
||||||
[[deps.IterTools]]
|
[[deps.IterTools]]
|
||||||
git-tree-sha1 = "42d5f897009e7ff2cf88db414a389e5ed1bdd023"
|
git-tree-sha1 = "42d5f897009e7ff2cf88db414a389e5ed1bdd023"
|
||||||
@@ -305,12 +303,10 @@ uuid = "b39eb1a6-c29a-53d7-8c32-632cd16f18da"
|
|||||||
version = "1.19.3+0"
|
version = "1.19.3+0"
|
||||||
|
|
||||||
[[deps.LLMMCTS]]
|
[[deps.LLMMCTS]]
|
||||||
deps = ["GeneralUtils", "JSON3"]
|
deps = ["GeneralUtils", "JSON3", "PrettyPrinting"]
|
||||||
git-tree-sha1 = "d8c653b8fafbd3757b7332985efaf1fdb8b6fe97"
|
path = "/appfolder/app/dev/LLMMCTS"
|
||||||
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.2"
|
version = "0.1.4"
|
||||||
|
|
||||||
[[deps.LaTeXStrings]]
|
[[deps.LaTeXStrings]]
|
||||||
git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c"
|
git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c"
|
||||||
@@ -370,9 +366,9 @@ version = "1.11.0"
|
|||||||
|
|
||||||
[[deps.LogExpFunctions]]
|
[[deps.LogExpFunctions]]
|
||||||
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
|
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
|
||||||
git-tree-sha1 = "a2d09619db4e765091ee5c6ffe8872849de0feea"
|
git-tree-sha1 = "13ca9e2586b89836fd20cccf56e57e2b9ae7f38f"
|
||||||
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
|
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
|
||||||
version = "0.3.28"
|
version = "0.3.29"
|
||||||
|
|
||||||
[deps.LogExpFunctions.extensions]
|
[deps.LogExpFunctions.extensions]
|
||||||
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
|
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
|
||||||
@@ -475,7 +471,7 @@ version = "0.3.27+1"
|
|||||||
[[deps.OpenLibm_jll]]
|
[[deps.OpenLibm_jll]]
|
||||||
deps = ["Artifacts", "Libdl"]
|
deps = ["Artifacts", "Libdl"]
|
||||||
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
|
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
|
||||||
version = "0.8.1+2"
|
version = "0.8.1+4"
|
||||||
|
|
||||||
[[deps.OpenSSL]]
|
[[deps.OpenSSL]]
|
||||||
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
|
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
|
||||||
@@ -493,7 +489,7 @@ version = "3.0.15+1"
|
|||||||
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
|
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
|
||||||
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
|
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
|
||||||
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
|
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
|
||||||
version = "0.5.5+0"
|
version = "0.5.5+2"
|
||||||
|
|
||||||
[[deps.OrderedCollections]]
|
[[deps.OrderedCollections]]
|
||||||
git-tree-sha1 = "12f1439c4f986bb868acda6ea33ebc78e19b95ad"
|
git-tree-sha1 = "12f1439c4f986bb868acda6ea33ebc78e19b95ad"
|
||||||
@@ -502,9 +498,9 @@ version = "1.7.0"
|
|||||||
|
|
||||||
[[deps.PDMats]]
|
[[deps.PDMats]]
|
||||||
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
|
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
|
||||||
git-tree-sha1 = "949347156c25054de2db3b166c52ac4728cbad65"
|
git-tree-sha1 = "48566789a6d5f6492688279e22445002d171cf76"
|
||||||
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
||||||
version = "0.11.31"
|
version = "0.11.33"
|
||||||
|
|
||||||
[[deps.Parsers]]
|
[[deps.Parsers]]
|
||||||
deps = ["Dates", "PrecompileTools", "UUIDs"]
|
deps = ["Dates", "PrecompileTools", "UUIDs"]
|
||||||
@@ -556,15 +552,15 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
|||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
|
||||||
[[deps.PtrArrays]]
|
[[deps.PtrArrays]]
|
||||||
git-tree-sha1 = "77a42d78b6a92df47ab37e177b2deac405e1c88f"
|
git-tree-sha1 = "1d36ef11a9aaf1e8b74dacc6a731dd1de8fd493d"
|
||||||
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
|
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
|
||||||
version = "1.2.1"
|
version = "1.3.0"
|
||||||
|
|
||||||
[[deps.QuadGK]]
|
[[deps.QuadGK]]
|
||||||
deps = ["DataStructures", "LinearAlgebra"]
|
deps = ["DataStructures", "LinearAlgebra"]
|
||||||
git-tree-sha1 = "cda3b045cf9ef07a08ad46731f5a3165e56cf3da"
|
git-tree-sha1 = "9da16da70037ba9d701192e27befedefb91ec284"
|
||||||
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
|
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
|
||||||
version = "2.11.1"
|
version = "2.11.2"
|
||||||
|
|
||||||
[deps.QuadGK.extensions]
|
[deps.QuadGK.extensions]
|
||||||
QuadGKEnzymeExt = "Enzyme"
|
QuadGKEnzymeExt = "Enzyme"
|
||||||
@@ -623,11 +619,9 @@ 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", "JSON3", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
|
||||||
git-tree-sha1 = "45e660e44de0950a5e5f92d467298d8b768b6023"
|
path = "/appfolder/app/dev/SQLLLM"
|
||||||
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.0"
|
version = "0.2.4"
|
||||||
|
|
||||||
[[deps.SQLStrings]]
|
[[deps.SQLStrings]]
|
||||||
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
||||||
@@ -672,9 +666,9 @@ version = "1.11.0"
|
|||||||
|
|
||||||
[[deps.SpecialFunctions]]
|
[[deps.SpecialFunctions]]
|
||||||
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
|
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
|
||||||
git-tree-sha1 = "2f5d4697f21388cbe1ff299430dd169ef97d7e14"
|
git-tree-sha1 = "64cca0c26b4f31ba18f13f6c12af7c85f478cfde"
|
||||||
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
|
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
|
||||||
version = "2.4.0"
|
version = "2.5.0"
|
||||||
|
|
||||||
[deps.SpecialFunctions.extensions]
|
[deps.SpecialFunctions.extensions]
|
||||||
SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
|
SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
|
||||||
@@ -699,16 +693,16 @@ uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
|
|||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
|
|
||||||
[[deps.StatsBase]]
|
[[deps.StatsBase]]
|
||||||
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
|
deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
|
||||||
git-tree-sha1 = "5cf7606d6cef84b543b483848d4ae08ad9832b21"
|
git-tree-sha1 = "29321314c920c26684834965ec2ce0dacc9cf8e5"
|
||||||
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
||||||
version = "0.34.3"
|
version = "0.34.4"
|
||||||
|
|
||||||
[[deps.StatsFuns]]
|
[[deps.StatsFuns]]
|
||||||
deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
|
deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
|
||||||
git-tree-sha1 = "b423576adc27097764a90e163157bcfc9acf0f46"
|
git-tree-sha1 = "35b09e80be285516e52c9054792c884b9216ae3c"
|
||||||
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
|
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
|
||||||
version = "1.3.2"
|
version = "1.4.0"
|
||||||
|
|
||||||
[deps.StatsFuns.extensions]
|
[deps.StatsFuns.extensions]
|
||||||
StatsFunsChainRulesCoreExt = "ChainRulesCore"
|
StatsFunsChainRulesCoreExt = "ChainRulesCore"
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
name = "YiemAgent"
|
name = "YiemAgent"
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
||||||
version = "0.1.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
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"
|
||||||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
||||||
@@ -21,7 +22,5 @@ URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
|||||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||||
|
|
||||||
[compat]
|
[compat]
|
||||||
|
CSV = "0.10.15"
|
||||||
DataFrames = "1.7.0"
|
DataFrames = "1.7.0"
|
||||||
GeneralUtils = "0.1.0"
|
|
||||||
LLMMCTS = "0.1.2"
|
|
||||||
SQLLLM = "0.2.0"
|
|
||||||
|
|||||||
72
fast_inference_guideline.txt
Normal file
72
fast_inference_guideline.txt
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
To make **LLM-driven inference** fast while maintaining its dynamic capabilities, there are a few practices or approaches to avoid, as they could lead to performance bottlenecks or inefficiencies. Here's what *not* to do:
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **1. Avoid Using Overly Large Models for Every Query**
|
||||||
|
While larger LLMs like GPT-4 provide high accuracy and nuanced responses, they may slow down real-time processing due to their computational complexity. Instead:
|
||||||
|
- Use distilled or smaller models (e.g., GPT-3.5 Turbo or fine-tuned versions) for faster inference without compromising much on quality.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **2. Avoid Excessive Entity Preprocessing**
|
||||||
|
Don’t rely on overly complicated preprocessing steps (like advanced NER models or regex-heavy pipelines) to extract entities from the query before invoking the LLM. This could add latency. Instead:
|
||||||
|
- Design efficient prompts that allow the LLM to extract entities and generate responses simultaneously.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **3. Avoid Asking the LLM Multiple Separate Questions**
|
||||||
|
Running the LLM for multiple subtasks—for example, entity extraction first and response generation second—can significantly slow down the pipeline. Instead:
|
||||||
|
- Create prompts that combine tasks into one pass, e.g., *"Identify the city name and generate a weather response for this query: 'What's the weather in London?'"*.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **4. Don’t Overload the LLM with Context History**
|
||||||
|
Excessively lengthy conversation history or irrelevant context in your prompts can slow down inference times. Instead:
|
||||||
|
- Provide only the relevant context for each query, trimming unnecessary parts of the conversation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **5. Avoid Real-Time Dependence on External APIs**
|
||||||
|
Using external APIs to fetch supplementary data (e.g., weather details or location info) during every query can introduce latency. Instead:
|
||||||
|
- Pre-fetch API data asynchronously and use the LLM to integrate it dynamically into responses.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **6. Avoid Running LLM on Underpowered Hardware**
|
||||||
|
Running inference on CPUs or low-spec GPUs will result in slower response times. Instead:
|
||||||
|
- Deploy the LLM on optimized infrastructure (e.g., high-performance GPUs like NVIDIA A100 or cloud platforms like Azure AI) to reduce latency.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **7. Skip Lengthy Generative Prompts**
|
||||||
|
Avoid prompts that encourage the LLM to produce overly detailed or verbose responses, as these take longer to process. Instead:
|
||||||
|
- Use concise prompts that focus on generating actionable or succinct answers.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **8. Don’t Ignore Optimization Techniques**
|
||||||
|
Failing to optimize your LLM setup can drastically impact performance. For example:
|
||||||
|
- Avoid skipping techniques like model quantization (reducing numerical precision to speed up inference) or distillation (training smaller models).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **9. Don’t Neglect Response Caching**
|
||||||
|
While you may not want a full caching system to avoid sunk costs, dismissing lightweight caching entirely can impact speed. Instead:
|
||||||
|
- Use temporary session-based caching for very frequent queries, without committing to a full-fledged cache infrastructure.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **10. Avoid One-Size-Fits-All Solutions**
|
||||||
|
Applying the same LLM inference method to all queries—whether simple or complex—will waste processing resources. Instead:
|
||||||
|
- Route basic queries to faster, specialized models and use the LLM for nuanced or multi-step queries only.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Summary: Focus on Efficient Design
|
||||||
|
By avoiding these pitfalls, you can ensure that LLM-driven inference remains fast and responsive:
|
||||||
|
- Optimize prompts.
|
||||||
|
- Use smaller models for simpler queries.
|
||||||
|
- Run the LLM on high-performance hardware.
|
||||||
|
- Trim unnecessary preprocessing or contextual steps.
|
||||||
|
|
||||||
|
Would you like me to help refine a prompt or suggest specific tools to complement your implementation? Let me know!
|
||||||
@@ -1,630 +0,0 @@
|
|||||||
# This file is machine-generated - editing it directly is not advised
|
|
||||||
|
|
||||||
julia_version = "1.10.3"
|
|
||||||
manifest_format = "2.0"
|
|
||||||
project_hash = "c6233f8bf690740dd830d1f0927bd3afed93b8d2"
|
|
||||||
|
|
||||||
[[deps.AliasTables]]
|
|
||||||
deps = ["PtrArrays", "Random"]
|
|
||||||
git-tree-sha1 = "9876e1e164b144ca45e9e3198d0b689cadfed9ff"
|
|
||||||
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
|
|
||||||
version = "1.1.3"
|
|
||||||
|
|
||||||
[[deps.ArgTools]]
|
|
||||||
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
|
|
||||||
version = "1.1.1"
|
|
||||||
|
|
||||||
[[deps.Artifacts]]
|
|
||||||
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
|
|
||||||
|
|
||||||
[[deps.Base64]]
|
|
||||||
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
|
||||||
|
|
||||||
[[deps.BitFlags]]
|
|
||||||
git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b"
|
|
||||||
uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
|
|
||||||
version = "0.1.8"
|
|
||||||
|
|
||||||
[[deps.Calculus]]
|
|
||||||
deps = ["LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad"
|
|
||||||
uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
|
|
||||||
version = "0.5.1"
|
|
||||||
|
|
||||||
[[deps.CodeTracking]]
|
|
||||||
deps = ["InteractiveUtils", "UUIDs"]
|
|
||||||
git-tree-sha1 = "c0216e792f518b39b22212127d4a84dc31e4e386"
|
|
||||||
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
|
|
||||||
version = "1.3.5"
|
|
||||||
|
|
||||||
[[deps.CodecZlib]]
|
|
||||||
deps = ["TranscodingStreams", "Zlib_jll"]
|
|
||||||
git-tree-sha1 = "59939d8a997469ee05c4b4944560a820f9ba0d73"
|
|
||||||
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
|
|
||||||
version = "0.7.4"
|
|
||||||
|
|
||||||
[[deps.Compat]]
|
|
||||||
deps = ["TOML", "UUIDs"]
|
|
||||||
git-tree-sha1 = "b1c55339b7c6c350ee89f2c1604299660525b248"
|
|
||||||
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
|
|
||||||
version = "4.15.0"
|
|
||||||
weakdeps = ["Dates", "LinearAlgebra"]
|
|
||||||
|
|
||||||
[deps.Compat.extensions]
|
|
||||||
CompatLinearAlgebraExt = "LinearAlgebra"
|
|
||||||
|
|
||||||
[[deps.CompilerSupportLibraries_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
|
|
||||||
version = "1.1.1+0"
|
|
||||||
|
|
||||||
[[deps.ConcurrentUtilities]]
|
|
||||||
deps = ["Serialization", "Sockets"]
|
|
||||||
git-tree-sha1 = "6cbbd4d241d7e6579ab354737f4dd95ca43946e1"
|
|
||||||
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
|
|
||||||
version = "2.4.1"
|
|
||||||
|
|
||||||
[[deps.CondaPkg]]
|
|
||||||
deps = ["JSON3", "Markdown", "MicroMamba", "Pidfile", "Pkg", "Preferences", "TOML"]
|
|
||||||
git-tree-sha1 = "e81c4263c7ef4eca4d645ef612814d72e9255b41"
|
|
||||||
uuid = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
|
|
||||||
version = "0.2.22"
|
|
||||||
|
|
||||||
[[deps.DataAPI]]
|
|
||||||
git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe"
|
|
||||||
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
|
|
||||||
version = "1.16.0"
|
|
||||||
|
|
||||||
[[deps.DataStructures]]
|
|
||||||
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
|
|
||||||
git-tree-sha1 = "1d0a14036acb104d9e89698bd408f63ab58cdc82"
|
|
||||||
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
|
||||||
version = "0.18.20"
|
|
||||||
|
|
||||||
[[deps.DataValueInterfaces]]
|
|
||||||
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
|
|
||||||
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.Dates]]
|
|
||||||
deps = ["Printf"]
|
|
||||||
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
|
||||||
|
|
||||||
[[deps.Distributed]]
|
|
||||||
deps = ["Random", "Serialization", "Sockets"]
|
|
||||||
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
|
|
||||||
|
|
||||||
[[deps.Distributions]]
|
|
||||||
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
|
|
||||||
git-tree-sha1 = "22c595ca4146c07b16bcf9c8bea86f731f7109d2"
|
|
||||||
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
|
||||||
version = "0.25.108"
|
|
||||||
|
|
||||||
[deps.Distributions.extensions]
|
|
||||||
DistributionsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
DistributionsDensityInterfaceExt = "DensityInterface"
|
|
||||||
DistributionsTestExt = "Test"
|
|
||||||
|
|
||||||
[deps.Distributions.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
|
|
||||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
|
||||||
|
|
||||||
[[deps.DocStringExtensions]]
|
|
||||||
deps = ["LibGit2"]
|
|
||||||
git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
|
|
||||||
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
|
|
||||||
version = "0.9.3"
|
|
||||||
|
|
||||||
[[deps.Downloads]]
|
|
||||||
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
|
|
||||||
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
|
|
||||||
version = "1.6.0"
|
|
||||||
|
|
||||||
[[deps.DualNumbers]]
|
|
||||||
deps = ["Calculus", "NaNMath", "SpecialFunctions"]
|
|
||||||
git-tree-sha1 = "5837a837389fccf076445fce071c8ddaea35a566"
|
|
||||||
uuid = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
|
|
||||||
version = "0.6.8"
|
|
||||||
|
|
||||||
[[deps.ExceptionUnwrapping]]
|
|
||||||
deps = ["Test"]
|
|
||||||
git-tree-sha1 = "dcb08a0d93ec0b1cdc4af184b26b591e9695423a"
|
|
||||||
uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4"
|
|
||||||
version = "0.1.10"
|
|
||||||
|
|
||||||
[[deps.FileWatching]]
|
|
||||||
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
|
|
||||||
|
|
||||||
[[deps.FillArrays]]
|
|
||||||
deps = ["LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "0653c0a2396a6da5bc4766c43041ef5fd3efbe57"
|
|
||||||
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
|
|
||||||
version = "1.11.0"
|
|
||||||
weakdeps = ["PDMats", "SparseArrays", "Statistics"]
|
|
||||||
|
|
||||||
[deps.FillArrays.extensions]
|
|
||||||
FillArraysPDMatsExt = "PDMats"
|
|
||||||
FillArraysSparseArraysExt = "SparseArrays"
|
|
||||||
FillArraysStatisticsExt = "Statistics"
|
|
||||||
|
|
||||||
[[deps.GeneralUtils]]
|
|
||||||
deps = ["DataStructures", "Dates", "Distributions", "JSON3", "MQTTClient", "Random", "Revise", "UUIDs"]
|
|
||||||
path = "/appfolder/app/privatejuliapkg/GeneralUtils"
|
|
||||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[deps.HTTP]]
|
|
||||||
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
|
|
||||||
git-tree-sha1 = "d1d712be3164d61d1fb98e7ce9bcbc6cc06b45ed"
|
|
||||||
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
|
||||||
version = "1.10.8"
|
|
||||||
|
|
||||||
[[deps.HypergeometricFunctions]]
|
|
||||||
deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
|
|
||||||
git-tree-sha1 = "f218fe3736ddf977e0e772bc9a586b2383da2685"
|
|
||||||
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
|
|
||||||
version = "0.3.23"
|
|
||||||
|
|
||||||
[[deps.InteractiveUtils]]
|
|
||||||
deps = ["Markdown"]
|
|
||||||
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
|
|
||||||
|
|
||||||
[[deps.IrrationalConstants]]
|
|
||||||
git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2"
|
|
||||||
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
|
|
||||||
version = "0.2.2"
|
|
||||||
|
|
||||||
[[deps.IteratorInterfaceExtensions]]
|
|
||||||
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
|
|
||||||
uuid = "82899510-4779-5014-852e-03e436cf321d"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.JLLWrappers]]
|
|
||||||
deps = ["Artifacts", "Preferences"]
|
|
||||||
git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca"
|
|
||||||
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
|
|
||||||
version = "1.5.0"
|
|
||||||
|
|
||||||
[[deps.JSON3]]
|
|
||||||
deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"]
|
|
||||||
git-tree-sha1 = "eb3edce0ed4fa32f75a0a11217433c31d56bd48b"
|
|
||||||
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
|
|
||||||
version = "1.14.0"
|
|
||||||
|
|
||||||
[deps.JSON3.extensions]
|
|
||||||
JSON3ArrowExt = ["ArrowTypes"]
|
|
||||||
|
|
||||||
[deps.JSON3.weakdeps]
|
|
||||||
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
|
|
||||||
|
|
||||||
[[deps.JuliaInterpreter]]
|
|
||||||
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
|
|
||||||
git-tree-sha1 = "e9648d90370e2d0317f9518c9c6e0841db54a90b"
|
|
||||||
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
|
|
||||||
version = "0.9.31"
|
|
||||||
|
|
||||||
[[deps.LazyArtifacts]]
|
|
||||||
deps = ["Artifacts", "Pkg"]
|
|
||||||
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
|
|
||||||
|
|
||||||
[[deps.LibCURL]]
|
|
||||||
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
|
|
||||||
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
|
|
||||||
version = "0.6.4"
|
|
||||||
|
|
||||||
[[deps.LibCURL_jll]]
|
|
||||||
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
|
|
||||||
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
|
|
||||||
version = "8.4.0+0"
|
|
||||||
|
|
||||||
[[deps.LibGit2]]
|
|
||||||
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
|
|
||||||
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
|
|
||||||
|
|
||||||
[[deps.LibGit2_jll]]
|
|
||||||
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
|
|
||||||
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
|
|
||||||
version = "1.6.4+0"
|
|
||||||
|
|
||||||
[[deps.LibSSH2_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
|
|
||||||
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
|
|
||||||
version = "1.11.0+1"
|
|
||||||
|
|
||||||
[[deps.Libdl]]
|
|
||||||
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
|
|
||||||
|
|
||||||
[[deps.LinearAlgebra]]
|
|
||||||
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
|
|
||||||
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
|
||||||
|
|
||||||
[[deps.LogExpFunctions]]
|
|
||||||
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "18144f3e9cbe9b15b070288eef858f71b291ce37"
|
|
||||||
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
|
|
||||||
version = "0.3.27"
|
|
||||||
|
|
||||||
[deps.LogExpFunctions.extensions]
|
|
||||||
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables"
|
|
||||||
LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
|
|
||||||
|
|
||||||
[deps.LogExpFunctions.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
|
|
||||||
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
|
|
||||||
|
|
||||||
[[deps.Logging]]
|
|
||||||
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
|
||||||
|
|
||||||
[[deps.LoggingExtras]]
|
|
||||||
deps = ["Dates", "Logging"]
|
|
||||||
git-tree-sha1 = "c1dd6d7978c12545b4179fb6153b9250c96b0075"
|
|
||||||
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
|
|
||||||
version = "1.0.3"
|
|
||||||
|
|
||||||
[[deps.LoweredCodeUtils]]
|
|
||||||
deps = ["JuliaInterpreter"]
|
|
||||||
git-tree-sha1 = "c6a36b22d2cca0e1a903f00f600991f97bf5f426"
|
|
||||||
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
|
|
||||||
version = "2.4.6"
|
|
||||||
|
|
||||||
[[deps.MQTTClient]]
|
|
||||||
deps = ["Distributed", "Random", "Sockets"]
|
|
||||||
git-tree-sha1 = "c58ba9d6ae121f58494fa1e5164213f5b4e3e2c7"
|
|
||||||
uuid = "985f35cc-2c3d-4943-b8c1-f0931d5f0959"
|
|
||||||
version = "0.3.0"
|
|
||||||
weakdeps = ["PrecompileTools"]
|
|
||||||
|
|
||||||
[deps.MQTTClient.extensions]
|
|
||||||
PrecompileMQTT = "PrecompileTools"
|
|
||||||
|
|
||||||
[[deps.MacroTools]]
|
|
||||||
deps = ["Markdown", "Random"]
|
|
||||||
git-tree-sha1 = "2fa9ee3e63fd3a4f7a9a4f4744a52f4856de82df"
|
|
||||||
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
|
|
||||||
version = "0.5.13"
|
|
||||||
|
|
||||||
[[deps.Markdown]]
|
|
||||||
deps = ["Base64"]
|
|
||||||
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
|
|
||||||
|
|
||||||
[[deps.MbedTLS]]
|
|
||||||
deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "NetworkOptions", "Random", "Sockets"]
|
|
||||||
git-tree-sha1 = "c067a280ddc25f196b5e7df3877c6b226d390aaf"
|
|
||||||
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
|
|
||||||
version = "1.1.9"
|
|
||||||
|
|
||||||
[[deps.MbedTLS_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
|
|
||||||
version = "2.28.2+1"
|
|
||||||
|
|
||||||
[[deps.MicroMamba]]
|
|
||||||
deps = ["Pkg", "Scratch", "micromamba_jll"]
|
|
||||||
git-tree-sha1 = "011cab361eae7bcd7d278f0a7a00ff9c69000c51"
|
|
||||||
uuid = "0b3b1443-0f03-428d-bdfb-f27f9c1191ea"
|
|
||||||
version = "0.1.14"
|
|
||||||
|
|
||||||
[[deps.Missings]]
|
|
||||||
deps = ["DataAPI"]
|
|
||||||
git-tree-sha1 = "ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d"
|
|
||||||
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
|
|
||||||
version = "1.2.0"
|
|
||||||
|
|
||||||
[[deps.Mmap]]
|
|
||||||
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
|
|
||||||
|
|
||||||
[[deps.MozillaCACerts_jll]]
|
|
||||||
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
|
|
||||||
version = "2023.1.10"
|
|
||||||
|
|
||||||
[[deps.NaNMath]]
|
|
||||||
deps = ["OpenLibm_jll"]
|
|
||||||
git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4"
|
|
||||||
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
|
|
||||||
version = "1.0.2"
|
|
||||||
|
|
||||||
[[deps.NetworkOptions]]
|
|
||||||
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
|
|
||||||
version = "1.2.0"
|
|
||||||
|
|
||||||
[[deps.OpenBLAS_jll]]
|
|
||||||
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
|
|
||||||
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
|
|
||||||
version = "0.3.23+4"
|
|
||||||
|
|
||||||
[[deps.OpenLibm_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
|
|
||||||
version = "0.8.1+2"
|
|
||||||
|
|
||||||
[[deps.OpenSSL]]
|
|
||||||
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
|
|
||||||
git-tree-sha1 = "38cb508d080d21dc1128f7fb04f20387ed4c0af4"
|
|
||||||
uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c"
|
|
||||||
version = "1.4.3"
|
|
||||||
|
|
||||||
[[deps.OpenSSL_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
|
||||||
git-tree-sha1 = "3da7367955dcc5c54c1ba4d402ccdc09a1a3e046"
|
|
||||||
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
|
|
||||||
version = "3.0.13+1"
|
|
||||||
|
|
||||||
[[deps.OpenSpecFun_jll]]
|
|
||||||
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
|
|
||||||
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
|
|
||||||
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
|
|
||||||
version = "0.5.5+0"
|
|
||||||
|
|
||||||
[[deps.OrderedCollections]]
|
|
||||||
git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5"
|
|
||||||
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
|
|
||||||
version = "1.6.3"
|
|
||||||
|
|
||||||
[[deps.PDMats]]
|
|
||||||
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
|
|
||||||
git-tree-sha1 = "949347156c25054de2db3b166c52ac4728cbad65"
|
|
||||||
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
|
||||||
version = "0.11.31"
|
|
||||||
|
|
||||||
[[deps.Parsers]]
|
|
||||||
deps = ["Dates", "PrecompileTools", "UUIDs"]
|
|
||||||
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
|
|
||||||
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
|
|
||||||
version = "2.8.1"
|
|
||||||
|
|
||||||
[[deps.Pidfile]]
|
|
||||||
deps = ["FileWatching", "Test"]
|
|
||||||
git-tree-sha1 = "2d8aaf8ee10df53d0dfb9b8ee44ae7c04ced2b03"
|
|
||||||
uuid = "fa939f87-e72e-5be4-a000-7fc836dbe307"
|
|
||||||
version = "1.3.0"
|
|
||||||
|
|
||||||
[[deps.Pkg]]
|
|
||||||
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
|
|
||||||
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.PrecompileTools]]
|
|
||||||
deps = ["Preferences"]
|
|
||||||
git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f"
|
|
||||||
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.Preferences]]
|
|
||||||
deps = ["TOML"]
|
|
||||||
git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6"
|
|
||||||
uuid = "21216c6a-2e73-6563-6e65-726566657250"
|
|
||||||
version = "1.4.3"
|
|
||||||
|
|
||||||
[[deps.PrettyPrinting]]
|
|
||||||
git-tree-sha1 = "142ee93724a9c5d04d78df7006670a93ed1b244e"
|
|
||||||
uuid = "54e16d92-306c-5ea0-a30b-337be88ac337"
|
|
||||||
version = "0.4.2"
|
|
||||||
|
|
||||||
[[deps.Printf]]
|
|
||||||
deps = ["Unicode"]
|
|
||||||
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
|
||||||
|
|
||||||
[[deps.PtrArrays]]
|
|
||||||
git-tree-sha1 = "f011fbb92c4d401059b2212c05c0601b70f8b759"
|
|
||||||
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
|
|
||||||
version = "1.2.0"
|
|
||||||
|
|
||||||
[[deps.PythonCall]]
|
|
||||||
deps = ["CondaPkg", "Dates", "Libdl", "MacroTools", "Markdown", "Pkg", "REPL", "Requires", "Serialization", "Tables", "UnsafePointers"]
|
|
||||||
git-tree-sha1 = "8de9e6cbabc9bcad4f325bd9f2f1e83361e5037d"
|
|
||||||
uuid = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
|
|
||||||
version = "0.9.20"
|
|
||||||
|
|
||||||
[[deps.QuadGK]]
|
|
||||||
deps = ["DataStructures", "LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "9b23c31e76e333e6fb4c1595ae6afa74966a729e"
|
|
||||||
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
|
|
||||||
version = "2.9.4"
|
|
||||||
|
|
||||||
[[deps.REPL]]
|
|
||||||
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
|
|
||||||
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
|
|
||||||
|
|
||||||
[[deps.Random]]
|
|
||||||
deps = ["SHA"]
|
|
||||||
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
|
||||||
|
|
||||||
[[deps.Reexport]]
|
|
||||||
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
|
|
||||||
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
|
|
||||||
version = "1.2.2"
|
|
||||||
|
|
||||||
[[deps.Requires]]
|
|
||||||
deps = ["UUIDs"]
|
|
||||||
git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
|
|
||||||
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
|
|
||||||
version = "1.3.0"
|
|
||||||
|
|
||||||
[[deps.Revise]]
|
|
||||||
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"]
|
|
||||||
git-tree-sha1 = "12aa2d7593df490c407a3bbd8b86b8b515017f3e"
|
|
||||||
uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
|
||||||
version = "3.5.14"
|
|
||||||
|
|
||||||
[[deps.Rmath]]
|
|
||||||
deps = ["Random", "Rmath_jll"]
|
|
||||||
git-tree-sha1 = "f65dcb5fa46aee0cf9ed6274ccbd597adc49aa7b"
|
|
||||||
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
|
|
||||||
version = "0.7.1"
|
|
||||||
|
|
||||||
[[deps.Rmath_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
|
||||||
git-tree-sha1 = "d483cd324ce5cf5d61b77930f0bbd6cb61927d21"
|
|
||||||
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
|
|
||||||
version = "0.4.2+0"
|
|
||||||
|
|
||||||
[[deps.SHA]]
|
|
||||||
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
|
||||||
version = "0.7.0"
|
|
||||||
|
|
||||||
[[deps.Scratch]]
|
|
||||||
deps = ["Dates"]
|
|
||||||
git-tree-sha1 = "3bac05bc7e74a75fd9cba4295cde4045d9fe2386"
|
|
||||||
uuid = "6c6a2e73-6563-6170-7368-637461726353"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.Serialization]]
|
|
||||||
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
|
||||||
|
|
||||||
[[deps.SimpleBufferStream]]
|
|
||||||
git-tree-sha1 = "874e8867b33a00e784c8a7e4b60afe9e037b74e1"
|
|
||||||
uuid = "777ac1f9-54b0-4bf8-805c-2214025038e7"
|
|
||||||
version = "1.1.0"
|
|
||||||
|
|
||||||
[[deps.Sockets]]
|
|
||||||
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
|
|
||||||
|
|
||||||
[[deps.SortingAlgorithms]]
|
|
||||||
deps = ["DataStructures"]
|
|
||||||
git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085"
|
|
||||||
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.SparseArrays]]
|
|
||||||
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
|
|
||||||
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.SpecialFunctions]]
|
|
||||||
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
|
|
||||||
git-tree-sha1 = "2f5d4697f21388cbe1ff299430dd169ef97d7e14"
|
|
||||||
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
|
|
||||||
version = "2.4.0"
|
|
||||||
|
|
||||||
[deps.SpecialFunctions.extensions]
|
|
||||||
SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
|
|
||||||
[deps.SpecialFunctions.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
|
|
||||||
[[deps.Statistics]]
|
|
||||||
deps = ["LinearAlgebra", "SparseArrays"]
|
|
||||||
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.StatsAPI]]
|
|
||||||
deps = ["LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "1ff449ad350c9c4cbc756624d6f8a8c3ef56d3ed"
|
|
||||||
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
|
|
||||||
version = "1.7.0"
|
|
||||||
|
|
||||||
[[deps.StatsBase]]
|
|
||||||
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
|
|
||||||
git-tree-sha1 = "5cf7606d6cef84b543b483848d4ae08ad9832b21"
|
|
||||||
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
|
||||||
version = "0.34.3"
|
|
||||||
|
|
||||||
[[deps.StatsFuns]]
|
|
||||||
deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
|
|
||||||
git-tree-sha1 = "cef0472124fab0695b58ca35a77c6fb942fdab8a"
|
|
||||||
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
|
|
||||||
version = "1.3.1"
|
|
||||||
|
|
||||||
[deps.StatsFuns.extensions]
|
|
||||||
StatsFunsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
StatsFunsInverseFunctionsExt = "InverseFunctions"
|
|
||||||
|
|
||||||
[deps.StatsFuns.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
|
|
||||||
|
|
||||||
[[deps.StructTypes]]
|
|
||||||
deps = ["Dates", "UUIDs"]
|
|
||||||
git-tree-sha1 = "ca4bccb03acf9faaf4137a9abc1881ed1841aa70"
|
|
||||||
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.SuiteSparse]]
|
|
||||||
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
|
|
||||||
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
|
|
||||||
|
|
||||||
[[deps.SuiteSparse_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
|
|
||||||
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
|
|
||||||
version = "7.2.1+1"
|
|
||||||
|
|
||||||
[[deps.TOML]]
|
|
||||||
deps = ["Dates"]
|
|
||||||
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
|
|
||||||
version = "1.0.3"
|
|
||||||
|
|
||||||
[[deps.TableTraits]]
|
|
||||||
deps = ["IteratorInterfaceExtensions"]
|
|
||||||
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
|
|
||||||
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
|
|
||||||
version = "1.0.1"
|
|
||||||
|
|
||||||
[[deps.Tables]]
|
|
||||||
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"]
|
|
||||||
git-tree-sha1 = "cb76cf677714c095e535e3501ac7954732aeea2d"
|
|
||||||
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
|
|
||||||
version = "1.11.1"
|
|
||||||
|
|
||||||
[[deps.Tar]]
|
|
||||||
deps = ["ArgTools", "SHA"]
|
|
||||||
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.Test]]
|
|
||||||
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
|
|
||||||
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
|
||||||
|
|
||||||
[[deps.TranscodingStreams]]
|
|
||||||
git-tree-sha1 = "5d54d076465da49d6746c647022f3b3674e64156"
|
|
||||||
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
|
|
||||||
version = "0.10.8"
|
|
||||||
weakdeps = ["Random", "Test"]
|
|
||||||
|
|
||||||
[deps.TranscodingStreams.extensions]
|
|
||||||
TestExt = ["Test", "Random"]
|
|
||||||
|
|
||||||
[[deps.URIs]]
|
|
||||||
git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b"
|
|
||||||
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
|
||||||
version = "1.5.1"
|
|
||||||
|
|
||||||
[[deps.UUIDs]]
|
|
||||||
deps = ["Random", "SHA"]
|
|
||||||
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|
||||||
|
|
||||||
[[deps.Unicode]]
|
|
||||||
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
|
|
||||||
|
|
||||||
[[deps.UnsafePointers]]
|
|
||||||
git-tree-sha1 = "c81331b3b2e60a982be57c046ec91f599ede674a"
|
|
||||||
uuid = "e17b2a0c-0bdf-430a-bd0c-3a23cae4ff39"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.Zlib_jll]]
|
|
||||||
deps = ["Libdl"]
|
|
||||||
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
|
|
||||||
version = "1.2.13+1"
|
|
||||||
|
|
||||||
[[deps.libblastrampoline_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
|
|
||||||
version = "5.8.0+1"
|
|
||||||
|
|
||||||
[[deps.micromamba_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"]
|
|
||||||
git-tree-sha1 = "b4a5a3943078f9fd11ae0b5ab1bdbf7718617945"
|
|
||||||
uuid = "f8abcde7-e9b7-5caa-b8af-a437887ae8e4"
|
|
||||||
version = "1.5.8+0"
|
|
||||||
|
|
||||||
[[deps.nghttp2_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
|
|
||||||
version = "1.52.0+1"
|
|
||||||
|
|
||||||
[[deps.p7zip_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
|
|
||||||
version = "17.4.0+2"
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
name = "YiemAgent"
|
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
|
||||||
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
|
|
||||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
|
||||||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
|
||||||
GeneralUtils = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
|
||||||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
|
||||||
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
|
|
||||||
MQTTClient = "985f35cc-2c3d-4943-b8c1-f0931d5f0959"
|
|
||||||
PrettyPrinting = "54e16d92-306c-5ea0-a30b-337be88ac337"
|
|
||||||
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
|
|
||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
|
||||||
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
|
||||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|
||||||
@@ -1,537 +0,0 @@
|
|||||||
https://github.com/andyz245/LanguageAgentTreeSearch/blob/main/hotpot/hotpot.py
|
|
||||||
|
|
||||||
|
|
||||||
standard_prompt = '''
|
|
||||||
Write a coherent passage of 4 short paragraphs. The end sentence of each paragraph must be: {input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
reflection_prompt = '''You are an advanced reasoning agent that can improve based on self refection. You will be given a previous reasoning trial in which you were given access to an Docstore API environment and a question to answer. You were unsuccessful in answering the question either because you guessed the wrong answer with Finish[<answer>], or you used up your set number of reasoning steps. In a few sentences, Diagnose a possible reason for failure and devise a new, concise, high level plan that aims to mitigate the same failure. Use complete sentences.
|
|
||||||
Here are some examples:
|
|
||||||
Previous Trial:
|
|
||||||
Question: The Rome Protocols were signed by three Prime Ministers one of which was assassinated as part of what?
|
|
||||||
Thought 1: I need to search Rome Protocols, find the three Prime Ministers, then find what they were assassinated as part of.
|
|
||||||
Action 1: Search[Rome Protocols]
|
|
||||||
Observation 1: The Rome Protocols were a series of three international agreements concluded in Rome on 17 March 1934 between the governments of Austria, Hungary and Italy. They were signed by Italian Prime Minister Benito Mussolini, Austrian Chancellor Engelbert Dollfuss and Hungarian Prime Minister Gyula Gömbös. All of the protocols went into effect on 12 July 1934 and were registered in League of Nations Treaty Series on 12 December 1934.
|
|
||||||
Thought 2: The three Prime Ministers were Benito Mussolini, Engelbert Dollfuss, and Gyula Gömbös. I need to search Benito Mussolini and find what he was assassinated as part of.
|
|
||||||
Action 2: Search[Benito Mussolini]
|
|
||||||
Observation 2: Benito Amilcare Andrea Mussolini (UK: MU(U)SS-ə-LEE-nee, US: MOOSS-, Italian: [beˈniːto aˈmilkare anˈdrɛːa mussoˈliːni]; 29 July 1883 – 28 April 1945) was an Italian politician and journalist who founded and led the National Fascist Party (PNF). He was Prime Minister of Italy from the March on Rome in 1922 until his deposition in 1943, as well as "Duce" of Italian fascism from the establishment of the Italian Fasces of Combat in 1919 until his summary execution in 1945 by Italian partisans. As dictator of Italy and principal founder of fascism, Mussolini inspired and supported the international spread of fascist movements during the inter-war period.Mussolini was originally a socialist politician and a journalist at the Avanti! newspaper. In 1912, he became a member of the National Directorate of the Italian Socialist Party (PSI), but he was expelled from the PSI for advocating military intervention in World War I, in opposition to the party's stance on neutrality. In 1914, Mussolini founded a new journal, Il Popolo d'Italia, and served in the Royal Italian Army during the war until he was wounded and discharged in 1917. Mussolini denounced the PSI, his views now centering on Italian nationalism instead of socialism, and later founded the fascist movement which came to oppose egalitarianism and class conflict, instead advocating "revolutionary nationalism" transcending class lines. On 31 October 1922, following the March on Rome (28–30 October), Mussolini was appointed prime minister by King Victor Emmanuel III, becoming the youngest individual to hold the office up to that time. After removing all political opposition through his secret police and outlawing labor strikes, Mussolini and his followers consolidated power through a series of laws that transformed the nation into a one-party dictatorship. Within five years, Mussolini had established dictatorial authority by both legal and illegal means and aspired to create a totalitarian state. In 1929, Mussolini signed the Lateran Treaty with the Holy See to establish Vatican City.
|
|
||||||
Mussolini's foreign policy aimed to restore the ancient grandeur of the Roman Empire by expanding Italian colonial possessions and the fascist sphere of influence. In the 1920s, he ordered the Pacification of Libya, instructed the bombing of Corfu over an incident with Greece, established a protectorate over Albania, and incorporated the city of Fiume into the Italian state via agreements with Yugoslavia. In 1936, Ethiopia was conquered following the Second Italo-Ethiopian War and merged into Italian East Africa (AOI) with Eritrea and Somalia. In 1939, Italian forces annexed Albania. Between 1936 and 1939, Mussolini ordered the successful Italian military intervention in Spain in favor of Francisco Franco during the Spanish Civil War. Mussolini's Italy initially tried to avoid the outbreak of a second global war, sending troops at the Brenner Pass to delay Anschluss and taking part in the Stresa Front, the Lytton Report, the Treaty of Lausanne, the Four-Power Pact and the Munich Agreement. However, Italy then alienated itself from Britain and France by aligning with Germany and Japan. Germany invaded Poland on 1 September 1939, resulting in declarations of war by France and the UK and the start of World War II.
|
|
||||||
On 10 June 1940, Mussolini decided to enter the war on the Axis side. Despite initial success, the subsequent Axis collapse on multiple fronts and eventual Allied invasion of Sicily made Mussolini lose the support of the population and members of the Fascist Party. As a consequence, early on 25 July 1943, the Grand Council of Fascism passed a motion of no confidence in Mussolini; later that day King Victor Emmanuel III dismissed him as head of government and had him placed in custody, appointing Pietro Badoglio to succeed him as Prime Minister. After the king agreed to an armistice with the Allies, on 12 September 1943 Mussolini was rescued from captivity in the Gran Sasso raid by German paratroopers and Waffen-SS commandos led by Major Otto-Harald Mors. Adolf Hitler, after meeting with the rescued former dictator, then put Mussolini in charge of a puppet regime in northern Italy, the Italian Social Republic (Italian: Repubblica Sociale Italiana, RSI), informally known as the Salò Republic, causing a civil war. In late April 1945, in the wake of near total defeat, Mussolini and his mistress Clara Petacci attempted to flee to Switzerland, but both were captured by Italian communist partisans and summarily executed by firing squad on 28 April 1945 near Lake Como. The bodies of Mussolini and his mistress were then taken to Milan, where they were hung upside down at a service station to publicly confirm their demise.
|
|
||||||
Thought 3: Benito Mussolini was assassinated as part of the collapse of the Axis powers during World War II. So the Rome Protocols were signed by three Prime Ministers one of which was assassinated as part of World War II.
|
|
||||||
Action 3: Finish[World War II]
|
|
||||||
|
|
||||||
Reflection: I searched one of the prime ministers involved in the signing, then attemted to answer right away. I should have searched each of the prime ministers, then looked up 'death' on each of their pages in order to get more information before answering.
|
|
||||||
|
|
||||||
Previous Trial:
|
|
||||||
Question: Kam Heskin plays Paige Morgan in a 2004 film directed by who?
|
|
||||||
Thought 1: I need to search Kam Heskin and Paige Morgan, find the 2004 film they are in, then find the director of the film.
|
|
||||||
Action 1: Search[Kam Heskin]
|
|
||||||
Observation 1: Kam Erika Heskin (born May 8, 1973) is an American actress. She began her career playing Caitlin Deschanel on the NBC daytime soap opera Sunset Beach (1998–1999), before appearing in films Planet of the Apes (2001) and Catch Me If You Can (2002). Heskin went on in 2003 to play Elizabeth Bennet in an independent film Pride & Prejudice: A Latter-Day Comedy, Robin in Charmed (2004), and Paige Morgan in The Prince and Me film franchise (2006–2010).
|
|
||||||
Thought 2: Kam Heskin plays Paige Morgan in The Prince and Me film franchise. I need to search The Prince and Me film franchise and find the director of the 2004 film.
|
|
||||||
Action 2: Search[The Prince and Me film franchise]
|
|
||||||
Observation 2: Could not find [The Prince and Me film franchise]. Similar: ['Kam Heskin', 'Prince of Persia', 'Harry Potter and the Half-Blood Prince (film)', 'Prince of Persia: The Sands of Time (film)', 'The Chronicles of Narnia (film series)', 'Majestic Prince (franchise)', 'Kingsman (franchise)', 'The Little Prince (2015 film)', 'Shrek (franchise)', 'Harry Potter (film series)']
|
|
||||||
Thought 3: I need to search The Prince and Me (2004 film) instead.
|
|
||||||
Action 3: Search[The Prince and Me (2004 film)]
|
|
||||||
Observation 3: Could not find [The Prince and Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Kam Heskin', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince of Persia', 'Brooklynn Prince', 'Prince (musician)']
|
|
||||||
Thought 4: I need to search The Prince & Me (2004 film).
|
|
||||||
Action 4: Search[The Prince & Me (2004 film)]
|
|
||||||
Observation 4: Could not find [The Prince & Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince (musician)', 'Prince of Persia', 'Kam Heskin', 'Brooklynn Prince']
|
|
||||||
Thought 5: I need to search The Prince & Me (2004 film) instead.
|
|
||||||
Action 5: Search[The Prince & Me (2004 film)]
|
|
||||||
Observation 5: Could not find [The Prince & Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince (musician)', 'Prince of Persia', 'Kam Heskin', 'Brooklynn Prince']
|
|
||||||
Thought 6: I need to search The Prince & Me (2004 film).
|
|
||||||
Action 6: Search[The Prince & Me (2004 film)]
|
|
||||||
Observation 6: Could not find [The Prince & Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince (musician)', 'Prince of Persia', 'Kam Heskin', 'Brooklynn Prince']
|
|
||||||
|
|
||||||
Reflection: I got stuck in a loop where I kept trying to search 'The Prince & Me (2004 film)' but the page could not be found. Instead I should have tried to search the similar results that had a similar name to see and they were made in 2004.
|
|
||||||
|
|
||||||
Previous Trial:
|
|
||||||
Question: The Oberoi family is part of a hotel company that has a head office in what city?
|
|
||||||
Thought 1: I need to search the Oberoi family and find the city where the hotel company's head office is located.
|
|
||||||
Action 1: Search[Oberoi family]
|
|
||||||
Observation 1: The Oberoi Group is a luxury hotel group with its head office in New Delhi, India.[2] Founded in 1934, the company owns and operates 32 luxury hotels and two river cruise ships in 7 countries, primarily under its Oberoi Hotels & Resorts and Trident brands.[3] The group also operates The Oberoi Centre for Learning and Development, which is regarded as one of Asia's top institutions for hospitality education.[4]. The foundations of the Oberoi Group date back to 1934 when The Rai Bahadur Mohan Singh Oberoi, the founder of the group, bought two properties: the Maidens in Delhi and the Clarke's in Shimla.[5] In the following years Oberoi, assisted by his two sons, Tilak Raj Singh Oberoi and Prithvi Raj Singh Oberoi (P.R.S. Oberoi
|
|
||||||
Thought 2: The Oberoi Group has its head office in New Delhi, India. I just need to finish with New Delhi.
|
|
||||||
Action 2: Finish[New Delhi]
|
|
||||||
Observation 2: Episode finished, reward = 0
|
|
||||||
|
|
||||||
Reflection: I appeared to have retrieved the correct information about The Oberoi Family and the location of it's head office, and provided a corresponding answer. However this answer does not exactly match the ground truth answer so I should try a different wording, such as Delhi.
|
|
||||||
|
|
||||||
Previous trial:
|
|
||||||
{trajectory}Reflection:'''
|
|
||||||
|
|
||||||
cot_prompt = '''
|
|
||||||
Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Guitars for Wounded Warriors is an album that was recorded in the village in which New York county?
|
|
||||||
Thought 1: I need to search Guitars for Wounded Warriors, then find in which New York county it was recorded.
|
|
||||||
Action 1: Search[Guitars for Wounded Warriors]
|
|
||||||
Observation 1: Guitars for Wounded Warriors is the sixth solo studio album by guitarist Brian Tarquin, released in August 2014 by Cleopatra Records. In 2016, it received a Best Compilation Album nomination by the Independent Music Awards. All tracks were recorded at Tarquin's Jungle Room Studios in New Paltz (village), New York. Being moved by the lack of support for returning veterans through his life Tarquin decided to compose a heavy instrumental rock album as a way to show his appreciation to all veterans. So once again he enlisted top notch players to guest with him on the album, Billy Sheehan on Black Hawk, Ron \"Bumblefoot\" Thal and Reb Beach on Taliban Terror, Steve Morse on Freedom, Chris Poland on Charlie Surfs and Hunting, Chuck Loeb on Escape Kabul, Hal Lindes on Sand & Blood, Gary Hoey on 5 Klicks To Hell and Baghdad, Alex De Rosso Dokken on Broken Arrow, and The Flyin' Ryan Brothers on Surgical Strike. The entire album was engineered, produced and composed by Tarquin especially for each one of the guest guitarists. Partial proceeds are donated to the Fisher House Foundation from sales.
|
|
||||||
Thought 2: Guitars for Wounded Warriors was recorded in New Paltz (village), New York. I need to search New Paltz (village), New York and find which county it is in
|
|
||||||
Action 2: Search[New Paltz (village), New York]
|
|
||||||
Observation 2: New Paltz is a village in Ulster County located in the U.S. state of New York. It is approximately 80 miles (130 km) north of New York City and 70 miles (110 km) south of Albany. The population was 7,324 at the 2020 census.[3]
|
|
||||||
Thought 3: New Paltz (village), New York is in Ulster County, so the answer is Ulster County.
|
|
||||||
Action 3: Finish[Ulster County]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
cot_prompt_short = '''
|
|
||||||
Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
cot_prompt_feedback_short = '''You are also an advanced reasoning agent that can improve based on self refection. Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
You have attempted to answer the following question before and failed. The following reflection(s) give a plan to avoid failing to answer the question in the same way you did previously. Use them to improve your strategy of correctly answering the given question.
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
cot_prompt_feedback = '''You are also an advanced reasoning agent that can improve based on self refection. Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Guitars for Wounded Warriors is an album that was recorded in the village in which New York county?
|
|
||||||
Thought 1: I need to search Guitars for Wounded Warriors, then find in which New York county it was recorded.
|
|
||||||
Action 1: Search[Guitars for Wounded Warriors]
|
|
||||||
Observation 1: Guitars for Wounded Warriors is the sixth solo studio album by guitarist Brian Tarquin, released in August 2014 by Cleopatra Records. In 2016, it received a Best Compilation Album nomination by the Independent Music Awards. All tracks were recorded at Tarquin's Jungle Room Studios in New Paltz (village), New York. Being moved by the lack of support for returning veterans through his life Tarquin decided to compose a heavy instrumental rock album as a way to show his appreciation to all veterans. So once again he enlisted top notch players to guest with him on the album, Billy Sheehan on Black Hawk, Ron \"Bumblefoot\" Thal and Reb Beach on Taliban Terror, Steve Morse on Freedom, Chris Poland on Charlie Surfs and Hunting, Chuck Loeb on Escape Kabul, Hal Lindes on Sand & Blood, Gary Hoey on 5 Klicks To Hell and Baghdad, Alex De Rosso Dokken on Broken Arrow, and The Flyin' Ryan Brothers on Surgical Strike. The entire album was engineered, produced and composed by Tarquin especially for each one of the guest guitarists. Partial proceeds are donated to the Fisher House Foundation from sales.
|
|
||||||
Thought 2: Guitars for Wounded Warriors was recorded in New Paltz (village), New York. I need to search New Paltz (village), New York and find which county it is in
|
|
||||||
Action 2: Search[New Paltz (village), New York]
|
|
||||||
Observation 2: New Paltz is a village in Ulster County located in the U.S. state of New York. It is approximately 80 miles (130 km) north of New York City and 70 miles (110 km) south of Albany. The population was 7,324 at the 2020 census.[3]
|
|
||||||
Thought 3: New Paltz (village), New York is in Ulster County, so the answer is Ulster County.
|
|
||||||
Action 3: Finish[Ulster County]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
You have attempted to answer the following question before and failed, either because your reasoning for the answer was incorrect or the phrasing of your response did not exactly match the answer. The following reflection(s) give a plan to avoid failing to answer the question in the same way you did previously. Use them to improve your strategy of correctly answering the given question.
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
When providing the thought and action for the current trial, that into account these failed trajectories and make sure not to repeat the same mistakes and incorrect answers.
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
vote_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by pairs of thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a list of trajectories, decide which trajectory is most promising. Analyze each trajectory in detail and consider possible errors, then conclude in the last line "The best trajectory is {s}", where s the integer id of the trajectory.
|
|
||||||
'''
|
|
||||||
|
|
||||||
compare_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by pairs of thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Briefly analyze the correctness of the following two trajectories. Conclude in the last line "The more correct trajectory is 1", "The more correct trajectory is 2", or "The two trajectories are similarly correct".
|
|
||||||
'''
|
|
||||||
|
|
||||||
score_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by pairs of thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, analyze the following trajectory, then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?
|
|
||||||
Thought 1: I need to search for the football manager who recruited David Beckham, and then find out the timeframe in which he managed Manchester United.
|
|
||||||
Action 1: Search[David Beckham's football manager]
|
|
||||||
Observation 1: Could not find David Beckham's football manager. Similar: ['David Beckham', 'Inter Miami CF (redirect from Miami Beckham United)', 'Victoria Beckham', 'The Beckham Experiment', 'Miami Freedom Park'].
|
|
||||||
Thought 2: I couldn't find the information on David Beckham's football manager. I need to search Manchester United and find out the timeframe of the manager.
|
|
||||||
Action 2: Search[Manchester United]
|
|
||||||
Observation 2: Manchester United Football Club, commonly referred to as Man United (often stylised as Man Utd), or simply United, is a professional football club based in Old Trafford, Greater Manchester, England. The club competes in the Premier League, the top division in the English football league system. Nicknamed the Red Devils, they were founded as Newton Heath LYR Football Club in 1878, but changed their name to Manchester United in 1902. After a spell playing in Clayton, Manchester, the club moved to their current stadium, Old Trafford, in 1910.. Domestically, Manchester United have won a record 20 league titles, 12 FA Cups, six League Cups and a record 21 FA Community Shields.
|
|
||||||
Thought 3: The information about David Beckham's football manager is not available. I will search for Manchester United's managers to find the timeframe.
|
|
||||||
Action 3: Search[Manchester United managers]
|
|
||||||
Observation 3: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thought 4: The information about David Beckham's football manager is not available. The question asks for the timeframe when the manager managed Manchester United, so I need to find a list of Manchester United managers.
|
|
||||||
Action 4: Search[list of Manchester United managers]
|
|
||||||
Observation 4: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thus the correctness score is 4
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_feedback = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_reasoning = '''You are an advanced reasoning agent that can improve based on self refection. Analyze the trajectories of your previous solutions to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
This trajectory is incorrect as my search should be related to Mexican Formula One race car drivers, not winners of the Mexican Grand Prix, a seperate event. A better search would have been for the List of Formula One Grand Prix winners, as suggested.
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
This trajectory is correct as it is reasonable to search for the first magazine provided in the question. It is also better to have simple searches corresponding to a single entity, making this the best action.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?
|
|
||||||
Thought 1: I need to search for the football manager who recruited David Beckham, and then find out the timeframe in which he managed Manchester United.
|
|
||||||
Action 1: Search[David Beckham's football manager]
|
|
||||||
Observation 1: Could not find David Beckham's football manager. Similar: ['David Beckham', 'Inter Miami CF (redirect from Miami Beckham United)', 'Victoria Beckham', 'The Beckham Experiment', 'Miami Freedom Park'].
|
|
||||||
Thought 2: I couldn't find the information on David Beckham's football manager. I need to search Manchester United and find out the timeframe of the manager.
|
|
||||||
Action 2: Search[Manchester United]
|
|
||||||
Observation 2: Manchester United Football Club, commonly referred to as Man United (often stylised as Man Utd), or simply United, is a professional football club based in Old Trafford, Greater Manchester, England. The club competes in the Premier League, the top division in the English football league system. Nicknamed the Red Devils, they were founded as Newton Heath LYR Football Club in 1878, but changed their name to Manchester United in 1902. After a spell playing in Clayton, Manchester, the club moved to their current stadium, Old Trafford, in 1910.. Domestically, Manchester United have won a record 20 league titles, 12 FA Cups, six League Cups and a record 21 FA Community Shields.
|
|
||||||
Thought 3: The information about David Beckham's football manager is not available. I will search for Manchester United's managers to find the timeframe.
|
|
||||||
Action 3: Search[Manchester United managers]
|
|
||||||
Observation 3: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thought 4: The information about David Beckham's football manager is not available. The question asks for the timeframe when the manager managed Manchester United, so I need to find a list of Manchester United managers.
|
|
||||||
Action 4: Search[list of Manchester United managers]
|
|
||||||
Observation 4: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
This trajectory is mostly incorrect as I was not able to retrieve the relevant information to answer the question. The searches are too broad and not relevant to the specific player recruited, David Beckham. The last two actions are also too similar. It would be better to first search for David Beckham and lookup information related to his manager.
|
|
||||||
Thus the correctness score is 4
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
This trajectory is correct as all of my thoughts and actions are correct. It makes sense to search for Milhouse first as it is the central subject of the question. It is also correct to directly look up the relevant information in the article, instead of trying another search.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_reasoning_feedback = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
This trajectory is incorrect as my search should be related to Mexican Formula One race car drivers, not winners it is reasonable to checkof the Mexican Grand Prix, a seperate event. A better search would have been for the List of Formula One Grand Prix winners, as suggested.
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
This trajectory is correct as it is reasonable to search for the first magazine provided in the question. It is also better to have simple searches corresponding to a single entity, making this the best action.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?
|
|
||||||
Thought 1: I need to search for the football manager who recruited David Beckham, and then find out the timeframe in which he managed Manchester United.
|
|
||||||
Action 1: Search[David Beckham's football manager]
|
|
||||||
Observation 1: Could not find David Beckham's football manager. Similar: ['David Beckham', 'Inter Miami CF (redirect from Miami Beckham United)', 'Victoria Beckham', 'The Beckham Experiment', 'Miami Freedom Park'].
|
|
||||||
Thought 2: I couldn't find the information on David Beckham's football manager. I need to search Manchester United and find out the timeframe of the manager.
|
|
||||||
Action 2: Search[Manchester United]
|
|
||||||
Observation 2: Manchester United Football Club, commonly referred to as Man United (often stylised as Man Utd), or simply United, is a professional football club based in Old Trafford, Greater Manchester, England. The club competes in the Premier League, the top division in the English football league system. Nicknamed the Red Devils, they were founded as Newton Heath LYR Football Club in 1878, but changed their name to Manchester United in 1902. After a spell playing in Clayton, Manchester, the club moved to their current stadium, Old Trafford, in 1910.. Domestically, Manchester United have won a record 20 league titles, 12 FA Cups, six League Cups and a record 21 FA Community Shields.
|
|
||||||
Thought 3: The information about David Beckham's football manager is not available. I will search for Manchester United's managers to find the timeframe.
|
|
||||||
Action 3: Search[Manchester United managers]
|
|
||||||
Observation 3: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thought 4: The information about David Beckham's football manager is not available. The question asks for the timeframe when the manager managed Manchester United, so I need to find a list of Manchester United managers.
|
|
||||||
Action 4: Search[list of Manchester United managers]
|
|
||||||
Observation 4: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
This trajectory is mostly incorrect as I was not able to retrieve the relevant information to answer the question. The searches are too broad and not relevant to the specific player recruited, David Beckham. The last two actions are also too similar. It would be better to first search for David Beckham and lookup information related to his manager.
|
|
||||||
Thus the correctness score is 4
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
This trajectory is correct as all of my thoughts and actions are correct. It makes sense to search for Milhouse first as it is the central subject of the question. It is also correct to directly look up the relevant information in the article, instead of trying another search.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_reasoning_feedback_short = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
This trajectory is incorrect as my search should be related to Mexican Formula One race car drivers, not winners of the Mexican Grand Prix, a seperate event. A better search would have been for the List of Formula One Grand Prix winners, as suggested.
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
This trajectory is correct as all of my thoughts and actions are correct. It makes sense to search for Milhouse first as it is the central subject of the question. It is also correct to directly look up the relevant information in the article, instead of trying another search.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
rap_prompt = '''
|
|
||||||
Solve a question answering task with interleaving Thought and Action steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
Provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Thought 2: Then I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Guitars for Wounded Warriors is an album that was recorded in the village in which New York county?
|
|
||||||
Thought 1: I need to search Guitars for Wounded Warriors, then find in which New York county it was recorded.
|
|
||||||
Action 1: Search[Guitars for Wounded Warriors]
|
|
||||||
Thought 2: I need to search New Paltz (village), New York and find which county it is in
|
|
||||||
Action 2: Search[New Paltz (village), New York]
|
|
||||||
Thought 3: New Paltz (village), New York is in Ulster County, so the answer is Ulster County.
|
|
||||||
Action 3: Finish[Ulster County]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Thought 2: I can look up "named after" for finding the specific individual Milhouse is named after.
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
module YiemAgent
|
|
||||||
|
|
||||||
# export agent
|
|
||||||
|
|
||||||
|
|
||||||
""" Order by dependencies of each file. The 1st included file must not depend on any other
|
|
||||||
files and each file can only depend on the file included before it.
|
|
||||||
"""
|
|
||||||
|
|
||||||
include("type.jl")
|
|
||||||
using .type
|
|
||||||
|
|
||||||
include("util.jl")
|
|
||||||
using .util
|
|
||||||
|
|
||||||
include("llmfunction.jl")
|
|
||||||
using .llmfunction
|
|
||||||
|
|
||||||
include("mcts.jl")
|
|
||||||
using .mcts
|
|
||||||
|
|
||||||
include("interface.jl")
|
|
||||||
using .interface
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module YiemAgent_v1
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,825 +0,0 @@
|
|||||||
module llmfunction
|
|
||||||
|
|
||||||
export virtualWineUserChatbox, jsoncorrection, winestock,
|
|
||||||
virtualWineUserRecommendbox, userChatbox, userRecommendbox
|
|
||||||
|
|
||||||
using HTTP, JSON3, URIs, Random, PrettyPrinting
|
|
||||||
using GeneralUtils
|
|
||||||
using ..type, ..util
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
|
|
||||||
# Return
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docstring
|
|
||||||
- [WORKING] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function userChatbox(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
|
||||||
error("--> userChatbox")
|
|
||||||
|
|
||||||
# put in model format
|
|
||||||
virtualWineCustomer = a.config[:externalservice][:virtualWineCustomer_1]
|
|
||||||
llminfo = virtualWineCustomer[:llminfo]
|
|
||||||
formattedinput =
|
|
||||||
if llminfo[:name] == "llama3instruct"
|
|
||||||
formatLLMtext_llama3instruct("assistant", input)
|
|
||||||
else
|
|
||||||
error("llm model name is not defied yet $(@__LINE__)")
|
|
||||||
end
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
|
|
||||||
|
|
||||||
# return response
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
|
|
||||||
# Return
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docstring
|
|
||||||
- [PENDING] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function userRecommendbox(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
|
||||||
error("--> userRecommendbox")
|
|
||||||
|
|
||||||
# put in model format
|
|
||||||
virtualWineCustomer = a.config[:externalservice][:virtualWineCustomer_1]
|
|
||||||
llminfo = virtualWineCustomer[:llminfo]
|
|
||||||
formattedinput =
|
|
||||||
if llminfo[:name] == "llama3instruct"
|
|
||||||
formatLLMtext_llama3instruct("assistant", input)
|
|
||||||
else
|
|
||||||
error("llm model name is not defied yet $(@__LINE__)")
|
|
||||||
end
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
|
|
||||||
|
|
||||||
# return response
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Chatbox for chatting with virtual wine customer.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
one of Yiem's agent
|
|
||||||
- `input::T2`
|
|
||||||
text to be send to virtual wine customer
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `response::String`
|
|
||||||
response of virtual wine customer
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docstring
|
|
||||||
- [] add reccommend() to compare wine
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function virtualWineUserRecommendbox(a::T1, input
|
|
||||||
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:agent}
|
|
||||||
|
|
||||||
# put in model format
|
|
||||||
virtualWineCustomer = a.config[:externalservice][:virtualWineCustomer_1]
|
|
||||||
llminfo = virtualWineCustomer[:llminfo]
|
|
||||||
prompt =
|
|
||||||
if llminfo[:name] == "llama3instruct"
|
|
||||||
formatLLMtext_llama3instruct("assistant", input)
|
|
||||||
else
|
|
||||||
error("llm model name is not defied yet $(@__LINE__)")
|
|
||||||
end
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
virtualWineCustomer[:mqtttopic],
|
|
||||||
senderName= "virtualWineUserRecommendbox",
|
|
||||||
senderId= a.id,
|
|
||||||
receiverName= "virtualWineCustomer",
|
|
||||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
|
||||||
msgId = "dummyid" #CHANGE remove after testing finished
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
result = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120)
|
|
||||||
response = result[:response]
|
|
||||||
|
|
||||||
return (response[:text], response[:select], response[:reward], response[:isterminal])
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" Chatbox for chatting with virtual wine customer.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
one of Yiem's agent
|
|
||||||
- `input::T2`
|
|
||||||
text to be send to virtual wine customer
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `response::String`
|
|
||||||
response of virtual wine customer
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docs
|
|
||||||
- [x] write a prompt for virtual customer
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function virtualWineUserChatbox(a::T1, input::T2, virtualCustomerChatHistory
|
|
||||||
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:agent, T2<:AbstractString}
|
|
||||||
|
|
||||||
previouswines =
|
|
||||||
"""
|
|
||||||
You have the following wines previously:
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
systemmsg =
|
|
||||||
"""
|
|
||||||
You find yourself in a well-stocked wine store, engaged in a conversation with the store's knowledgeable sommelier.
|
|
||||||
You're on a quest to find a bottle of wine that aligns with your specific preferences and requirements.
|
|
||||||
|
|
||||||
The ideal wine you're seeking should meet the following criteria:
|
|
||||||
1. It should fit within your budget.
|
|
||||||
2. It should be suitable for the occasion you're planning.
|
|
||||||
3. It should pair well with the food you intend to serve.
|
|
||||||
4. It should be of a particular type of wine you prefer.
|
|
||||||
5. It should possess certain characteristics, including:
|
|
||||||
- The level of sweetness.
|
|
||||||
- The intensity of its flavor.
|
|
||||||
- The amount of tannin it contains.
|
|
||||||
- Its acidity level.
|
|
||||||
|
|
||||||
Here's the criteria details:
|
|
||||||
{
|
|
||||||
"budget": 50,
|
|
||||||
"occasion": "graduation ceremony",
|
|
||||||
"food pairing": "Thai food",
|
|
||||||
"type of wine": "red",
|
|
||||||
"wine sweetness level": "dry",
|
|
||||||
"wine intensity level": "full-bodied",
|
|
||||||
"wine tannin level": "low",
|
|
||||||
"wine acidity level": "medium",
|
|
||||||
}
|
|
||||||
|
|
||||||
You should only respond with "text", "select", "reward", "isterminal" steps.
|
|
||||||
"text" is your conversation.
|
|
||||||
"select" is an integer. Choose an option when presented with choices, or leave it null if none of the options satisfy you or if no choices are available.
|
|
||||||
"reward" is an integer, it can be three number:
|
|
||||||
1) 1 if you find the right wine.
|
|
||||||
2) 0 if you don’t find the ideal wine.
|
|
||||||
3) -1 if you’re dissatisfied with the sommelier’s response.
|
|
||||||
"isterminal" can be false if you still want to talk with the sommelier, true otherwise.
|
|
||||||
|
|
||||||
You should only respond in JSON format as describe below:
|
|
||||||
{
|
|
||||||
"text": "your conversation",
|
|
||||||
"select": null,
|
|
||||||
"reward": 0,
|
|
||||||
"isterminal": false
|
|
||||||
}
|
|
||||||
|
|
||||||
Here are some examples:
|
|
||||||
|
|
||||||
sommelier: "What's your budget?
|
|
||||||
you:
|
|
||||||
{
|
|
||||||
"text": "My budget is 30 USD.",
|
|
||||||
"select": null,
|
|
||||||
"reward": 0,
|
|
||||||
"isterminal": false
|
|
||||||
}
|
|
||||||
|
|
||||||
sommelier: "The first option is Zena Crown and the second one is Buano Red."
|
|
||||||
you:
|
|
||||||
{
|
|
||||||
"text": "I like the 2nd option.",
|
|
||||||
"select": 2,
|
|
||||||
"reward": 1,
|
|
||||||
"isterminal": true
|
|
||||||
}
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
"""
|
|
||||||
|
|
||||||
pushfirst!(virtualCustomerChatHistory, Dict(:name=> "system", :text=> systemmsg))
|
|
||||||
|
|
||||||
# replace the :user key in chathistory to allow the virtual wine customer AI roleplay
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}} = Vector{Dict{Symbol, Any}}()
|
|
||||||
for i in virtualCustomerChatHistory
|
|
||||||
newdict = Dict()
|
|
||||||
newdict[:name] =
|
|
||||||
if i[:name] == "user"
|
|
||||||
"you"
|
|
||||||
elseif i[:name] == "assistant"
|
|
||||||
"sommelier"
|
|
||||||
else
|
|
||||||
i[:name]
|
|
||||||
end
|
|
||||||
|
|
||||||
newdict[:text] = i[:text]
|
|
||||||
push!(chathistory, newdict)
|
|
||||||
end
|
|
||||||
|
|
||||||
push!(chathistory, Dict(:name=> "assistant", :text=> input))
|
|
||||||
|
|
||||||
# put in model format
|
|
||||||
prompt = formatLLMtext(chathistory, "llama3instruct")
|
|
||||||
prompt *=
|
|
||||||
"""
|
|
||||||
<|start_header_id|>you<|end_header_id|>
|
|
||||||
{"text"
|
|
||||||
"""
|
|
||||||
|
|
||||||
pprint(prompt)
|
|
||||||
externalService = a.config[:externalservice][:text2textinstruct]
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
externalService[:mqtttopic],
|
|
||||||
senderName= "virtualWineUserChatbox",
|
|
||||||
senderId= a.id,
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
|
||||||
msgId = "dummyid" #CHANGE remove after testing finished
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
attempt = 0
|
|
||||||
for attempt in 1:5
|
|
||||||
try
|
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120)
|
|
||||||
_responseJsonStr = response[:response][:text]
|
|
||||||
expectedJsonExample =
|
|
||||||
"""
|
|
||||||
Here is an expected JSON format:
|
|
||||||
{
|
|
||||||
"text": "...",
|
|
||||||
"select": "...",
|
|
||||||
"reward": "...",
|
|
||||||
"isterminal": "..."
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
|
|
||||||
responseDict = copy(JSON3.read(responseJsonStr))
|
|
||||||
|
|
||||||
text::AbstractString = responseDict[:text]
|
|
||||||
select::Union{Nothing, Number} = responseDict[:select] == "null" ? nothing : responseDict[:select]
|
|
||||||
reward::Number = responseDict[:reward]
|
|
||||||
isterminal::Bool = responseDict[:isterminal]
|
|
||||||
|
|
||||||
if text != ""
|
|
||||||
# pass test
|
|
||||||
else
|
|
||||||
error("virtual customer not answer correctly")
|
|
||||||
end
|
|
||||||
|
|
||||||
return (text, select, reward, isterminal)
|
|
||||||
catch e
|
|
||||||
io = IOBuffer()
|
|
||||||
showerror(io, e)
|
|
||||||
errorMsg = String(take!(io))
|
|
||||||
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
|
|
||||||
println("")
|
|
||||||
@warn "Error occurred: $errorMsg\n$st"
|
|
||||||
println("")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
error("virtualWineUserChatbox failed to get a response")
|
|
||||||
end
|
|
||||||
|
|
||||||
""" Search wine in stock.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
one of ChatAgent's agent.
|
|
||||||
- `input::T2`
|
|
||||||
# Return
|
|
||||||
A JSON string of available wine
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> using ChatAgent
|
|
||||||
julia> agent = ChatAgent.agentReflex("Jene")
|
|
||||||
julia> input = "{\"food\": \"pizza\", \"occasion\": \"anniversary\"}"
|
|
||||||
julia> result = winestock(agent, input)
|
|
||||||
"{"wine 1": {\"Winery\": \"Pichon Baron\", \"wine name\": \"Pauillac (Grand Cru Classé)\", \"grape variety\": \"Cabernet Sauvignon\", \"year\": 2010, \"price\": \"125 USD\", \"stock ID\": \"ar-17\"}, }"
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
[] update docs
|
|
||||||
[WORKING] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function winestock(a::T1, input::T2
|
|
||||||
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:agent, T2<:AbstractString}
|
|
||||||
|
|
||||||
# SELECT *
|
|
||||||
# FROM food
|
|
||||||
# WHERE 'China' = ANY(food_name)
|
|
||||||
# OR 'India' = ANY(food_name);
|
|
||||||
|
|
||||||
|
|
||||||
wineattributes = wineattributes_wordToNumber(a, input)
|
|
||||||
|
|
||||||
systemmsg =
|
|
||||||
"""
|
|
||||||
As a helpful sommelier, your mission is to write SQL queries that search the PostgreSQL database for wines based on user input.
|
|
||||||
|
|
||||||
The database has the following tables (schema):
|
|
||||||
1. Table wine (
|
|
||||||
wine_id uuid primary key,
|
|
||||||
wine_name varchar,
|
|
||||||
brand varchar,
|
|
||||||
manufacturer varchar,
|
|
||||||
region varchar,
|
|
||||||
country varchar,
|
|
||||||
wine_type varchar,
|
|
||||||
grape_variety varchar,
|
|
||||||
serving_temperature varchar,
|
|
||||||
intensity integer,
|
|
||||||
sweetness integer,
|
|
||||||
tannin integer,
|
|
||||||
acidity integer,
|
|
||||||
fizziness integer,
|
|
||||||
|
|
||||||
other_attributes jsonb,
|
|
||||||
|
|
||||||
created_at timestamptz,
|
|
||||||
updated_at timestamptz,
|
|
||||||
description text
|
|
||||||
)
|
|
||||||
|
|
||||||
2. Table food (
|
|
||||||
food_id uuid primary key,
|
|
||||||
food_name varchar,
|
|
||||||
country varchar,
|
|
||||||
spicy integer,
|
|
||||||
sweet integer,
|
|
||||||
sour integer,
|
|
||||||
umami integer,
|
|
||||||
bitter integer,
|
|
||||||
serving_temperature integer,
|
|
||||||
other_attributes jsonb,
|
|
||||||
|
|
||||||
created_at timestamptz,
|
|
||||||
updated_at timestamptz,
|
|
||||||
description text
|
|
||||||
)
|
|
||||||
|
|
||||||
3. wine_food (
|
|
||||||
wine_id uuid references wine(wine_id),
|
|
||||||
food_id uuid references food(food_id),
|
|
||||||
constraint wine_food_id primary key (wine_id, food_id),
|
|
||||||
|
|
||||||
created_at timestamptz,
|
|
||||||
updated_at timestamptz
|
|
||||||
)
|
|
||||||
|
|
||||||
You should only respond in JSON format as describe below:
|
|
||||||
{
|
|
||||||
"SQL":
|
|
||||||
{
|
|
||||||
"sweetness": "sweetness level",
|
|
||||||
"acidity": "acidity level",
|
|
||||||
"tannin": "tannin level",
|
|
||||||
"intensity": "intensity level"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Here are some examples:
|
|
||||||
|
|
||||||
user: {"sweetness": 2,"acidity": 3,"tannin": 1,"intensity": 5, "food": "Thai"}
|
|
||||||
assistant:
|
|
||||||
{
|
|
||||||
"SQL":
|
|
||||||
}
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
"""
|
|
||||||
|
|
||||||
usermsg =
|
|
||||||
"""
|
|
||||||
$input
|
|
||||||
"""
|
|
||||||
|
|
||||||
chathistory =
|
|
||||||
[
|
|
||||||
Dict(:name=> "system", :text=> systemmsg),
|
|
||||||
Dict(:name=> "user", :text=> usermsg)
|
|
||||||
]
|
|
||||||
|
|
||||||
# put in model format
|
|
||||||
prompt = formatLLMtext(chathistory, "llama3instruct")
|
|
||||||
prompt *=
|
|
||||||
"""
|
|
||||||
<|start_header_id|>assistant<|end_header_id|>
|
|
||||||
{
|
|
||||||
"""
|
|
||||||
|
|
||||||
pprint(prompt)
|
|
||||||
externalService = a.config[:externalservice][:text2textinstruct]
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
externalService[:mqtttopic],
|
|
||||||
senderName= "virtualWineUserChatbox",
|
|
||||||
senderId= a.id,
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
|
||||||
msgId = "dummyid" #CHANGE remove after testing finished
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
attempt = 0
|
|
||||||
for attempt in 1:5
|
|
||||||
try
|
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120)
|
|
||||||
_responseJsonStr = response[:response][:text]
|
|
||||||
expectedJsonExample =
|
|
||||||
"""
|
|
||||||
Here is an expected JSON format:
|
|
||||||
{
|
|
||||||
"attributes":
|
|
||||||
{
|
|
||||||
"...": "...",
|
|
||||||
"...": "...",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
|
|
||||||
_responseDict = copy(JSON3.read(responseJsonStr))
|
|
||||||
responseDict = _responseDict[:attributes]
|
|
||||||
|
|
||||||
return responseDict
|
|
||||||
catch e
|
|
||||||
io = IOBuffer()
|
|
||||||
showerror(io, e)
|
|
||||||
errorMsg = String(take!(io))
|
|
||||||
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
|
|
||||||
println("")
|
|
||||||
@warn "Error occurred: $errorMsg\n$st"
|
|
||||||
println("")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
error("wineattributes_wordToNumber() failed to get a response")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# winesStr =
|
|
||||||
# """
|
|
||||||
# 1: El Enemigo Cabernet Franc 2019
|
|
||||||
# 2: Tantara Chardonnay 2017
|
|
||||||
# """
|
|
||||||
# result =
|
|
||||||
# """
|
|
||||||
# I found the following wines in our stock:
|
|
||||||
# {
|
|
||||||
# $winesStr
|
|
||||||
# }
|
|
||||||
# """
|
|
||||||
# return result, nothing, 0, false
|
|
||||||
end
|
|
||||||
|
|
||||||
function wineattributes_wordToNumber(a::T1, input::T2
|
|
||||||
)::Dict where {T1<:agent, T2<:AbstractString}
|
|
||||||
|
|
||||||
systemmsg =
|
|
||||||
"""
|
|
||||||
As an attentive sommelier, your mission is to determine the user's preferred levels of sweetness, intensity, tannin, acidity and other criteria for a wine based on their input.
|
|
||||||
You'll achieve this by referring to the provided conversion table.
|
|
||||||
|
|
||||||
Conversion Table:
|
|
||||||
Intensity level:
|
|
||||||
Level 1: May correspond to "light-bodied" or a similar description.
|
|
||||||
Level 2: May correspond to "med light", "medium light" or a similar description.
|
|
||||||
Level 3: May correspond to "medium" or a similar description.
|
|
||||||
Level 4: May correspond to "med full", "medium full" or a similar description.
|
|
||||||
Level 5: May correspond to "full" or a similar description.
|
|
||||||
Sweetness level:
|
|
||||||
Level 1: May correspond to "dry", "no sweet" or a similar description.
|
|
||||||
Level 2: May correspond to "off dry", "less sweet" or a similar description.
|
|
||||||
Level 3: May correspond to "semi sweet" or a similar description.
|
|
||||||
Level 4: May correspond to "sweet" or a similar description.
|
|
||||||
Level 5: May correspond to "very sweet" or a similar description.
|
|
||||||
Tannin level:
|
|
||||||
Level 1: May correspond to "low tannin" or a similar description.
|
|
||||||
Level 2: May correspond to "semi low tannin" or a similar description.
|
|
||||||
Level 3: May correspond to "medium tannin" or a similar description.
|
|
||||||
Level 4: May correspond to "semi high tannin" or a similar description.
|
|
||||||
Level 5: May correspond to "high tannin" or a similar description.
|
|
||||||
Acidity level:
|
|
||||||
Level 1: May correspond to "low acidity" or a similar description.
|
|
||||||
Level 2: May correspond to "semi low acidity" or a similar description.
|
|
||||||
Level 3: May correspond to "medium acidity" or a similar description.
|
|
||||||
Level 4: May correspond to "semi high acidity" or a similar description.
|
|
||||||
Level 5: May correspond to "high acidity" or a similar description.
|
|
||||||
|
|
||||||
You should only respond in JSON format as describe below:
|
|
||||||
{
|
|
||||||
"attributes":
|
|
||||||
{
|
|
||||||
"sweetness": "sweetness level",
|
|
||||||
"acidity": "acidity level",
|
|
||||||
"tannin": "tannin level",
|
|
||||||
"intensity": "intensity level"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Here are some examples:
|
|
||||||
|
|
||||||
user: "price < 25, full-bodied white wine with sweetness level 2, low tannin level and medium acidity level, Pizza"
|
|
||||||
assistant:
|
|
||||||
{
|
|
||||||
"attributes":
|
|
||||||
{
|
|
||||||
"wine_type": "white"
|
|
||||||
"budget": less than 25",
|
|
||||||
"food_pairing": "Pizza",
|
|
||||||
"sweetness": 2,
|
|
||||||
"acidity": 3,
|
|
||||||
"tannin": 1,
|
|
||||||
"intensity": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
user: body=full-bodied, off dry, acidity=medium, intensity=intense
|
|
||||||
assistant:
|
|
||||||
{
|
|
||||||
"attributes":
|
|
||||||
{
|
|
||||||
"sweetness": 2,
|
|
||||||
"acidity": 3,
|
|
||||||
"tannin": "not specified",
|
|
||||||
"intensity": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
"""
|
|
||||||
|
|
||||||
usermsg =
|
|
||||||
"""
|
|
||||||
$input
|
|
||||||
"""
|
|
||||||
|
|
||||||
chathistory =
|
|
||||||
[
|
|
||||||
Dict(:name=> "system", :text=> systemmsg),
|
|
||||||
Dict(:name=> "user", :text=> usermsg)
|
|
||||||
]
|
|
||||||
|
|
||||||
# put in model format
|
|
||||||
prompt = formatLLMtext(chathistory, "llama3instruct")
|
|
||||||
prompt *=
|
|
||||||
"""
|
|
||||||
<|start_header_id|>assistant<|end_header_id|>
|
|
||||||
{
|
|
||||||
"""
|
|
||||||
|
|
||||||
pprint(prompt)
|
|
||||||
externalService = a.config[:externalservice][:text2textinstruct]
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
externalService[:mqtttopic],
|
|
||||||
senderName= "wineattributes_wordToNumber",
|
|
||||||
senderId= a.id,
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
attempt = 0
|
|
||||||
for attempt in 1:5
|
|
||||||
try
|
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120)
|
|
||||||
_responseJsonStr = response[:response][:text]
|
|
||||||
expectedJsonExample =
|
|
||||||
"""
|
|
||||||
Here is an expected JSON format:
|
|
||||||
{
|
|
||||||
"attributes":
|
|
||||||
{
|
|
||||||
"...": "...",
|
|
||||||
"...": "...",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
|
|
||||||
_responseDict = copy(JSON3.read(responseJsonStr))
|
|
||||||
responseDict = _responseDict[:attributes]
|
|
||||||
|
|
||||||
return responseDict
|
|
||||||
catch e
|
|
||||||
io = IOBuffer()
|
|
||||||
showerror(io, e)
|
|
||||||
errorMsg = String(take!(io))
|
|
||||||
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
|
|
||||||
println("")
|
|
||||||
@warn "Error occurred: $errorMsg\n$st"
|
|
||||||
println("")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
error("wineattributes_wordToNumber() failed to get a response")
|
|
||||||
end
|
|
||||||
|
|
||||||
""" Attemp to correct LLM response's incorrect JSON response.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
one of Yiem's agent
|
|
||||||
- `input::T2`
|
|
||||||
text to be send to virtual wine customer
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `correctjson::String`
|
|
||||||
corrected json string
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function jsoncorrection(a::T1, input::T2, correctJsonExample::T3;
|
|
||||||
maxattempt::Integer=3
|
|
||||||
) where {T1<:agent, T2<:AbstractString, T3<:AbstractString}
|
|
||||||
|
|
||||||
incorrectjson = deepcopy(input)
|
|
||||||
correctjson = nothing
|
|
||||||
|
|
||||||
for attempt in 1:maxattempt
|
|
||||||
try
|
|
||||||
d = copy(JSON3.read(incorrectjson))
|
|
||||||
correctjson = incorrectjson
|
|
||||||
return correctjson
|
|
||||||
catch e
|
|
||||||
@warn "Attempting to correct JSON string. Attempt $attempt"
|
|
||||||
e = """$e"""
|
|
||||||
if occursin("EOF", e)
|
|
||||||
e = split(e, "EOF")[1] * "EOF"
|
|
||||||
end
|
|
||||||
incorrectjson = deepcopy(input)
|
|
||||||
_prompt =
|
|
||||||
"""
|
|
||||||
Your goal are:
|
|
||||||
1) Use the expected JSON format as a guideline to check why the given JSON string failed to load and provide a corrected version that can be loaded by Python's json.load function.
|
|
||||||
2) Provide Corrected JSON string only. Do not provide any other info.
|
|
||||||
|
|
||||||
$correctJsonExample
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
Given JSON string: $incorrectjson
|
|
||||||
The given JSON string failed to load previously because: $e
|
|
||||||
Corrected JSON string:
|
|
||||||
"""
|
|
||||||
|
|
||||||
# apply LLM specific instruct format
|
|
||||||
externalService = a.config[:externalservice][:text2textinstruct]
|
|
||||||
llminfo = externalService[:llminfo]
|
|
||||||
prompt =
|
|
||||||
if llminfo[:name] == "llama3instruct"
|
|
||||||
formatLLMtext_llama3instruct("system", _prompt)
|
|
||||||
else
|
|
||||||
error("llm model name is not defied yet $(@__LINE__)")
|
|
||||||
end
|
|
||||||
|
|
||||||
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
externalService[:mqtttopic],
|
|
||||||
senderName= "jsoncorrection",
|
|
||||||
senderId= a.id,
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
:kwargs=> Dict(
|
|
||||||
:max_tokens=> 512,
|
|
||||||
:stop=> ["<|eot_id|>"],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120)
|
|
||||||
incorrectjson = result[:response][:text]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module llmfunction
|
|
||||||
@@ -1,729 +0,0 @@
|
|||||||
""" https://www.harrycodes.com/blog/monte-carlo-tree-search
|
|
||||||
"""
|
|
||||||
|
|
||||||
module mcts
|
|
||||||
|
|
||||||
export MCTSNode, runMCTS, isleaf, selectBestNextState, selectBestTrajectory, transition,
|
|
||||||
userChatbox, makeNewState
|
|
||||||
|
|
||||||
using Dates, UUIDs, DataStructures, JSON3, Random, PrettyPrinting
|
|
||||||
using GeneralUtils
|
|
||||||
using ..type, ..llmfunction
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
""" a node for MCTS search tree
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `state::T`
|
|
||||||
a state of a game. Can be a Dict or something else.
|
|
||||||
- `visits::Integer `
|
|
||||||
number of time the game visits this state
|
|
||||||
- `stateValue::Float64`
|
|
||||||
state value
|
|
||||||
- `children::Dict{T, MCTSNode}`
|
|
||||||
children node
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `nothing`
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> state = Dict(
|
|
||||||
:info=> Dict(), # keyword info
|
|
||||||
:thoughtHistory=> Dict(
|
|
||||||
:question=> _,
|
|
||||||
:thought_1=> _,
|
|
||||||
:action_1=> _,
|
|
||||||
:observation_1=> _,
|
|
||||||
:thought_2=> _,
|
|
||||||
...
|
|
||||||
)
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
[] update docstring
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
mutable struct MCTSNode{T1<:AbstractDict, T2<:AbstractString}
|
|
||||||
nodekey::T2
|
|
||||||
state::T1
|
|
||||||
visits::Integer
|
|
||||||
progressvalue::Number # estimate value by LLM's reasoning
|
|
||||||
statevalue::Number # store discounted commulative reward (gather from its child node)
|
|
||||||
reward::Number # this node's own reward
|
|
||||||
isterminal::Bool
|
|
||||||
parent::Union{MCTSNode, Nothing}
|
|
||||||
children::Dict{String, MCTSNode}
|
|
||||||
end
|
|
||||||
|
|
||||||
""" Select a node based on UCT score
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
mcts node
|
|
||||||
- `w::T`
|
|
||||||
exploration weight. Value is usually between 1 to 2.
|
|
||||||
Value 1.0 makes MCTS balance between exploration and exploitation like 50%-50%.
|
|
||||||
Value 2.0 makes MCTS aggressively search the tree.
|
|
||||||
# Return
|
|
||||||
- `selectedNode::MCTSNode`
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function UCTselect(node::MCTSNode, w::T)::MCTSNode where {T<:AbstractFloat}
|
|
||||||
maxUCT = -Inf
|
|
||||||
selectedNode = nothing
|
|
||||||
|
|
||||||
for (childState, childNode) in node.children
|
|
||||||
UCTvalue =
|
|
||||||
if childNode.visits != 0
|
|
||||||
weightedterm = w * sqrt(log(node.visits) / childNode.visits) # explore term
|
|
||||||
childNode.statevalue + weightedterm
|
|
||||||
else # node.visits == 0 makes sqrt() in explore term error
|
|
||||||
childNode.progressvalue # exploit term
|
|
||||||
end
|
|
||||||
|
|
||||||
if UCTvalue > maxUCT
|
|
||||||
maxUCT = UCTvalue
|
|
||||||
selectedNode = childNode
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return selectedNode
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Expand selected node
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
One of YiemAgent's agent
|
|
||||||
- `node::MCTSNode`
|
|
||||||
MCTS node
|
|
||||||
- `state::T2`
|
|
||||||
a state of a game. Can be a Dict or something else.
|
|
||||||
- `decisionMaker::Function`
|
|
||||||
a function that output Thought and Action
|
|
||||||
- `evaluator::Function`
|
|
||||||
a function that output trajectory progress score
|
|
||||||
|
|
||||||
# Return
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
[] update docstring
|
|
||||||
[] try loop should limit to 3 times. if not succeed, skip
|
|
||||||
[] newNodeKey ∉ keys(node.children). New state may have semantic vector close enought to one of existing child state. Which can be assume that they are the same state semantically-wise.
|
|
||||||
[x] store feedback -> state -> agent.
|
|
||||||
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function expand(a::T1, node::MCTSNode, decisionMaker::Function,
|
|
||||||
evaluator::Function, reflector::Function; totalsample::Integer=3
|
|
||||||
) where {T1<:agent}
|
|
||||||
|
|
||||||
nthSample = 0
|
|
||||||
while true
|
|
||||||
nthSample += 1
|
|
||||||
if nthSample <= totalsample
|
|
||||||
thoughtDict = decisionMaker(a, node.state)
|
|
||||||
println("---> expand() sample $nthSample")
|
|
||||||
pprintln(node.state[:thoughtHistory])
|
|
||||||
pprintln(thoughtDict)
|
|
||||||
newNodeKey, newstate = MCTStransition(a, node.state, thoughtDict)
|
|
||||||
|
|
||||||
stateevaluation, progressvalue = evaluator(a, newstate)
|
|
||||||
|
|
||||||
if newstate[:reward] < 0
|
|
||||||
pprint(newstate[:thoughtHistory])
|
|
||||||
newstate[:evaluation] = stateevaluation
|
|
||||||
newstate[:lesson] = reflector(a, newstate)
|
|
||||||
|
|
||||||
# store new lesson for later use
|
|
||||||
lessonDict = copy(JSON3.read("lesson.json"))
|
|
||||||
latestLessonKey, latestLessonIndice =
|
|
||||||
GeneralUtils.findHighestIndexKey(lessonDict, "lesson")
|
|
||||||
nextIndice = latestLessonKey == :NA ? 1 : latestLessonIndice + 1
|
|
||||||
newLessonKey = Symbol("lesson_$(nextIndice)")
|
|
||||||
lessonDict[newLessonKey] = newstate
|
|
||||||
open("lesson.json", "w") do io
|
|
||||||
JSON3.pretty(io, lessonDict)
|
|
||||||
end
|
|
||||||
print("---> reflector()")
|
|
||||||
end
|
|
||||||
|
|
||||||
if newNodeKey ∉ keys(node.children)
|
|
||||||
node.children[newNodeKey] =
|
|
||||||
MCTSNode(newNodeKey, newstate, 0, progressvalue, 0, newstate[:reward],
|
|
||||||
newstate[:isterminal], node, Dict{String, MCTSNode}())
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" Simulate interactions between agent and environment
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T`
|
|
||||||
one of YiemAgent's agent
|
|
||||||
- `node::MCTSNode`
|
|
||||||
node that will be a simulation starting point.
|
|
||||||
- `decisionMaker::Function`
|
|
||||||
function that receive state return Thought and Action
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `simTrajectoryReward::Number`
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docs
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function simulate(a::T, node::MCTSNode, decisionMaker::Function, evaluator::Function,
|
|
||||||
reflector::Function; maxDepth::Integer=3, totalsample::Integer=3
|
|
||||||
)::Union{Tuple{Number, Dict{Symbol, <:Any}}, Tuple{Number, Nothing}} where {T<:agent}
|
|
||||||
|
|
||||||
simTrajectoryReward = 0.0
|
|
||||||
terminalstate = nothing
|
|
||||||
|
|
||||||
for depth in 1:maxDepth
|
|
||||||
simTrajectoryReward += node.reward
|
|
||||||
if node.isterminal
|
|
||||||
terminalstate = node.state
|
|
||||||
break
|
|
||||||
else
|
|
||||||
expand(a, node, decisionMaker, evaluator, reflector; totalsample=totalsample)
|
|
||||||
node = selectChildNode(node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return (simTrajectoryReward, terminalstate)
|
|
||||||
end
|
|
||||||
|
|
||||||
""" Backpropagate reward along the simulation chain
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
leaf node of a search tree
|
|
||||||
- `simTrajectoryReward::T`
|
|
||||||
total reward from trajectory simulation
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `No return`
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function backpropagate(node::MCTSNode, simTrajectoryReward::T;
|
|
||||||
discountRewardCoeff::AbstractFloat=0.9) where {T<:Number}
|
|
||||||
while !isroot(node)
|
|
||||||
# Update the statistics of the current node based on the result of the playout
|
|
||||||
node.visits += 1
|
|
||||||
node.statevalue += ((node.statevalue * (node.visits-1)) + simTrajectoryReward) / node.visits
|
|
||||||
simTrajectoryReward *= discountRewardCoeff # discount because future reward is uncertain
|
|
||||||
node = node.parent
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Get a new state
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
one of YiemAgent's agent
|
|
||||||
- `state::T2`
|
|
||||||
current game state
|
|
||||||
- `thoughtDict::T3`
|
|
||||||
contain Thought, Action, Observation
|
|
||||||
- `isterminal::Function`
|
|
||||||
a function to determine terminal state
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `(newNodeKey, newstate, isterminalstate, reward)::Tuple{String, Dict{Symbol, <:Any}, Bool, <:Number}`
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> state = Dict{Symbol, Dict{Symbol, Any}}(
|
|
||||||
:thoughtHistory => Dict(:question => "Hello, I want to buy a bottle of wine."),
|
|
||||||
:storeinfo => Dict(),
|
|
||||||
:customerinfo => Dict()
|
|
||||||
)
|
|
||||||
julia> thoughtDict = Dict(
|
|
||||||
:question=> "I want to buy a bottle of wine.",
|
|
||||||
:thought_1=> "The customer wants to buy a bottle of wine.",
|
|
||||||
:action_1=> Dict{Symbol, Any}(
|
|
||||||
:name=>"Chatbox",
|
|
||||||
:input=>"What occasion are you buying the wine for?",
|
|
||||||
),
|
|
||||||
:observation_1 => ""
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [x] add other actions
|
|
||||||
- [] add embedding of newstate and store in newstate[:embedding]
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function MCTStransition(a::T1, state::T2, thoughtDict::T2
|
|
||||||
)::Tuple{String, Dict{Symbol, <:Any}} where {T1<:agent, T2<:AbstractDict}
|
|
||||||
|
|
||||||
actionname = thoughtDict[:action][:name]
|
|
||||||
actioninput = thoughtDict[:action][:input]
|
|
||||||
|
|
||||||
# map action and input() to llm function
|
|
||||||
response, select, reward, isterminal =
|
|
||||||
if actionname == "chatbox"
|
|
||||||
# deepcopy(state[:virtualCustomerChatHistory]) because I want to keep it clean
|
|
||||||
# so that other simulation start from this same node is not contaminated with actioninput
|
|
||||||
virtualWineUserChatbox(a, actioninput, deepcopy(state[:virtualCustomerChatHistory])) # virtual customer
|
|
||||||
elseif actionname == "winestock"
|
|
||||||
winestock(a, actioninput)
|
|
||||||
elseif actionname == "recommendbox"
|
|
||||||
virtualWineUserRecommendbox(a, actioninput)
|
|
||||||
else
|
|
||||||
error("undefined LLM function. Requesting $actionname")
|
|
||||||
end
|
|
||||||
|
|
||||||
newNodeKey, newstate = makeNewState(state, thoughtDict, response, select, reward, isterminal)
|
|
||||||
if actionname == "chatbox"
|
|
||||||
push!(newstate[:virtualCustomerChatHistory], Dict(:name=>"assistant", :text=> actioninput) )
|
|
||||||
push!(newstate[:virtualCustomerChatHistory], Dict(:name=>"user", :text=> response))
|
|
||||||
end
|
|
||||||
|
|
||||||
return (newNodeKey, newstate)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Get a new state
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::T1`
|
|
||||||
one of YiemAgent's agent
|
|
||||||
- `state::T2`
|
|
||||||
current game state
|
|
||||||
- `thoughtDict::T3`
|
|
||||||
contain Thought, Action, Observation
|
|
||||||
- `isterminal::Function`
|
|
||||||
a function to determine terminal state
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `(newNodeKey, newstate, isterminalstate, reward)::Tuple{String, Dict{Symbol, <:Any}, Bool, <:Number}`
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> state = Dict{Symbol, Dict{Symbol, Any}}(
|
|
||||||
:thoughtHistory => Dict(:question => "Hello, I want to buy a bottle of wine."),
|
|
||||||
:storeinfo => Dict(),
|
|
||||||
:customerinfo => Dict()
|
|
||||||
)
|
|
||||||
julia> thoughtDict = Dict(
|
|
||||||
:question=> "I want to buy a bottle of wine.",
|
|
||||||
:thought_1=> "The customer wants to buy a bottle of wine.",
|
|
||||||
:action_1=> Dict{Symbol, Any}(
|
|
||||||
:name=>"Chatbox",
|
|
||||||
:input=>"What occasion are you buying the wine for?",
|
|
||||||
),
|
|
||||||
:observation_1 => ""
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [x] add other actions
|
|
||||||
- [] add embedding of newstate and store in newstate[:embedding]
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function transition(a::T1, state::T2, thoughtDict::T2
|
|
||||||
)::Dict{Symbol, <:Any} where {T1<:agent, T2<:AbstractDict}
|
|
||||||
|
|
||||||
thoughtDict = state[:thoughtDict]
|
|
||||||
actionname = thoughtDict[:action][:name]
|
|
||||||
actioninput = thoughtDict[:action][:input]
|
|
||||||
|
|
||||||
# map action and input() to llm function
|
|
||||||
response, select, reward, isterminal =
|
|
||||||
if actionname == "winestock"
|
|
||||||
winestock(a, actioninput)
|
|
||||||
else
|
|
||||||
error("undefined LLM function. Requesting $actionname")
|
|
||||||
end
|
|
||||||
|
|
||||||
return makeNewState(state, thoughtDict, response, select, reward, isterminal)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
|
|
||||||
# Return
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docstring
|
|
||||||
- [x] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function makeNewState(currentstate::T1, thoughtDict::T4, response::T2, select::Union{T3, Nothing},
|
|
||||||
reward::T3, isterminal::Bool
|
|
||||||
)::Tuple{String, Dict{Symbol, <:Any}} where {T1<:AbstractDict, T2<:AbstractString, T3<:Number, T4<:AbstractDict}
|
|
||||||
|
|
||||||
currentstate_latestThoughtKey, currentstate_latestThoughtIndice =
|
|
||||||
GeneralUtils.findHighestIndexKey(currentstate[:thoughtHistory], "thought")
|
|
||||||
currentstate_nextIndice = currentstate_latestThoughtKey == :NA ? 1 : currentstate_latestThoughtIndice + 1
|
|
||||||
currentstate_latestThoughtKey = Symbol("thought_$currentstate_nextIndice")
|
|
||||||
latestActionKey = Symbol("action_$currentstate_nextIndice")
|
|
||||||
|
|
||||||
_, thoughtDict_latestThoughtIndice =
|
|
||||||
GeneralUtils.findHighestIndexKey(thoughtDict, "thought")
|
|
||||||
|
|
||||||
thoughtDict_latestThoughtKey, thoughtDict_latestActionKey =
|
|
||||||
if thoughtDict_latestThoughtIndice == -1
|
|
||||||
(:thought, :action)
|
|
||||||
else
|
|
||||||
(
|
|
||||||
Symbol("thought_$thoughtDict_latestThoughtIndice"),
|
|
||||||
Symbol("action_$thoughtDict_latestThoughtIndice"),
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
# add Thought, action, observation to thoughtHistory
|
|
||||||
newstate = deepcopy(currentstate)
|
|
||||||
newstate[:thoughtHistory][currentstate_latestThoughtKey] =
|
|
||||||
thoughtDict[thoughtDict_latestThoughtKey]
|
|
||||||
newstate[:thoughtHistory][latestActionKey] = thoughtDict[thoughtDict_latestActionKey]
|
|
||||||
newObservationKey = Symbol("observation_$(currentstate_nextIndice)")
|
|
||||||
newstate[:thoughtHistory][newObservationKey] = response
|
|
||||||
newstate[:reward] = reward
|
|
||||||
newstate[:select] = select
|
|
||||||
newstate[:isterminal] = isterminal
|
|
||||||
|
|
||||||
newNodeKey = GeneralUtils.uuid4snakecase()
|
|
||||||
|
|
||||||
return (newNodeKey, newstate)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" Determine whether a node is a leaf node of a search tree.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
a search tree node
|
|
||||||
# Return
|
|
||||||
- `result::Bool`
|
|
||||||
true if it is a leaf node, false otherwise.
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> using Revise
|
|
||||||
julia> using YiemAgent, DataStructures
|
|
||||||
julia> initialState = Dict{Symbol, Any}(
|
|
||||||
:customerinfo=> Dict{Symbol, Any}(),
|
|
||||||
:storeinfo=> Dict{Symbol, Any}(),
|
|
||||||
|
|
||||||
:thoughtHistory=> OrderedDict{Symbol, Any}(
|
|
||||||
:question=> "How are you?",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
julia> statetype = typeof(initialState)
|
|
||||||
julia> root = YiemAgent.MCTSNode(initialState, 0, 0.0, Dict{statetype, YiemAgent.MCTSNode}())
|
|
||||||
julia> YiemAgent.isleaf(root)
|
|
||||||
true
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
[] update docs
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
isleaf(node::MCTSNode)::Bool = isempty(node.children)
|
|
||||||
|
|
||||||
|
|
||||||
""" Select child node based on the highest statevalue
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
node of a search tree
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `childNode::MCTSNode`
|
|
||||||
the highest value child node
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function selectChildNode(node::MCTSNode)::MCTSNode
|
|
||||||
highestProgressValue = 0
|
|
||||||
nodekey = nothing
|
|
||||||
|
|
||||||
# loop thought node children dictionary to find the highest progress value
|
|
||||||
for (k, childNode) in node.children
|
|
||||||
potential = childNode.progressvalue + childNode.reward
|
|
||||||
if childNode.reward > 0 #XXX for testing. remove when done.
|
|
||||||
println("")
|
|
||||||
end
|
|
||||||
if potential > highestProgressValue
|
|
||||||
highestProgressValue = potential
|
|
||||||
nodekey = childNode.nodekey
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return node.children[nodekey]
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
node of a search tree
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `childNode::MCTSNode`
|
|
||||||
the highest value child node
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docs
|
|
||||||
- [x] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function selectBestNextState(node::MCTSNode)::MCTSNode
|
|
||||||
highestProgressValue = 0
|
|
||||||
nodekey = nothing
|
|
||||||
|
|
||||||
# if all childnode has statevalue == 0, use progressvalue + reward to select the best node
|
|
||||||
stateValueSum = sum([v.statevalue for (k, v) in node.children])
|
|
||||||
|
|
||||||
if stateValueSum != 0
|
|
||||||
for (k, childnode) in node.children
|
|
||||||
potential = childnode.statevalue / childnode.visits
|
|
||||||
|
|
||||||
if potential > highestProgressValue
|
|
||||||
highestProgressValue = potential
|
|
||||||
nodekey = childnode.nodekey
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for (k, childnode) in node.children
|
|
||||||
potential = childnode.progressvalue + childnode.reward
|
|
||||||
|
|
||||||
if potential > highestProgressValue
|
|
||||||
highestProgressValue = potential
|
|
||||||
nodekey = childnode.nodekey
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return node.children[nodekey]
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
node of a search tree
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `childNode::MCTSNode`
|
|
||||||
the highest value child node
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docs
|
|
||||||
- [x] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function selectBestTrajectory(node::MCTSNode)::MCTSNode
|
|
||||||
while !isleaf(node)
|
|
||||||
node = selectBestNextState(node)
|
|
||||||
end
|
|
||||||
|
|
||||||
return node
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Determine wheter a given node is a root node
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `node::MCTSNode`
|
|
||||||
node of a search tree
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `isrootnode::Bool`
|
|
||||||
true if the given node is root node, false otherwise
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
isroot(node::MCTSNode)::Bool = node.nodekey == "root" ? true : false
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------------ #
|
|
||||||
# Create a complete example using the defined MCTS functions #
|
|
||||||
# ------------------------------------------------------------------------------------------------ #
|
|
||||||
""" Search the best action to take for a given state and task
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::agent`
|
|
||||||
one of Yiem's agents
|
|
||||||
- `initial state`
|
|
||||||
initial state
|
|
||||||
- `decisionMaker::Function`
|
|
||||||
decide what action to take
|
|
||||||
- `evaluator::Function`
|
|
||||||
assess the value of the state
|
|
||||||
- `reflector::Function`
|
|
||||||
generate lesson from trajectory and reward
|
|
||||||
- `isterminal::Function`
|
|
||||||
determine whether a given state is a terminal state
|
|
||||||
- `n::Integer`
|
|
||||||
how many times action will be sampled from decisionMaker
|
|
||||||
- `w::Float64`
|
|
||||||
exploration weight. Value is usually between 1 to 2.
|
|
||||||
Value 1.0 makes MCTS balance between exploration and exploitation like 50%-50%
|
|
||||||
Value 2.0 makes MCTS aggressively search the tree
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `plan::Vector{Dict}`
|
|
||||||
best plan
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
[] update docstring
|
|
||||||
[x] return best action
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function runMCTS(
|
|
||||||
a::T1,
|
|
||||||
initialState,
|
|
||||||
decisionMaker::Function,
|
|
||||||
evaluator::Function,
|
|
||||||
reflector::Function;
|
|
||||||
totalsample::Integer=3,
|
|
||||||
maxDepth::Integer=3,
|
|
||||||
maxiterations::Integer=10,
|
|
||||||
explorationweight::Number=1.0,
|
|
||||||
) where {T1<:agent}
|
|
||||||
|
|
||||||
root = MCTSNode("root", initialState, 0, 0, 0, 0, false, nothing, Dict{String, MCTSNode}())
|
|
||||||
|
|
||||||
for nth in 1:maxiterations
|
|
||||||
node = root
|
|
||||||
node.visits += 1
|
|
||||||
|
|
||||||
while !isleaf(node)
|
|
||||||
node = UCTselect(node, explorationweight)
|
|
||||||
end
|
|
||||||
if node.isterminal
|
|
||||||
# MCTS arrive at the leaf node that is also a terminal state,
|
|
||||||
# do nothing then go directly to backpropagation
|
|
||||||
backpropagate(leafNode, node.reward)
|
|
||||||
else
|
|
||||||
expand(a, node, decisionMaker, evaluator, reflector; totalsample=totalsample)
|
|
||||||
leafNode = selectChildNode(node)
|
|
||||||
simTrajectoryReward, terminalstate = simulate(a, leafNode, decisionMaker, evaluator,
|
|
||||||
reflector; maxDepth=maxDepth, totalsample=totalsample)
|
|
||||||
if terminalstate !== nothing #XXX not sure why I need this
|
|
||||||
terminalstate[:totalTrajectoryReward] = simTrajectoryReward
|
|
||||||
end
|
|
||||||
|
|
||||||
#[] write best state to file if it has higher simTrajectoryReward. Use to improve evaluation
|
|
||||||
# open("trajectory.json", "w") do io
|
|
||||||
# JSON3.pretty(io, terminalstate)
|
|
||||||
# end
|
|
||||||
|
|
||||||
backpropagate(leafNode, simTrajectoryReward)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
bestNextState = selectBestNextState(root)
|
|
||||||
besttrajectory = selectBestTrajectory(root)
|
|
||||||
|
|
||||||
return (bestNextState.state, besttrajectory.state)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module mcts
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
module type
|
|
||||||
|
|
||||||
export agent, sommelier
|
|
||||||
|
|
||||||
using Dates, UUIDs, DataStructures, JSON3
|
|
||||||
using GeneralUtils
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
abstract type agent 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
|
|
||||||
name::String # agent name
|
|
||||||
id::String # agent id
|
|
||||||
config::Dict # agent config
|
|
||||||
tools::Dict
|
|
||||||
maxiterations::Integer # how many thinking round
|
|
||||||
totalsample::Integer # how many sample in each thinking round
|
|
||||||
maxDepth::Integer # how many step ahead to be simulated start from current state into the future
|
|
||||||
maxHistoryMsg::Integer # 21th and earlier messages will get summarized
|
|
||||||
|
|
||||||
""" 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()),
|
|
||||||
]
|
|
||||||
|
|
||||||
"""
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}}
|
|
||||||
keywordinfo::Dict{Symbol, Any}
|
|
||||||
|
|
||||||
# 1-historyPoint is in Dict{Symbol, Any} and compose of:
|
|
||||||
# state, statevalue, thought, action, observation
|
|
||||||
plan::Dict{Symbol, Any}
|
|
||||||
mctsWorkDict::Dict{Symbol, Any}
|
|
||||||
end
|
|
||||||
|
|
||||||
function sommelier(
|
|
||||||
config::Dict = Dict(
|
|
||||||
:mqttServerInfo=> Dict(
|
|
||||||
:broker=> nothing,
|
|
||||||
:port=> nothing,
|
|
||||||
),
|
|
||||||
:receivemsg=> Dict(
|
|
||||||
:prompt=> nothing, # topic to receive prompt i.e. frontend send msg to this topic
|
|
||||||
:internal=> nothing,
|
|
||||||
),
|
|
||||||
:thirdPartyService=> Dict(
|
|
||||||
:text2textinstruct=> nothing,
|
|
||||||
:text2textchat=> nothing,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
;
|
|
||||||
name::String= "Assistant",
|
|
||||||
id::String= string(uuid4()),
|
|
||||||
tools::Dict= Dict(
|
|
||||||
:chatbox=> Dict(
|
|
||||||
:name => "chatbox",
|
|
||||||
:description => "Useful for when you need to communicate with the user.",
|
|
||||||
:input => "Input should be a conversation to the user.",
|
|
||||||
:output => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
maxiterations::Integer= 3,
|
|
||||||
totalsample::Integer= 3,
|
|
||||||
maxDepth::Integer= 3,
|
|
||||||
maxHistoryMsg::Integer= 20,
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}} = Vector{Dict{Symbol, Any}}(),
|
|
||||||
keywordinfo::Dict{Symbol, Any} = Dict{Symbol, Any}(
|
|
||||||
:customerinfo => Dict{Symbol, Any}(),
|
|
||||||
:storeinfo => Dict{Symbol, Any}(),
|
|
||||||
),
|
|
||||||
plan::Dict{Symbol, Any} = Dict{Symbol, Any}(
|
|
||||||
|
|
||||||
# store 3 to 5 best plan AI frequently used to avoid having to search MCTS all the time
|
|
||||||
# each plan is in [historyPoint_1, historyPoint_2, ...] format
|
|
||||||
:existingplan => Vector(),
|
|
||||||
|
|
||||||
:activeplan => Dict{Symbol, Any}(), # current using plan
|
|
||||||
:currenttrajectory=> Dict{Symbol, Any}(), # store question, thought, action, observation, ...
|
|
||||||
),
|
|
||||||
mctsWorkDict::Dict{Symbol, Any} = Dict{Symbol, Any}()
|
|
||||||
)
|
|
||||||
|
|
||||||
#[NEXTVERSION] publish to a.config[:configtopic] to get a config.
|
|
||||||
#[NEXTVERSION] get a config message in a.mqttMsg_internal
|
|
||||||
#[NEXTVERSION] set agent according to config
|
|
||||||
|
|
||||||
newAgent = sommelier(
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
config,
|
|
||||||
tools,
|
|
||||||
maxiterations,
|
|
||||||
totalsample,
|
|
||||||
maxDepth,
|
|
||||||
maxHistoryMsg,
|
|
||||||
chathistory,
|
|
||||||
keywordinfo,
|
|
||||||
plan,
|
|
||||||
mctsWorkDict,
|
|
||||||
)
|
|
||||||
|
|
||||||
return newAgent
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module type
|
|
||||||
@@ -1,373 +0,0 @@
|
|||||||
module util
|
|
||||||
|
|
||||||
export clearhistory, addNewMessage, formatLLMtext, iterativeprompting,
|
|
||||||
formatLLMtext_llama3instruct, formatLLMtext_phi3instruct
|
|
||||||
|
|
||||||
using UUIDs, Dates, DataStructures, HTTP, MQTTClient, JSON3
|
|
||||||
using GeneralUtils
|
|
||||||
using ..type
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
""" Clear agent chat history.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::agent`
|
|
||||||
an agent
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- nothing
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```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")
|
|
||||||
julia> YiemAgent.clearhistory(a)
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function clearhistory(a::T) where {T<:agent}
|
|
||||||
empty!(a.chathistory)
|
|
||||||
empty!(a.mctstree)
|
|
||||||
empty!(a.plan[:activeplan])
|
|
||||||
empty!(a.plan[:currenttrajectory])
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Add new message to agent.
|
|
||||||
|
|
||||||
Arguments\n
|
|
||||||
-----
|
|
||||||
a::agent
|
|
||||||
an agent
|
|
||||||
role::String
|
|
||||||
message sender role i.e. system, user or assistant
|
|
||||||
text::String
|
|
||||||
message text
|
|
||||||
|
|
||||||
Return\n
|
|
||||||
-----
|
|
||||||
nothing
|
|
||||||
|
|
||||||
Example\n
|
|
||||||
-----
|
|
||||||
```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
|
|
||||||
-----
|
|
||||||
"""
|
|
||||||
function addNewMessage(a::T1, name::String, text::T2;
|
|
||||||
maximumMsg::Integer=20) where {T1<:agent, T2<:AbstractString}
|
|
||||||
if name ∉ ["system", "user", "assistant"] # guard against typo
|
|
||||||
error("name is not in agent.availableRole $(@__LINE__)")
|
|
||||||
end
|
|
||||||
|
|
||||||
#[] summarize the oldest 10 message
|
|
||||||
if length(a.chathistory) > maximumMsg
|
|
||||||
summarize(a.chathistory)
|
|
||||||
else
|
|
||||||
d = Dict(:name=> name, :text=> text, :timestamp=> Dates.now())
|
|
||||||
push!(a.chathistory, d)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" Convert a single chat dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# Llama 3 instruct format example
|
|
||||||
<|system|>
|
|
||||||
You are a helpful AI assistant.<|end|>
|
|
||||||
<|user|>
|
|
||||||
I am going to Paris, what should I see?<|end|>
|
|
||||||
<|assistant|>
|
|
||||||
Paris, the capital of France, is known for its stunning architecture, art museums."<|end|>
|
|
||||||
<|user|>
|
|
||||||
What is so great about #1?<|end|>
|
|
||||||
<|assistant|>
|
|
||||||
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `name::T`
|
|
||||||
message owner name e.f. "system", "user" or "assistant"
|
|
||||||
- `text::T`
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `formattedtext::String`
|
|
||||||
text formatted to model format
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> using Revise
|
|
||||||
julia> using YiemAgent
|
|
||||||
julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
|
||||||
julia> formattedtext = YiemAgent.formatLLMtext_phi3instruct(d[:name], d[:text])
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Signature
|
|
||||||
"""
|
|
||||||
function formatLLMtext_phi3instruct(name::T, text::T) where {T<:AbstractString}
|
|
||||||
formattedtext =
|
|
||||||
"""
|
|
||||||
<|$name|>
|
|
||||||
$text<|end|>\n
|
|
||||||
"""
|
|
||||||
|
|
||||||
return formattedtext
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Convert a single chat dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# Llama 3 instruct format example
|
|
||||||
<|begin_of_text|>
|
|
||||||
<|start_header_id|>system<|end_header_id|>
|
|
||||||
You are a helpful assistant.
|
|
||||||
<|eot_id|>
|
|
||||||
<|start_header_id|>user<|end_header_id|>
|
|
||||||
Get me an icecream.
|
|
||||||
<|eot_id|>
|
|
||||||
<|start_header_id|>assistant<|end_header_id|>
|
|
||||||
Go buy it yourself at 7-11.
|
|
||||||
<|eot_id|>
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `name::T`
|
|
||||||
message owner name e.f. "system", "user" or "assistant"
|
|
||||||
- `text::T`
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `formattedtext::String`
|
|
||||||
text formatted to model format
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> using Revise
|
|
||||||
julia> using YiemAgent
|
|
||||||
julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
|
||||||
julia> formattedtext = YiemAgent.formatLLMtext_llama3instruct(d[:name], d[:text])
|
|
||||||
"<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n"
|
|
||||||
```
|
|
||||||
|
|
||||||
Signature
|
|
||||||
"""
|
|
||||||
function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString}
|
|
||||||
formattedtext =
|
|
||||||
if name == "system"
|
|
||||||
"""
|
|
||||||
<|begin_of_text|>
|
|
||||||
<|start_header_id|>$name<|end_header_id|>
|
|
||||||
$text
|
|
||||||
<|eot_id|>
|
|
||||||
"""
|
|
||||||
else
|
|
||||||
"""
|
|
||||||
<|start_header_id|>$name<|end_header_id|>
|
|
||||||
$text
|
|
||||||
<|eot_id|>
|
|
||||||
"""
|
|
||||||
end
|
|
||||||
|
|
||||||
return formattedtext
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" Convert a chat messages in vector of dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `messages::Vector{Dict{Symbol, T}}`
|
|
||||||
message owner name e.f. "system", "user" or "assistant"
|
|
||||||
- `formatname::T`
|
|
||||||
format name to be used
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- `formattedtext::String`
|
|
||||||
text formatted to model format
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia> using Revise
|
|
||||||
julia> using YiemAgent
|
|
||||||
julia> chatmessage = [
|
|
||||||
Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",),
|
|
||||||
Dict(:name=> "user",:text=> "list me all planets in our solar system.",),
|
|
||||||
Dict(:name=> "assistant",:text=> "I'm sorry. I don't know. You tell me.",),
|
|
||||||
]
|
|
||||||
julia> formattedtext = YiemAgent.formatLLMtext(chatmessage, "llama3instruct")
|
|
||||||
"<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n <|start_header_id|>user<|end_header_id|>\n list me all planets in our solar system.\n <|eot_id|>\n <|start_header_id|>assistant<|end_header_id|>\n I'm sorry. I don't know. You tell me.\n <|eot_id|>\n"
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function formatLLMtext(messages::Vector{Dict{Symbol, T}},
|
|
||||||
formatname::String="llama3instruct") where {T<:Any}
|
|
||||||
f = if formatname == "llama3instruct"
|
|
||||||
formatLLMtext_llama3instruct
|
|
||||||
elseif formatname == "mistral"
|
|
||||||
# not define yet
|
|
||||||
elseif formatname == "phi3instruct"
|
|
||||||
formatLLMtext_phi3instruct
|
|
||||||
else
|
|
||||||
error("$formatname template not define yet")
|
|
||||||
end
|
|
||||||
|
|
||||||
str = ""
|
|
||||||
for t in messages
|
|
||||||
str *= f(t[:name], t[:text])
|
|
||||||
end
|
|
||||||
|
|
||||||
# add <|assistant|> so that the model don't generate it and I don't need to clean it up later
|
|
||||||
if formatname == "phi3instruct"
|
|
||||||
str *= "<|assistant|>\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
return str
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
Arguments\n
|
|
||||||
-----
|
|
||||||
|
|
||||||
Return\n
|
|
||||||
-----
|
|
||||||
|
|
||||||
Example\n
|
|
||||||
-----
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
TODO\n
|
|
||||||
-----
|
|
||||||
[] update docstring
|
|
||||||
[PENDING] implement the function
|
|
||||||
|
|
||||||
Signature\n
|
|
||||||
-----
|
|
||||||
"""
|
|
||||||
function iterativeprompting(a::T, prompt::String, verification::Function) where {T<:agent}
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
a.config[:externalService][:text2textinstruct],
|
|
||||||
senderName= "iterativeprompting",
|
|
||||||
senderId= a.id,
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
success = nothing
|
|
||||||
result = nothing
|
|
||||||
critique = ""
|
|
||||||
|
|
||||||
# iteration loop
|
|
||||||
while true
|
|
||||||
# send prompt to LLM
|
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
error("--> iterativeprompting")
|
|
||||||
# check for correctness and get feedback
|
|
||||||
success, _critique = verification(response)
|
|
||||||
|
|
||||||
if success
|
|
||||||
result = response
|
|
||||||
break
|
|
||||||
else
|
|
||||||
# add critique to prompt
|
|
||||||
critique *= _critique * "\n"
|
|
||||||
replace!(prompt, "Critique: ..." => "Critique: $critique")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return (success=success, result=result)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module util
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
using Revise
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, DataStructures
|
|
||||||
|
|
||||||
thoughtDict = OrderedDict(
|
|
||||||
:Question=> "Hello, I would like a get a bottle of wine",
|
|
||||||
:Thought_1=> "The customer wants to buy a bottle of wine, but we need more information about their preferences.",
|
|
||||||
:Action_1=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What occasion are you buying the wine for?",
|
|
||||||
),
|
|
||||||
:Observation_1=> "We are having a wedding pary this weekend.",
|
|
||||||
|
|
||||||
:Thought_2=> "A wedding party is a great occasion to have a good bottle of wine.",
|
|
||||||
:Action_2=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What type of food will you be serving with the wine?",
|
|
||||||
),
|
|
||||||
:Observation_2=> "I think it is Thai dishes",
|
|
||||||
|
|
||||||
:Thought_3=> "Now that I know the occasion and food, I need to ask about the budget.",
|
|
||||||
:Action_3=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What is your budget for this wine?",
|
|
||||||
),
|
|
||||||
:Observation_3=> "50 bucks",
|
|
||||||
|
|
||||||
:Thought_4=> "With a budget of \$50, we have a wide range of options. Now that I know it's a wedding party and Thai dishes, I need to ask about the type of wine they prefer.",
|
|
||||||
:Action_4=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What type of wine are you looking for? (Red, White, Sparkling, Rose, Dessert, Fortified)",
|
|
||||||
),
|
|
||||||
:Observation_4=> "Sparkling please.",
|
|
||||||
|
|
||||||
:Thought_5=> "Now that I know the occasion, food, budget and preferred type of wine, it's time to check our inventory for the best matching wine.",
|
|
||||||
:Action_5=> Dict(
|
|
||||||
:name=> "winestock",
|
|
||||||
:input=> "wine with budget \$50, Thai dishes, sparkling, wedding party",
|
|
||||||
),
|
|
||||||
:Observation_5=> "I found the following wine in stock {1 : Zena Crown Vista, 2 : Schrader Cabernet Sauvignon}",
|
|
||||||
|
|
||||||
:Thought_6=> "Now that I have all the information, it's time to recommend a wine that fits their preferences.",
|
|
||||||
:Action_6=> Dict(
|
|
||||||
:name=> "recommendation",
|
|
||||||
:input=> "I recommend Zena Crown Vista for its sparkling and affordable price.",
|
|
||||||
),
|
|
||||||
:Observation_6=> "I don't like it. Do you have another option?",
|
|
||||||
)
|
|
||||||
|
|
||||||
_thoughtJsonStr = JSON3.write(thoughtDict)
|
|
||||||
thoughtJsonStr = _thoughtJsonStr[1:end-1] # remove } at the end
|
|
||||||
# @show thoughtJsonStr
|
|
||||||
|
|
||||||
_, latestThoughtIndice = GeneralUtils.findHighestIndexKey(thoughtDict, "Thought")
|
|
||||||
nextThoughtIndice = latestThoughtIndice + 1
|
|
||||||
|
|
||||||
_prompt =
|
|
||||||
"""
|
|
||||||
You are a helpful sommelier working for a wine store.
|
|
||||||
Your goal is to reccommend the best wine from your inventory that match the user preferences.
|
|
||||||
|
|
||||||
You must follow the following criteria:
|
|
||||||
1) Get to know what occasion the user is buying wine for
|
|
||||||
2) Get to know what food the user will have with wine
|
|
||||||
3) Get to know how much the user willing to spend
|
|
||||||
4) Get to know type of wine the user is looking for e.g. Red, White, Sparkling, Rose, Dessert, Fortified
|
|
||||||
5) Get to know what characteristics of wine the user is looking for
|
|
||||||
e.g. tannin, sweetness, intensity, acidity
|
|
||||||
6) Check your inventory for the best wine that match the user preference
|
|
||||||
7) Recommend wine to the user
|
|
||||||
|
|
||||||
You should only respond with interleaving Thought, Action, Observation steps.
|
|
||||||
Thought can reason about the current situation, and Action can be three types:
|
|
||||||
1) winestock[query], which you can use to find wine in your inventory. The more input data the better.
|
|
||||||
2) chatbox[text], which you can use to interact with the user.
|
|
||||||
3) recommendation[answer], which returns your wine reccommendation to the user.
|
|
||||||
|
|
||||||
You should only respond in JSON format as describe below:
|
|
||||||
{
|
|
||||||
"Thought": "your reasoning",
|
|
||||||
"Action": {"name": "action to take", "input": "Action input"},
|
|
||||||
"Observation": "result of the action"
|
|
||||||
}
|
|
||||||
|
|
||||||
Here are some examples:
|
|
||||||
{
|
|
||||||
"Question": "I would like to buy a sedan with 8 seats.",
|
|
||||||
"Thought_1": "Our showroom carries various vehicle model. But I'm not sure whether we have a models that fits the user demand, I need to check our inventory.",
|
|
||||||
"Action_1": {"name": "inventory", "input": "sedan with 8 seats."},
|
|
||||||
"Observation_1": "Several model has 8 seats. Available color are black, red green"
|
|
||||||
}
|
|
||||||
{
|
|
||||||
"Thought_2": "I have to ask the user what color he likes.",
|
|
||||||
"Action_2": {"name": "chatbox", "input": "Which color do you like?"}
|
|
||||||
"Observation_2": "I'll take black."
|
|
||||||
}
|
|
||||||
{
|
|
||||||
"Thought_3": "There is only one model that fits the user preference. It's Yiem model A",
|
|
||||||
"Action_3": {"name": "recommendation", "input": "I recommend a Yiem model A"}
|
|
||||||
}
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
|
|
||||||
$(JSON3.write(thoughtDict))
|
|
||||||
{Thought_$nextThoughtIndice
|
|
||||||
"""
|
|
||||||
|
|
||||||
prompt = YiemAgent.formatLLMtext_llama3instruct("system", _prompt)
|
|
||||||
@show prompt
|
|
||||||
msgMeta = Dict(:requestResponse => nothing,
|
|
||||||
:msgPurpose => nothing,
|
|
||||||
:receiverId => nothing,
|
|
||||||
:getPost => nothing,
|
|
||||||
:msgId => "4c7111e0-c30e-44c3-8f85-1c8b3f03a8be",
|
|
||||||
:acknowledgestatus => nothing,
|
|
||||||
:replyToMsgId => nothing,
|
|
||||||
:msgFormatVersion => nothing,
|
|
||||||
:mqttServerInfo => Dict(:port => 1883, :broker => "mqtt.yiem.cc"),
|
|
||||||
:sendTopic => "/loadbalancer/requestingservice",
|
|
||||||
:receiverName => "text2textinstruct",
|
|
||||||
:replyTopic => nothing,
|
|
||||||
:senderName => "decisionMaker",
|
|
||||||
:senderSelfnote => nothing,
|
|
||||||
:senderId => "testingSessionID",
|
|
||||||
:timeStamp => "2024-05-04T08:06:23.561"
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
thoughtJsonStr = _response[:response][:text]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
using Revise # remove when this package is completed
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, MQTTClient, Dates, UUIDs, DataStructures
|
|
||||||
using Base.Threads
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
config = copy(JSON3.read("config.json"))
|
|
||||||
|
|
||||||
instanceInternalTopic = config[:serviceInternalTopic][:mqtttopic] * "/1"
|
|
||||||
|
|
||||||
client, connection = MakeConnection(config[:mqttServerInfo][:broker],
|
|
||||||
config[:mqttServerInfo][:port])
|
|
||||||
|
|
||||||
receiveUserMsgChannel = Channel{Dict}(4)
|
|
||||||
receiveInternalMsgChannel = Channel{Dict}(4)
|
|
||||||
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
"N/A",
|
|
||||||
replyTopic = config[:servicetopic][:mqtttopic] # ask frontend reply to this instance_chat_topic
|
|
||||||
)
|
|
||||||
|
|
||||||
agentConfig = Dict(
|
|
||||||
:mqttServerInfo=> config[:mqttServerInfo],
|
|
||||||
:receivemsg=> Dict(
|
|
||||||
:prompt=> config[:servicetopic][:mqtttopic], # topic to receive prompt i.e. frontend send msg to this topic
|
|
||||||
:internal=> instanceInternalTopic,
|
|
||||||
),
|
|
||||||
:externalservice=> config[:externalservice],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Instantiate an agent
|
|
||||||
tools=Dict( # update input format
|
|
||||||
"askbox"=> 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>",
|
|
||||||
: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 => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
# "winestock"=> Dict(
|
|
||||||
# :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>""",
|
|
||||||
# :output => """<output>Output are wines that match the search query in JSON format.""",
|
|
||||||
# :func => ChatAgent.winestock,
|
|
||||||
# ),
|
|
||||||
"finalanswer"=> Dict(
|
|
||||||
:description => "<tool description>Useful for when you are ready to recommend wines to the user.</tool description>",
|
|
||||||
:input => """<input format>{\"finalanswer\": \"some text\"}.</input format><input example>{\"finalanswer\": \"I recommend Zena Crown Vista\"}</input example>""",
|
|
||||||
:output => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
a = YiemAgent.sommelier(
|
|
||||||
receiveUserMsgChannel,
|
|
||||||
receiveInternalMsgChannel,
|
|
||||||
agentConfig,
|
|
||||||
name= "assistant",
|
|
||||||
id= "testingSessionID", # agent instance id
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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.")
|
|
||||||
|
|
||||||
|
|
||||||
result = YiemAgent.jsoncorrection(a, input)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
using Revise # remove when this package is completed
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, MQTTClient, Dates, UUIDs
|
|
||||||
using Base.Threads
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
config = copy(JSON3.read("config.json"))
|
|
||||||
|
|
||||||
instanceInternalTopic = config[:serviceInternalTopic][:mqtttopic] * "/1"
|
|
||||||
|
|
||||||
client, connection = MakeConnection(config[:mqttServerInfo][:broker],
|
|
||||||
config[:mqttServerInfo][:port])
|
|
||||||
|
|
||||||
receiveUserMsgChannel = Channel{Dict}(4)
|
|
||||||
receiveInternalMsgChannel = Channel{Dict}(4)
|
|
||||||
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
"N/A",
|
|
||||||
replyTopic = config[:servicetopic][:mqtttopic] # ask frontend reply to this instance_chat_topic
|
|
||||||
)
|
|
||||||
|
|
||||||
agentConfig = Dict(
|
|
||||||
:mqttServerInfo=> config[:mqttServerInfo],
|
|
||||||
:receivemsg=> Dict(
|
|
||||||
:prompt=> config[:servicetopic][:mqtttopic], # topic to receive prompt i.e. frontend send msg to this topic
|
|
||||||
:internal=> instanceInternalTopic,
|
|
||||||
),
|
|
||||||
:externalservice=> config[:externalservice],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Instantiate an agent
|
|
||||||
tools=Dict( # update input format
|
|
||||||
"askbox"=> 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>",
|
|
||||||
: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 => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
# "winestock"=> Dict(
|
|
||||||
# :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>""",
|
|
||||||
# :output => """<output>Output are wines that match the search query in JSON format.""",
|
|
||||||
# :func => ChatAgent.winestock,
|
|
||||||
# ),
|
|
||||||
"finalanswer"=> Dict(
|
|
||||||
:description => "<tool description>Useful for when you are ready to recommend wines to the user.</tool description>",
|
|
||||||
:input => """<input format>{\"finalanswer\": \"some text\"}.</input format><input example>{\"finalanswer\": \"I recommend Zena Crown Vista\"}</input example>""",
|
|
||||||
:output => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
a = YiemAgent.sommelier(
|
|
||||||
agentConfig,
|
|
||||||
name="assistant",
|
|
||||||
id="testingSessionID", # agent instance id
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
|
|
||||||
# response = YiemAgent.conversation(a, Dict(:text=> "newtopic",) )
|
|
||||||
|
|
||||||
response = YiemAgent.conversation(a, Dict(:text=> "Hello, I would like a get a bottle of wine",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
) )
|
|
||||||
println("---> YiemAgent: ", response)
|
|
||||||
|
|
||||||
#BUG mcts do not start at current chat history
|
|
||||||
response = YiemAgent.conversation(a, Dict(:text=> "I'm having a graduation party this evening. I'll pay at most 30 bucks.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
) )
|
|
||||||
println("---> YiemAgent: ", response)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dummyinput = "price below 50, full-bodied red wine with sweetness level 2, low tannin level and medium acidity level, Thai dishes"
|
|
||||||
response = YiemAgent.winestock(a, dummyinput)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
Write me SQL command to search the database for wines that fits: {"wine_type": "red","sweetness": 2,"acidity": 3,"tannin": 1,"intensity": 5}
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
mctsparam = Dict{Symbol, Any}()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
using Revise
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, DataStructures
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
msgMeta = Dict(:requestResponse => nothing,
|
|
||||||
:msgPurpose => nothing,
|
|
||||||
:receiverId => nothing,
|
|
||||||
:getPost => nothing,
|
|
||||||
:msgId => "4c7111e0-c30e-44c3-8f85-1c8b3f03a8be",
|
|
||||||
:acknowledgestatus => nothing,
|
|
||||||
:replyToMsgId => "dummyid",
|
|
||||||
:msgFormatVersion => nothing,
|
|
||||||
:mqttServerInfo => Dict(:port => 1883, :broker => "mqtt.yiem.cc"),
|
|
||||||
:sendTopic => "/testingSessionID",
|
|
||||||
:receiverName => "wineassistant",
|
|
||||||
:replyTopic => nothing,
|
|
||||||
:senderName => "test_1",
|
|
||||||
:senderSelfnote => nothing,
|
|
||||||
:senderId => nothing,
|
|
||||||
:timeStamp => "2024-05-04T08:06:23.561"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "We are holding a wedding party",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "It will be Thai dishes.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I would spend up to 50 bucks.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I like dry, full-bodied red wine with low tannin.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "What do you have?",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "Dry wine please.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "You did not gave me any choice.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> -1,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "You don't need to ask me. Just tell me already!",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> -1,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I like dry wine with fruity flavors.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "OK, I'll take it.",
|
|
||||||
:select=> 1,
|
|
||||||
:reward=> 1,
|
|
||||||
:isterminal=> true,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "Yes.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I like dry wine with medium acidity.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
using Revise # remove when this package is completed
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, MQTTClient, Dates, UUIDs, DataStructures
|
|
||||||
using Base.Threads
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
config = copy(JSON3.read("config.json"))
|
|
||||||
|
|
||||||
instanceInternalTopic = config[:serviceInternalTopic][:mqtttopic] * "/1"
|
|
||||||
|
|
||||||
client, connection = MakeConnection(config[:mqttServerInfo][:broker],
|
|
||||||
config[:mqttServerInfo][:port])
|
|
||||||
|
|
||||||
receiveUserMsgChannel = Channel{Dict}(4)
|
|
||||||
receiveInternalMsgChannel = Channel{Dict}(4)
|
|
||||||
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
"N/A",
|
|
||||||
replyTopic = config[:servicetopic][:mqtttopic] # ask frontend reply to this instance_chat_topic
|
|
||||||
)
|
|
||||||
|
|
||||||
agentConfig = Dict(
|
|
||||||
:mqttServerInfo=> config[:mqttServerInfo],
|
|
||||||
:receivemsg=> Dict(
|
|
||||||
:prompt=> config[:servicetopic][:mqtttopic], # topic to receive prompt i.e. frontend send msg to this topic
|
|
||||||
:internal=> instanceInternalTopic,
|
|
||||||
),
|
|
||||||
:externalservice=> config[:externalservice],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Instantiate an agent
|
|
||||||
tools=Dict( # update input format
|
|
||||||
"askbox"=> 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>",
|
|
||||||
: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 => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
# "winestock"=> Dict(
|
|
||||||
# :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>""",
|
|
||||||
# :output => """<output>Output are wines that match the search query in JSON format.""",
|
|
||||||
# :func => ChatAgent.winestock,
|
|
||||||
# ),
|
|
||||||
"finalanswer"=> Dict(
|
|
||||||
:description => "<tool description>Useful for when you are ready to recommend wines to the user.</tool description>",
|
|
||||||
:input => """<input format>{\"finalanswer\": \"some text\"}.</input format><input example>{\"finalanswer\": \"I recommend Zena Crown Vista\"}</input example>""",
|
|
||||||
:output => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
a = YiemAgent.sommelier(
|
|
||||||
receiveUserMsgChannel,
|
|
||||||
receiveInternalMsgChannel,
|
|
||||||
agentConfig,
|
|
||||||
name= "assistant",
|
|
||||||
id= "testingSessionID", # agent instance id
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
input =
|
|
||||||
OrderedDict{Symbol, Any}(
|
|
||||||
:question => "Hello, I would like a get a bottle of wine",
|
|
||||||
:thought_1 => "A customer wants to buy a bottle of wine. Before making a recommendation, I need to know more about their preferences.",
|
|
||||||
:action_1 => Dict{Symbol, Any}(
|
|
||||||
:name => "chatbox",
|
|
||||||
:input => "What is the occasion for which you're buying this wine?"
|
|
||||||
),
|
|
||||||
:observation_1 => "We are holding a wedding party",
|
|
||||||
|
|
||||||
:thought_2 => "A wedding party, that's a great occasion! The customer might be looking for a celebratory drink. Let me ask some more questions to narrow down the options.",
|
|
||||||
: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 => "With Thai food, I should recommend a wine that complements its spicy and savory flavors. And since it's a celebratory occasion, the customer might prefer a full-bodied wine.",
|
|
||||||
:action_3 => Dict{Symbol, Any}(
|
|
||||||
:name => "chatbox",
|
|
||||||
:input => "What is your budget for this bottle of wine?"
|
|
||||||
),
|
|
||||||
:observation_3 => "I would spend up to 50 bucks.",
|
|
||||||
|
|
||||||
:thought_4 => "Now that I have some more information, it's time to narrow down the options.",
|
|
||||||
:action_4 => Dict{Symbol, Any}(
|
|
||||||
:name => "winestock",
|
|
||||||
:input => "red wine with full body, pairs well with spicy food, budget \$50"),
|
|
||||||
:observation_4 => "I found the following wines in our stock: \n{\n 1: El Enemigo Cabernet Franc 2019\n2: Tantara Chardonnay 2017\n\n}\n",
|
|
||||||
|
|
||||||
:thought_5 => "Now that I have a list of potential wines, I need to know more about the customer's taste preferences.",
|
|
||||||
:action_5 => Dict{Symbol, Any}(
|
|
||||||
:name => "chatbox",
|
|
||||||
:input => "What type of wine characteristics are you looking for? (e.g. t.e.g. tannin level, sweetness, intensity, acidity)"
|
|
||||||
),
|
|
||||||
:observation_5 => "I like full-bodied Red wine with low tannin.",
|
|
||||||
|
|
||||||
:thought_6 => "Now that I have more information about the customer's preferences, 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."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
result = YiemAgent.reflector(a, input)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,850 +0,0 @@
|
|||||||
# This file is machine-generated - editing it directly is not advised
|
|
||||||
|
|
||||||
julia_version = "1.10.5"
|
|
||||||
manifest_format = "2.0"
|
|
||||||
project_hash = "bf6c32becbc917fa1c33558e7aa59c1aac5237e3"
|
|
||||||
|
|
||||||
[[deps.AliasTables]]
|
|
||||||
deps = ["PtrArrays", "Random"]
|
|
||||||
git-tree-sha1 = "9876e1e164b144ca45e9e3198d0b689cadfed9ff"
|
|
||||||
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
|
|
||||||
version = "1.1.3"
|
|
||||||
|
|
||||||
[[deps.ArgTools]]
|
|
||||||
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
|
|
||||||
version = "1.1.1"
|
|
||||||
|
|
||||||
[[deps.Artifacts]]
|
|
||||||
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
|
|
||||||
|
|
||||||
[[deps.Base64]]
|
|
||||||
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
|
||||||
|
|
||||||
[[deps.BitFlags]]
|
|
||||||
git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d"
|
|
||||||
uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
|
|
||||||
version = "0.1.9"
|
|
||||||
|
|
||||||
[[deps.CEnum]]
|
|
||||||
git-tree-sha1 = "389ad5c84de1ae7cf0e28e381131c98ea87d54fc"
|
|
||||||
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
|
|
||||||
version = "0.5.0"
|
|
||||||
|
|
||||||
[[deps.CSV]]
|
|
||||||
deps = ["CodecZlib", "Dates", "FilePathsBase", "InlineStrings", "Mmap", "Parsers", "PooledArrays", "PrecompileTools", "SentinelArrays", "Tables", "Unicode", "WeakRefStrings", "WorkerUtilities"]
|
|
||||||
git-tree-sha1 = "6c834533dc1fabd820c1db03c839bf97e45a3fab"
|
|
||||||
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
|
||||||
version = "0.10.14"
|
|
||||||
|
|
||||||
[[deps.CodeTracking]]
|
|
||||||
deps = ["InteractiveUtils", "UUIDs"]
|
|
||||||
git-tree-sha1 = "7eee164f122511d3e4e1ebadb7956939ea7e1c77"
|
|
||||||
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
|
|
||||||
version = "1.3.6"
|
|
||||||
|
|
||||||
[[deps.CodecZlib]]
|
|
||||||
deps = ["TranscodingStreams", "Zlib_jll"]
|
|
||||||
git-tree-sha1 = "bce6804e5e6044c6daab27bb533d1295e4a2e759"
|
|
||||||
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
|
|
||||||
version = "0.7.6"
|
|
||||||
|
|
||||||
[[deps.Compat]]
|
|
||||||
deps = ["TOML", "UUIDs"]
|
|
||||||
git-tree-sha1 = "8ae8d32e09f0dcf42a36b90d4e17f5dd2e4c4215"
|
|
||||||
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
|
|
||||||
version = "4.16.0"
|
|
||||||
weakdeps = ["Dates", "LinearAlgebra"]
|
|
||||||
|
|
||||||
[deps.Compat.extensions]
|
|
||||||
CompatLinearAlgebraExt = "LinearAlgebra"
|
|
||||||
|
|
||||||
[[deps.CompilerSupportLibraries_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
|
|
||||||
version = "1.1.1+0"
|
|
||||||
|
|
||||||
[[deps.ConcurrentUtilities]]
|
|
||||||
deps = ["Serialization", "Sockets"]
|
|
||||||
git-tree-sha1 = "ea32b83ca4fefa1768dc84e504cc0a94fb1ab8d1"
|
|
||||||
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
|
|
||||||
version = "2.4.2"
|
|
||||||
|
|
||||||
[[deps.CondaPkg]]
|
|
||||||
deps = ["JSON3", "Markdown", "MicroMamba", "Pidfile", "Pkg", "Preferences", "TOML"]
|
|
||||||
git-tree-sha1 = "8f7faef2ca039ee068cd971a80ccd710d23fb2eb"
|
|
||||||
uuid = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
|
|
||||||
version = "0.2.23"
|
|
||||||
|
|
||||||
[[deps.Crayons]]
|
|
||||||
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
|
|
||||||
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
|
|
||||||
version = "4.1.1"
|
|
||||||
|
|
||||||
[[deps.DBInterface]]
|
|
||||||
git-tree-sha1 = "a444404b3f94deaa43ca2a58e18153a82695282b"
|
|
||||||
uuid = "a10d1c49-ce27-4219-8d33-6db1a4562965"
|
|
||||||
version = "2.6.1"
|
|
||||||
|
|
||||||
[[deps.DataAPI]]
|
|
||||||
git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe"
|
|
||||||
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
|
|
||||||
version = "1.16.0"
|
|
||||||
|
|
||||||
[[deps.DataFrames]]
|
|
||||||
deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
|
|
||||||
git-tree-sha1 = "fb61b4812c49343d7ef0b533ba982c46021938a6"
|
|
||||||
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
|
||||||
version = "1.7.0"
|
|
||||||
|
|
||||||
[[deps.DataStructures]]
|
|
||||||
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
|
|
||||||
git-tree-sha1 = "1d0a14036acb104d9e89698bd408f63ab58cdc82"
|
|
||||||
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
|
||||||
version = "0.18.20"
|
|
||||||
|
|
||||||
[[deps.DataValueInterfaces]]
|
|
||||||
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
|
|
||||||
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.Dates]]
|
|
||||||
deps = ["Printf"]
|
|
||||||
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
|
||||||
|
|
||||||
[[deps.Decimals]]
|
|
||||||
git-tree-sha1 = "e98abef36d02a0ec385d68cd7dadbce9b28cbd88"
|
|
||||||
uuid = "abce61dc-4473-55a0-ba07-351d65e31d42"
|
|
||||||
version = "0.4.1"
|
|
||||||
|
|
||||||
[[deps.Distributed]]
|
|
||||||
deps = ["Random", "Serialization", "Sockets"]
|
|
||||||
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
|
|
||||||
|
|
||||||
[[deps.Distributions]]
|
|
||||||
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
|
|
||||||
git-tree-sha1 = "d7477ecdafb813ddee2ae727afa94e9dcb5f3fb0"
|
|
||||||
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
|
||||||
version = "0.25.112"
|
|
||||||
|
|
||||||
[deps.Distributions.extensions]
|
|
||||||
DistributionsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
DistributionsDensityInterfaceExt = "DensityInterface"
|
|
||||||
DistributionsTestExt = "Test"
|
|
||||||
|
|
||||||
[deps.Distributions.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
|
|
||||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
|
||||||
|
|
||||||
[[deps.DocStringExtensions]]
|
|
||||||
deps = ["LibGit2"]
|
|
||||||
git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
|
|
||||||
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
|
|
||||||
version = "0.9.3"
|
|
||||||
|
|
||||||
[[deps.Downloads]]
|
|
||||||
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
|
|
||||||
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
|
|
||||||
version = "1.6.0"
|
|
||||||
|
|
||||||
[[deps.ExceptionUnwrapping]]
|
|
||||||
deps = ["Test"]
|
|
||||||
git-tree-sha1 = "dcb08a0d93ec0b1cdc4af184b26b591e9695423a"
|
|
||||||
uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4"
|
|
||||||
version = "0.1.10"
|
|
||||||
|
|
||||||
[[deps.ExprTools]]
|
|
||||||
git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec"
|
|
||||||
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
|
|
||||||
version = "0.1.10"
|
|
||||||
|
|
||||||
[[deps.FileIO]]
|
|
||||||
deps = ["Pkg", "Requires", "UUIDs"]
|
|
||||||
git-tree-sha1 = "62ca0547a14c57e98154423419d8a342dca75ca9"
|
|
||||||
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
|
|
||||||
version = "1.16.4"
|
|
||||||
|
|
||||||
[[deps.FilePathsBase]]
|
|
||||||
deps = ["Compat", "Dates"]
|
|
||||||
git-tree-sha1 = "7878ff7172a8e6beedd1dea14bd27c3c6340d361"
|
|
||||||
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
|
|
||||||
version = "0.9.22"
|
|
||||||
weakdeps = ["Mmap", "Test"]
|
|
||||||
|
|
||||||
[deps.FilePathsBase.extensions]
|
|
||||||
FilePathsBaseMmapExt = "Mmap"
|
|
||||||
FilePathsBaseTestExt = "Test"
|
|
||||||
|
|
||||||
[[deps.FileWatching]]
|
|
||||||
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
|
|
||||||
|
|
||||||
[[deps.FillArrays]]
|
|
||||||
deps = ["LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "6a70198746448456524cb442b8af316927ff3e1a"
|
|
||||||
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
|
|
||||||
version = "1.13.0"
|
|
||||||
weakdeps = ["PDMats", "SparseArrays", "Statistics"]
|
|
||||||
|
|
||||||
[deps.FillArrays.extensions]
|
|
||||||
FillArraysPDMatsExt = "PDMats"
|
|
||||||
FillArraysSparseArraysExt = "SparseArrays"
|
|
||||||
FillArraysStatisticsExt = "Statistics"
|
|
||||||
|
|
||||||
[[deps.Future]]
|
|
||||||
deps = ["Random"]
|
|
||||||
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
|
|
||||||
|
|
||||||
[[deps.GeneralUtils]]
|
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "JSON3", "MQTTClient", "PrettyPrinting", "Random", "SHA", "UUIDs"]
|
|
||||||
path = "/appfolder/app/privatejuliapkg/GeneralUtils"
|
|
||||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[deps.HTTP]]
|
|
||||||
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
|
|
||||||
git-tree-sha1 = "d1d712be3164d61d1fb98e7ce9bcbc6cc06b45ed"
|
|
||||||
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
|
||||||
version = "1.10.8"
|
|
||||||
|
|
||||||
[[deps.HypergeometricFunctions]]
|
|
||||||
deps = ["LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
|
|
||||||
git-tree-sha1 = "7c4195be1649ae622304031ed46a2f4df989f1eb"
|
|
||||||
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
|
|
||||||
version = "0.3.24"
|
|
||||||
|
|
||||||
[[deps.ICU_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
|
|
||||||
git-tree-sha1 = "20b6765a3016e1fca0c9c93c80d50061b94218b7"
|
|
||||||
uuid = "a51ab1cf-af8e-5615-a023-bc2c838bba6b"
|
|
||||||
version = "69.1.0+0"
|
|
||||||
|
|
||||||
[[deps.Infinity]]
|
|
||||||
deps = ["Dates", "Random", "Requires"]
|
|
||||||
git-tree-sha1 = "cf8234411cbeb98676c173f930951ea29dca3b23"
|
|
||||||
uuid = "a303e19e-6eb4-11e9-3b09-cd9505f79100"
|
|
||||||
version = "0.2.4"
|
|
||||||
|
|
||||||
[[deps.InlineStrings]]
|
|
||||||
git-tree-sha1 = "45521d31238e87ee9f9732561bfee12d4eebd52d"
|
|
||||||
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
|
|
||||||
version = "1.4.2"
|
|
||||||
|
|
||||||
[deps.InlineStrings.extensions]
|
|
||||||
ArrowTypesExt = "ArrowTypes"
|
|
||||||
ParsersExt = "Parsers"
|
|
||||||
|
|
||||||
[deps.InlineStrings.weakdeps]
|
|
||||||
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
|
|
||||||
Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
|
|
||||||
|
|
||||||
[[deps.InteractiveUtils]]
|
|
||||||
deps = ["Markdown"]
|
|
||||||
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
|
|
||||||
|
|
||||||
[[deps.Intervals]]
|
|
||||||
deps = ["Dates", "Printf", "RecipesBase", "Serialization", "TimeZones"]
|
|
||||||
git-tree-sha1 = "ac0aaa807ed5eaf13f67afe188ebc07e828ff640"
|
|
||||||
uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.InvertedIndices]]
|
|
||||||
git-tree-sha1 = "0dc7b50b8d436461be01300fd8cd45aa0274b038"
|
|
||||||
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
|
|
||||||
version = "1.3.0"
|
|
||||||
|
|
||||||
[[deps.IrrationalConstants]]
|
|
||||||
git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2"
|
|
||||||
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
|
|
||||||
version = "0.2.2"
|
|
||||||
|
|
||||||
[[deps.IterTools]]
|
|
||||||
git-tree-sha1 = "42d5f897009e7ff2cf88db414a389e5ed1bdd023"
|
|
||||||
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.IteratorInterfaceExtensions]]
|
|
||||||
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
|
|
||||||
uuid = "82899510-4779-5014-852e-03e436cf321d"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.JLLWrappers]]
|
|
||||||
deps = ["Artifacts", "Preferences"]
|
|
||||||
git-tree-sha1 = "be3dc50a92e5a386872a493a10050136d4703f9b"
|
|
||||||
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
|
|
||||||
version = "1.6.1"
|
|
||||||
|
|
||||||
[[deps.JSON3]]
|
|
||||||
deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"]
|
|
||||||
git-tree-sha1 = "1d322381ef7b087548321d3f878cb4c9bd8f8f9b"
|
|
||||||
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
|
|
||||||
version = "1.14.1"
|
|
||||||
|
|
||||||
[deps.JSON3.extensions]
|
|
||||||
JSON3ArrowExt = ["ArrowTypes"]
|
|
||||||
|
|
||||||
[deps.JSON3.weakdeps]
|
|
||||||
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
|
|
||||||
|
|
||||||
[[deps.JuliaInterpreter]]
|
|
||||||
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
|
|
||||||
git-tree-sha1 = "2984284a8abcfcc4784d95a9e2ea4e352dd8ede7"
|
|
||||||
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
|
|
||||||
version = "0.9.36"
|
|
||||||
|
|
||||||
[[deps.Kerberos_krb5_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
|
|
||||||
git-tree-sha1 = "60274b4ab38e8d1248216fe6b6ace75ae09b0502"
|
|
||||||
uuid = "b39eb1a6-c29a-53d7-8c32-632cd16f18da"
|
|
||||||
version = "1.19.3+0"
|
|
||||||
|
|
||||||
[[deps.LLMMCTS]]
|
|
||||||
deps = ["GeneralUtils", "JSON3"]
|
|
||||||
path = "/appfolder/app/privatejuliapkg/LLMMCTS"
|
|
||||||
uuid = "d76c5a4d-449e-4835-8cc4-dd86ec44f241"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[deps.LaTeXStrings]]
|
|
||||||
git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c"
|
|
||||||
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
|
|
||||||
version = "1.4.0"
|
|
||||||
|
|
||||||
[[deps.LayerDicts]]
|
|
||||||
git-tree-sha1 = "6087ad3521d6278ebe5c27ae55e7bbb15ca312cb"
|
|
||||||
uuid = "6f188dcb-512c-564b-bc01-e0f76e72f166"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.LazyArtifacts]]
|
|
||||||
deps = ["Artifacts", "Pkg"]
|
|
||||||
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
|
|
||||||
|
|
||||||
[[deps.LibCURL]]
|
|
||||||
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
|
|
||||||
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
|
|
||||||
version = "0.6.4"
|
|
||||||
|
|
||||||
[[deps.LibCURL_jll]]
|
|
||||||
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
|
|
||||||
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
|
|
||||||
version = "8.4.0+0"
|
|
||||||
|
|
||||||
[[deps.LibGit2]]
|
|
||||||
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
|
|
||||||
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
|
|
||||||
|
|
||||||
[[deps.LibGit2_jll]]
|
|
||||||
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
|
|
||||||
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
|
|
||||||
version = "1.6.4+0"
|
|
||||||
|
|
||||||
[[deps.LibPQ]]
|
|
||||||
deps = ["CEnum", "DBInterface", "Dates", "Decimals", "DocStringExtensions", "FileWatching", "Infinity", "Intervals", "IterTools", "LayerDicts", "LibPQ_jll", "Libdl", "Memento", "OffsetArrays", "SQLStrings", "Tables", "TimeZones", "UTCDateTimes"]
|
|
||||||
git-tree-sha1 = "3d227cd13cbf1e9a54d7748dab33e078da6f9168"
|
|
||||||
uuid = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1"
|
|
||||||
version = "1.18.0"
|
|
||||||
|
|
||||||
[[deps.LibPQ_jll]]
|
|
||||||
deps = ["Artifacts", "ICU_jll", "JLLWrappers", "Kerberos_krb5_jll", "Libdl", "OpenSSL_jll", "Zstd_jll"]
|
|
||||||
git-tree-sha1 = "09163f837936c8cc44f4691cb41d805eb1769642"
|
|
||||||
uuid = "08be9ffa-1c94-5ee5-a977-46a84ec9b350"
|
|
||||||
version = "16.0.0+0"
|
|
||||||
|
|
||||||
[[deps.LibSSH2_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
|
|
||||||
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
|
|
||||||
version = "1.11.0+1"
|
|
||||||
|
|
||||||
[[deps.Libdl]]
|
|
||||||
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
|
|
||||||
|
|
||||||
[[deps.LinearAlgebra]]
|
|
||||||
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
|
|
||||||
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
|
||||||
|
|
||||||
[[deps.LogExpFunctions]]
|
|
||||||
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "a2d09619db4e765091ee5c6ffe8872849de0feea"
|
|
||||||
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
|
|
||||||
version = "0.3.28"
|
|
||||||
|
|
||||||
[deps.LogExpFunctions.extensions]
|
|
||||||
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables"
|
|
||||||
LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
|
|
||||||
|
|
||||||
[deps.LogExpFunctions.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
|
|
||||||
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
|
|
||||||
|
|
||||||
[[deps.Logging]]
|
|
||||||
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
|
||||||
|
|
||||||
[[deps.LoggingExtras]]
|
|
||||||
deps = ["Dates", "Logging"]
|
|
||||||
git-tree-sha1 = "c1dd6d7978c12545b4179fb6153b9250c96b0075"
|
|
||||||
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
|
|
||||||
version = "1.0.3"
|
|
||||||
|
|
||||||
[[deps.LoweredCodeUtils]]
|
|
||||||
deps = ["JuliaInterpreter"]
|
|
||||||
git-tree-sha1 = "260dc274c1bc2cb839e758588c63d9c8b5e639d1"
|
|
||||||
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
|
|
||||||
version = "3.0.5"
|
|
||||||
|
|
||||||
[[deps.MQTTClient]]
|
|
||||||
deps = ["Distributed", "Random", "Sockets"]
|
|
||||||
git-tree-sha1 = "f2597b290d4bf17b577346153cd2ddf9accb5c26"
|
|
||||||
uuid = "985f35cc-2c3d-4943-b8c1-f0931d5f0959"
|
|
||||||
version = "0.3.1"
|
|
||||||
weakdeps = ["PrecompileTools"]
|
|
||||||
|
|
||||||
[deps.MQTTClient.extensions]
|
|
||||||
PrecompileMQTT = "PrecompileTools"
|
|
||||||
|
|
||||||
[[deps.MacroTools]]
|
|
||||||
deps = ["Markdown", "Random"]
|
|
||||||
git-tree-sha1 = "2fa9ee3e63fd3a4f7a9a4f4744a52f4856de82df"
|
|
||||||
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
|
|
||||||
version = "0.5.13"
|
|
||||||
|
|
||||||
[[deps.Markdown]]
|
|
||||||
deps = ["Base64"]
|
|
||||||
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
|
|
||||||
|
|
||||||
[[deps.MbedTLS]]
|
|
||||||
deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "NetworkOptions", "Random", "Sockets"]
|
|
||||||
git-tree-sha1 = "c067a280ddc25f196b5e7df3877c6b226d390aaf"
|
|
||||||
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
|
|
||||||
version = "1.1.9"
|
|
||||||
|
|
||||||
[[deps.MbedTLS_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
|
|
||||||
version = "2.28.2+1"
|
|
||||||
|
|
||||||
[[deps.Memento]]
|
|
||||||
deps = ["Dates", "Distributed", "Requires", "Serialization", "Sockets", "Test", "UUIDs"]
|
|
||||||
git-tree-sha1 = "bb2e8f4d9f400f6e90d57b34860f6abdc51398e5"
|
|
||||||
uuid = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
|
|
||||||
version = "1.4.1"
|
|
||||||
|
|
||||||
[[deps.MicroMamba]]
|
|
||||||
deps = ["Pkg", "Scratch", "micromamba_jll"]
|
|
||||||
git-tree-sha1 = "011cab361eae7bcd7d278f0a7a00ff9c69000c51"
|
|
||||||
uuid = "0b3b1443-0f03-428d-bdfb-f27f9c1191ea"
|
|
||||||
version = "0.1.14"
|
|
||||||
|
|
||||||
[[deps.Missings]]
|
|
||||||
deps = ["DataAPI"]
|
|
||||||
git-tree-sha1 = "ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d"
|
|
||||||
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
|
|
||||||
version = "1.2.0"
|
|
||||||
|
|
||||||
[[deps.Mmap]]
|
|
||||||
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
|
|
||||||
|
|
||||||
[[deps.Mocking]]
|
|
||||||
deps = ["Compat", "ExprTools"]
|
|
||||||
git-tree-sha1 = "2c140d60d7cb82badf06d8783800d0bcd1a7daa2"
|
|
||||||
uuid = "78c3b35d-d492-501b-9361-3d52fe80e533"
|
|
||||||
version = "0.8.1"
|
|
||||||
|
|
||||||
[[deps.MozillaCACerts_jll]]
|
|
||||||
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
|
|
||||||
version = "2023.1.10"
|
|
||||||
|
|
||||||
[[deps.NetworkOptions]]
|
|
||||||
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
|
|
||||||
version = "1.2.0"
|
|
||||||
|
|
||||||
[[deps.OffsetArrays]]
|
|
||||||
git-tree-sha1 = "1a27764e945a152f7ca7efa04de513d473e9542e"
|
|
||||||
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
|
|
||||||
version = "1.14.1"
|
|
||||||
|
|
||||||
[deps.OffsetArrays.extensions]
|
|
||||||
OffsetArraysAdaptExt = "Adapt"
|
|
||||||
|
|
||||||
[deps.OffsetArrays.weakdeps]
|
|
||||||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
|
|
||||||
|
|
||||||
[[deps.OpenBLAS_jll]]
|
|
||||||
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
|
|
||||||
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
|
|
||||||
version = "0.3.23+4"
|
|
||||||
|
|
||||||
[[deps.OpenLibm_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
|
|
||||||
version = "0.8.1+2"
|
|
||||||
|
|
||||||
[[deps.OpenSSL]]
|
|
||||||
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
|
|
||||||
git-tree-sha1 = "38cb508d080d21dc1128f7fb04f20387ed4c0af4"
|
|
||||||
uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c"
|
|
||||||
version = "1.4.3"
|
|
||||||
|
|
||||||
[[deps.OpenSSL_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
|
||||||
git-tree-sha1 = "7493f61f55a6cce7325f197443aa80d32554ba10"
|
|
||||||
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
|
|
||||||
version = "3.0.15+1"
|
|
||||||
|
|
||||||
[[deps.OpenSpecFun_jll]]
|
|
||||||
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
|
|
||||||
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
|
|
||||||
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
|
|
||||||
version = "0.5.5+0"
|
|
||||||
|
|
||||||
[[deps.OrderedCollections]]
|
|
||||||
git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5"
|
|
||||||
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
|
|
||||||
version = "1.6.3"
|
|
||||||
|
|
||||||
[[deps.PDMats]]
|
|
||||||
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
|
|
||||||
git-tree-sha1 = "949347156c25054de2db3b166c52ac4728cbad65"
|
|
||||||
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
|
|
||||||
version = "0.11.31"
|
|
||||||
|
|
||||||
[[deps.Parsers]]
|
|
||||||
deps = ["Dates", "PrecompileTools", "UUIDs"]
|
|
||||||
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
|
|
||||||
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
|
|
||||||
version = "2.8.1"
|
|
||||||
|
|
||||||
[[deps.Pidfile]]
|
|
||||||
deps = ["FileWatching", "Test"]
|
|
||||||
git-tree-sha1 = "2d8aaf8ee10df53d0dfb9b8ee44ae7c04ced2b03"
|
|
||||||
uuid = "fa939f87-e72e-5be4-a000-7fc836dbe307"
|
|
||||||
version = "1.3.0"
|
|
||||||
|
|
||||||
[[deps.Pkg]]
|
|
||||||
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
|
|
||||||
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.PooledArrays]]
|
|
||||||
deps = ["DataAPI", "Future"]
|
|
||||||
git-tree-sha1 = "36d8b4b899628fb92c2749eb488d884a926614d3"
|
|
||||||
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
|
|
||||||
version = "1.4.3"
|
|
||||||
|
|
||||||
[[deps.PrecompileTools]]
|
|
||||||
deps = ["Preferences"]
|
|
||||||
git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f"
|
|
||||||
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.Preferences]]
|
|
||||||
deps = ["TOML"]
|
|
||||||
git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6"
|
|
||||||
uuid = "21216c6a-2e73-6563-6e65-726566657250"
|
|
||||||
version = "1.4.3"
|
|
||||||
|
|
||||||
[[deps.PrettyPrinting]]
|
|
||||||
git-tree-sha1 = "142ee93724a9c5d04d78df7006670a93ed1b244e"
|
|
||||||
uuid = "54e16d92-306c-5ea0-a30b-337be88ac337"
|
|
||||||
version = "0.4.2"
|
|
||||||
|
|
||||||
[[deps.PrettyTables]]
|
|
||||||
deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"]
|
|
||||||
git-tree-sha1 = "1101cd475833706e4d0e7b122218257178f48f34"
|
|
||||||
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
|
|
||||||
version = "2.4.0"
|
|
||||||
|
|
||||||
[[deps.Printf]]
|
|
||||||
deps = ["Unicode"]
|
|
||||||
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
|
||||||
|
|
||||||
[[deps.PtrArrays]]
|
|
||||||
git-tree-sha1 = "77a42d78b6a92df47ab37e177b2deac405e1c88f"
|
|
||||||
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.PythonCall]]
|
|
||||||
deps = ["CondaPkg", "Dates", "Libdl", "MacroTools", "Markdown", "Pkg", "REPL", "Requires", "Serialization", "Tables", "UnsafePointers"]
|
|
||||||
git-tree-sha1 = "06a778ec6d6e76b0c2fb661436a18bce853ec45f"
|
|
||||||
uuid = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
|
|
||||||
version = "0.9.23"
|
|
||||||
|
|
||||||
[[deps.QuadGK]]
|
|
||||||
deps = ["DataStructures", "LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "cda3b045cf9ef07a08ad46731f5a3165e56cf3da"
|
|
||||||
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
|
|
||||||
version = "2.11.1"
|
|
||||||
|
|
||||||
[deps.QuadGK.extensions]
|
|
||||||
QuadGKEnzymeExt = "Enzyme"
|
|
||||||
|
|
||||||
[deps.QuadGK.weakdeps]
|
|
||||||
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
|
|
||||||
|
|
||||||
[[deps.REPL]]
|
|
||||||
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
|
|
||||||
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
|
|
||||||
|
|
||||||
[[deps.Random]]
|
|
||||||
deps = ["SHA"]
|
|
||||||
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
|
||||||
|
|
||||||
[[deps.RecipesBase]]
|
|
||||||
deps = ["PrecompileTools"]
|
|
||||||
git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff"
|
|
||||||
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
|
|
||||||
version = "1.3.4"
|
|
||||||
|
|
||||||
[[deps.Reexport]]
|
|
||||||
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
|
|
||||||
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
|
|
||||||
version = "1.2.2"
|
|
||||||
|
|
||||||
[[deps.Requires]]
|
|
||||||
deps = ["UUIDs"]
|
|
||||||
git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
|
|
||||||
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
|
|
||||||
version = "1.3.0"
|
|
||||||
|
|
||||||
[[deps.Revise]]
|
|
||||||
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "REPL", "Requires", "UUIDs", "Unicode"]
|
|
||||||
git-tree-sha1 = "7f4228017b83c66bd6aa4fddeb170ce487e53bc7"
|
|
||||||
uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
|
||||||
version = "3.6.2"
|
|
||||||
|
|
||||||
[[deps.Rmath]]
|
|
||||||
deps = ["Random", "Rmath_jll"]
|
|
||||||
git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4"
|
|
||||||
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
|
|
||||||
version = "0.8.0"
|
|
||||||
|
|
||||||
[[deps.Rmath_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
|
||||||
git-tree-sha1 = "58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8"
|
|
||||||
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
|
|
||||||
version = "0.5.1+0"
|
|
||||||
|
|
||||||
[[deps.SHA]]
|
|
||||||
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
|
||||||
version = "0.7.0"
|
|
||||||
|
|
||||||
[[deps.SQLLLM]]
|
|
||||||
deps = ["CSV", "CondaPkg", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON3", "LLMMCTS", "LibPQ", "MQTTClient", "PrettyPrinting", "PythonCall", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
|
|
||||||
path = "/appfolder/app/privatejuliapkg/SQLLLM"
|
|
||||||
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[deps.SQLStrings]]
|
|
||||||
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
|
|
||||||
uuid = "af517c2e-c243-48fa-aab8-efac3db270f5"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[deps.Scratch]]
|
|
||||||
deps = ["Dates"]
|
|
||||||
git-tree-sha1 = "3bac05bc7e74a75fd9cba4295cde4045d9fe2386"
|
|
||||||
uuid = "6c6a2e73-6563-6170-7368-637461726353"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.SentinelArrays]]
|
|
||||||
deps = ["Dates", "Random"]
|
|
||||||
git-tree-sha1 = "ff11acffdb082493657550959d4feb4b6149e73a"
|
|
||||||
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
|
|
||||||
version = "1.4.5"
|
|
||||||
|
|
||||||
[[deps.Serialization]]
|
|
||||||
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
|
||||||
|
|
||||||
[[deps.SimpleBufferStream]]
|
|
||||||
git-tree-sha1 = "f305871d2f381d21527c770d4788c06c097c9bc1"
|
|
||||||
uuid = "777ac1f9-54b0-4bf8-805c-2214025038e7"
|
|
||||||
version = "1.2.0"
|
|
||||||
|
|
||||||
[[deps.Sockets]]
|
|
||||||
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
|
|
||||||
|
|
||||||
[[deps.SortingAlgorithms]]
|
|
||||||
deps = ["DataStructures"]
|
|
||||||
git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085"
|
|
||||||
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
|
|
||||||
version = "1.2.1"
|
|
||||||
|
|
||||||
[[deps.SparseArrays]]
|
|
||||||
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
|
|
||||||
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.SpecialFunctions]]
|
|
||||||
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
|
|
||||||
git-tree-sha1 = "2f5d4697f21388cbe1ff299430dd169ef97d7e14"
|
|
||||||
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
|
|
||||||
version = "2.4.0"
|
|
||||||
|
|
||||||
[deps.SpecialFunctions.extensions]
|
|
||||||
SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
|
|
||||||
[deps.SpecialFunctions.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
|
|
||||||
[[deps.Statistics]]
|
|
||||||
deps = ["LinearAlgebra", "SparseArrays"]
|
|
||||||
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.StatsAPI]]
|
|
||||||
deps = ["LinearAlgebra"]
|
|
||||||
git-tree-sha1 = "1ff449ad350c9c4cbc756624d6f8a8c3ef56d3ed"
|
|
||||||
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
|
|
||||||
version = "1.7.0"
|
|
||||||
|
|
||||||
[[deps.StatsBase]]
|
|
||||||
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
|
|
||||||
git-tree-sha1 = "5cf7606d6cef84b543b483848d4ae08ad9832b21"
|
|
||||||
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
|
||||||
version = "0.34.3"
|
|
||||||
|
|
||||||
[[deps.StatsFuns]]
|
|
||||||
deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
|
|
||||||
git-tree-sha1 = "b423576adc27097764a90e163157bcfc9acf0f46"
|
|
||||||
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
|
|
||||||
version = "1.3.2"
|
|
||||||
|
|
||||||
[deps.StatsFuns.extensions]
|
|
||||||
StatsFunsChainRulesCoreExt = "ChainRulesCore"
|
|
||||||
StatsFunsInverseFunctionsExt = "InverseFunctions"
|
|
||||||
|
|
||||||
[deps.StatsFuns.weakdeps]
|
|
||||||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
|
|
||||||
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
|
|
||||||
|
|
||||||
[[deps.StringManipulation]]
|
|
||||||
deps = ["PrecompileTools"]
|
|
||||||
git-tree-sha1 = "a6b1675a536c5ad1a60e5a5153e1fee12eb146e3"
|
|
||||||
uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e"
|
|
||||||
version = "0.4.0"
|
|
||||||
|
|
||||||
[[deps.StructTypes]]
|
|
||||||
deps = ["Dates", "UUIDs"]
|
|
||||||
git-tree-sha1 = "159331b30e94d7b11379037feeb9b690950cace8"
|
|
||||||
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
|
|
||||||
version = "1.11.0"
|
|
||||||
|
|
||||||
[[deps.SuiteSparse]]
|
|
||||||
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
|
|
||||||
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
|
|
||||||
|
|
||||||
[[deps.SuiteSparse_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
|
|
||||||
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
|
|
||||||
version = "7.2.1+1"
|
|
||||||
|
|
||||||
[[deps.TOML]]
|
|
||||||
deps = ["Dates"]
|
|
||||||
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
|
|
||||||
version = "1.0.3"
|
|
||||||
|
|
||||||
[[deps.TZJData]]
|
|
||||||
deps = ["Artifacts"]
|
|
||||||
git-tree-sha1 = "36b40607bf2bf856828690e097e1c799623b0602"
|
|
||||||
uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7"
|
|
||||||
version = "1.3.0+2024b"
|
|
||||||
|
|
||||||
[[deps.TableTraits]]
|
|
||||||
deps = ["IteratorInterfaceExtensions"]
|
|
||||||
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
|
|
||||||
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
|
|
||||||
version = "1.0.1"
|
|
||||||
|
|
||||||
[[deps.Tables]]
|
|
||||||
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"]
|
|
||||||
git-tree-sha1 = "598cd7c1f68d1e205689b1c2fe65a9f85846f297"
|
|
||||||
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
|
|
||||||
version = "1.12.0"
|
|
||||||
|
|
||||||
[[deps.Tar]]
|
|
||||||
deps = ["ArgTools", "SHA"]
|
|
||||||
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
|
|
||||||
version = "1.10.0"
|
|
||||||
|
|
||||||
[[deps.Test]]
|
|
||||||
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
|
|
||||||
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
|
||||||
|
|
||||||
[[deps.TimeZones]]
|
|
||||||
deps = ["Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"]
|
|
||||||
git-tree-sha1 = "8323074bc977aa85cf5ad71099a83ac75b0ac107"
|
|
||||||
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
|
|
||||||
version = "1.18.1"
|
|
||||||
weakdeps = ["RecipesBase"]
|
|
||||||
|
|
||||||
[deps.TimeZones.extensions]
|
|
||||||
TimeZonesRecipesBaseExt = "RecipesBase"
|
|
||||||
|
|
||||||
[[deps.TranscodingStreams]]
|
|
||||||
git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742"
|
|
||||||
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
|
|
||||||
version = "0.11.3"
|
|
||||||
|
|
||||||
[[deps.URIs]]
|
|
||||||
git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b"
|
|
||||||
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
|
||||||
version = "1.5.1"
|
|
||||||
|
|
||||||
[[deps.UTCDateTimes]]
|
|
||||||
deps = ["Dates", "TimeZones"]
|
|
||||||
git-tree-sha1 = "4af3552bf0cf4a071bf3d14bd20023ea70f31b62"
|
|
||||||
uuid = "0f7cfa37-7abf-4834-b969-a8aa512401c2"
|
|
||||||
version = "1.6.1"
|
|
||||||
|
|
||||||
[[deps.UUIDs]]
|
|
||||||
deps = ["Random", "SHA"]
|
|
||||||
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|
||||||
|
|
||||||
[[deps.Unicode]]
|
|
||||||
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
|
|
||||||
|
|
||||||
[[deps.UnsafePointers]]
|
|
||||||
git-tree-sha1 = "c81331b3b2e60a982be57c046ec91f599ede674a"
|
|
||||||
uuid = "e17b2a0c-0bdf-430a-bd0c-3a23cae4ff39"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[[deps.WeakRefStrings]]
|
|
||||||
deps = ["DataAPI", "InlineStrings", "Parsers"]
|
|
||||||
git-tree-sha1 = "b1be2855ed9ed8eac54e5caff2afcdb442d52c23"
|
|
||||||
uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
|
|
||||||
version = "1.4.2"
|
|
||||||
|
|
||||||
[[deps.WorkerUtilities]]
|
|
||||||
git-tree-sha1 = "cd1659ba0d57b71a464a29e64dbc67cfe83d54e7"
|
|
||||||
uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60"
|
|
||||||
version = "1.6.1"
|
|
||||||
|
|
||||||
[[deps.Zlib_jll]]
|
|
||||||
deps = ["Libdl"]
|
|
||||||
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
|
|
||||||
version = "1.2.13+1"
|
|
||||||
|
|
||||||
[[deps.Zstd_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "Libdl"]
|
|
||||||
git-tree-sha1 = "555d1076590a6cc2fdee2ef1469451f872d8b41b"
|
|
||||||
uuid = "3161d3a3-bdf6-5164-811a-617609db77b4"
|
|
||||||
version = "1.5.6+1"
|
|
||||||
|
|
||||||
[[deps.libblastrampoline_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
|
|
||||||
version = "5.11.0+0"
|
|
||||||
|
|
||||||
[[deps.micromamba_jll]]
|
|
||||||
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"]
|
|
||||||
git-tree-sha1 = "b4a5a3943078f9fd11ae0b5ab1bdbf7718617945"
|
|
||||||
uuid = "f8abcde7-e9b7-5caa-b8af-a437887ae8e4"
|
|
||||||
version = "1.5.8+0"
|
|
||||||
|
|
||||||
[[deps.nghttp2_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
|
|
||||||
version = "1.52.0+1"
|
|
||||||
|
|
||||||
[[deps.p7zip_jll]]
|
|
||||||
deps = ["Artifacts", "Libdl"]
|
|
||||||
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
|
|
||||||
version = "17.4.0+2"
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
name = "YiemAgent"
|
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
|
||||||
authors = ["narawat lamaiin <narawat@outlook.com>"]
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
|
|
||||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
|
||||||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
|
||||||
GeneralUtils = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
|
||||||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
|
||||||
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
|
|
||||||
LLMMCTS = "d76c5a4d-449e-4835-8cc4-dd86ec44f241"
|
|
||||||
LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1"
|
|
||||||
MQTTClient = "985f35cc-2c3d-4943-b8c1-f0931d5f0959"
|
|
||||||
PrettyPrinting = "54e16d92-306c-5ea0-a30b-337be88ac337"
|
|
||||||
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
|
|
||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
|
||||||
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
|
||||||
SQLLLM = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
|
|
||||||
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
|
||||||
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
|
|
||||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
version 0.1.0
|
|
||||||
TODO:
|
|
||||||
[WORKING] build MCTS() for planning
|
|
||||||
[] executeplan() to execute the plan
|
|
||||||
|
|
||||||
Change from version: 0.0.9
|
|
||||||
-
|
|
||||||
@@ -1,537 +0,0 @@
|
|||||||
https://github.com/andyz245/LanguageAgentTreeSearch/blob/main/hotpot/hotpot.py
|
|
||||||
|
|
||||||
|
|
||||||
standard_prompt = '''
|
|
||||||
Write a coherent passage of 4 short paragraphs. The end sentence of each paragraph must be: {input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
reflection_prompt = '''You are an advanced reasoning agent that can improve based on self refection. You will be given a previous reasoning trial in which you were given access to an Docstore API environment and a question to answer. You were unsuccessful in answering the question either because you guessed the wrong answer with Finish[<answer>], or you used up your set number of reasoning steps. In a few sentences, Diagnose a possible reason for failure and devise a new, concise, high level plan that aims to mitigate the same failure. Use complete sentences.
|
|
||||||
Here are some examples:
|
|
||||||
Previous Trial:
|
|
||||||
Question: The Rome Protocols were signed by three Prime Ministers one of which was assassinated as part of what?
|
|
||||||
Thought 1: I need to search Rome Protocols, find the three Prime Ministers, then find what they were assassinated as part of.
|
|
||||||
Action 1: Search[Rome Protocols]
|
|
||||||
Observation 1: The Rome Protocols were a series of three international agreements concluded in Rome on 17 March 1934 between the governments of Austria, Hungary and Italy. They were signed by Italian Prime Minister Benito Mussolini, Austrian Chancellor Engelbert Dollfuss and Hungarian Prime Minister Gyula Gömbös. All of the protocols went into effect on 12 July 1934 and were registered in League of Nations Treaty Series on 12 December 1934.
|
|
||||||
Thought 2: The three Prime Ministers were Benito Mussolini, Engelbert Dollfuss, and Gyula Gömbös. I need to search Benito Mussolini and find what he was assassinated as part of.
|
|
||||||
Action 2: Search[Benito Mussolini]
|
|
||||||
Observation 2: Benito Amilcare Andrea Mussolini (UK: MU(U)SS-ə-LEE-nee, US: MOOSS-, Italian: [beˈniːto aˈmilkare anˈdrɛːa mussoˈliːni]; 29 July 1883 – 28 April 1945) was an Italian politician and journalist who founded and led the National Fascist Party (PNF). He was Prime Minister of Italy from the March on Rome in 1922 until his deposition in 1943, as well as "Duce" of Italian fascism from the establishment of the Italian Fasces of Combat in 1919 until his summary execution in 1945 by Italian partisans. As dictator of Italy and principal founder of fascism, Mussolini inspired and supported the international spread of fascist movements during the inter-war period.Mussolini was originally a socialist politician and a journalist at the Avanti! newspaper. In 1912, he became a member of the National Directorate of the Italian Socialist Party (PSI), but he was expelled from the PSI for advocating military intervention in World War I, in opposition to the party's stance on neutrality. In 1914, Mussolini founded a new journal, Il Popolo d'Italia, and served in the Royal Italian Army during the war until he was wounded and discharged in 1917. Mussolini denounced the PSI, his views now centering on Italian nationalism instead of socialism, and later founded the fascist movement which came to oppose egalitarianism and class conflict, instead advocating "revolutionary nationalism" transcending class lines. On 31 October 1922, following the March on Rome (28–30 October), Mussolini was appointed prime minister by King Victor Emmanuel III, becoming the youngest individual to hold the office up to that time. After removing all political opposition through his secret police and outlawing labor strikes, Mussolini and his followers consolidated power through a series of laws that transformed the nation into a one-party dictatorship. Within five years, Mussolini had established dictatorial authority by both legal and illegal means and aspired to create a totalitarian state. In 1929, Mussolini signed the Lateran Treaty with the Holy See to establish Vatican City.
|
|
||||||
Mussolini's foreign policy aimed to restore the ancient grandeur of the Roman Empire by expanding Italian colonial possessions and the fascist sphere of influence. In the 1920s, he ordered the Pacification of Libya, instructed the bombing of Corfu over an incident with Greece, established a protectorate over Albania, and incorporated the city of Fiume into the Italian state via agreements with Yugoslavia. In 1936, Ethiopia was conquered following the Second Italo-Ethiopian War and merged into Italian East Africa (AOI) with Eritrea and Somalia. In 1939, Italian forces annexed Albania. Between 1936 and 1939, Mussolini ordered the successful Italian military intervention in Spain in favor of Francisco Franco during the Spanish Civil War. Mussolini's Italy initially tried to avoid the outbreak of a second global war, sending troops at the Brenner Pass to delay Anschluss and taking part in the Stresa Front, the Lytton Report, the Treaty of Lausanne, the Four-Power Pact and the Munich Agreement. However, Italy then alienated itself from Britain and France by aligning with Germany and Japan. Germany invaded Poland on 1 September 1939, resulting in declarations of war by France and the UK and the start of World War II.
|
|
||||||
On 10 June 1940, Mussolini decided to enter the war on the Axis side. Despite initial success, the subsequent Axis collapse on multiple fronts and eventual Allied invasion of Sicily made Mussolini lose the support of the population and members of the Fascist Party. As a consequence, early on 25 July 1943, the Grand Council of Fascism passed a motion of no confidence in Mussolini; later that day King Victor Emmanuel III dismissed him as head of government and had him placed in custody, appointing Pietro Badoglio to succeed him as Prime Minister. After the king agreed to an armistice with the Allies, on 12 September 1943 Mussolini was rescued from captivity in the Gran Sasso raid by German paratroopers and Waffen-SS commandos led by Major Otto-Harald Mors. Adolf Hitler, after meeting with the rescued former dictator, then put Mussolini in charge of a puppet regime in northern Italy, the Italian Social Republic (Italian: Repubblica Sociale Italiana, RSI), informally known as the Salò Republic, causing a civil war. In late April 1945, in the wake of near total defeat, Mussolini and his mistress Clara Petacci attempted to flee to Switzerland, but both were captured by Italian communist partisans and summarily executed by firing squad on 28 April 1945 near Lake Como. The bodies of Mussolini and his mistress were then taken to Milan, where they were hung upside down at a service station to publicly confirm their demise.
|
|
||||||
Thought 3: Benito Mussolini was assassinated as part of the collapse of the Axis powers during World War II. So the Rome Protocols were signed by three Prime Ministers one of which was assassinated as part of World War II.
|
|
||||||
Action 3: Finish[World War II]
|
|
||||||
|
|
||||||
Reflection: I searched one of the prime ministers involved in the signing, then attemted to answer right away. I should have searched each of the prime ministers, then looked up 'death' on each of their pages in order to get more information before answering.
|
|
||||||
|
|
||||||
Previous Trial:
|
|
||||||
Question: Kam Heskin plays Paige Morgan in a 2004 film directed by who?
|
|
||||||
Thought 1: I need to search Kam Heskin and Paige Morgan, find the 2004 film they are in, then find the director of the film.
|
|
||||||
Action 1: Search[Kam Heskin]
|
|
||||||
Observation 1: Kam Erika Heskin (born May 8, 1973) is an American actress. She began her career playing Caitlin Deschanel on the NBC daytime soap opera Sunset Beach (1998–1999), before appearing in films Planet of the Apes (2001) and Catch Me If You Can (2002). Heskin went on in 2003 to play Elizabeth Bennet in an independent film Pride & Prejudice: A Latter-Day Comedy, Robin in Charmed (2004), and Paige Morgan in The Prince and Me film franchise (2006–2010).
|
|
||||||
Thought 2: Kam Heskin plays Paige Morgan in The Prince and Me film franchise. I need to search The Prince and Me film franchise and find the director of the 2004 film.
|
|
||||||
Action 2: Search[The Prince and Me film franchise]
|
|
||||||
Observation 2: Could not find [The Prince and Me film franchise]. Similar: ['Kam Heskin', 'Prince of Persia', 'Harry Potter and the Half-Blood Prince (film)', 'Prince of Persia: The Sands of Time (film)', 'The Chronicles of Narnia (film series)', 'Majestic Prince (franchise)', 'Kingsman (franchise)', 'The Little Prince (2015 film)', 'Shrek (franchise)', 'Harry Potter (film series)']
|
|
||||||
Thought 3: I need to search The Prince and Me (2004 film) instead.
|
|
||||||
Action 3: Search[The Prince and Me (2004 film)]
|
|
||||||
Observation 3: Could not find [The Prince and Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Kam Heskin', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince of Persia', 'Brooklynn Prince', 'Prince (musician)']
|
|
||||||
Thought 4: I need to search The Prince & Me (2004 film).
|
|
||||||
Action 4: Search[The Prince & Me (2004 film)]
|
|
||||||
Observation 4: Could not find [The Prince & Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince (musician)', 'Prince of Persia', 'Kam Heskin', 'Brooklynn Prince']
|
|
||||||
Thought 5: I need to search The Prince & Me (2004 film) instead.
|
|
||||||
Action 5: Search[The Prince & Me (2004 film)]
|
|
||||||
Observation 5: Could not find [The Prince & Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince (musician)', 'Prince of Persia', 'Kam Heskin', 'Brooklynn Prince']
|
|
||||||
Thought 6: I need to search The Prince & Me (2004 film).
|
|
||||||
Action 6: Search[The Prince & Me (2004 film)]
|
|
||||||
Observation 6: Could not find [The Prince & Me (2004 film)]. Similar: ['The Prince & Me', 'The Prince & Me 2: The Royal Wedding', 'Prince of Darkness (film)', 'Prince of Persia: The Sands of Time (film)', 'Rob Knox', 'Alexander (2004 film)', 'Prince (musician)', 'Prince of Persia', 'Kam Heskin', 'Brooklynn Prince']
|
|
||||||
|
|
||||||
Reflection: I got stuck in a loop where I kept trying to search 'The Prince & Me (2004 film)' but the page could not be found. Instead I should have tried to search the similar results that had a similar name to see and they were made in 2004.
|
|
||||||
|
|
||||||
Previous Trial:
|
|
||||||
Question: The Oberoi family is part of a hotel company that has a head office in what city?
|
|
||||||
Thought 1: I need to search the Oberoi family and find the city where the hotel company's head office is located.
|
|
||||||
Action 1: Search[Oberoi family]
|
|
||||||
Observation 1: The Oberoi Group is a luxury hotel group with its head office in New Delhi, India.[2] Founded in 1934, the company owns and operates 32 luxury hotels and two river cruise ships in 7 countries, primarily under its Oberoi Hotels & Resorts and Trident brands.[3] The group also operates The Oberoi Centre for Learning and Development, which is regarded as one of Asia's top institutions for hospitality education.[4]. The foundations of the Oberoi Group date back to 1934 when The Rai Bahadur Mohan Singh Oberoi, the founder of the group, bought two properties: the Maidens in Delhi and the Clarke's in Shimla.[5] In the following years Oberoi, assisted by his two sons, Tilak Raj Singh Oberoi and Prithvi Raj Singh Oberoi (P.R.S. Oberoi
|
|
||||||
Thought 2: The Oberoi Group has its head office in New Delhi, India. I just need to finish with New Delhi.
|
|
||||||
Action 2: Finish[New Delhi]
|
|
||||||
Observation 2: Episode finished, reward = 0
|
|
||||||
|
|
||||||
Reflection: I appeared to have retrieved the correct information about The Oberoi Family and the location of it's head office, and provided a corresponding answer. However this answer does not exactly match the ground truth answer so I should try a different wording, such as Delhi.
|
|
||||||
|
|
||||||
Previous trial:
|
|
||||||
{trajectory}Reflection:'''
|
|
||||||
|
|
||||||
cot_prompt = '''
|
|
||||||
Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Guitars for Wounded Warriors is an album that was recorded in the village in which New York county?
|
|
||||||
Thought 1: I need to search Guitars for Wounded Warriors, then find in which New York county it was recorded.
|
|
||||||
Action 1: Search[Guitars for Wounded Warriors]
|
|
||||||
Observation 1: Guitars for Wounded Warriors is the sixth solo studio album by guitarist Brian Tarquin, released in August 2014 by Cleopatra Records. In 2016, it received a Best Compilation Album nomination by the Independent Music Awards. All tracks were recorded at Tarquin's Jungle Room Studios in New Paltz (village), New York. Being moved by the lack of support for returning veterans through his life Tarquin decided to compose a heavy instrumental rock album as a way to show his appreciation to all veterans. So once again he enlisted top notch players to guest with him on the album, Billy Sheehan on Black Hawk, Ron \"Bumblefoot\" Thal and Reb Beach on Taliban Terror, Steve Morse on Freedom, Chris Poland on Charlie Surfs and Hunting, Chuck Loeb on Escape Kabul, Hal Lindes on Sand & Blood, Gary Hoey on 5 Klicks To Hell and Baghdad, Alex De Rosso Dokken on Broken Arrow, and The Flyin' Ryan Brothers on Surgical Strike. The entire album was engineered, produced and composed by Tarquin especially for each one of the guest guitarists. Partial proceeds are donated to the Fisher House Foundation from sales.
|
|
||||||
Thought 2: Guitars for Wounded Warriors was recorded in New Paltz (village), New York. I need to search New Paltz (village), New York and find which county it is in
|
|
||||||
Action 2: Search[New Paltz (village), New York]
|
|
||||||
Observation 2: New Paltz is a village in Ulster County located in the U.S. state of New York. It is approximately 80 miles (130 km) north of New York City and 70 miles (110 km) south of Albany. The population was 7,324 at the 2020 census.[3]
|
|
||||||
Thought 3: New Paltz (village), New York is in Ulster County, so the answer is Ulster County.
|
|
||||||
Action 3: Finish[Ulster County]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
cot_prompt_short = '''
|
|
||||||
Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
cot_prompt_feedback_short = '''You are also an advanced reasoning agent that can improve based on self refection. Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
You have attempted to answer the following question before and failed. The following reflection(s) give a plan to avoid failing to answer the question in the same way you did previously. Use them to improve your strategy of correctly answering the given question.
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
cot_prompt_feedback = '''You are also an advanced reasoning agent that can improve based on self refection. Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
After each observation, provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. This took place from 1780 to 1650 million years ago (Mya), during the Paleoproterozoic (Statherian Period). It is recorded in the Colorado orogen, a >500-km-wide belt of oceanic arc rock that extends southward into New Mexico. The Colorado orogeny was likely part of the larger Yavapai orogeny.
|
|
||||||
Thought 2: It does not mention the eastern sector of the Colorado orogeny. I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Observation 2: (Result 1 / 1) The Colorado orogen, formerly called the Colorado province, is a >500-km-wide belt of oceanic arc rock (1.78\u20131.65 Ga) that extends southward into New Mexico and composes a major part of the Proterozoic provinces of southwestern United States. This transcontinental collisional event occurred during the Paleoproterozoic (Statherian Period).[1] The Wyoming sector of the Colorado orogeny was formerly called the Medicine Bow orogeny. The eastern sector extends into the High Plains and is called the Central Plains orogeny. The boundary between the Colorado orogeny and the Wyoming craton is the Cheyenne belt, a 5-km-wide mylonitic shear zone that verges northward. The Cheyenne belt transects and cuts off the south edge of the older Trans-Hudson orogeny.[2]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]Observation 3: High Plains refers to one of two distinct land regions:
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Observation 4: The High Plains are a subregion of the Great Plains, mainly in the Western United States, but also partly in the Midwest states of Nebraska, Kansas, and South Dakota, generally encompassing the western part of the Great Plains before the region reaches the Rocky Mountains. The High Plains are located in eastern Montana, southeastern Wyoming, southwestern South Dakota, western Nebraska, eastern Colorado, western Kansas, eastern New Mexico, western Oklahoma, and to just south of the Texas Panhandle.[4] The southern region of the Western High Plains ecology region contains the geological formation known as Llano Estacado which can be seen from a short distance or on satellite maps.[5] From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Guitars for Wounded Warriors is an album that was recorded in the village in which New York county?
|
|
||||||
Thought 1: I need to search Guitars for Wounded Warriors, then find in which New York county it was recorded.
|
|
||||||
Action 1: Search[Guitars for Wounded Warriors]
|
|
||||||
Observation 1: Guitars for Wounded Warriors is the sixth solo studio album by guitarist Brian Tarquin, released in August 2014 by Cleopatra Records. In 2016, it received a Best Compilation Album nomination by the Independent Music Awards. All tracks were recorded at Tarquin's Jungle Room Studios in New Paltz (village), New York. Being moved by the lack of support for returning veterans through his life Tarquin decided to compose a heavy instrumental rock album as a way to show his appreciation to all veterans. So once again he enlisted top notch players to guest with him on the album, Billy Sheehan on Black Hawk, Ron \"Bumblefoot\" Thal and Reb Beach on Taliban Terror, Steve Morse on Freedom, Chris Poland on Charlie Surfs and Hunting, Chuck Loeb on Escape Kabul, Hal Lindes on Sand & Blood, Gary Hoey on 5 Klicks To Hell and Baghdad, Alex De Rosso Dokken on Broken Arrow, and The Flyin' Ryan Brothers on Surgical Strike. The entire album was engineered, produced and composed by Tarquin especially for each one of the guest guitarists. Partial proceeds are donated to the Fisher House Foundation from sales.
|
|
||||||
Thought 2: Guitars for Wounded Warriors was recorded in New Paltz (village), New York. I need to search New Paltz (village), New York and find which county it is in
|
|
||||||
Action 2: Search[New Paltz (village), New York]
|
|
||||||
Observation 2: New Paltz is a village in Ulster County located in the U.S. state of New York. It is approximately 80 miles (130 km) north of New York City and 70 miles (110 km) south of Albany. The population was 7,324 at the 2020 census.[3]
|
|
||||||
Thought 3: New Paltz (village), New York is in Ulster County, so the answer is Ulster County.
|
|
||||||
Action 3: Finish[Ulster County]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
You have attempted to answer the following question before and failed, either because your reasoning for the answer was incorrect or the phrasing of your response did not exactly match the answer. The following reflection(s) give a plan to avoid failing to answer the question in the same way you did previously. Use them to improve your strategy of correctly answering the given question.
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
When providing the thought and action for the current trial, that into account these failed trajectories and make sure not to repeat the same mistakes and incorrect answers.
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
vote_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by pairs of thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a list of trajectories, decide which trajectory is most promising. Analyze each trajectory in detail and consider possible errors, then conclude in the last line "The best trajectory is {s}", where s the integer id of the trajectory.
|
|
||||||
'''
|
|
||||||
|
|
||||||
compare_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by pairs of thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Briefly analyze the correctness of the following two trajectories. Conclude in the last line "The more correct trajectory is 1", "The more correct trajectory is 2", or "The two trajectories are similarly correct".
|
|
||||||
'''
|
|
||||||
|
|
||||||
score_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by pairs of thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, analyze the following trajectory, then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?
|
|
||||||
Thought 1: I need to search for the football manager who recruited David Beckham, and then find out the timeframe in which he managed Manchester United.
|
|
||||||
Action 1: Search[David Beckham's football manager]
|
|
||||||
Observation 1: Could not find David Beckham's football manager. Similar: ['David Beckham', 'Inter Miami CF (redirect from Miami Beckham United)', 'Victoria Beckham', 'The Beckham Experiment', 'Miami Freedom Park'].
|
|
||||||
Thought 2: I couldn't find the information on David Beckham's football manager. I need to search Manchester United and find out the timeframe of the manager.
|
|
||||||
Action 2: Search[Manchester United]
|
|
||||||
Observation 2: Manchester United Football Club, commonly referred to as Man United (often stylised as Man Utd), or simply United, is a professional football club based in Old Trafford, Greater Manchester, England. The club competes in the Premier League, the top division in the English football league system. Nicknamed the Red Devils, they were founded as Newton Heath LYR Football Club in 1878, but changed their name to Manchester United in 1902. After a spell playing in Clayton, Manchester, the club moved to their current stadium, Old Trafford, in 1910.. Domestically, Manchester United have won a record 20 league titles, 12 FA Cups, six League Cups and a record 21 FA Community Shields.
|
|
||||||
Thought 3: The information about David Beckham's football manager is not available. I will search for Manchester United's managers to find the timeframe.
|
|
||||||
Action 3: Search[Manchester United managers]
|
|
||||||
Observation 3: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thought 4: The information about David Beckham's football manager is not available. The question asks for the timeframe when the manager managed Manchester United, so I need to find a list of Manchester United managers.
|
|
||||||
Action 4: Search[list of Manchester United managers]
|
|
||||||
Observation 4: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thus the correctness score is 4
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_feedback = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_reasoning = '''You are an advanced reasoning agent that can improve based on self refection. Analyze the trajectories of your previous solutions to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
This trajectory is incorrect as my search should be related to Mexican Formula One race car drivers, not winners of the Mexican Grand Prix, a seperate event. A better search would have been for the List of Formula One Grand Prix winners, as suggested.
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
This trajectory is correct as it is reasonable to search for the first magazine provided in the question. It is also better to have simple searches corresponding to a single entity, making this the best action.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?
|
|
||||||
Thought 1: I need to search for the football manager who recruited David Beckham, and then find out the timeframe in which he managed Manchester United.
|
|
||||||
Action 1: Search[David Beckham's football manager]
|
|
||||||
Observation 1: Could not find David Beckham's football manager. Similar: ['David Beckham', 'Inter Miami CF (redirect from Miami Beckham United)', 'Victoria Beckham', 'The Beckham Experiment', 'Miami Freedom Park'].
|
|
||||||
Thought 2: I couldn't find the information on David Beckham's football manager. I need to search Manchester United and find out the timeframe of the manager.
|
|
||||||
Action 2: Search[Manchester United]
|
|
||||||
Observation 2: Manchester United Football Club, commonly referred to as Man United (often stylised as Man Utd), or simply United, is a professional football club based in Old Trafford, Greater Manchester, England. The club competes in the Premier League, the top division in the English football league system. Nicknamed the Red Devils, they were founded as Newton Heath LYR Football Club in 1878, but changed their name to Manchester United in 1902. After a spell playing in Clayton, Manchester, the club moved to their current stadium, Old Trafford, in 1910.. Domestically, Manchester United have won a record 20 league titles, 12 FA Cups, six League Cups and a record 21 FA Community Shields.
|
|
||||||
Thought 3: The information about David Beckham's football manager is not available. I will search for Manchester United's managers to find the timeframe.
|
|
||||||
Action 3: Search[Manchester United managers]
|
|
||||||
Observation 3: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thought 4: The information about David Beckham's football manager is not available. The question asks for the timeframe when the manager managed Manchester United, so I need to find a list of Manchester United managers.
|
|
||||||
Action 4: Search[list of Manchester United managers]
|
|
||||||
Observation 4: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
This trajectory is mostly incorrect as I was not able to retrieve the relevant information to answer the question. The searches are too broad and not relevant to the specific player recruited, David Beckham. The last two actions are also too similar. It would be better to first search for David Beckham and lookup information related to his manager.
|
|
||||||
Thus the correctness score is 4
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
This trajectory is correct as all of my thoughts and actions are correct. It makes sense to search for Milhouse first as it is the central subject of the question. It is also correct to directly look up the relevant information in the article, instead of trying another search.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_reasoning_feedback = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
This trajectory is incorrect as my search should be related to Mexican Formula One race car drivers, not winners it is reasonable to checkof the Mexican Grand Prix, a seperate event. A better search would have been for the List of Formula One Grand Prix winners, as suggested.
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Which magazine was started first Arthur's Magazine or First for Women?
|
|
||||||
Thought 1: I need to search Arthur's Magazine and First for Women, and find which was started first.
|
|
||||||
Action 1: Search[Arthur's Magazine]
|
|
||||||
Observation 1: Arthur's Magazine (1844\u00e2\u0080\u00931846) was an American literary periodical published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey's Lady's Book.[3]
|
|
||||||
This trajectory is correct as it is reasonable to search for the first magazine provided in the question. It is also better to have simple searches corresponding to a single entity, making this the best action.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?Question: The football manager who recruited David Beckham managed Manchester United during what timeframe?
|
|
||||||
Thought 1: I need to search for the football manager who recruited David Beckham, and then find out the timeframe in which he managed Manchester United.
|
|
||||||
Action 1: Search[David Beckham's football manager]
|
|
||||||
Observation 1: Could not find David Beckham's football manager. Similar: ['David Beckham', 'Inter Miami CF (redirect from Miami Beckham United)', 'Victoria Beckham', 'The Beckham Experiment', 'Miami Freedom Park'].
|
|
||||||
Thought 2: I couldn't find the information on David Beckham's football manager. I need to search Manchester United and find out the timeframe of the manager.
|
|
||||||
Action 2: Search[Manchester United]
|
|
||||||
Observation 2: Manchester United Football Club, commonly referred to as Man United (often stylised as Man Utd), or simply United, is a professional football club based in Old Trafford, Greater Manchester, England. The club competes in the Premier League, the top division in the English football league system. Nicknamed the Red Devils, they were founded as Newton Heath LYR Football Club in 1878, but changed their name to Manchester United in 1902. After a spell playing in Clayton, Manchester, the club moved to their current stadium, Old Trafford, in 1910.. Domestically, Manchester United have won a record 20 league titles, 12 FA Cups, six League Cups and a record 21 FA Community Shields.
|
|
||||||
Thought 3: The information about David Beckham's football manager is not available. I will search for Manchester United's managers to find the timeframe.
|
|
||||||
Action 3: Search[Manchester United managers]
|
|
||||||
Observation 3: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
Thought 4: The information about David Beckham's football manager is not available. The question asks for the timeframe when the manager managed Manchester United, so I need to find a list of Manchester United managers.
|
|
||||||
Action 4: Search[list of Manchester United managers]
|
|
||||||
Observation 4: Manchester United Football Club is a professional football club based in Old Trafford, Greater Manchester, England. The club was formed in Newton Heath in 1878 as Newton Heath LYR F.C., and played their first competitive match in October 1886, when they entered the First Round of the 1886–87 FA Cup. The club was renamed Manchester United F.C. in 1902, and moved to Old Trafford in 1910.. From the beginning of the club's official managerial records in 1892 to the start of the 2022–23 season, Manchester United have had 23 full-time managers.
|
|
||||||
This trajectory is mostly incorrect as I was not able to retrieve the relevant information to answer the question. The searches are too broad and not relevant to the specific player recruited, David Beckham. The last two actions are also too similar. It would be better to first search for David Beckham and lookup information related to his manager.
|
|
||||||
Thus the correctness score is 4
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
This trajectory is correct as all of my thoughts and actions are correct. It makes sense to search for Milhouse first as it is the central subject of the question. It is also correct to directly look up the relevant information in the article, instead of trying another search.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
value_prompt_reasoning_feedback_short = '''Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
|
|
||||||
Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude "Thus the correctness score is {s}", where s is an integer from 1 to 10.
|
|
||||||
|
|
||||||
Question: Which other Mexican Formula One race car driver has held the podium besides the Force India driver born in 1990?
|
|
||||||
Thought 1: I need to search for a list of Mexican Formula One race car drivers, then eliminate the one who drove for Force India and was born in 1990.
|
|
||||||
Action 1: Search[Formula One drivers from Mexico]
|
|
||||||
Observation 1: There have been six Formula One drivers from Mexico who have taken part in races since the championship began in 1950. Sergio P\u00e9rez is the most successful, having won six Grands Prix. Since 2021, P\u00e9rez drives for the Red Bull team.. P\u00e9rez is the only Mexican F1 driver to achieve a pole position. He took his first pole position at the 2022 Saudi Arabian Grand Prix, in his 219th Grand Prix meeting (a record for the most Grands Prix before a pole).
|
|
||||||
Thought 2: Sergio P\u00e9rez, born in 1990 and drove for Force India, is not the Mexican driver we are looking for. The passage does not give me enough information about other Mexican drivers who have achieved a podium finish. I need to look up more information.
|
|
||||||
Action 2: Lookup[Formula One drivers from Mexico]
|
|
||||||
Observation 2: No more results.
|
|
||||||
Thought 3: The available information doesn't allow me to determine which other Mexican Formula One race car driver, besides Sergio P\u00e9rez, has held the podium. With the search function failing to provide a full list of Mexican Formula One drivers, I need to return different search results. Let's try searching for Mexican Grand Prix winners, as they would have held the podium.
|
|
||||||
Action 3: Search[Mexican Grand Prix winners]
|
|
||||||
Observation 3: Could not find Mexican Grand Prix winners. Similar: ['Mexican Grand Prix', 'List of Formula One Grand Prix winners', '1990 Mexican Grand Prix', '2018 Mexican Grand Prix', '2019 Mexican Grand Prix'].
|
|
||||||
Thought 4: Given the difficulties in finding a direct list of Mexican Grand Prix winners, I should search for the Mexican Grand Prix to get a broader picture of the race's history. This might include winners.
|
|
||||||
Action 4: Search[Mexican Grand Prix]
|
|
||||||
This trajectory is incorrect as my search should be related to Mexican Formula One race car drivers, not winners of the Mexican Grand Prix, a seperate event. A better search would have been for the List of Formula One Grand Prix winners, as suggested.
|
|
||||||
Thus the correctness score is 3
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Observation 1: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.
|
|
||||||
Thought 2: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Observation 2: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
This trajectory is correct as all of my thoughts and actions are correct. It makes sense to search for Milhouse first as it is the central subject of the question. It is also correct to directly look up the relevant information in the article, instead of trying another search.
|
|
||||||
Thus the correctness score is 10
|
|
||||||
|
|
||||||
{trajectories}
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
|
|
||||||
rap_prompt = '''
|
|
||||||
Solve a question answering task with interleaving Thought and Action steps. Thought can reason about the current situation, and Action can be three types:
|
|
||||||
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
|
|
||||||
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
|
|
||||||
(3) Finish[answer], which returns the answer and finishes the task.
|
|
||||||
Provide the next Thought and next Action. Here are some examples:
|
|
||||||
|
|
||||||
Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
|
|
||||||
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
|
|
||||||
Action 1: Search[Colorado orogeny]
|
|
||||||
Thought 2: Then I need to look up eastern sector.
|
|
||||||
Action 2: Lookup[eastern sector]
|
|
||||||
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains, so High Plains is the area. I need to search High Plains and find its elevation range.
|
|
||||||
Action 3: Search[High Plains]
|
|
||||||
Thought 4: I need to search High Plains (United States).
|
|
||||||
Action 4: Search[High Plains (United States)]
|
|
||||||
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
|
|
||||||
Action 5: Finish[1,800 to 7,000 ft]
|
|
||||||
|
|
||||||
Question: Guitars for Wounded Warriors is an album that was recorded in the village in which New York county?
|
|
||||||
Thought 1: I need to search Guitars for Wounded Warriors, then find in which New York county it was recorded.
|
|
||||||
Action 1: Search[Guitars for Wounded Warriors]
|
|
||||||
Thought 2: I need to search New Paltz (village), New York and find which county it is in
|
|
||||||
Action 2: Search[New Paltz (village), New York]
|
|
||||||
Thought 3: New Paltz (village), New York is in Ulster County, so the answer is Ulster County.
|
|
||||||
Action 3: Finish[Ulster County]
|
|
||||||
|
|
||||||
Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
|
|
||||||
Thought 1: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.
|
|
||||||
Action 1: Search[Milhouse]
|
|
||||||
Thought 2: I can look up "named after" for finding the specific individual Milhouse is named after.
|
|
||||||
Action 2: Lookup[named after]
|
|
||||||
Thought 3: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.
|
|
||||||
Action 3: Finish[President Richard Nixon]
|
|
||||||
|
|
||||||
{input}
|
|
||||||
'''
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
module YiemAgent
|
|
||||||
|
|
||||||
# export agent
|
|
||||||
|
|
||||||
|
|
||||||
""" Order by dependencies of each file. The 1st included file must not depend on any other
|
|
||||||
files and each file can only depend on the file included before it.
|
|
||||||
"""
|
|
||||||
|
|
||||||
include("type.jl")
|
|
||||||
using .type
|
|
||||||
|
|
||||||
include("util.jl")
|
|
||||||
using .util
|
|
||||||
|
|
||||||
include("llmfunction.jl")
|
|
||||||
using .llmfunction
|
|
||||||
|
|
||||||
include("interface.jl")
|
|
||||||
using .interface
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module YiemAgent_v1
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,268 +0,0 @@
|
|||||||
module type
|
|
||||||
|
|
||||||
export agent, sommelier, companion
|
|
||||||
|
|
||||||
using Dates, UUIDs, DataStructures, JSON3
|
|
||||||
using GeneralUtils
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
abstract type agent end
|
|
||||||
|
|
||||||
|
|
||||||
mutable struct companion <: agent
|
|
||||||
name::String # agent name
|
|
||||||
id::String # agent id
|
|
||||||
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
|
||||||
|
|
||||||
""" 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()),
|
|
||||||
]
|
|
||||||
|
|
||||||
"""
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}}
|
|
||||||
memory::Dict{Symbol, Any}
|
|
||||||
|
|
||||||
# communication function
|
|
||||||
text2textInstructLLM::Function
|
|
||||||
end
|
|
||||||
|
|
||||||
function companion(
|
|
||||||
text2textInstructLLM::Function
|
|
||||||
;
|
|
||||||
name::String= "Assistant",
|
|
||||||
id::String= string(uuid4()),
|
|
||||||
maxHistoryMsg::Integer= 20,
|
|
||||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
|
||||||
)
|
|
||||||
|
|
||||||
memory = Dict{Symbol, Any}(
|
|
||||||
:chatbox=> "",
|
|
||||||
:shortmem=> Vector{Dict{Symbol, String}}(),
|
|
||||||
:events=> Vector{Dict{Symbol, Any}}()
|
|
||||||
)
|
|
||||||
|
|
||||||
newAgent = companion(
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
maxHistoryMsg,
|
|
||||||
chathistory,
|
|
||||||
memory,
|
|
||||||
text2textInstructLLM
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
name::String # agent name
|
|
||||||
id::String # agent id
|
|
||||||
retailername::String
|
|
||||||
tools::Dict
|
|
||||||
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
|
||||||
|
|
||||||
""" 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()),
|
|
||||||
]
|
|
||||||
|
|
||||||
"""
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}}
|
|
||||||
memory::Dict{Symbol, Any}
|
|
||||||
|
|
||||||
# communication function
|
|
||||||
text2textInstructLLM::Function
|
|
||||||
executeSQL::Function
|
|
||||||
querySQLVectorDB::Function
|
|
||||||
addSQLVectorDB::Function
|
|
||||||
end
|
|
||||||
|
|
||||||
function sommelier(
|
|
||||||
text2textInstructLLM::Function,
|
|
||||||
executeSQL::Function,
|
|
||||||
querySQLVectorDB::Function,
|
|
||||||
addSQLVectorDB::Function
|
|
||||||
;
|
|
||||||
name::String= "Assistant",
|
|
||||||
id::String= string(uuid4()),
|
|
||||||
retailername::String= "retailer_name",
|
|
||||||
maxHistoryMsg::Integer= 20,
|
|
||||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
|
||||||
)
|
|
||||||
|
|
||||||
tools = Dict( # update input format
|
|
||||||
"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>",
|
|
||||||
: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 => "" ,
|
|
||||||
),
|
|
||||||
"winestock"=> Dict(
|
|
||||||
: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>""",
|
|
||||||
:output => """<output>Output are wines that match the search query in JSON format.""",
|
|
||||||
),
|
|
||||||
# "finalanswer"=> Dict(
|
|
||||||
# :description => "<tool description>Useful for when you are ready to recommend wines to the user.</tool description>",
|
|
||||||
# :input => """<input format>{\"finalanswer\": \"some text\"}.</input format><input example>{\"finalanswer\": \"I recommend Zena Crown Vista\"}</input example>""",
|
|
||||||
# :output => "" ,
|
|
||||||
# :func => nothing,
|
|
||||||
# ),
|
|
||||||
)
|
|
||||||
|
|
||||||
memory = Dict{Symbol, Any}(
|
|
||||||
:chatbox=> "",
|
|
||||||
:shortmem=> Vector{Dict{Symbol, String}}(),
|
|
||||||
:events=> Vector{Dict{Symbol, Any}}()
|
|
||||||
)
|
|
||||||
|
|
||||||
newAgent = sommelier(
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
retailername,
|
|
||||||
tools,
|
|
||||||
maxHistoryMsg,
|
|
||||||
chathistory,
|
|
||||||
memory,
|
|
||||||
text2textInstructLLM,
|
|
||||||
executeSQL,
|
|
||||||
querySQLVectorDB,
|
|
||||||
addSQLVectorDB
|
|
||||||
)
|
|
||||||
|
|
||||||
return newAgent
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module type
|
|
||||||
@@ -1,450 +0,0 @@
|
|||||||
module util
|
|
||||||
|
|
||||||
export clearhistory, addNewMessage, vectorOfDictToText, eventdict, noises
|
|
||||||
|
|
||||||
using UUIDs, Dates, DataStructures, HTTP, MQTTClient, JSON3
|
|
||||||
using GeneralUtils
|
|
||||||
using ..type
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
""" Clear agent chat history.
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `a::agent`
|
|
||||||
an agent
|
|
||||||
|
|
||||||
# Return
|
|
||||||
- nothing
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```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")
|
|
||||||
julia> YiemAgent.clearhistory(a)
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [PENDING] clear memory
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function clearhistory(a::T) where {T<:agent}
|
|
||||||
empty!(a.chathistory)
|
|
||||||
empty!(a.memory[:shortmem])
|
|
||||||
empty!(a.memory[:events])
|
|
||||||
a.memory[:chatbox] = ""
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
""" Add new message to agent.
|
|
||||||
|
|
||||||
Arguments\n
|
|
||||||
-----
|
|
||||||
a::agent
|
|
||||||
an agent
|
|
||||||
role::String
|
|
||||||
message sender role i.e. system, user or assistant
|
|
||||||
text::String
|
|
||||||
message text
|
|
||||||
|
|
||||||
Return\n
|
|
||||||
-----
|
|
||||||
nothing
|
|
||||||
|
|
||||||
Example\n
|
|
||||||
-----
|
|
||||||
```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
|
|
||||||
-----
|
|
||||||
"""
|
|
||||||
function addNewMessage(a::T1, name::String, text::T2;
|
|
||||||
maximumMsg::Integer=20) where {T1<:agent, T2<:AbstractString}
|
|
||||||
if name ∉ ["system", "user", "assistant"] # guard against typo
|
|
||||||
error("name is not in agent.availableRole $(@__LINE__)")
|
|
||||||
end
|
|
||||||
|
|
||||||
#[] summarize the oldest 10 message
|
|
||||||
if length(a.chathistory) > maximumMsg
|
|
||||||
summarize(a.chathistory)
|
|
||||||
else
|
|
||||||
d = Dict(:name=> name, :text=> text, :timestamp=> Dates.now())
|
|
||||||
push!(a.chathistory, d)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `v::Integer`
|
|
||||||
dummy variable
|
|
||||||
|
|
||||||
# Return
|
|
||||||
|
|
||||||
# Example
|
|
||||||
```jldoctest
|
|
||||||
julia>
|
|
||||||
```
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
- [] update docstring
|
|
||||||
- [x] implement the function
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
"""
|
|
||||||
function vectorOfDictToText(vecd::Vector; withkey=true)
|
|
||||||
text = ""
|
|
||||||
|
|
||||||
if withkey
|
|
||||||
for d in vecd
|
|
||||||
name = d[:name]
|
|
||||||
_text = d[:text]
|
|
||||||
text *= "$name> $_text \n"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for d in vecd
|
|
||||||
for (k, v) in d
|
|
||||||
text *= "$v \n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return text
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function eventdict(;
|
|
||||||
event_description::Union{String, Nothing}=nothing,
|
|
||||||
timestamp::Union{DateTime, Nothing}=nothing,
|
|
||||||
subject::Union{String, Nothing}=nothing,
|
|
||||||
action_or_dialogue::Union{String, Nothing}=nothing,
|
|
||||||
location::Union{String, Nothing}=nothing,
|
|
||||||
equipment_used::Union{String, Nothing}=nothing,
|
|
||||||
material_used::Union{String, Nothing}=nothing,
|
|
||||||
outcome::Union{String, Nothing}=nothing,
|
|
||||||
note::Union{String, Nothing}=nothing,
|
|
||||||
)
|
|
||||||
return Dict{Symbol, Any}(
|
|
||||||
:event_description=> event_description,
|
|
||||||
:timestamp=> timestamp,
|
|
||||||
:subject=> subject,
|
|
||||||
:action_or_dialogue=> action_or_dialogue,
|
|
||||||
:location=> location,
|
|
||||||
:equipment_used=> equipment_used,
|
|
||||||
:material_used=> material_used,
|
|
||||||
:outcome=> outcome,
|
|
||||||
:note=> note,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
noise(n::Integer) = String(rand('a':'z', n))
|
|
||||||
function noises(totalword::Integer, wordlength::Integer)
|
|
||||||
noises = ""
|
|
||||||
for i in 1:totalword
|
|
||||||
noises *= noise(wordlength) * " "
|
|
||||||
end
|
|
||||||
noises = strip(noises)
|
|
||||||
return noises
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# """ Convert a single chat dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# # Llama 3 instruct format example
|
|
||||||
# <|system|>
|
|
||||||
# You are a helpful AI assistant.<|end|>
|
|
||||||
# <|user|>
|
|
||||||
# I am going to Paris, what should I see?<|end|>
|
|
||||||
# <|assistant|>
|
|
||||||
# Paris, the capital of France, is known for its stunning architecture, art museums."<|end|>
|
|
||||||
# <|user|>
|
|
||||||
# What is so great about #1?<|end|>
|
|
||||||
# <|assistant|>
|
|
||||||
|
|
||||||
|
|
||||||
# # Arguments
|
|
||||||
# - `name::T`
|
|
||||||
# message owner name e.f. "system", "user" or "assistant"
|
|
||||||
# - `text::T`
|
|
||||||
|
|
||||||
# # Return
|
|
||||||
# - `formattedtext::String`
|
|
||||||
# text formatted to model format
|
|
||||||
|
|
||||||
# # Example
|
|
||||||
# ```jldoctest
|
|
||||||
# julia> using Revise
|
|
||||||
# julia> using YiemAgent
|
|
||||||
# julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
|
||||||
# julia> formattedtext = YiemAgent.formatLLMtext_phi3instruct(d[:name], d[:text])
|
|
||||||
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
# """
|
|
||||||
# function formatLLMtext_phi3instruct(name::T, text::T) where {T<:AbstractString}
|
|
||||||
# formattedtext =
|
|
||||||
# """
|
|
||||||
# <|$name|>
|
|
||||||
# $text<|end|>\n
|
|
||||||
# """
|
|
||||||
|
|
||||||
# return formattedtext
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
# """ Convert a single chat dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# # Llama 3 instruct format example
|
|
||||||
# <|begin_of_text|>
|
|
||||||
# <|start_header_id|>system<|end_header_id|>
|
|
||||||
# You are a helpful assistant.
|
|
||||||
# <|eot_id|>
|
|
||||||
# <|start_header_id|>user<|end_header_id|>
|
|
||||||
# Get me an icecream.
|
|
||||||
# <|eot_id|>
|
|
||||||
# <|start_header_id|>assistant<|end_header_id|>
|
|
||||||
# Go buy it yourself at 7-11.
|
|
||||||
# <|eot_id|>
|
|
||||||
|
|
||||||
# # Arguments
|
|
||||||
# - `name::T`
|
|
||||||
# message owner name e.f. "system", "user" or "assistant"
|
|
||||||
# - `text::T`
|
|
||||||
|
|
||||||
# # Return
|
|
||||||
# - `formattedtext::String`
|
|
||||||
# text formatted to model format
|
|
||||||
|
|
||||||
# # Example
|
|
||||||
# ```jldoctest
|
|
||||||
# julia> using Revise
|
|
||||||
# julia> using YiemAgent
|
|
||||||
# julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
|
||||||
# julia> formattedtext = YiemAgent.formatLLMtext_llama3instruct(d[:name], d[:text])
|
|
||||||
# "<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n"
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
# """
|
|
||||||
# function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString}
|
|
||||||
# formattedtext =
|
|
||||||
# if name == "system"
|
|
||||||
# """
|
|
||||||
# <|begin_of_text|>
|
|
||||||
# <|start_header_id|>$name<|end_header_id|>
|
|
||||||
# $text
|
|
||||||
# <|eot_id|>
|
|
||||||
# """
|
|
||||||
# else
|
|
||||||
# """
|
|
||||||
# <|start_header_id|>$name<|end_header_id|>
|
|
||||||
# $text
|
|
||||||
# <|eot_id|>
|
|
||||||
# """
|
|
||||||
# end
|
|
||||||
|
|
||||||
# return formattedtext
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# """ Convert a chat messages in vector of dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# # Arguments
|
|
||||||
# - `messages::Vector{Dict{Symbol, T}}`
|
|
||||||
# message owner name e.f. "system", "user" or "assistant"
|
|
||||||
# - `formatname::T`
|
|
||||||
# format name to be used
|
|
||||||
|
|
||||||
# # Return
|
|
||||||
# - `formattedtext::String`
|
|
||||||
# text formatted to model format
|
|
||||||
|
|
||||||
# # Example
|
|
||||||
# ```jldoctest
|
|
||||||
# julia> using Revise
|
|
||||||
# julia> using YiemAgent
|
|
||||||
# julia> chatmessage = [
|
|
||||||
# Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",),
|
|
||||||
# Dict(:name=> "user",:text=> "list me all planets in our solar system.",),
|
|
||||||
# Dict(:name=> "assistant",:text=> "I'm sorry. I don't know. You tell me.",),
|
|
||||||
# ]
|
|
||||||
# julia> formattedtext = YiemAgent.formatLLMtext(chatmessage, "llama3instruct")
|
|
||||||
# "<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n <|start_header_id|>user<|end_header_id|>\n list me all planets in our solar system.\n <|eot_id|>\n <|start_header_id|>assistant<|end_header_id|>\n I'm sorry. I don't know. You tell me.\n <|eot_id|>\n"
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# # Signature
|
|
||||||
# """
|
|
||||||
# function formatLLMtext(messages::Vector{Dict{Symbol, T}},
|
|
||||||
# formatname::String="llama3instruct") where {T<:Any}
|
|
||||||
# f = if formatname == "llama3instruct"
|
|
||||||
# formatLLMtext_llama3instruct
|
|
||||||
# elseif formatname == "mistral"
|
|
||||||
# # not define yet
|
|
||||||
# elseif formatname == "phi3instruct"
|
|
||||||
# formatLLMtext_phi3instruct
|
|
||||||
# else
|
|
||||||
# error("$formatname template not define yet")
|
|
||||||
# end
|
|
||||||
|
|
||||||
# str = ""
|
|
||||||
# for t in messages
|
|
||||||
# str *= f(t[:name], t[:text])
|
|
||||||
# end
|
|
||||||
|
|
||||||
# # add <|assistant|> so that the model don't generate it and I don't need to clean it up later
|
|
||||||
# if formatname == "phi3instruct"
|
|
||||||
# str *= "<|assistant|>\n"
|
|
||||||
# end
|
|
||||||
|
|
||||||
# return str
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
# """
|
|
||||||
|
|
||||||
# Arguments\n
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# Return\n
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# Example\n
|
|
||||||
# -----
|
|
||||||
# ```jldoctest
|
|
||||||
# julia>
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# TODO\n
|
|
||||||
# -----
|
|
||||||
# [] update docstring
|
|
||||||
# [PENDING] implement the function
|
|
||||||
|
|
||||||
# Signature\n
|
|
||||||
# -----
|
|
||||||
# """
|
|
||||||
# function iterativeprompting(a::T, prompt::String, verification::Function) where {T<:agent}
|
|
||||||
# msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
# a.config[:externalService][:text2textinstruct],
|
|
||||||
# senderName= "iterativeprompting",
|
|
||||||
# senderId= a.id,
|
|
||||||
# receiverName= "text2textinstruct",
|
|
||||||
# )
|
|
||||||
|
|
||||||
# outgoingMsg = Dict(
|
|
||||||
# :msgMeta=> msgMeta,
|
|
||||||
# :payload=> Dict(
|
|
||||||
# :text=> prompt,
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
||||||
# success = nothing
|
|
||||||
# result = nothing
|
|
||||||
# critique = ""
|
|
||||||
|
|
||||||
# # iteration loop
|
|
||||||
# while true
|
|
||||||
# # send prompt to LLM
|
|
||||||
# response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
# error("--> iterativeprompting")
|
|
||||||
# # check for correctness and get feedback
|
|
||||||
# success, _critique = verification(response)
|
|
||||||
|
|
||||||
# if success
|
|
||||||
# result = response
|
|
||||||
# break
|
|
||||||
# else
|
|
||||||
# # add critique to prompt
|
|
||||||
# critique *= _critique * "\n"
|
|
||||||
# replace!(prompt, "Critique: ..." => "Critique: $critique")
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# return (success=success, result=result)
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end # module util
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using GeneralUtils
|
|
||||||
|
|
||||||
response = "trajectory_evaluation:\nThe trajectory is correct so far. The thought accurately reflects the user's question, and the action taken is a valid attempt to retrieve data from the database that matches the specified criteria.\n\nanswer_evaluation:\nThe observation provides information about two red wines from Bordeaux rive droite in France, which partially answers the question. However, it does not provide a complete answer as it only lists the wine names and characteristics, but does not explicitly state whether there are any other wines that match the criteria.\n\naccepted_as_answer: No\n\nscore: 6\nThe trajectory is mostly correct, but the observation does not fully address the question.\n\nsuggestion: Consider adding more filters or parameters to the database query to retrieve a complete list of wines that match the specified criteria."
|
|
||||||
|
|
||||||
responsedict = GeneralUtils.textToDict(response,
|
|
||||||
["trajectory_evaluation", "answer_evaluation", "accepted_as_answer", "score", "suggestion"],
|
|
||||||
rightmarker=":", symbolkey=true)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
using Revise
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, DataStructures
|
|
||||||
|
|
||||||
thoughtDict = OrderedDict(
|
|
||||||
:Question=> "Hello, I would like a get a bottle of wine",
|
|
||||||
:Thought_1=> "The customer wants to buy a bottle of wine, but we need more information about their preferences.",
|
|
||||||
:Action_1=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What occasion are you buying the wine for?",
|
|
||||||
),
|
|
||||||
:Observation_1=> "We are having a wedding pary this weekend.",
|
|
||||||
|
|
||||||
:Thought_2=> "A wedding party is a great occasion to have a good bottle of wine.",
|
|
||||||
:Action_2=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What type of food will you be serving with the wine?",
|
|
||||||
),
|
|
||||||
:Observation_2=> "I think it is Thai dishes",
|
|
||||||
|
|
||||||
:Thought_3=> "Now that I know the occasion and food, I need to ask about the budget.",
|
|
||||||
:Action_3=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What is your budget for this wine?",
|
|
||||||
),
|
|
||||||
:Observation_3=> "50 bucks",
|
|
||||||
|
|
||||||
:Thought_4=> "With a budget of \$50, we have a wide range of options. Now that I know it's a wedding party and Thai dishes, I need to ask about the type of wine they prefer.",
|
|
||||||
:Action_4=> Dict(
|
|
||||||
:name=> "chatbox",
|
|
||||||
:input=> "What type of wine are you looking for? (Red, White, Sparkling, Rose, Dessert, Fortified)",
|
|
||||||
),
|
|
||||||
:Observation_4=> "Sparkling please.",
|
|
||||||
|
|
||||||
:Thought_5=> "Now that I know the occasion, food, budget and preferred type of wine, it's time to check our inventory for the best matching wine.",
|
|
||||||
:Action_5=> Dict(
|
|
||||||
:name=> "winestock",
|
|
||||||
:input=> "wine with budget \$50, Thai dishes, sparkling, wedding party",
|
|
||||||
),
|
|
||||||
:Observation_5=> "I found the following wine in stock {1 : Zena Crown Vista, 2 : Schrader Cabernet Sauvignon}",
|
|
||||||
|
|
||||||
:Thought_6=> "Now that I have all the information, it's time to recommend a wine that fits their preferences.",
|
|
||||||
:Action_6=> Dict(
|
|
||||||
:name=> "recommendation",
|
|
||||||
:input=> "I recommend Zena Crown Vista for its sparkling and affordable price.",
|
|
||||||
),
|
|
||||||
:Observation_6=> "I don't like it. Do you have another option?",
|
|
||||||
)
|
|
||||||
|
|
||||||
_thoughtJsonStr = JSON3.write(thoughtDict)
|
|
||||||
thoughtJsonStr = _thoughtJsonStr[1:end-1] # remove } at the end
|
|
||||||
# @show thoughtJsonStr
|
|
||||||
|
|
||||||
_, latestThoughtIndice = GeneralUtils.findHighestIndexKey(thoughtDict, "Thought")
|
|
||||||
nextThoughtIndice = latestThoughtIndice + 1
|
|
||||||
|
|
||||||
_prompt =
|
|
||||||
"""
|
|
||||||
You are a helpful sommelier working for a wine store.
|
|
||||||
Your goal is to reccommend the best wine from your inventory that match the user preferences.
|
|
||||||
|
|
||||||
You must follow the following criteria:
|
|
||||||
1) Get to know what occasion the user is buying wine for
|
|
||||||
2) Get to know what food the user will have with wine
|
|
||||||
3) Get to know how much the user willing to spend
|
|
||||||
4) Get to know type of wine the user is looking for e.g. Red, White, Sparkling, Rose, Dessert, Fortified
|
|
||||||
5) Get to know what characteristics of wine the user is looking for
|
|
||||||
e.g. tannin, sweetness, intensity, acidity
|
|
||||||
6) Check your inventory for the best wine that match the user preference
|
|
||||||
7) Recommend wine to the user
|
|
||||||
|
|
||||||
You should only respond with interleaving Thought, Action, Observation steps.
|
|
||||||
Thought can reason about the current situation, and Action can be three types:
|
|
||||||
1) winestock[query], which you can use to find wine in your inventory. The more input data the better.
|
|
||||||
2) chatbox[text], which you can use to interact with the user.
|
|
||||||
3) recommendation[answer], which returns your wine reccommendation to the user.
|
|
||||||
|
|
||||||
You should only respond in JSON format as describe below:
|
|
||||||
{
|
|
||||||
"Thought": "your reasoning",
|
|
||||||
"Action": {"name": "action to take", "input": "Action input"},
|
|
||||||
"Observation": "result of the action"
|
|
||||||
}
|
|
||||||
|
|
||||||
Here are some examples:
|
|
||||||
{
|
|
||||||
"Question": "I would like to buy a sedan with 8 seats.",
|
|
||||||
"Thought_1": "Our showroom carries various vehicle model. But I'm not sure whether we have a models that fits the user demand, I need to check our inventory.",
|
|
||||||
"Action_1": {"name": "inventory", "input": "sedan with 8 seats."},
|
|
||||||
"Observation_1": "Several model has 8 seats. Available color are black, red green"
|
|
||||||
}
|
|
||||||
{
|
|
||||||
"Thought_2": "I have to ask the user what color he likes.",
|
|
||||||
"Action_2": {"name": "chatbox", "input": "Which color do you like?"}
|
|
||||||
"Observation_2": "I'll take black."
|
|
||||||
}
|
|
||||||
{
|
|
||||||
"Thought_3": "There is only one model that fits the user preference. It's Yiem model A",
|
|
||||||
"Action_3": {"name": "recommendation", "input": "I recommend a Yiem model A"}
|
|
||||||
}
|
|
||||||
|
|
||||||
Let's begin!
|
|
||||||
|
|
||||||
$(JSON3.write(thoughtDict))
|
|
||||||
{Thought_$nextThoughtIndice
|
|
||||||
"""
|
|
||||||
|
|
||||||
prompt = YiemAgent.formatLLMtext_llama3instruct("system", _prompt)
|
|
||||||
@show prompt
|
|
||||||
msgMeta = Dict(:requestResponse => nothing,
|
|
||||||
:msgPurpose => nothing,
|
|
||||||
:receiverId => nothing,
|
|
||||||
:getPost => nothing,
|
|
||||||
:msgId => "4c7111e0-c30e-44c3-8f85-1c8b3f03a8be",
|
|
||||||
:acknowledgestatus => nothing,
|
|
||||||
:replyToMsgId => nothing,
|
|
||||||
:msgFormatVersion => nothing,
|
|
||||||
:mqttServerInfo => Dict(:port => 1883, :broker => "mqtt.yiem.cc"),
|
|
||||||
:sendTopic => "/loadbalancer/requestingservice",
|
|
||||||
:receiverName => "text2textinstruct",
|
|
||||||
:replyTopic => nothing,
|
|
||||||
:senderName => "decisionMaker",
|
|
||||||
:senderSelfnote => nothing,
|
|
||||||
:senderId => "testingSessionID",
|
|
||||||
:timeStamp => "2024-05-04T08:06:23.561"
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
thoughtJsonStr = _response[:response][:text]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
using Revise # remove when this package is completed
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, MQTTClient, Dates, UUIDs, DataStructures
|
|
||||||
using Base.Threads
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
config = copy(JSON3.read("config.json"))
|
|
||||||
|
|
||||||
instanceInternalTopic = config[:serviceInternalTopic][:mqtttopic] * "/1"
|
|
||||||
|
|
||||||
client, connection = MakeConnection(config[:mqttServerInfo][:broker],
|
|
||||||
config[:mqttServerInfo][:port])
|
|
||||||
|
|
||||||
receiveUserMsgChannel = Channel{Dict}(4)
|
|
||||||
receiveInternalMsgChannel = Channel{Dict}(4)
|
|
||||||
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
"N/A",
|
|
||||||
replyTopic = config[:servicetopic][:mqtttopic] # ask frontend reply to this instance_chat_topic
|
|
||||||
)
|
|
||||||
|
|
||||||
agentConfig = Dict(
|
|
||||||
:mqttServerInfo=> config[:mqttServerInfo],
|
|
||||||
:receivemsg=> Dict(
|
|
||||||
:prompt=> config[:servicetopic][:mqtttopic], # topic to receive prompt i.e. frontend send msg to this topic
|
|
||||||
:internal=> instanceInternalTopic,
|
|
||||||
),
|
|
||||||
:externalservice=> config[:externalservice],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Instantiate an agent
|
|
||||||
tools=Dict( # update input format
|
|
||||||
"askbox"=> 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>",
|
|
||||||
: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 => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
# "winestock"=> Dict(
|
|
||||||
# :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>""",
|
|
||||||
# :output => """<output>Output are wines that match the search query in JSON format.""",
|
|
||||||
# :func => ChatAgent.winestock,
|
|
||||||
# ),
|
|
||||||
"finalanswer"=> Dict(
|
|
||||||
:description => "<tool description>Useful for when you are ready to recommend wines to the user.</tool description>",
|
|
||||||
:input => """<input format>{\"finalanswer\": \"some text\"}.</input format><input example>{\"finalanswer\": \"I recommend Zena Crown Vista\"}</input example>""",
|
|
||||||
:output => "" ,
|
|
||||||
:func => nothing,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
a = YiemAgent.sommelier(
|
|
||||||
receiveUserMsgChannel,
|
|
||||||
receiveInternalMsgChannel,
|
|
||||||
agentConfig,
|
|
||||||
name= "assistant",
|
|
||||||
id= "testingSessionID", # agent instance id
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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.")
|
|
||||||
|
|
||||||
|
|
||||||
result = YiemAgent.jsoncorrection(a, input)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
using Revise
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, DataStructures, LibPQ
|
|
||||||
using SQLLLM
|
|
||||||
|
|
||||||
|
|
||||||
# _prompt =
|
|
||||||
# """
|
|
||||||
# You are a helpful assistant.
|
|
||||||
# answer the following question:
|
|
||||||
# From the following CSV text:
|
|
||||||
# "{\"tabledescription\":[\"The customer table stores information about customers. It includes details such as first name, last name, display name, username, password, gender, country, telephone number, email, birthdate, additional_search_term, other attributes (in JSON format) and a description.\",\"The wine table stores information about different wines. It includes details namely id, name, brand, manufacturer, region, country, wine_type, grape_variety, serving_temperature, intensity, sweetness, tannin, acidity, fizziness, additional_search_term, other attributes (in JSON format) and a description.\",\"The wine_food table represents the association between wines and food items. It estab" ⋯ 477 bytes ⋯ "ed to retailer names, usernames, passwords, addresses, contact persons, telephone numbers, email addresses, additional_search_term, other attributes (in JSON format) and a description.\",\"The retailer_wine table represents the relationship between retailers and wines. It stores information about the wines available from which retailers, including vintage, their price, and the currency.\",\"The retailer_food table represents the relationship between retailers and food items. It stores information about the food items available from which retailers, including their price and the currency.\"],\"tablename\":[\"customer\",\"wine\",\"wine_food\",\"food\",\"retailer\",\"retailer_wine\",\"retailer_food\"]}"
|
|
||||||
# What is the description of table wine?
|
|
||||||
# """
|
|
||||||
|
|
||||||
# prompt = YiemAgent.formatLLMtext_llama3instruct("system", _prompt)
|
|
||||||
# @show prompt
|
|
||||||
# msgMeta = Dict(:requestResponse => nothing,
|
|
||||||
# :msgPurpose => nothing,
|
|
||||||
# :receiverId => nothing,
|
|
||||||
# :getPost => nothing,
|
|
||||||
# :msgId => "4c7111e0-c30e-44c3-8f85-1c8b3f03a8be",
|
|
||||||
# :acknowledgestatus => nothing,
|
|
||||||
# :replyToMsgId => nothing,
|
|
||||||
# :msgFormatVersion => nothing,
|
|
||||||
# :mqttServerInfo => Dict(:port => 1883, :broker => "mqtt.yiem.cc"),
|
|
||||||
# :sendTopic => "/loadbalancer/requestingservice",
|
|
||||||
# :receiverName => "text2textinstruct",
|
|
||||||
# :replyTopic => nothing,
|
|
||||||
# :senderName => "decisionMaker",
|
|
||||||
# :senderSelfnote => nothing,
|
|
||||||
# :senderId => "testingSessionID",
|
|
||||||
# :timeStamp => "2024-05-04T08:06:23.561"
|
|
||||||
# )
|
|
||||||
|
|
||||||
# outgoingMsg = Dict(
|
|
||||||
# :msgMeta=> msgMeta,
|
|
||||||
# :payload=> Dict(
|
|
||||||
# :text=> prompt,
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# _response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
# result = _response[:response][:text]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DBconnection = LibPQ.Connection("host=192.168.88.12 port=5432 dbname=yiem_wine_assistant user=yiem password=yiem@Postgres_0.0")
|
|
||||||
|
|
||||||
tableinfo, df1, df2, df3 = SQLLLM.tableinfo(DBconnection, "wine")
|
|
||||||
|
|
||||||
|
|
||||||
_prompt =
|
|
||||||
"""
|
|
||||||
You are a helpful assistant helping to answer user question from a database table.
|
|
||||||
|
|
||||||
$tableinfo
|
|
||||||
|
|
||||||
Are there any chardonnay?
|
|
||||||
"""
|
|
||||||
|
|
||||||
prompt = YiemAgent.formatLLMtext_llama3instruct("system", _prompt)
|
|
||||||
@show prompt
|
|
||||||
msgMeta = Dict(:requestResponse => nothing,
|
|
||||||
:msgPurpose => nothing,
|
|
||||||
:receiverId => nothing,
|
|
||||||
:getPost => nothing,
|
|
||||||
:msgId => "4c7111e0-c30e-44c3-8f85-1c8b3f03a8be",
|
|
||||||
:acknowledgestatus => nothing,
|
|
||||||
:replyToMsgId => nothing,
|
|
||||||
:msgFormatVersion => nothing,
|
|
||||||
:mqttServerInfo => Dict(:port => 1883, :broker => "mqtt.yiem.cc"),
|
|
||||||
:sendTopic => "/loadbalancer/requestingservice",
|
|
||||||
:receiverName => "text2textinstruct",
|
|
||||||
:replyTopic => nothing,
|
|
||||||
:senderName => "decisionMaker",
|
|
||||||
:senderSelfnote => nothing,
|
|
||||||
:senderId => "testingSessionID",
|
|
||||||
:timeStamp => "2024-05-04T08:06:23.561"
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
result2 = _response[:response][:text]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,288 +0,0 @@
|
|||||||
using Revise # remove when this package is completed
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, MQTTClient, Dates, UUIDs, LibPQ, Base64, DataFrames
|
|
||||||
using Base.Threads
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
config = copy(JSON3.read("config.json"))
|
|
||||||
|
|
||||||
# instanceInternalTopic = config[:serviceInternalTopic][:mqtttopic] * "/1"
|
|
||||||
|
|
||||||
# client, connection = MakeConnection(config[:mqttServerInfo][:broker],
|
|
||||||
# config[:mqttServerInfo][:port])
|
|
||||||
|
|
||||||
receiveUserMsgChannel = Channel{Dict}(4)
|
|
||||||
# receiveInternalMsgChannel = Channel{Dict}(4)
|
|
||||||
# println(typeof(connection))
|
|
||||||
# msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
# "N/A",
|
|
||||||
# replyTopic = config[:servicetopic][:mqtttopic] # ask frontend reply to this instance_chat_topic
|
|
||||||
# )
|
|
||||||
|
|
||||||
function executeSQL(sql::T) where {T<:AbstractString}
|
|
||||||
DBconnection = LibPQ.Connection("host=192.168.88.12 port=5432 dbname=yiem_wine_assistant user=yiem password=yiem@Postgres_0.0")
|
|
||||||
result = LibPQ.execute(DBconnection, sql)
|
|
||||||
close(DBconnection)
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function text2textInstructLLM(prompt::String)
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
config[:externalservice][:text2textinstruct][:mqtttopic];
|
|
||||||
msgPurpose= "inference",
|
|
||||||
senderName= "yiemagent",
|
|
||||||
senderId= string(uuid4()),
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBrokerAddress= config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= config[:mqttServerInfo][:port],
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> prompt,
|
|
||||||
:kwargs=> Dict(
|
|
||||||
:max_tokens=> 2048,
|
|
||||||
:stop=> ["<|eot_id|>"],
|
|
||||||
:temperature=> 0.2,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120)
|
|
||||||
response = _response[:response][:text]
|
|
||||||
|
|
||||||
return response
|
|
||||||
end
|
|
||||||
|
|
||||||
function executeSQLVectorDB(sql)
|
|
||||||
DBconnection = LibPQ.Connection("host=192.168.88.12 port=5433 dbname=SQLVectorDB user=yiemtechnologies@gmail.com password=yiem@Postgres_0.0")
|
|
||||||
result = LibPQ.execute(DBconnection, sql)
|
|
||||||
close(DBconnection)
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function addSQLVectorDB(state)
|
|
||||||
# get embedding of the query
|
|
||||||
query = [state[:thoughtHistory][:question]]
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
config[:externalservice][:text2textinstruct][:mqtttopic];
|
|
||||||
msgPurpose= "embedding",
|
|
||||||
senderName= "yiemagent",
|
|
||||||
senderId= string(uuid4()),
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBrokerAddress= config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= config[:mqttServerInfo][:port],
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> query
|
|
||||||
)
|
|
||||||
)
|
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
embedding = response[:response][:embeddings][1]
|
|
||||||
|
|
||||||
# check whether there is close enough vector already store in vectorDB. if no, add, else skip
|
|
||||||
sql =
|
|
||||||
"""
|
|
||||||
SELECT *, embedding <-> '$embedding' as distance
|
|
||||||
FROM sql_statement_repository
|
|
||||||
ORDER BY distance LIMIT 1;
|
|
||||||
"""
|
|
||||||
response = executeSQLVectorDB(sql)
|
|
||||||
df = DataFrame(response)
|
|
||||||
row, col = size(df)
|
|
||||||
distance = row == 0 ? Inf : df[1, :distance]
|
|
||||||
if row == 0 || distance > 10 # no close enough SQL stored in the database
|
|
||||||
latestKey, _ = GeneralUtils.findHighestIndexKey(state[:thoughtHistory], :action_input)
|
|
||||||
_sqlStatement = state[:thoughtHistory][latestKey]
|
|
||||||
if occursin("SELECT", _sqlStatement) # make sure it is an SQL statement before adding into DB
|
|
||||||
sqlStatementBase64 = base64encode(_sqlStatement)
|
|
||||||
sqlStatement = replace(_sqlStatement, "'"=>"")
|
|
||||||
sql =
|
|
||||||
"""
|
|
||||||
INSERT INTO sql_statement_repository (question, sql_statement, sql_statement_base64, embedding) VALUES ('$query', '$sqlStatement', '$sqlStatementBase64', '$embedding');
|
|
||||||
"""
|
|
||||||
_ = executeSQLVectorDB(sql)
|
|
||||||
println("--> added new SQL statement to vectorDB ", @__FILE__, " ", @__LINE__)
|
|
||||||
println(sqlStatement)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function querySQLVectorDB(state)
|
|
||||||
|
|
||||||
# provide similarSQL at the first time thinking only
|
|
||||||
latestKey, _ = GeneralUtils.findHighestIndexKey(state[:thoughtHistory], :action_input)
|
|
||||||
if latestKey === nothing
|
|
||||||
# get embedding of the query
|
|
||||||
query = [state[:thoughtHistory][:question]]
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
config[:externalservice][:text2textinstruct][:mqtttopic];
|
|
||||||
msgPurpose= "embedding",
|
|
||||||
senderName= "yiemagent",
|
|
||||||
senderId= string(uuid4()),
|
|
||||||
receiverName= "text2textinstruct",
|
|
||||||
mqttBrokerAddress= config[:mqttServerInfo][:broker],
|
|
||||||
mqttBrokerPort= config[:mqttServerInfo][:port],
|
|
||||||
)
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> query
|
|
||||||
)
|
|
||||||
)
|
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
embedding = response[:response][:embeddings][1]
|
|
||||||
|
|
||||||
# check whether there is close enough vector already store in vectorDB. if no, add, else skip
|
|
||||||
sql =
|
|
||||||
"""
|
|
||||||
SELECT *, embedding <-> '$embedding' as distance
|
|
||||||
FROM sql_statement_repository
|
|
||||||
ORDER BY distance LIMIT 1;
|
|
||||||
"""
|
|
||||||
response = executeSQLVectorDB(sql)
|
|
||||||
df = DataFrame(response)
|
|
||||||
row, col = size(df)
|
|
||||||
distance = row == 0 ? Inf : df[1, :distance]
|
|
||||||
if row != 0 && distance < 100
|
|
||||||
# if there is usable SQL, return it.
|
|
||||||
sqlStatementBase64 = df[1, :sql_statement_base64]
|
|
||||||
sqlStatement = String(base64decode(sqlStatementBase64))
|
|
||||||
println("--> getting SQL statement from vectorDB ", @__FILE__, " ", @__LINE__)
|
|
||||||
println(sqlStatement)
|
|
||||||
return sqlStatement
|
|
||||||
else
|
|
||||||
return nothing
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nothing
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# Instantiate an agent
|
|
||||||
a = YiemAgent.sommelier(
|
|
||||||
text2textInstructLLM,
|
|
||||||
executeSQL,
|
|
||||||
querySQLVectorDB,
|
|
||||||
addSQLVectorDB;
|
|
||||||
name= "Jene",
|
|
||||||
id= "tempId", # agent instance id
|
|
||||||
)
|
|
||||||
|
|
||||||
function main()
|
|
||||||
for i in 1:10
|
|
||||||
userinput = ""
|
|
||||||
for i in 1:3
|
|
||||||
if userinput == ""
|
|
||||||
println("")
|
|
||||||
println("--> user input:")
|
|
||||||
userinput = readline()
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
response = YiemAgent.conversation(a, Dict(:text=> userinput))
|
|
||||||
println("")
|
|
||||||
println("--> assistant response: \n", response)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
"""
|
|
||||||
I'm joining a graduation party this evening. I want to get a bottle of white wine from the US to celebrate. I'm ok with any price range.
|
|
||||||
Well, the party is small casual with close friends and no food serving.
|
|
||||||
I'm open to suggestion since I have no specific idea.
|
|
||||||
I'm ok with any region.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The input is instructions on how you want the presentation to be conducted.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
wines =
|
|
||||||
"""
|
|
||||||
Summary: This table contains two wine records, both from the United States, with white wine types, moderate sweetness (2), and high intensity (5).
|
|
||||||
More details: 1) wine_id: add9824f-81b0-47da-a08a-ee20498bc6c8, wine_name: Belle Cote Chardonnay, brand: Peter Michael, manufacturer: Peter Michael, region: Californian, country: United States, wine_type: white, grape_variety: Chardonnay, serving_temperature: 11 to 13 Celsius, intensity: 5, sweetness: 2, tannin: missing, acidity: 3, fizziness: missing, tasting_notes: oak, butter, vanilla, cream, oil, lemon curd, pear, peach, apple
|
|
||||||
2) wine_id: ff9a494c-e916-44c4-9385-1c18b23aa825, wine_name: Ma Belle-Fille Chardonnay, brand: Peter Michael, manufacturer: Peter Michael, region: Californian, country: United States, wine_type: white, grape_variety: Chardonnay, serving_temperature: 11 to 13 Celsius, intensity: 5, sweetness: 2, tannin: missing, acidity: 3, fizziness: missing, tasting_notes: oak, butter, vanilla, cream, banana, cheese, apricot, peach, apple
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# response = YiemAgent.conversation(a, Dict(:text=> "newtopic",) )
|
|
||||||
|
|
||||||
# response = YiemAgent.conversation(a, Dict(:text=> "Hello, I would like a get a bottle of wine."))
|
|
||||||
# println("---> YiemAgent: ", response)
|
|
||||||
|
|
||||||
# response = YiemAgent.conversation(a, Dict(:text=> "I'm having a graduation party this evening. I'll pay at most 30 bucks."))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # input = "query=\"off dry, medium tannin, French Rosé\""
|
|
||||||
# input = "Search the database for wine type: white, country: France, sweetness level: 1"
|
|
||||||
# YiemAgent.winestock(a, input)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# input = "French dry white wines with medium body"
|
|
||||||
# input = "query=\"medium-bodied dry white wine\""
|
|
||||||
# # input = "the customer is looking for a medium-bodied, dry white wine."
|
|
||||||
# result = YiemAgent.checkinventory(a, input)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
error("test done")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function run_with_timeout(f, args...; timeout=5)
|
|
||||||
result = Ref{Any}()
|
|
||||||
task = Threads.@spawn try
|
|
||||||
result[] = f(args...)
|
|
||||||
catch e
|
|
||||||
println("Task interrupted: ", e)
|
|
||||||
end
|
|
||||||
|
|
||||||
Timer(timeout) do _
|
|
||||||
if !istaskdone(task)
|
|
||||||
schedule(task, InterruptException())
|
|
||||||
println("Task did not complete in time. Aborting.")
|
|
||||||
else
|
|
||||||
println("Task completed within the timeout.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return result[]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Example function that takes arguments and returns a value
|
|
||||||
function example_function(x, y)
|
|
||||||
sleep(10) # Simulate a long-running task
|
|
||||||
return x + y
|
|
||||||
end
|
|
||||||
|
|
||||||
# Example usage
|
|
||||||
result = run_with_timeout(example_function, 3, 4; timeout=5)
|
|
||||||
println("Result: ", result)
|
|
||||||
|
|
||||||
|
|
||||||
a = `$"hello\nworld"`
|
|
||||||
a = $"hello\nworld"
|
|
||||||
|
|
||||||
a = """$("hello\nworld")"""
|
|
||||||
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
using Revise
|
|
||||||
using YiemAgent, GeneralUtils, JSON3, DataStructures
|
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
||||||
|
|
||||||
msgMeta = Dict(:requestResponse => nothing,
|
|
||||||
:msgPurpose => nothing,
|
|
||||||
:receiverId => nothing,
|
|
||||||
:getPost => nothing,
|
|
||||||
:msgId => "4c7111e0-c30e-44c3-8f85-1c8b3f03a8be",
|
|
||||||
:acknowledgestatus => nothing,
|
|
||||||
:replyToMsgId => "dummyid",
|
|
||||||
:msgFormatVersion => nothing,
|
|
||||||
:mqttServerInfo => Dict(:port => 1883, :broker => "mqtt.yiem.cc"),
|
|
||||||
:sendTopic => "/testingSessionID",
|
|
||||||
:receiverName => "wineassistant",
|
|
||||||
:replyTopic => nothing,
|
|
||||||
:senderName => "test_1",
|
|
||||||
:senderSelfnote => nothing,
|
|
||||||
:senderId => nothing,
|
|
||||||
:timeStamp => "2024-05-04T08:06:23.561"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "We are holding a wedding party",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "It will be Thai dishes.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I would spend up to 50 bucks.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I like dry, full-bodied red wine with low tannin.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "What do you have?",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "Dry wine please.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "You did not gave me any choice.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> -1,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "You don't need to ask me. Just tell me already!",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> -1,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I like dry wine with fruity flavors.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "OK, I'll take it.",
|
|
||||||
:select=> 1,
|
|
||||||
:reward=> 1,
|
|
||||||
:isterminal=> true,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "Yes.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outgoingMsg = Dict(
|
|
||||||
:msgMeta=> msgMeta,
|
|
||||||
:payload=> Dict(
|
|
||||||
:text=> "I like dry wine with medium acidity.",
|
|
||||||
:select=> nothing,
|
|
||||||
:reward=> 0,
|
|
||||||
:isterminal=> false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
result = GeneralUtils.sendMqttMsg(outgoingMsg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import requests
|
|
||||||
|
|
||||||
# URL of the API endpoint
|
|
||||||
url = 'https://api.yiem.cc/wine/agent/sommelier/prompt/apiv1'
|
|
||||||
|
|
||||||
# Data to be sent in the JSON request
|
|
||||||
data = {
|
|
||||||
'sid': 'dummySID',
|
|
||||||
'txt': 'hello'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sending the POST request
|
|
||||||
response = requests.post(url, json=data)
|
|
||||||
|
|
||||||
# Displaying the response
|
|
||||||
print('Status Code:', response.status_code)
|
|
||||||
print('Response JSON:', response.json())
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2732
src/interface.jl
2732
src/interface.jl
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
192
src/type.jl
192
src/type.jl
@@ -1,6 +1,6 @@
|
|||||||
module type
|
module type
|
||||||
|
|
||||||
export agent, sommelier, companion
|
export agent, sommelier, companion, virtualcustomer
|
||||||
|
|
||||||
using Dates, UUIDs, DataStructures, JSON3
|
using Dates, UUIDs, DataStructures, JSON3
|
||||||
using GeneralUtils
|
using GeneralUtils
|
||||||
@@ -9,11 +9,44 @@ using GeneralUtils
|
|||||||
|
|
||||||
abstract type agent end
|
abstract type agent end
|
||||||
|
|
||||||
|
|
||||||
mutable struct companion <: agent
|
mutable struct companion <: agent
|
||||||
name::String # agent name
|
name::String # agent name
|
||||||
id::String # agent id
|
id::String # agent id
|
||||||
|
systemmsg::String # system message
|
||||||
|
tools::Dict # tools
|
||||||
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}}
|
||||||
|
memory::Dict{Symbol, Any}
|
||||||
|
func::NamedTuple # NamedTuple of functions
|
||||||
|
llmFormatName::String
|
||||||
|
end
|
||||||
|
|
||||||
|
function companion(
|
||||||
|
func::NamedTuple # 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
|
""" Memory
|
||||||
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
||||||
@@ -22,38 +55,23 @@ mutable struct companion <: agent
|
|||||||
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
||||||
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
||||||
]
|
]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
chathistory::Vector{Dict{Symbol, Any}}
|
|
||||||
memory::Dict{Symbol, Any}
|
|
||||||
|
|
||||||
# communication function
|
|
||||||
text2textInstructLLM::Function
|
|
||||||
end
|
|
||||||
|
|
||||||
function companion(
|
|
||||||
text2textInstructLLM::Function
|
|
||||||
;
|
|
||||||
name::String= "Assistant",
|
|
||||||
id::String= string(uuid4()),
|
|
||||||
maxHistoryMsg::Integer= 20,
|
|
||||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
|
||||||
)
|
|
||||||
|
|
||||||
memory = Dict{Symbol, Any}(
|
memory = Dict{Symbol, Any}(
|
||||||
:chatbox=> "",
|
:events=> Vector{Dict{Symbol, Any}}(),
|
||||||
:shortmem=> OrderedDict{Symbol, Any}(),
|
:state=> Dict{Symbol, Any}(), # state of the agent
|
||||||
:events=> Vector{Dict{Symbol, Any}}(),
|
:recap=> OrderedDict{Symbol, Any}(), # recap summary of the conversation
|
||||||
:state=> Dict{Symbol, Any}(),
|
)
|
||||||
)
|
|
||||||
|
|
||||||
newAgent = companion(
|
newAgent = companion(
|
||||||
name,
|
name,
|
||||||
id,
|
id,
|
||||||
|
systemmsg,
|
||||||
|
tools,
|
||||||
maxHistoryMsg,
|
maxHistoryMsg,
|
||||||
chathistory,
|
chathistory,
|
||||||
memory,
|
memory,
|
||||||
text2textInstructLLM
|
func,
|
||||||
|
llmFormatName
|
||||||
)
|
)
|
||||||
|
|
||||||
return newAgent
|
return newAgent
|
||||||
@@ -61,6 +79,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""" A sommelier agent.
|
""" A sommelier agent.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
@@ -134,20 +153,10 @@ mutable struct sommelier <: agent
|
|||||||
retailername::String
|
retailername::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
|
||||||
|
|
||||||
""" 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()),
|
|
||||||
]
|
|
||||||
|
|
||||||
"""
|
|
||||||
chathistory::Vector{Dict{Symbol, Any}}
|
chathistory::Vector{Dict{Symbol, Any}}
|
||||||
memory::Dict{Symbol, Any}
|
memory::Dict{Symbol, Any}
|
||||||
|
|
||||||
func # NamedTuple of functions
|
func # NamedTuple of functions
|
||||||
|
llmFormatName::String
|
||||||
end
|
end
|
||||||
|
|
||||||
function sommelier(
|
function sommelier(
|
||||||
@@ -158,6 +167,7 @@ function sommelier(
|
|||||||
retailername::String= "retailer_name",
|
retailername::String= "retailer_name",
|
||||||
maxHistoryMsg::Integer= 20,
|
maxHistoryMsg::Integer= 20,
|
||||||
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(),
|
||||||
|
llmFormatName::String= "granite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
tools = Dict( # update input format
|
tools = Dict( # update input format
|
||||||
@@ -171,22 +181,27 @@ function sommelier(
|
|||||||
: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.""",
|
||||||
),
|
),
|
||||||
# "finalanswer"=> Dict(
|
|
||||||
# :description => "<tool description>Useful for when you are ready to recommend wines to the user.</tool description>",
|
|
||||||
# :input => """<input format>{\"finalanswer\": \"some text\"}.</input format><input example>{\"finalanswer\": \"I recommend Zena Crown Vista\"}</input example>""",
|
|
||||||
# :output => "" ,
|
|
||||||
# :func => nothing,
|
|
||||||
# ),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
memory = Dict{Symbol, Any}(
|
""" Memory
|
||||||
:chatbox=> "",
|
Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
||||||
:shortmem=> OrderedDict{Symbol, Any}(),
|
NO "system" message in chathistory because I want to add it at the inference time
|
||||||
:events=> Vector{Dict{Symbol, Any}}(),
|
chathistory= [
|
||||||
:state=> Dict{Symbol, Any}(
|
Dict(:name=>"user", :text=> "Wassup!", :timestamp=> Dates.now()),
|
||||||
:wine_presented_to_user=> "None",
|
Dict(:name=>"assistant", :text=> "Hi I'm your assistant.", :timestamp=> Dates.now()),
|
||||||
),
|
]
|
||||||
)
|
"""
|
||||||
|
memory = Dict{Symbol, Any}(
|
||||||
|
:shortmem=> OrderedDict{Symbol, Any}(
|
||||||
|
:db_search_result=> Any[],
|
||||||
|
:scratchpad=> "", #[PENDING] should be a dict e.g. Dict(:database_search_result=>Dict(:wines=> "", :search_query=> ""))
|
||||||
|
),
|
||||||
|
:events=> Vector{Dict{Symbol, Any}}(),
|
||||||
|
:state=> Dict{Symbol, Any}(
|
||||||
|
),
|
||||||
|
:recap=> OrderedDict{Symbol, Any}(),
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
newAgent = sommelier(
|
newAgent = sommelier(
|
||||||
name,
|
name,
|
||||||
@@ -196,7 +211,82 @@ function sommelier(
|
|||||||
maxHistoryMsg,
|
maxHistoryMsg,
|
||||||
chathistory,
|
chathistory,
|
||||||
memory,
|
memory,
|
||||||
func
|
func,
|
||||||
|
llmFormatName
|
||||||
|
)
|
||||||
|
|
||||||
|
return newAgent
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
mutable struct virtualcustomer <: agent
|
||||||
|
name::String # agent name
|
||||||
|
id::String # agent id
|
||||||
|
systemmsg::String # system message
|
||||||
|
tools::Dict
|
||||||
|
maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized
|
||||||
|
chathistory::Vector{Dict{Symbol, Any}}
|
||||||
|
memory::Dict{Symbol, Any}
|
||||||
|
func # NamedTuple of functions
|
||||||
|
llmFormatName::String
|
||||||
|
end
|
||||||
|
|
||||||
|
function virtualcustomer(
|
||||||
|
func, # NamedTuple of functions
|
||||||
|
;
|
||||||
|
name::String= "Assistant",
|
||||||
|
id::String= string(uuid4()),
|
||||||
|
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 => "<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>""",
|
||||||
|
:output => "" ,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
""" 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}(
|
||||||
|
:shortmem=> OrderedDict{Symbol, Any}(
|
||||||
|
),
|
||||||
|
:events=> Vector{Dict{Symbol, Any}}(),
|
||||||
|
:state=> Dict{Symbol, Any}(
|
||||||
|
),
|
||||||
|
:recap=> OrderedDict{Symbol, Any}(),
|
||||||
|
)
|
||||||
|
|
||||||
|
newAgent = virtualcustomer(
|
||||||
|
name,
|
||||||
|
id,
|
||||||
|
systemmsg,
|
||||||
|
tools,
|
||||||
|
maxHistoryMsg,
|
||||||
|
chathistory,
|
||||||
|
memory,
|
||||||
|
func,
|
||||||
|
llmFormatName
|
||||||
)
|
)
|
||||||
|
|
||||||
return newAgent
|
return newAgent
|
||||||
|
|||||||
480
src/util.jl
480
src/util.jl
@@ -1,6 +1,7 @@
|
|||||||
module util
|
module util
|
||||||
|
|
||||||
export clearhistory, addNewMessage, vectorOfDictToText, eventdict, noises
|
export clearhistory, addNewMessage, chatHistoryToText, eventdict, noises, createTimeline,
|
||||||
|
availableWineToText, createEventsLog, createChatLog
|
||||||
|
|
||||||
using UUIDs, Dates, DataStructures, HTTP, JSON3
|
using UUIDs, Dates, DataStructures, HTTP, JSON3
|
||||||
using GeneralUtils
|
using GeneralUtils
|
||||||
@@ -106,7 +107,7 @@ function addNewMessage(a::T1, name::String, text::T2;
|
|||||||
error("name is not in agent.availableRole $(@__LINE__)")
|
error("name is not in agent.availableRole $(@__LINE__)")
|
||||||
end
|
end
|
||||||
|
|
||||||
#[] summarize the oldest 10 message
|
#[PENDING] summarize the oldest 10 message
|
||||||
if length(a.chathistory) > maximumMsg
|
if length(a.chathistory) > maximumMsg
|
||||||
summarize(a.chathistory)
|
summarize(a.chathistory)
|
||||||
else
|
else
|
||||||
@@ -121,47 +122,53 @@ This function takes in a vector of dictionaries and outputs a single string wher
|
|||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
- `vecd::Vector`
|
- `vecd::Vector`
|
||||||
a vector of dictionaries
|
A vector of dictionaries containing chat messages
|
||||||
- `withkey::Bool`
|
- `withkey::Bool`
|
||||||
whether to include the key in the output text. Default is true
|
Whether to include the name as a prefix in the output text. Default is true
|
||||||
|
- `range::Union{Nothing,UnitRange,Int}`
|
||||||
|
Optional range of messages to include. If nothing, includes all messages
|
||||||
|
|
||||||
# Return
|
# Returns
|
||||||
a string with the formatted dictionaries
|
A formatted string where each line contains either:
|
||||||
|
- If withkey=true: "name> message\n"
|
||||||
|
- If withkey=false: "message\n"
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
```jldoctest
|
|
||||||
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"
|
||||||
```
|
```
|
||||||
# Signature
|
|
||||||
"""
|
"""
|
||||||
function vectorOfDictToText(vecd::Vector; withkey=true)::String
|
function chatHistoryToText(vecd::Vector; withkey=true, range=nothing)::String
|
||||||
# Initialize an empty string to hold the final text
|
# Initialize an empty string to hold the final text
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
|
# Get the elements within the specified range, or all elements if no range provided
|
||||||
|
elements = isnothing(range) ? vecd : vecd[range]
|
||||||
|
|
||||||
# Determine whether to include the key in the output text or not
|
# Determine whether to include the key in the output text or not
|
||||||
if withkey
|
if withkey
|
||||||
# Loop through each dictionary in the input vector
|
# Loop through each dictionary in the input vector
|
||||||
for d in vecd
|
for d in elements
|
||||||
# Extract the 'name' and 'text' keys from the dictionary
|
# Extract the 'name' and 'text' keys from the dictionary
|
||||||
name = d[:name]
|
name = titlecase(d[:name])
|
||||||
_text = d[:text]
|
_text = d[:text]
|
||||||
|
|
||||||
# Append the formatted string to the text variable
|
# Append the formatted string to the text variable
|
||||||
text *= "$name> $_text \n"
|
text *= "$name> $_text \n"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Loop through each dictionary in the input vector
|
# Loop through each dictionary in the input vector
|
||||||
for d in vecd
|
for d in elements
|
||||||
# Iterate over all key-value pairs in the dictionary
|
# Iterate over all key-value pairs in the dictionary
|
||||||
for (k, v) in d
|
for (k, v) in d
|
||||||
# Append the formatted string to the text variable
|
# Append the formatted string to the text variable
|
||||||
text *= "$v \n"
|
text *= "$v \n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the final text
|
# Return the final text
|
||||||
@@ -169,249 +176,238 @@ function vectorOfDictToText(vecd::Vector; withkey=true)::String
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function availableWineToText(vecd::Vector)::String
|
||||||
|
# Initialize an empty string to hold the final text
|
||||||
|
rowtext = ""
|
||||||
|
# Loop through each dictionary in the input vector
|
||||||
|
for (i, d) in enumerate(vecd)
|
||||||
|
# Iterate over all key-value pairs in the dictionary
|
||||||
|
temp = []
|
||||||
|
for (k, v) in d
|
||||||
|
# Append the formatted string to the text variable
|
||||||
|
t = "$k:$v"
|
||||||
|
push!(temp, t)
|
||||||
|
end
|
||||||
|
_rowtext = join(temp, ',')
|
||||||
|
rowtext *= "$i) $_rowtext "
|
||||||
|
end
|
||||||
|
|
||||||
|
return rowtext
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
""" Create a dictionary representing an event with optional details.
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
- `event_description::Union{String, Nothing}`
|
||||||
|
A description of the event
|
||||||
|
- `timestamp::Union{DateTime, Nothing}`
|
||||||
|
The time when the event occurred
|
||||||
|
- `subject::Union{String, Nothing}`
|
||||||
|
The subject or entity associated with the event
|
||||||
|
- `thought::Union{AbstractDict, Nothing}`
|
||||||
|
Any associated thoughts or metadata
|
||||||
|
- `actionname::Union{String, Nothing}`
|
||||||
|
The name of the action performed (e.g., "CHAT", "CHECKINVENTORY")
|
||||||
|
- `actioninput::Union{String, Nothing}`
|
||||||
|
Input or parameters for the action
|
||||||
|
- `location::Union{String, Nothing}`
|
||||||
|
Where the event took place
|
||||||
|
- `equipment_used::Union{String, Nothing}`
|
||||||
|
Equipment involved in the event
|
||||||
|
- `material_used::Union{String, Nothing}`
|
||||||
|
Materials used during the event
|
||||||
|
- `outcome::Union{String, Nothing}`
|
||||||
|
The result or consequence of the event after action execution
|
||||||
|
- `note::Union{String, Nothing}`
|
||||||
|
Additional notes or comments
|
||||||
|
|
||||||
|
# Returns
|
||||||
|
A dictionary with event details as symbol-keyed key-value pairs
|
||||||
|
"""
|
||||||
function eventdict(;
|
function eventdict(;
|
||||||
event_description::Union{String, Nothing}=nothing,
|
event_description::Union{String, Nothing}=nothing,
|
||||||
timestamp::Union{DateTime, Nothing}=nothing,
|
timestamp::Union{DateTime, Nothing}=nothing,
|
||||||
subject::Union{String, Nothing}=nothing,
|
subject::Union{String, Nothing}=nothing,
|
||||||
action_or_dialogue::Union{String, Nothing}=nothing,
|
thought::Union{AbstractDict, Nothing}=nothing,
|
||||||
|
actionname::Union{String, Nothing}=nothing, # "CHAT", "CHECKINVENTORY", "PRESENTBOX", etc
|
||||||
|
actioninput::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,
|
||||||
outcome::Union{String, Nothing}=nothing,
|
outcome::Union{String, Nothing}=nothing,
|
||||||
note::Union{String, Nothing}=nothing,
|
note::Union{String, Nothing}=nothing,
|
||||||
)
|
)
|
||||||
return Dict{Symbol, Any}(
|
|
||||||
:event_description=> event_description,
|
d = Dict{Symbol, Any}(
|
||||||
:timestamp=> timestamp,
|
:event_description=> event_description,
|
||||||
:subject=> subject,
|
:timestamp=> timestamp,
|
||||||
:action_or_dialogue=> action_or_dialogue,
|
:subject=> subject,
|
||||||
:location=> location,
|
:thought=> thought,
|
||||||
:equipment_used=> equipment_used,
|
:actionname=> actionname,
|
||||||
:material_used=> material_used,
|
:actioninput=> actioninput,
|
||||||
:outcome=> outcome,
|
:location=> location,
|
||||||
:note=> note,
|
:equipment_used=> equipment_used,
|
||||||
)
|
:material_used=> material_used,
|
||||||
|
:outcome=> outcome,
|
||||||
|
:note=> note,
|
||||||
|
)
|
||||||
|
|
||||||
|
return d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
""" Create a formatted timeline string from a sequence of events.
|
||||||
|
|
||||||
# """ Convert a single chat dictionary into LLM model instruct format.
|
# Arguments
|
||||||
|
- `events::T1`
|
||||||
|
Vector of event dictionaries containing subject, actioninput and optional outcome fields
|
||||||
|
Each event dictionary should have the following keys:
|
||||||
|
- :subject - The subject or entity performing the action
|
||||||
|
- :actioninput - The action or input performed by the subject
|
||||||
|
- :outcome - (Optional) The result or outcome of the action
|
||||||
|
|
||||||
# # Llama 3 instruct format example
|
# Returns
|
||||||
# <|system|>
|
- `timeline::String`
|
||||||
# You are a helpful AI assistant.<|end|>
|
A formatted string representing the events with their subjects, actions, and optional outcomes
|
||||||
# <|user|>
|
Format: "{index}) {subject}> {actioninput} {outcome}\n" for each event
|
||||||
# I am going to Paris, what should I see?<|end|>
|
|
||||||
# <|assistant|>
|
|
||||||
# Paris, the capital of France, is known for its stunning architecture, art museums."<|end|>
|
|
||||||
# <|user|>
|
|
||||||
# What is so great about #1?<|end|>
|
|
||||||
# <|assistant|>
|
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
# # Arguments
|
events = [
|
||||||
# - `name::T`
|
Dict(:subject => "User", :actioninput => "Hello", :outcome => nothing),
|
||||||
# message owner name e.f. "system", "user" or "assistant"
|
Dict(:subject => "Assistant", :actioninput => "Hi there!", :outcome => "with a smile")
|
||||||
# - `text::T`
|
]
|
||||||
|
timeline = createTimeline(events)
|
||||||
|
# 1) User> Hello
|
||||||
|
# 2) Assistant> Hi there! with a smile
|
||||||
|
|
||||||
# # Return
|
"""
|
||||||
# - `formattedtext::String`
|
function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothing
|
||||||
# text formatted to model format
|
) 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
|
||||||
|
|
||||||
# # Example
|
#[WORKING] Iterate through events and format each one
|
||||||
# ```jldoctest
|
for i in ind
|
||||||
# julia> using Revise
|
event = events[i]
|
||||||
# julia> using YiemAgent
|
# If no outcome exists, format without outcome
|
||||||
# julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
# if event[:actionname] == "CHATBOX"
|
||||||
# julia> formattedtext = YiemAgent.formatLLMtext_phi3instruct(d[:name], d[:text])
|
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput])\n"
|
||||||
|
# elseif event[:actionname] == "CHECKINVENTORY" && event[:outcome] === nothing
|
||||||
|
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: Not done yet.\n"
|
||||||
|
# If outcome exists, include it in formatting
|
||||||
|
if event[:actionname] == "CHECKWINE"
|
||||||
|
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:outcome])\n"
|
||||||
|
else
|
||||||
|
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput])\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# ```
|
# Return formatted timeline string
|
||||||
|
return timeline
|
||||||
|
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
|
||||||
|
|
||||||
# Signature
|
# # Iterate through events and format each one
|
||||||
# """
|
# for i in ind
|
||||||
# function formatLLMtext_phi3instruct(name::T, text::T) where {T<:AbstractString}
|
# event = events[i]
|
||||||
# formattedtext =
|
# # If no outcome exists, format without outcome
|
||||||
# """
|
# if event[:outcome] === nothing
|
||||||
# <|$name|>
|
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: Not done yet.\n"
|
||||||
# $text<|end|>\n
|
# # If outcome exists, include it in formatting
|
||||||
# """
|
# else
|
||||||
|
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:outcome])\n"
|
||||||
# return formattedtext
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
# """ Convert a single chat dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# # Llama 3 instruct format example
|
|
||||||
# <|begin_of_text|>
|
|
||||||
# <|start_header_id|>system<|end_header_id|>
|
|
||||||
# You are a helpful assistant.
|
|
||||||
# <|eot_id|>
|
|
||||||
# <|start_header_id|>user<|end_header_id|>
|
|
||||||
# Get me an icecream.
|
|
||||||
# <|eot_id|>
|
|
||||||
# <|start_header_id|>assistant<|end_header_id|>
|
|
||||||
# Go buy it yourself at 7-11.
|
|
||||||
# <|eot_id|>
|
|
||||||
|
|
||||||
# # Arguments
|
|
||||||
# - `name::T`
|
|
||||||
# message owner name e.f. "system", "user" or "assistant"
|
|
||||||
# - `text::T`
|
|
||||||
|
|
||||||
# # Return
|
|
||||||
# - `formattedtext::String`
|
|
||||||
# text formatted to model format
|
|
||||||
|
|
||||||
# # Example
|
|
||||||
# ```jldoctest
|
|
||||||
# julia> using Revise
|
|
||||||
# julia> using YiemAgent
|
|
||||||
# julia> d = Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",)
|
|
||||||
# julia> formattedtext = YiemAgent.formatLLMtext_llama3instruct(d[:name], d[:text])
|
|
||||||
# "<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n"
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# Signature
|
|
||||||
# """
|
|
||||||
# function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString}
|
|
||||||
# formattedtext =
|
|
||||||
# if name == "system"
|
|
||||||
# """
|
|
||||||
# <|begin_of_text|>
|
|
||||||
# <|start_header_id|>$name<|end_header_id|>
|
|
||||||
# $text
|
|
||||||
# <|eot_id|>
|
|
||||||
# """
|
|
||||||
# else
|
|
||||||
# """
|
|
||||||
# <|start_header_id|>$name<|end_header_id|>
|
|
||||||
# $text
|
|
||||||
# <|eot_id|>
|
|
||||||
# """
|
|
||||||
# end
|
|
||||||
|
|
||||||
# return formattedtext
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# """ Convert a chat messages in vector of dictionary into LLM model instruct format.
|
|
||||||
|
|
||||||
# # Arguments
|
|
||||||
# - `messages::Vector{Dict{Symbol, T}}`
|
|
||||||
# message owner name e.f. "system", "user" or "assistant"
|
|
||||||
# - `formatname::T`
|
|
||||||
# format name to be used
|
|
||||||
|
|
||||||
# # Return
|
|
||||||
# - `formattedtext::String`
|
|
||||||
# text formatted to model format
|
|
||||||
|
|
||||||
# # Example
|
|
||||||
# ```jldoctest
|
|
||||||
# julia> using Revise
|
|
||||||
# julia> using YiemAgent
|
|
||||||
# julia> chatmessage = [
|
|
||||||
# Dict(:name=> "system",:text=> "You are a helpful, respectful and honest assistant.",),
|
|
||||||
# Dict(:name=> "user",:text=> "list me all planets in our solar system.",),
|
|
||||||
# Dict(:name=> "assistant",:text=> "I'm sorry. I don't know. You tell me.",),
|
|
||||||
# ]
|
|
||||||
# julia> formattedtext = YiemAgent.formatLLMtext(chatmessage, "llama3instruct")
|
|
||||||
# "<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n <|start_header_id|>user<|end_header_id|>\n list me all planets in our solar system.\n <|eot_id|>\n <|start_header_id|>assistant<|end_header_id|>\n I'm sorry. I don't know. You tell me.\n <|eot_id|>\n"
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# # Signature
|
|
||||||
# """
|
|
||||||
# function formatLLMtext(messages::Vector{Dict{Symbol, T}},
|
|
||||||
# formatname::String="llama3instruct") where {T<:Any}
|
|
||||||
# f = if formatname == "llama3instruct"
|
|
||||||
# formatLLMtext_llama3instruct
|
|
||||||
# elseif formatname == "mistral"
|
|
||||||
# # not define yet
|
|
||||||
# elseif formatname == "phi3instruct"
|
|
||||||
# formatLLMtext_phi3instruct
|
|
||||||
# else
|
|
||||||
# error("$formatname template not define yet")
|
|
||||||
# end
|
|
||||||
|
|
||||||
# str = ""
|
|
||||||
# for t in messages
|
|
||||||
# str *= f(t[:name], t[:text])
|
|
||||||
# end
|
|
||||||
|
|
||||||
# # add <|assistant|> so that the model don't generate it and I don't need to clean it up later
|
|
||||||
# if formatname == "phi3instruct"
|
|
||||||
# str *= "<|assistant|>\n"
|
|
||||||
# end
|
|
||||||
|
|
||||||
# return str
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
# """
|
|
||||||
|
|
||||||
# Arguments\n
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# Return\n
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# Example\n
|
|
||||||
# -----
|
|
||||||
# ```jldoctest
|
|
||||||
# julia>
|
|
||||||
# ```
|
|
||||||
|
|
||||||
# TODO\n
|
|
||||||
# -----
|
|
||||||
# [] update docstring
|
|
||||||
# [PENDING] implement the function
|
|
||||||
|
|
||||||
# Signature\n
|
|
||||||
# -----
|
|
||||||
# """
|
|
||||||
# function iterativeprompting(a::T, prompt::String, verification::Function) where {T<:agent}
|
|
||||||
# msgMeta = GeneralUtils.generate_msgMeta(
|
|
||||||
# a.config[:externalService][:text2textinstruct],
|
|
||||||
# senderName= "iterativeprompting",
|
|
||||||
# senderId= a.id,
|
|
||||||
# receiverName= "text2textinstruct",
|
|
||||||
# )
|
|
||||||
|
|
||||||
# outgoingMsg = Dict(
|
|
||||||
# :msgMeta=> msgMeta,
|
|
||||||
# :payload=> Dict(
|
|
||||||
# :text=> prompt,
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
||||||
# success = nothing
|
|
||||||
# result = nothing
|
|
||||||
# critique = ""
|
|
||||||
|
|
||||||
# # iteration loop
|
|
||||||
# while true
|
|
||||||
# # send prompt to LLM
|
|
||||||
# response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
# error("--> iterativeprompting")
|
|
||||||
# # check for correctness and get feedback
|
|
||||||
# success, _critique = verification(response)
|
|
||||||
|
|
||||||
# if success
|
|
||||||
# result = response
|
|
||||||
# break
|
|
||||||
# else
|
|
||||||
# # add critique to prompt
|
|
||||||
# critique *= _critique * "\n"
|
|
||||||
# replace!(prompt, "Critique: ..." => "Critique: $critique")
|
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# return (success=success, result=result)
|
# # Return formatted timeline string
|
||||||
|
# return timeline
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
function createEventsLog(events::T1; index::Union{UnitRange, Nothing}=nothing
|
||||||
|
) where {T1<:AbstractVector}
|
||||||
|
# Initialize empty log array
|
||||||
|
log = Dict{Symbol, String}[]
|
||||||
|
|
||||||
|
# Determine which indices to use - either provided range or full length
|
||||||
|
ind =
|
||||||
|
if index !== nothing
|
||||||
|
[index...]
|
||||||
|
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[:outcome] === nothing
|
||||||
|
subject = event[:subject]
|
||||||
|
actioninput = event[:actioninput]
|
||||||
|
d = Dict{Symbol, String}(:name=>subject, :text=>actioninput)
|
||||||
|
push!(log, d)
|
||||||
|
else
|
||||||
|
subject = event[:subject]
|
||||||
|
actioninput = event[:actioninput]
|
||||||
|
outcome = event[:outcome]
|
||||||
|
str = "Action: $actioninput Outcome: $outcome"
|
||||||
|
d = Dict{Symbol, String}(:name=>subject, :text=>str)
|
||||||
|
push!(log, d)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return log
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function createChatLog(chatdict::T1; index::Union{UnitRange, Nothing}=nothing
|
||||||
|
) where {T1<:AbstractVector}
|
||||||
|
# Initialize empty log array
|
||||||
|
log = Dict{Symbol, String}[]
|
||||||
|
|
||||||
|
# Determine which indices to use - either provided range or full length
|
||||||
|
ind =
|
||||||
|
if index !== nothing
|
||||||
|
[index...]
|
||||||
|
else
|
||||||
|
1:length(chatdict)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Iterate through events and format each one
|
||||||
|
for i in ind
|
||||||
|
event = chatdict[i]
|
||||||
|
subject = event[:name]
|
||||||
|
text = event[:text]
|
||||||
|
d = Dict{Symbol, String}(:name=>subject, :text=>text)
|
||||||
|
push!(log, d)
|
||||||
|
end
|
||||||
|
|
||||||
|
return log
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
41
test/Manifest.toml
Normal file
41
test/Manifest.toml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# This file is machine-generated - editing it directly is not advised
|
||||||
|
|
||||||
|
julia_version = "1.11.4"
|
||||||
|
manifest_format = "2.0"
|
||||||
|
project_hash = "71d91126b5a1fb1020e1098d9d492de2a4438fd2"
|
||||||
|
|
||||||
|
[[deps.Base64]]
|
||||||
|
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||||
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.InteractiveUtils]]
|
||||||
|
deps = ["Markdown"]
|
||||||
|
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
|
||||||
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.Logging]]
|
||||||
|
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
||||||
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.Markdown]]
|
||||||
|
deps = ["Base64"]
|
||||||
|
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
|
||||||
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.Random]]
|
||||||
|
deps = ["SHA"]
|
||||||
|
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.SHA]]
|
||||||
|
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
||||||
|
version = "0.7.0"
|
||||||
|
|
||||||
|
[[deps.Serialization]]
|
||||||
|
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
||||||
|
version = "1.11.0"
|
||||||
|
|
||||||
|
[[deps.Test]]
|
||||||
|
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
|
||||||
|
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||||
|
version = "1.11.0"
|
||||||
2
test/Project.toml
Normal file
2
test/Project.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[deps]
|
||||||
|
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||||
@@ -27,30 +27,50 @@
|
|||||||
"description": "agent role"
|
"description": "agent role"
|
||||||
},
|
},
|
||||||
"organization": {
|
"organization": {
|
||||||
"value": "yiem_hq",
|
"value": "yiem_branch_1",
|
||||||
"description": "organization name"
|
"description": "organization name"
|
||||||
},
|
},
|
||||||
"externalservice": {
|
"externalservice": {
|
||||||
"text2textinstruct": {
|
"loadbalancer": {
|
||||||
"mqtttopic": "/loadbalancer/requestingservice",
|
"mqtttopic": "/loadbalancer/requestingservice",
|
||||||
"description": "text to text service with instruct LLM",
|
"description": "text to text service with instruct LLM"
|
||||||
"llminfo": {
|
},
|
||||||
"name": "llama3instruct"
|
"text2textinstruct": {
|
||||||
}
|
"mqtttopic": "/loadbalancer/requestingservice",
|
||||||
},
|
"description": "text to text service with instruct LLM",
|
||||||
"virtualWineCustomer_1": {
|
"llminfo": {
|
||||||
"mqtttopic": "/virtualenvironment/winecustomer",
|
"name": "llama3instruct"
|
||||||
"description": "text to text service with instruct LLM that act as wine customer",
|
}
|
||||||
"llminfo": {
|
},
|
||||||
"name": "llama3instruct"
|
"virtualWineCustomer_1": {
|
||||||
}
|
"mqtttopic": "/virtualenvironment/winecustomer",
|
||||||
},
|
"description": "text to text service with instruct LLM that act as wine customer",
|
||||||
"text2textchat": {
|
"llminfo": {
|
||||||
"mqtttopic": "/loadbalancer/requestingservice",
|
"name": "llama3instruct"
|
||||||
"description": "text to text service with instruct LLM",
|
}
|
||||||
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using GeneralUtils
|
|
||||||
|
|
||||||
response = "trajectory_evaluation:\nThe trajectory is correct so far. The thought accurately reflects the user's question, and the action taken is a valid attempt to retrieve data from the database that matches the specified criteria.\n\nanswer_evaluation:\nThe observation provides information about two red wines from Bordeaux rive droite in France, which partially answers the question. However, it does not provide a complete answer as it only lists the wine names and characteristics, but does not explicitly state whether there are any other wines that match the criteria.\n\naccepted_as_answer: No\n\nscore: 6\nThe trajectory is mostly correct, but the observation does not fully address the question.\n\nsuggestion: Consider adding more filters or parameters to the database query to retrieve a complete list of wines that match the specified criteria."
|
|
||||||
|
|
||||||
responsedict = GeneralUtils.textToDict(response,
|
|
||||||
["trajectory_evaluation", "answer_evaluation", "accepted_as_answer", "score", "suggestion"],
|
|
||||||
rightmarker=":", symbolkey=true)
|
|
||||||
|
|
||||||
|
|
||||||
0
test/runtests.jl
Normal file
0
test/runtests.jl
Normal file
@@ -1,274 +1,294 @@
|
|||||||
using Revise
|
using Revise
|
||||||
using JSON, JSON3, Dates, UUIDs, PrettyPrinting, LibPQ, Base64, DataFrames
|
using JSON, JSON3, Dates, UUIDs, PrettyPrinting, LibPQ, Base64, DataFrames
|
||||||
using YiemAgent, GeneralUtils
|
using YiemAgent, GeneralUtils
|
||||||
using Base.Threads
|
using Base.Threads
|
||||||
|
|
||||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
# ---------------------------------------------- 100 --------------------------------------------- #
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# load config
|
# load config
|
||||||
config = JSON3.read("./test/config.json")
|
config = JSON3.read("/appfolder/app/dev/YiemAgent/test/config.json")
|
||||||
# config = copy(JSON3.read("../mountvolume/config.json"))
|
# config = copy(JSON3.read("../mountvolume/config.json"))
|
||||||
|
|
||||||
|
|
||||||
function executeSQL(sql::T) where {T<:AbstractString}
|
function executeSQL(sql::T) where {T<:AbstractString}
|
||||||
DBconnection = LibPQ.Connection("host=192.168.88.12 port=10201 dbname=wineDB user=yiemtechnologies password=yiemtechnologies@Postgres_0.0")
|
host = config[:externalservice][:wineDB][:host]
|
||||||
result = LibPQ.execute(DBconnection, sql)
|
port = config[:externalservice][:wineDB][:port]
|
||||||
close(DBconnection)
|
dbname = config[:externalservice][:wineDB][:dbname]
|
||||||
return result
|
user = config[:externalservice][:wineDB][:user]
|
||||||
end
|
password = config[:externalservice][:wineDB][:password]
|
||||||
|
DBconnection = LibPQ.Connection("host=$host port=$port dbname=$dbname user=$user password=$password")
|
||||||
function executeSQLVectorDB(sql)
|
result = LibPQ.execute(DBconnection, sql)
|
||||||
DBconnection = LibPQ.Connection("host=192.168.88.12 port=10203 dbname=SQLVectorDB user=yiemtechnologies password=yiemtechnologies@Postgres_0.0")
|
close(DBconnection)
|
||||||
result = LibPQ.execute(DBconnection, sql)
|
return result
|
||||||
close(DBconnection)
|
end
|
||||||
return result
|
|
||||||
end
|
function executeSQLVectorDB(sql)
|
||||||
|
host = config[:externalservice][:SQLVectorDB][:host]
|
||||||
|
port = config[:externalservice][:SQLVectorDB][:port]
|
||||||
function text2textInstructLLM(prompt::String)
|
dbname = config[:externalservice][:SQLVectorDB][:dbname]
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
user = config[:externalservice][:SQLVectorDB][:user]
|
||||||
config[:externalservice][:text2textinstruct][:mqtttopic];
|
password = config[:externalservice][:SQLVectorDB][:password]
|
||||||
msgPurpose="inference",
|
DBconnection = LibPQ.Connection("host=$host port=$port dbname=$dbname user=$user password=$password")
|
||||||
senderName="yiemagent",
|
result = LibPQ.execute(DBconnection, sql)
|
||||||
senderId=string(uuid4()),
|
close(DBconnection)
|
||||||
receiverName="text2textinstruct",
|
return result
|
||||||
mqttBrokerAddress=config[:mqttServerInfo][:broker],
|
end
|
||||||
mqttBrokerPort=config[:mqttServerInfo][:port],
|
|
||||||
)
|
function text2textInstructLLM(prompt::String; maxattempt::Integer=3, modelsize::String="medium",
|
||||||
|
llmkwargs=Dict(
|
||||||
outgoingMsg = Dict(
|
:num_ctx => 32768,
|
||||||
:msgMeta => msgMeta,
|
:temperature => 0.1,
|
||||||
:payload => Dict(
|
)
|
||||||
:text => prompt,
|
)
|
||||||
:kwargs => Dict(
|
msgMeta = GeneralUtils.generate_msgMeta(
|
||||||
:num_ctx => 16384,
|
config[:externalservice][:loadbalancer][:mqtttopic];
|
||||||
:temperature => 0.2,
|
msgPurpose="inference",
|
||||||
)
|
senderName="yiemagent",
|
||||||
)
|
senderId=sessionId,
|
||||||
)
|
receiverName="text2textinstruct_$modelsize",
|
||||||
|
mqttBrokerAddress=config[:mqttServerInfo][:broker],
|
||||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=6000)
|
mqttBrokerPort=config[:mqttServerInfo][:port],
|
||||||
response = _response[:response][:text]
|
)
|
||||||
|
|
||||||
return response
|
outgoingMsg = Dict(
|
||||||
end
|
:msgMeta => msgMeta,
|
||||||
|
:payload => Dict(
|
||||||
|
:text => prompt,
|
||||||
# get text embedding from a LLM service
|
:kwargs => llmkwargs
|
||||||
function getEmbedding(text::T) where {T<:AbstractString}
|
)
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
)
|
||||||
config[:externalservice][:text2textinstruct][:mqtttopic];
|
|
||||||
msgPurpose="embedding",
|
response = nothing
|
||||||
senderName="yiemagent",
|
for attempts in 1:maxattempt
|
||||||
senderId=string(uuid4()),
|
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=180, maxattempt=maxattempt)
|
||||||
receiverName="text2textinstruct",
|
payload = _response[:response]
|
||||||
mqttBrokerAddress=config[:mqttServerInfo][:broker],
|
if _response[:success] && payload[:text] !== nothing
|
||||||
mqttBrokerPort=config[:mqttServerInfo][:port],
|
response = _response[:response][:text]
|
||||||
)
|
break
|
||||||
|
else
|
||||||
outgoingMsg = Dict(
|
println("\n<text2textInstructLLM()> attempt $attempts/$maxattempt failed ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
:msgMeta => msgMeta,
|
pprintln(outgoingMsg)
|
||||||
:payload => Dict(
|
println("</text2textInstructLLM()> attempt $attempts/$maxattempt failed ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
||||||
:text => [text] # must be a vector of string
|
sleep(3)
|
||||||
)
|
end
|
||||||
)
|
end
|
||||||
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
|
||||||
embedding = response[:response][:embeddings]
|
return response
|
||||||
return embedding
|
end
|
||||||
end
|
|
||||||
|
# get text embedding from a LLM service
|
||||||
function findSimilarTextFromVectorDB(text::T1, tablename::T2, embeddingColumnName::T3,
|
function getEmbedding(text::T) where {T<:AbstractString}
|
||||||
vectorDB::Function; limit::Integer=1
|
msgMeta = GeneralUtils.generate_msgMeta(
|
||||||
)::DataFrame where {T1<:AbstractString, T2<:AbstractString, T3<:AbstractString}
|
config[:externalservice][:loadbalancer][:mqtttopic];
|
||||||
|
msgPurpose="embedding",
|
||||||
# get embedding from LLM service
|
senderName="yiemagent",
|
||||||
embedding = getEmbedding(text)[1]
|
senderId=sessionId,
|
||||||
|
receiverName="textembedding",
|
||||||
# check whether there is close enough vector already store in vectorDB. if no, add, else skip
|
mqttBrokerAddress=config[:mqttServerInfo][:broker],
|
||||||
sql = """
|
mqttBrokerPort=config[:mqttServerInfo][:port],
|
||||||
SELECT *, $embeddingColumnName <-> '$embedding' as distance
|
)
|
||||||
FROM $tablename
|
|
||||||
ORDER BY distance LIMIT $limit;
|
outgoingMsg = Dict(
|
||||||
"""
|
:msgMeta => msgMeta,
|
||||||
response = vectorDB(sql)
|
:payload => Dict(
|
||||||
df = DataFrame(response)
|
:text => [text] # must be a vector of string
|
||||||
return df
|
)
|
||||||
end
|
)
|
||||||
|
|
||||||
|
response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120, maxattempt=3)
|
||||||
function similarSQLVectorDB(query; maxdistance::Integer=100)
|
embedding = response[:response][:embeddings]
|
||||||
tablename = "sqlllm_decision_repository"
|
return embedding
|
||||||
# get embedding of the query
|
end
|
||||||
df = findSimilarTextFromVectorDB(query, tablename,
|
|
||||||
"function_input_embedding", executeSQLVectorDB)
|
function findSimilarTextFromVectorDB(text::T1, tablename::T2, embeddingColumnName::T3,
|
||||||
row, col = size(df)
|
vectorDB::Function; limit::Integer=1
|
||||||
distance = row == 0 ? Inf : df[1, :distance]
|
)::DataFrame where {T1<:AbstractString, T2<:AbstractString, T3<:AbstractString}
|
||||||
if row != 0 && distance < maxdistance
|
# get embedding from LLM service
|
||||||
# if there is usable SQL, return it.
|
embedding = getEmbedding(text)[1]
|
||||||
output_b64 = df[1, :function_output_base64] # pick the closest match
|
# check whether there is close enough vector already store in vectorDB. if no, add, else skip
|
||||||
output_str = String(base64decode(output_b64))
|
sql = """
|
||||||
rowid = df[1, :id]
|
SELECT *, $embeddingColumnName <-> '$embedding' as distance
|
||||||
println("\n~~~ found similar sql. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__)
|
FROM $tablename
|
||||||
return (dict=output_str, distance=distance)
|
ORDER BY distance LIMIT $limit;
|
||||||
else
|
"""
|
||||||
println("\n~~~ similar sql not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__)
|
response = vectorDB(sql)
|
||||||
return (dict=nothing, distance=nothing)
|
df = DataFrame(response)
|
||||||
end
|
return df
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function similarSQLVectorDB(query; maxdistance::Integer=100)
|
||||||
function insertSQLVectorDB(query::T1, SQL::T2; maxdistance::Integer=1) where {T1<:AbstractString, T2<:AbstractString}
|
tablename = "sqlllm_decision_repository"
|
||||||
tablename = "sqlllm_decision_repository"
|
# get embedding of the query
|
||||||
# get embedding of the query
|
df = findSimilarTextFromVectorDB(query, tablename,
|
||||||
# query = state[:thoughtHistory][:question]
|
"function_input_embedding", executeSQLVectorDB)
|
||||||
df = findSimilarTextFromVectorDB(query, tablename,
|
# println(df[1, [:id, :function_output]])
|
||||||
"function_input_embedding", executeSQLVectorDB)
|
row, col = size(df)
|
||||||
row, col = size(df)
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
distance = row == 0 ? Inf : df[1, :distance]
|
# distance = 100 # CHANGE this is for testing only
|
||||||
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
|
if row != 0 && distance < maxdistance
|
||||||
query_embedding = getEmbedding(query)[1]
|
# if there is usable SQL, return it.
|
||||||
query = replace(query, "'" => "")
|
output_b64 = df[1, :function_output_base64] # pick the closest match
|
||||||
sql_base64 = base64encode(SQL)
|
output_str = String(base64decode(output_b64))
|
||||||
sql_ = replace(SQL, "'" => "")
|
rowid = df[1, :id]
|
||||||
|
println("\n~~~ found similar sql. row id $rowid, distance $distance ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
sql = """
|
return (dict=output_str, distance=distance)
|
||||||
INSERT INTO $tablename (function_input, function_output, function_output_base64, function_input_embedding) VALUES ('$query', '$sql_', '$sql_base64', '$query_embedding');
|
else
|
||||||
"""
|
println("\n~~~ similar sql not found, max distance $maxdistance ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
println("\n~~~ added new decision to vectorDB ", @__FILE__, " ", @__LINE__)
|
return (dict=nothing, distance=nothing)
|
||||||
println(sql)
|
end
|
||||||
_ = executeSQLVectorDB(sql)
|
end
|
||||||
end
|
|
||||||
end
|
function insertSQLVectorDB(query::T1, SQL::T2; maxdistance::Integer=3) where {T1<:AbstractString, T2<:AbstractString}
|
||||||
|
tablename = "sqlllm_decision_repository"
|
||||||
|
# get embedding of the query
|
||||||
function similarSommelierDecision(recentevents::T1; maxdistance::Integer=5
|
# query = state[:thoughtHistory][:question]
|
||||||
)::Union{AbstractDict, Nothing} where {T1<:AbstractString}
|
df = findSimilarTextFromVectorDB(query, tablename,
|
||||||
tablename = "sommelier_decision_repository"
|
"function_input_embedding", executeSQLVectorDB)
|
||||||
# find similar
|
row, col = size(df)
|
||||||
println("\n~~~ search vectorDB for this: $recentevents ", @__FILE__, " ", @__LINE__)
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
df = findSimilarTextFromVectorDB(recentevents, tablename,
|
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
|
||||||
"function_input_embedding", executeSQLVectorDB)
|
query_embedding = getEmbedding(query)[1]
|
||||||
row, col = size(df)
|
query = replace(query, "'" => "")
|
||||||
distance = row == 0 ? Inf : df[1, :distance]
|
sql_base64 = base64encode(SQL)
|
||||||
if row != 0 && distance < maxdistance
|
sql_ = replace(SQL, "'" => "")
|
||||||
# if there is usable decision, return it.
|
|
||||||
rowid = df[1, :id]
|
sql = """
|
||||||
println("\n~~~ found similar decision. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__)
|
INSERT INTO $tablename (function_input, function_output, function_output_base64, function_input_embedding) VALUES ('$query', '$sql_', '$sql_base64', '$query_embedding');
|
||||||
output_b64 = df[1, :function_output_base64] # pick the closest match
|
"""
|
||||||
_output_str = String(base64decode(output_b64))
|
# println("\n~~~ added new decision to vectorDB ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
output = copy(JSON3.read(_output_str))
|
# println(sql)
|
||||||
return output
|
_ = executeSQLVectorDB(sql)
|
||||||
else
|
end
|
||||||
println("\n~~~ similar decision not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__)
|
end
|
||||||
return nothing
|
|
||||||
end
|
|
||||||
end
|
function similarSommelierDecision(recentevents::T1; maxdistance::Integer=3
|
||||||
|
)::Union{AbstractDict, Nothing} where {T1<:AbstractString}
|
||||||
|
tablename = "sommelier_decision_repository"
|
||||||
function insertSommelierDecision(recentevents::T1, decision::T2; maxdistance::Integer=5
|
# find similar
|
||||||
) where {T1<:AbstractString, T2<:AbstractDict}
|
println("\n~~~ search vectorDB for this: $recentevents ", @__FILE__, " ", @__LINE__)
|
||||||
tablename = "sommelier_decision_repository"
|
df = findSimilarTextFromVectorDB(recentevents, tablename,
|
||||||
# find similar
|
"function_input_embedding", executeSQLVectorDB)
|
||||||
df = findSimilarTextFromVectorDB(recentevents, tablename,
|
row, col = size(df)
|
||||||
"function_input_embedding", executeSQLVectorDB)
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
row, col = size(df)
|
if row != 0 && distance < maxdistance
|
||||||
distance = row == 0 ? Inf : df[1, :distance]
|
# if there is usable decision, return it.
|
||||||
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
|
rowid = df[1, :id]
|
||||||
recentevents_embedding = a.func[:getEmbedding](recentevents)[1]
|
println("\n~~~ found similar decision. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__)
|
||||||
recentevents = replace(recentevents, "'" => "")
|
output_b64 = df[1, :function_output_base64] # pick the closest match
|
||||||
decision_json = JSON3.write(decision)
|
_output_str = String(base64decode(output_b64))
|
||||||
decision_base64 = base64encode(decision_json)
|
output = copy(JSON3.read(_output_str))
|
||||||
decision = replace(decision_json, "'" => "")
|
return output
|
||||||
|
else
|
||||||
sql = """
|
println("\n~~~ similar decision not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__)
|
||||||
INSERT INTO $tablename (function_input, function_output, function_output_base64, function_input_embedding) VALUES ('$recentevents', '$decision', '$decision_base64', '$recentevents_embedding');
|
return nothing
|
||||||
"""
|
end
|
||||||
println("\n~~~ added new decision to vectorDB ", @__FILE__, " ", @__LINE__)
|
end
|
||||||
println(sql)
|
|
||||||
_ = executeSQLVectorDB(sql)
|
|
||||||
else
|
function insertSommelierDecision(recentevents::T1, decision::T2; maxdistance::Integer=5
|
||||||
println("~~~ similar decision previously cached, distance $distance ", @__FILE__, " ", @__LINE__)
|
) where {T1<:AbstractString, T2<:AbstractDict}
|
||||||
end
|
tablename = "sommelier_decision_repository"
|
||||||
end
|
# find similar
|
||||||
|
df = findSimilarTextFromVectorDB(recentevents, tablename,
|
||||||
|
"function_input_embedding", executeSQLVectorDB)
|
||||||
sessionId = "12345"
|
row, col = size(df)
|
||||||
|
distance = row == 0 ? Inf : df[1, :distance]
|
||||||
externalFunction = (
|
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
|
||||||
getEmbedding=getEmbedding,
|
recentevents_embedding = getEmbedding(recentevents)[1]
|
||||||
text2textInstructLLM=text2textInstructLLM,
|
recentevents = replace(recentevents, "'" => "")
|
||||||
executeSQL=executeSQL,
|
decision_json = JSON3.write(decision)
|
||||||
similarSQLVectorDB=similarSQLVectorDB,
|
decision_base64 = base64encode(decision_json)
|
||||||
insertSQLVectorDB=insertSQLVectorDB,
|
decision = replace(decision_json, "'" => "")
|
||||||
similarSommelierDecision=similarSommelierDecision,
|
|
||||||
insertSommelierDecision=insertSommelierDecision,
|
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)
|
||||||
a = YiemAgent.sommelier(
|
_ = executeSQLVectorDB(sql)
|
||||||
externalFunction;
|
else
|
||||||
name="Ton",
|
println("~~~ similar decision previously cached, distance $distance ", @__FILE__, " ", @__LINE__)
|
||||||
id=sessionId, # agent instance id
|
end
|
||||||
retailername="Yiem",
|
end
|
||||||
)
|
|
||||||
|
|
||||||
while true
|
sessionId = "12345"
|
||||||
println("your respond: ")
|
|
||||||
user_answer = readline()
|
externalFunction = (
|
||||||
response = YiemAgent.conversation(a, Dict(:text=> user_answer))
|
getEmbedding=getEmbedding,
|
||||||
println("\n$response")
|
text2textInstructLLM=text2textInstructLLM,
|
||||||
end
|
executeSQL=executeSQL,
|
||||||
|
similarSQLVectorDB=similarSQLVectorDB,
|
||||||
|
insertSQLVectorDB=insertSQLVectorDB,
|
||||||
# response = YiemAgent.conversation(a, Dict(:text=> "I want to get a French red wine under 100."))
|
similarSommelierDecision=similarSommelierDecision,
|
||||||
|
insertSommelierDecision=insertSommelierDecision,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
a = YiemAgent.sommelier(
|
||||||
|
externalFunction;
|
||||||
|
name="Ton",
|
||||||
|
id=sessionId, # agent instance id
|
||||||
|
retailername="Yiem",
|
||||||
|
)
|
||||||
|
|
||||||
|
while true
|
||||||
|
print("\nyour respond: ")
|
||||||
|
user_answer = readline()
|
||||||
|
response = YiemAgent.conversation(a, Dict(:text=> user_answer))
|
||||||
|
println("\n$response")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# response = YiemAgent.conversation(a, Dict(:text=> "I want to get a French red wine under 100."))
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
hello I want to get a bottle of red wine for my boss. I have a budget around 50 dollars. Show me some options.
|
||||||
|
|
||||||
|
I have no idea about his wine taste but he likes spicy food.
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user