This commit is contained in:
2023-11-29 08:52:20 +00:00
parent 6a8e24f20f
commit e487f6aadc
3 changed files with 132 additions and 147 deletions

View File

@@ -30,6 +30,7 @@ function wikisearch(a::agentReflex, phrase::T) where {T<:AbstractString}
phrase = replace(phrase, "\n"=>"")
url = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&titles=$(replace(phrase, " " => "%20"))&exintro=1&explaintext=1"
@show url
response = HTTP.get(url)
json_data = JSON3.read(String(response.body))
page_id = first(keys(json_data["query"]["pages"]))
@@ -40,16 +41,18 @@ function wikisearch(a::agentReflex, phrase::T) where {T<:AbstractString}
result = nothing
try
result = json_data["query"]["pages"][page_id]["extract"]
wiki = result
@show wiki
catch
result = "No info available for your search query."
end
if result == ""
result = "No info available for your search query."
end
if result != "No info available for your search query." #TODO for use with wikisearch(). Not good for other tools
else
result = makeSummary(a, result)
end
return result
end