update
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user