I’ve been working on a function for the Prompt Repository to return places of interest at a given location. I’ve made this primarily for my Wimpy Tour as I would like to find local attractions near each Wimpy I visit. My original post on the Wimpy Tour can be found here.
​
I’ve made a self contained function at the bottom of this post. Try it out and let me know what you think!
​
Note: The LLMFunction requires external service authentication, billing and internet connectivity.

Constructing the LLMFunction

To make my LLMFunction, I first need to construct the template.
In[]:=
template=TemplateObject[{"Please give a list of places that you can visit at ",​​TemplateSlot["Location",DefaultValue:>"Location"]," as a tourist. \n",​​TemplateExpression[If[TemplateSlot["Interests",DefaultValue->Null]===Null,"",​​"I am particularly interested in"]]," ",​​TemplateSlot["Interests",DefaultValue:>""],"\nThe information should be in the form\n{\n\t{\"name of place\", \"information about place\", \"address\"},\n\t{\"name of place\",\" information about place\", \"address\"},\n\t…\n}\n\n. Only include this form in your response. The address must have a specific address. Make sure all quotes are escaped \\\" other than the ones I specified above. "},CombinerFunction->StringJoin,InsertionFunction->TextString,​​MetaInformation->Association["DisplayInformation"->​​Association["Name"->"TouristInformation"]]];
This template can take 2 values, “Location” and “Interests”. I want the results in a certain form. If no interests are specified, the line which mentions interests is omitted.
In[]:=
template[<|"Location"->"Leeds","Interests"->"burgers"|>]
Out[]=
Please give a list of places that you can visit at Leeds as a tourist. I am particularly interested in burgersThe information should be in the form{ {"name of place", "information about place", "address"}, {"name of place"," information about place", "address"}, …}​. Only include this form in your response. The address must have a specific address. Make sure all quotes are escaped \" other than the ones I specified above.
I want to add an Interpreter that takes a string result, converts it into an Expression and then processes the data into a Dataset. I also use FindGeoLocation to attempt to find a GeoLocation from the address given from the LLM, which may not always work.
In[]:=
interpreter=With[{x=Interpreter["Expression"][#]},Dataset[<|"Name"->#[[1]],"Description"->#[[2]],"Address"->#[[3]],"GeoLocation"->FindGeoLocation[#[[3]]]|>&/@x]]&;
With the template and the interpreter I can construct my LLMFunction.
In[]:=
touristInformation=LLMFunction​​ template,​​ interpreter​​
Out[]=
LLMFunction
​
Name: TouristInformation
Parameters: "Interests","Location"

Now I can use the LLMFunction. It takes an Association of parameters at its input. (Click on the image to see the dataset in higher resolution)
In[]:=
leedsSites=touristInformation[<|"Location"->"Leeds","Interests"->"Burgers"|>]

Linking with WimpyCodingTools

I built this for my Wimpy Tour and I can hook this into my WimpyCodingTools paclet on GitHub. To get the paclet you can run this ResourceFunction.
In[]:=
ResourceFunction["GitHubInstall"]["Zupnik","WimpyCodingTools"]​​
Out[]=
PacletObject
Name: WimpyCodingTools
Version: 0.0.3

In[]:=
Needs["WimpyCodingTools`"]
Using the $WimpyData symbol, I can get a full set of data on all the Wimpys in the country. I just want to look at Wimpy Harlow.
In[]:=
wimpy=Dataset[First[Select[$WimpyData,#Name==="Harlow"&]]]
Out[]=
Id
312
Name
Harlow
OpeningTimes

…
7

GeoPosition
51.77°N 0.09033°E
Address
Street2 Harvey Centre Approach,CityHarlow,CountyEssex,PostcodeCM20 1HF
Now I want to get the local attractions at in Harlow. (Click on the image to see the dataset in higher resolution)
In[]:=
harlowSites=touristInformation[<|"Location"->"Harlow"|>]
This contains an entry with a missing GeoLocation and I can remove this with a Select statement. I’ve also numbered my locations for my legend. (Click on the image to see the dataset in higher resolution)
In[]:=
cleanHarlowSites=MapIndexed[Prepend[#,"Number"->#2[[1]]]&,Select[harlowSites,!MissingQ[#GeoLocation]&]]
Before I start mapping, I want a nice icon for my restaurant.
In[]:=
burgerIcon=ImageSynthesize["good, basic drawing with color of a tiny hamburger"]
Out[]=
I’ve also made a custom marker function which can take a number.
makeMarker[name_]:=Graphics[{RGBColor[0.790588,0.201176,0.],Polygon[{{-0.4,1.25},{0,0},{0.4,1.25}}],Rectangle[{-1,1.25},{1,3.25},RoundingRadius->0.6],Inset[Style[name,White,FontSize->Scaled[0.5]],{0,2.3}]},PlotRangePadding->None]
In[]:=
makeMarker[1]
Out[]=
With all of this, I can now make a map with Wimpy Harlow and all local attractions. (Click on the image to see the dataset in higher resolution)
In[]:=
Column​​ GeoGraphics​​ (*Wimpy*)​​ Tooltip[GeoMarker[wimpy["GeoPosition"],RemoveBackground[burgerIcon]],"Wimpy "<>wimpy["Name"]],​​ (*Touristattractions*)​​ Tooltip[GeoMarker[#GeoLocation,makeMarker[#Number]],#Name]&/@cleanHarlowSites​​ ,ImageSize->Large,cleanHarlowSites​​

Give it a go!

I’ve packaged this up into a into a single block of code for you to try yourself here. My makeTouristMap function takes a location and optional interests. (Click on the image to see the dataset in higher resolution)

CITE THIS NOTEBOOK

Tourist Information - Making use of LLMs to find local attractions​
by Anthony Zupnik​
Wolfram Community, STAFF PICKS, June 12, 2024
​https://community.wolfram.com/groups/-/m/t/3191918