Skip to content

Instantly share code, notes, and snippets.

@eastlondoner
Created February 12, 2025 16:37
Show Gist options
  • Save eastlondoner/e99c3f29c4b6872dd4089daf17fe32fb to your computer and use it in GitHub Desktop.
Save eastlondoner/e99c3f29c4b6872dd4089daf17fe32fb to your computer and use it in GitHub Desktop.
reproduce gemini issue
#!/usr/bin/env bash
#
# Usage:
# gemini-docs.sh <path-to-repoContext-file>
#
# Description:
# Reads text from the specified file (e.g. ".repomix-output.txt") as your repository
# context, then calls the Gemini API to generate documentation.
#
# Requirements:
# - GEMINI_API_KEY must be set in your environment.
# - curl must be installed.
# Exit immediately if any command fails
set -e
if [ -z "$1" ]; then
echo "Usage: $0 <path-to-repoContext-file>"
exit 1
fi
if [ -z "$GEMINI_API_KEY" ]; then
echo "Error: GEMINI_API_KEY environment variable is not set."
exit 1
fi
# The file containing the repo context (text from .repomix-output.txt or similar).
REPO_CONTEXT_FILE="$1"
# Read entire file contents into a variable
REPO_CONTEXT="$(<"$REPO_CONTEXT_FILE")"
# You can adjust the Gemini model here if desired.
MODEL="gemini-2.0-pro-exp-02-05"
# This is the additional instruction from the original code snippet.
FOCUS_TEXT="Focus on:
1. Repository purpose and \"what is it\" summary
2. Quick start: How to install and use the basic core features of the project
4. Configuration options and how to configure the project for use (if applicable)
3. If a repository has multiple public packages perform all the steps for each package:
4. Package summary & usage instructions
5. Detailed documentation of every public feature / API / interface
6. Dependencies and requirements
7. Advanced usage examples
"
echo "Calling Gemini API to generate documentation..."
echo "Model: $MODEL"
echo ""
curl -s -X POST \
-H "Content-Type: application/json" \
"https://generativelanguage.googleapis.com/v1beta/models/${MODEL}:generateContent?key=${GEMINI_API_KEY}" \
-d "{
\"systemInstruction\": {
\"parts\": [
{
\"text\": \"You are a helpful assistant that generates public user-facing documentation for a given repository. Format the documentation in markdown. Keep explanations concise, direct, and easy to understand.\"
}
]
},
\"contents\": [
{
\"role\": \"user\",
\"parts\": [
{
\"text\": \"$REPO_CONTEXT\"
},
{
\"text\": \"$FOCUS_TEXT\"
}
]
}
],
\"generationConfig\": {
\"maxOutputTokens\": 2048
}
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment