Sign inSign up

lolcatcodes/gemini-search

By lolcatcodes

•Updated 12 months ago

Gemini Search App - Flask-based Chatbot API

Image
API management
Machine learning & AI
Web servers
0

789

lolcatcodes/gemini-search repository overview

⁠Gemini Search App - Flask-based Chatbot API

The Gemini Search App is a simple Python Flask-based REST server that allows users to interact with the Gemini chatbot via API calls. It takes a user-defined prompt and returns a pre-parsed JSON response, providing the flexibility to specify a custom response format.

⁠Key Features:

  • Flask REST Server: Runs a lightweight REST API on a customizable port (default: 8080).
  • Gemini Chatbot Integration: Allows users to send prompts to the Gemini chatbot (gemini-1.5-flash) and get detailed, structured responses in a JSON format.
  • Customizable Response Format: Users can define their own JSON response format by specifying the desired structure.

⁠Running the Container:

To run the container, define the GEMINI_API_KEYS environment variable (multiple keys handled separated by comma) and run the following command:

docker run -d -e GEMINI_API_KEY=your_key_1,your_key_2,your_key_3 -p 8080:8080 lolcatcodes/gemini-search:latest

This will start the Flask server on the default port 8080. You can change the port by specifying the -p flag with the docker run command.

⁠Sample POST Request:

Endpoint:

http://localhost:8080/search⁠

⁠Sample usage example:

curl -X POST http://localhost:8080/search \
-H "Content-Type: application/json" \
-d "{
  \"prompt\": \"Please provide the following information about the phrase 'fresh'. 1. English explanation: A brief definition of the word; 2.Polish translation: The translation of the word in Polish; 3. Usage examples: A list of example sentences using the word;\",
  \"response_format\": {
    \"explanation\": \"\",
    \"translation\": \"\",
    \"usages\": []
  }
}"

Sample Request Body:

{
  "prompt": "Please provide the following information about the phrase 'fresh'. 1. English explanation: A brief definition of the word; 2. Polish translation: The translation of the word in Polish; 3. Usage examples: A list of example sentences using the word;",
  "response_format": {
    "explanation": "",
    "translation": "",
    "usages": []
  }
}

Sample Response:

{
    "explanation": "Recently made, produced, or obtained; also, pleasantly new or different",
    "translation": "świeży",
    "usages": [
        "This bread is incredibly fresh.",
        "She wore a fresh, summer dress.",
        "Let's start with a fresh perspective.",
        "The air smelled fresh after the rain.",
        "He had a fresh batch of cookies."
    ]
}

⁠Environment Variable:

  • GEMINI_API_KEYS: You must define the GEMINI_API_KEYS environment variable with your API key (or multiple keys separated by comma) to interact with the Gemini API.

⁠Notes:

  • Customize the JSON response format to suit your needs.
  • The server defaults to port 8080; however, you can map it to any other port of your choice.

⁠Easy Way to Obtain Your Gemini API Key:

⁠Step 1: Visit the Google AI Studio
  • You can find the landing page here⁠. Once there, click on the “Gemini API” tab or the “Learn more about the Gemini API” button.

  • Alternatively, you can visit the Gemini API landing page directly by clicking here⁠.

⁠Step 2: Click on “Get API Key in Google AI Studio”
  • Follow the instructions on the page to navigate to the API key section.
⁠Step 3: Create Your API Key
  • Click the “Create API Key” button to generate your key. Save this key securely, as it will be required for application usage.

Tag summary

Content type

Image

Digest

sha256:691bb6563…

Size

105.2 MB

Last updated

12 months ago

docker pull lolcatcodes/gemini-search