Studio: Gemini Text Generation
Overview
The Gemini Text Generation project demonstrates how to use a button to generate text content from Gemini, a Large Language Model (LLM). The generated text is displayed in a designated AR text box.
Must add your own Gemini API Key in random-quote-api.ts for the project to work. Replace your key in the place where it says ADD_KEY_HERE
Controls
- Generate Text Button:
Clicking the button triggers the Gemini API to generate a random two-line poem, which is displayed in the text box.
Components
Random Quote API
Description:
This component handles the interaction with the Gemini API to generate and display text content in an AR environment.
Schema:
- Button: Entity ID for the button UI element that triggers text generation.
- TextBox: Entity ID for the UI element where the generated text is displayed.
Data:
- content: A string that stores the text content received from the Gemini API.
Functionality:
- API Request: Sends a request to the Gemini API with a prompt to generate a two-line poem.
- Response Handling: Processes the API response to extract the generated text.
- UI Update: Updates the text box with the generated content.
Project Setup
Main Entities:
- Button: Triggers the text generation process.
- TextBox: Displays the generated text content.
Organization:
- The component is registered using the ECS framework and binds a click event to the button.
Customization
Adding Your API Key:
Replace in the variable with your Gemini API key.Modifying the Prompt:
Update the in the function to specify a different prompt for the Gemini API. For example:
Other Work by GTXR Club