Skip to content

Commit 29ec07c

Browse files
add reame.md
1 parent e23c263 commit 29ec07c

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Gemini Ai code execution and function calling app
2+
3+
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)]()
4+
[![Maintaner](https://img.shields.io/static/v1?label=Oleksandr%20Samoilenko&message=Maintainer&color=red)](mailto:[email protected])
5+
[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)]()
6+
![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)
7+
![GitHub release](https://img.shields.io/badge/release-v1.0.0-blue)
8+
9+
## PROJECT INFO
10+
11+
- **Node.js app designed to showcase Gemini code generation and function calling approaches**
12+
- **The app includes two parts:**
13+
**1. code execution which allows the AI to run computer code directly within its system to solve tasks, analyze data, or produce outputs programmatically.**
14+
**2. Function calling - allows the AI to interact with external functions or APIs (predefined blocks of code) to fetch information, perform actions, or connect with other systems. It has integration with third party ai services for searching hotels attractions ad flight tickets**
15+
16+
## Features
17+
18+
- Google generative ai gemini-1.5-flash
19+
- Gemini function calling
20+
- Gemini code execution
21+
- FlightApi.io - https://www.flightapi.io/
22+
- Mackorps.com - https://docs.makcorps.com/hotel-apis
23+
- Geoapify.com - https://www.geoapify.com/
24+
25+
## Preview
26+
27+
## Installing:
28+
29+
**1. Clone this repo to your folder:**
30+
31+
```
32+
git clone https://gitlab.extrawest.com/gemini-api-functions-calling
33+
```
34+
35+
**2. Change current directory to the cloned folder:**
36+
37+
```
38+
cd gemini-api-functions-calling
39+
```
40+
41+
## Setup Project
42+
43+
**1. First you need to sign up on several services to get access to api: https://www.flightapi.io/, https://docs.makcorps.com/hotel-apis, https://www.geoapify.com/**
44+
**2. In the root of the directory create .env file and add the following variables:**
45+
46+
```
47+
API_KEY = "YOUR_GEMINI_API_KEY"
48+
GEOAPIFY_API_KEY = 'YOUR_GEOAPIFY_API_KEY'
49+
FLIGHT_API_KEY = "YOUR_FLIGHT_API_KEY"
50+
HOTEL_API_KEY = "YOUR_HOTEL_API_KEY"
51+
```
52+
53+
**4. Run code execution:**
54+
To start code execution, just run `npm code_execution.js`.
55+
56+
**5. Run code execution:**
57+
To start functions calling, just run `npm functions_calling.js`.
58+
59+
Now you can use the app
60+
61+
Created by Oleksandr Samoilenko
62+
63+
[Extrawest.com](https://www.extrawest.com), 2025

functions_calling.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { GoogleGenerativeAI } from '@google/generative-ai';
22
import axios from 'axios';
33
import dotenv from 'dotenv';
4-
import util from 'util';
54
dotenv.config();
65

6+
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
7+
78
async function setAttractionsValues(city) {
89
try {
910
const GEOAPIFY_API_KEY = process.env.GEOAPIFY_API_KEY;
@@ -351,8 +352,6 @@ const functions = {
351352
}
352353
};
353354

354-
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
355-
356355
const generativeModel = genAI.getGenerativeModel({
357356
model: 'gemini-1.5-flash',
358357
tools: {
@@ -402,4 +401,5 @@ processChat('what are the most popular attractions in Tokyo, Japan?');
402401
// For flights:
403402
// processChat('find flights from Berlin to Tokyo on January 18, 2025 for 1 passenger in Economy class');
404403

404+
// For hotels:
405405
// processChat('find hotels in New York from January 25 to January 26, 2025 for 2 adults in 1 room');

0 commit comments

Comments
 (0)