Gesso Gemini Middleware
Installation
pnpm install
Configuration
- Create a
.envfile in the root of the project based on.env.example
Environment Variables for Gemini Middleware
Below are the key environment variables required for the Gemini middleware, along with their details:
GEMINI_API_KEY
- Description: The API key required to authenticate with the Gemini API.
- Required: Yes
GEMINI_MODEL
- Description: Specifies the model to use with the Gemini API.
- Default:
gemini-1.5-flash - Supported Models:
gemini-2.0-flashgemini-2.0-flash-lite-preview-02-05gemini-1.5-flashgemini-1.5-flash-8bgemini-1.5-protext-embedding-004
- Details: For more information on available models and their variations, see the Gemini API Models Documentation.
GEMINI_SAFETY_SETTINGS
-
Description: Configures safety settings for content moderation in the Gemini API.
-
Default: The following JSON configuration:
[
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
}
] -
Details: For more information on the safety settings, please refer to the Gemini API documentation.
GEMINI_SYSTEM_INSTRUCTION
-
Description: Overrides the default Gesso schema instructions with your own system instruction. By default, Gesso uses the following schema instructions:
schemaInstructions: getSchemaInstructions(options?.responseStructure);{
"role": "model",
"parts": [
{
"text": {schemaInstructions}
}
]
} -
This can be set in either a string or a JSON object
-
Details: For more information on the system instruction, please refer to the Gemini API documentation.
Usage
pnpm testto run the testspnpm lintto lint the code