A simple, text-based REPL (Read-Evaluate-Print Loop) application that connects to the Gemini API using Java and Python.
- Demonstrate hybrid development using the strengths of Java and Python.
- Explore basic API interaction with the Gemini AI platform.
- Provide a foundation for building more sophisticated AI-powered text-based applications.
- Java Development Kit (JDK) – Installation instructions vary based on your OS.
- Python 3 – Download from https://www.python.org/downloads/
google-generativeai
Python library: Install usingpip install google-generativeai
- A Gemini API key: Obtain from https://ai.google.dev (sign-up may be required)
- Clone or download this repository.
- Set up your Gemini API key:
Create a file named
api_key.txt
in the project's root directory and place your API key inside. Ensure this file is not committed to version control. - Install the
google-generativeai
library in your Python environment:
pip install google-generativeai
- Navigate to the directory in your terminal.
- Compile the code using
javac Chatter.java
- Run the program using
java Chatter
Type in a prompt or a question and press Enter. The REPL will send your input to the Gemini API and display the response. Type 'goodbye' to exit the REPL.
- This project is intended for demonstration and learning purposes.
- For production applications, explore more robust API key management and error handling.
- Consider using tools like gRPC for potentially more efficient communication between Java and Python processes.
- Improve the user interface with a Java library like Swing or JavaFX.
- Add advanced error handling and input validation.
- Implement a command-line argument parser for customization options.
This project is not directly affiliated with or endorsed by Gemini AI or Google. Use the Gemini API in accordance with their terms of service.