~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Update ai-reviewer.sh
LearningCircuit141013297ef0
diff --git a/github/scripts/ai-reviewer.sh b/github/scripts/ai-reviewer.shindex 789ccf823e..358c6577ef 100755--- a/github/scripts/ai-reviewer.sh+++ b/github/scripts/ai-reviewer.sh@@ -5,6 +5,7 @@set -e+# Get API key from environment variableAPI_KEY="${OPENROUTER_API_KEY}"@@ -58,7 +59,7 @@ if [ -n "$PR_NUMBER" ] && [ -n "$REPO_FULL_NAME" ] && [ -n "$GITHUB_TOKEN" ]; thif [ -n "$HEAD_SHA" ]; then# Fetch check runs for this commitCHECK_RUNS_STATUS=$(gh api "repos/$REPO_FULL_NAME/commits/$HEAD_SHA/check-runs" \- --jq '.check_runs[] | "- **\(.name)**: \(.status)\(if .conclusion then " (\(.conclusion))" else "" end)"' 2>/dev/null || echo "")+ --jq '.check_runs // [] | .[] | "- **\(.name)**: \(.status)\(if .conclusion then " (\(.conclusion))" else "" end)"' 2>/dev/null || echo "")fifi@@ -100,50 +101,61 @@ Code diff to analyze:"-# Create the request JSON by combining parts-jq -n \- --arg model "$AI_MODEL" \- --argjson temperature "$AI_TEMPERATURE" \- --argjson max_tokens "$AI_MAX_TOKENS" \- --arg system_content "You are a helpful code reviewer analyzing pull requests. Provide a comprehensive review covering security, performance, code quality, and best practices. Respond with a clear, human-readable comment in markdown format." \- --arg prompt_prefix "$PROMPT_PREFIX" \- --rawfile diff_content "$DIFF_FILE" \- '{- "model": $model,- "messages": [- {- "role": "system",- "content": $system_content- },- {- "role": "user",- "content": ($prompt_prefix + $diff_content)- }- ],- "temperature": $temperature,- "max_tokens": $max_tokens- }' > request.json+# Create a simple text prompt+# Read diff content+DIFF_CONTENT=$(cat "$DIFF_FILE")++# Simple text prompt+PROMPT="Please analyze this code diff and provide a comprehensive review.++Focus on security, performance, code quality, and best practices.++IMPORTANT: Respond with valid JSON only using this exact format:+{+ \"review\": \"Detailed review in markdown format\",+ \"fail_pass_workflow\": \"pass\",+ \"labels_added\": [\"bug\", \"feature\", \"enhancement\"]+}++Focus action items on critical fixes only, not trivial nitpicks.++Code to review:+$PROMPT_PREFIX++$DIFF_CONTENT"+# Clean up diff filerm -f "$DIFF_FILE"-# Make API call to OpenRouter+# Make API call to OpenRouter with simple JSON# Use generic or repo-specific refererREFERER_URL="https://github.com/${REPO_FULL_NAME:-unknown/repo}"RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \-H "Content-Type: application/json" \-H "Authorization: Bearer $API_KEY" \-H "HTTP-Referer: $REFERER_URL" \- -d @request.json)--# Clean up temporary file-rm -f request.json+ -d "{+ \"model\": \"$AI_MODEL\",+ \"messages\": [+ {+ \"role\": \"user\",+ \"content\": $(echo "$PROMPT" | jq -Rs .)+ }+ ],+ \"temperature\": $AI_TEMPERATURE,+ \"max_tokens\": $AI_MAX_TOKENS+ }")# Check if API call was successfulif [ -z "$RESPONSE" ]; then- echo "## 🤖 AI Code Review+ echo '{"review":"## 🤖 AI Code Review\n\n❌ **Error**: API call failed - no response received","fail_pass_workflow":"uncertain","labels_added":[]}'+ exit 1+fi-❌ **Error**: API call failed - no response received"+# Check if response is valid JSON+if ! echo "$RESPONSE" | jq . >/dev/null 2>&1; then+ echo '{"review":"## 🤖 AI Code Review\n\n❌ **Error**: Invalid JSON response from API","fail_pass_workflow":"uncertain","labels_added":[]}'exit 1fi@@ -155,23 +167,38 @@ if [ "$CONTENT" = "error" ]; thenERROR_MSG=$(echo "$RESPONSE" | jq -r '.error.message // "Invalid API response format"')ERROR_CODE=$(echo "$RESPONSE" | jq -r '.error.code // ""')- echo "## 🤖 AI Code Review--❌ **Error**: $ERROR_MSG"-+ # Return error as JSON+ ERROR_CONTENT="## 🤖 AI Code Review\n\n❌ **Error**: $ERROR_MSG"if [ -n "$ERROR_CODE" ]; then- echo "Error code: \`$ERROR_CODE\`"+ ERROR_CONTENT="$ERROR_CONTENT\n\nError code: \`$ERROR_CODE\`"fi+ ERROR_CONTENT="$ERROR_CONTENT\n\n---\n*Review by [FAIR](https://github.com/LearningCircuit/Friendly-AI-Reviewer) - needs human verification*"++ echo "{\"review\":\"$ERROR_CONTENT\",\"fail_pass_workflow\":\"uncertain\",\"labels_added\":[]}"# Log full response for debugging (will appear in GitHub Actions logs)echo "Full API response: $RESPONSE" >&2exit 1fi-# Output the review directly as a comment-echo "## 🤖 AI Code Review--$CONTENT+# Ensure CONTENT is not empty+if [ -z "$CONTENT" ]; then+ echo '{"review":"## 🤖 AI Code Review\n\n❌ **Error**: AI returned empty response","fail_pass_workflow":"uncertain","labels_added":[]}'+ exit 0+fi-----*This review was generated by AI and should be verified by a human reviewer.*"+# Validate that CONTENT is valid JSON+if ! echo "$CONTENT" | jq . >/dev/null 2>&1; then+ # If not JSON, wrap it in JSON structure+ JSON_CONTENT="{\"review\":\"## 🤖 AI Code Review\n\n$CONTENT\n\n---\n*Review by [FAIR](https://github.com/LearningCircuit/Friendly-AI-Reviewer) - needs human verification*\",\"fail_pass_workflow\":\"uncertain\",\"labels_added\":[]}"+ echo "$JSON_CONTENT"+else+ # If already JSON, validate it has the required structure+ if ! echo "$CONTENT" | jq -e '.review' >/dev/null 2>&1; then+ JSON_CONTENT="{\"review\":\"## 🤖 AI Code Review\n\n$CONTENT\n\n---\n*Review by [FAIR](https://github.com/LearningCircuit/Friendly-AI-Reviewer) - needs human verification*\",\"fail_pass_workflow\":\"uncertain\",\"labels_added\":[]}"+ echo "$JSON_CONTENT"+ else+ # If already valid JSON with required structure, return as-is+ echo "$CONTENT"+ fi+fi