File size: 2,501 Bytes
e220aaf
 
 
 
 
870c2fe
75d19f5
5986369
 
dc88e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
license: mit
sdk: gradio
colorFrom: red
pinned: true
sdk_version: 5.20.0
colorTo: yellow
---


# Gemini Playground 💬

## Overview

Gemini Playground is an interactive Python application that leverages Google Generative AI and Gradio to provide a platform for experimenting with Gemini Pro and Gemini Pro Vision models. Users can engage in dynamic conversations with the chatbot, utilizing text and image prompts to generate creative and context-aware responses.

![img](https://github.com/arham-kk/gemini-demo/assets/108623726/d88a8c82-4fcc-45fd-aea3-4a6a88787200)

## Prerequisites

Before running the code, ensure you have the necessary dependencies installed. You can install them using the following command:

```bash
pip install -r requirements.txt
```

Make sure to obtain your own Google API key by visiting [GOOGLE API KEY](https://makersuite.google.com/app/apikey) and follow the instructions.

## Usage

1. Set up your Google API key by entering it in the `GOOGLE API KEY` textbox.
2. Optionally provide an image prompt to explore the capabilities of Gemini Pro Vision.
3. Input your text prompt in the `Ask me anything and press Enter` textbox.
4. Adjust various parameters such as temperature, token limit, stop sequences, top-K, and top-P to tailor the model's behavior.
5. Click the "Run" button to initiate the conversation.

## Features

- **Gemini Pro and Gemini Pro Vision**: Choose between text-only (Gemini Pro) or text and image prompts (Gemini Pro Vision).
- **Interactive Chat Interface**: Engage in dynamic conversations with the chatbot using Gradio's intuitive chat interface.
- **Flexible Parameter Adjustment**: Fine-tune model behavior with adjustable parameters like temperature, token limit, and more.

## Parameters

- **GOOGLE API KEY**: Your personal Google API key for accessing the Generative AI models.
- **Image**: Optional image prompt for Gemini Pro Vision.
- **Temperature**: Controls the randomness of the generated content. Higher values lead to more creative responses.
- **Token Limit**: Limit the length of the generated content in tokens.
- **Stop Sequences**: Specify stop sequences to control the generation process.
- **Top-K**: Control the diversity of the output by selecting from the top-K most likely tokens.
- **Top-P**: Control the diversity of the output by selecting tokens with cumulative probabilities up to the top-P threshold.

## Important Note

Ensure you a valid Google API key to use the Gemini Pro and Gemini Pro Vision models.