Notebooks
A
Azure
Function Calling Finding Nearby Places

Function Calling Finding Nearby Places

Functionsazure-openai-samplesBasic_Samplesdotnetcsharp

Function calling for nearby places: Leveraging the Bing Maps Local Search api

This notebook is centered around the integration of the Bing Maps Local Search api to enhance location-based searches. Please note that while we focus on the Bing Maps Local Search api in this instance, there are numerous other APIs you could explore and apply in a similar fashion.

We'll explore the application of three main components:

  • Bing Maps Local Search api: This API provides real-time data about nearby places. It factors in various data points such as ratings, types of venues, costs, and more from the locations around you.

  • Function calling: A single command such as "I'm hungry" or "I want to visit a museum" activates the function which invokes the Bing Maps Local Search api to identify suitable venues.

This notebook introduces two primary use cases:

  • API integration with function calling: Understand how to integrate and call Bing Maps Local Search api effectively to source real-time data of various places using function calling.

Please note that while this system is highly versatile, its effectiveness may vary based on user preferences and available place data. For the purposes of this notebook, the customer data is fake and the location is hardcoded. "

Setup

Bing Maps Local Search api

To use the Bing Maps Local Search api, you'll need:

  • Microsoft Account: If you don't already have one, you will need to create a Microsoft account.

  • Bing Maps Local Search api API Key: The API key is a unique identifier that is used to authenticate requests associated with your project. You can get your API key from the Bing Maps Dev Center.

Installation

Install the Azure Open AI SDK using the below command.

[1]
[ ]

Run this cell, it will prompt you for the apiKey, endPoint, gtpDeployment, and bingMap

[3]

Import namesapaces and create an instance of OpenAiClient using the azureOpenAIEndpoint and the azureOpenAIKey

[4]
[5]
[6]

This ustility functions helps translating a GptFunction to the ChatCompletionsFunctionToolDefinition type

[7]

Create a GptFunction

A GptFunction is an object that can be used to create a ChatCompletionOption and later execute the logic in the delegate passed in the constructor.

Let's create ones that will take as input a location and a placeType. They will be used to search a matching location using the Bing Map Local Search Api.

[8]

Create ProvideReccomendations

This function will use the GptFunction and ChatGPT to answer a user question by calling the function with parameters generated by the LLM.

[9]
[11]
{
,  "currentLocation": "Capitol Hill, Seattle",
,  "placeType": "BarsGrillsAndPubs"
,}

Now the full loop

[16]
[17]
Here are some local and affordable pubs in Capitol Hill, Seattle that you might like:

1. [Capitol Hill Comedy / Bar](https://comedyslashbar.com/): 210 Broadway E, Seattle, WA, 98125. Contact: (206) 390-9152

2. [Barrio Mexican Kitchen & Bar](https://www.barriorestaurant.com/): 1420 12th Ave, Seattle, WA, 98122. Contact: (206) 588-8105

3. [Mezcaleria Oaxaca Capitol Hill](https://mercadoluna.com/mezcaleria-oaxaca/): 422 E Pine St, Seattle, WA, 98122. Contact: (206) 324-0506

4. [Capitol Cider](https://www.capitolcider.com/): 818 E Pike St, Seattle, WA, 98122. Contact: (206) 397-3564

5. [GOLD BAR](https://goldbarseattle.com/Info): 1418 E OLIVE Way, Seattle, WA, 98122. Contact: (206) 402-3473

Please note that prices and availability may vary. Make sure to check their websites or contact them for more information. Enjoy your meal!