MCPcopy Create free account
hub / github.com/developersdigest/llm-answer-engine / searchPlaces

Function searchPlaces

app/function-calling.tsx:17–49  ·  view source on GitHub ↗
(query: string, location: string)

Source from the content-addressed store, hash-verified

15);
16
17export async function searchPlaces(query: string, location: string) {
18 try {
19 const response = await fetch('https://google.serper.dev/places', {
20 method: 'POST',
21 headers: {
22 'X-API-KEY': process.env.SERPER_API,
23 'Content-Type': 'application/json',
24 },
25 body: JSON.stringify({ q: query, location: location }),
26 });
27 const data = await response.json();
28 const normalizedData = {
29 type: 'places',
30 places: data.places.map(place => ({
31 position: place.position,
32 title: place.title,
33 address: place.address,
34 latitude: place.latitude,
35 longitude: place.longitude,
36 rating: place.rating,
37 ratingCount: place.ratingCount,
38 category: place.category,
39 phoneNumber: place.phoneNumber,
40 website: place.website,
41 cid: place.cid
42 }))
43 };
44 return JSON.stringify(normalizedData);
45 } catch (error) {
46 console.error('Error searching for places:', error);
47 return JSON.stringify({ error: 'Failed to search for places' });
48 }
49}
50export async function goShopping(message: string) {
51 const url = 'https://google.serper.dev/shopping';
52 const requestOptions: RequestInit = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected