Back to Repositories
TypeScript
assignment-ai-search
Free-text travel search built for CityCity: Gemini on Vertex AI reads a sentence for the city, dates and rooms, then hands off to the hotel search.
0 stars
0 forks
1 watchers
freeformsearchvertex-ai
Stack
TypeScriptReact 18ViteNode.js and ExpressVertex AI SDK (Gemini 1.0 Pro)Google Maps Geocoding APIZodreact-icons
Features
Free-text search
- One input for a sentence such as "Stockholm, Sverige from 18th to 28th of March for one person"
- Service selector with an example query for each service type
- Hotel search wired up end to end
Location suggestions
- City suggestions from the CityCity test API as you type
- Picking a suggestion fills in the search box
AI interpretation
- Express endpoint POST /api/interpret sends the sentence to Gemini 1.0 Pro on Vertex AI
- The prompt asks for the city, country code, check-in and check-out dates and number of rooms as JSON
- Each field is read from the reply on its own, so extra text around the JSON is ignored
- Vertex AI safety settings on hate speech, harassment, dangerous and sexually explicit content
Geocoding
- Google Maps Geocoding API turns the city into a latitude, longitude and two-letter country code
- A clear 404 message when no destination can be found
Results and redirect
- Shows the understood city, dates, coordinates and number of rooms
- Builds the CityCity hotel search URL and redirects after 15 seconds
Project
- Separate client and server packages, each with its own README
- Model, Google Cloud project and region set by environment variables
- Change log covering nine releases from April to May 2024
Quick Start
- 1
Clone the repository (needs Node.js and a Google Cloud project with Vertex AI enabled)
git clone https://github.com/tec-smith/assignment-ai-search.git - 2
Sign in to Google Cloud so the server can call Vertex AI
gcloud auth application-default login - 3
Install and build the server
cd assignment-ai-search/server && npm install && npm run build - 4
Start it with your project ID and Google Maps key (it listens on port 3001)
PROJECT_IDENTITY=your-project GOOGLES_MAPS_KEY=your-key npm start - 5
In another terminal, start the client
cd assignment-ai-search/client && npm install && npm run dev - 6
Open the address Vite prints and try "Stockholm, Sverige from 18th to 28th of March for one person"