Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@ def graphrag_setup_endpoint():
api_key = api_keys.get("geminiKey") or config_manager.get("ai_providers.google_genai.api_key", "")
graphrag_api_keys = {"geminiKey": api_key}
provider = "gemini" # Map to GraphRAG service provider name
elif provider == "gemini":
# Support direct "gemini" provider selection from frontend
api_key = api_keys.get("geminiKey") or config_manager.get("ai_providers.google_genai.api_key", "")
graphrag_api_keys = {"geminiKey": api_key}
Comment on lines +757 to +760
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is identical to the existing 'google_genai' condition above it (lines 754-756). Consider consolidating these conditions using 'elif provider in ["google_genai", "gemini"]:' to avoid code duplication.

Copilot uses AI. Check for mistakes.
elif provider == "anthropic":
api_key = api_keys.get("anthropicKey") or config_manager.get("ai_providers.anthropic.api_key", "")
graphrag_api_keys = {"anthropicKey": api_key}
Expand Down Expand Up @@ -881,6 +885,10 @@ def graphrag_change_provider_endpoint():
api_key = api_keys.get("geminiKey") or config_manager.get("ai_providers.google_genai.api_key", "")
graphrag_api_keys = {"geminiKey": api_key}
provider = "gemini" # Map to GraphRAG service provider name
elif provider == "gemini":
# Support direct "gemini" provider selection from frontend
api_key = api_keys.get("geminiKey") or config_manager.get("ai_providers.google_genai.api_key", "")
graphrag_api_keys = {"geminiKey": api_key}
Comment on lines +888 to +891
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is identical to the existing 'google_genai' condition above it (lines 885-887). Consider consolidating these conditions using 'elif provider in ["google_genai", "gemini"]:' to avoid code duplication.

Copilot uses AI. Check for mistakes.
elif provider == "anthropic":
api_key = api_keys.get("anthropicKey") or config_manager.get("ai_providers.anthropic.api_key", "")
graphrag_api_keys = {"anthropicKey": api_key}
Expand Down Expand Up @@ -1125,6 +1133,10 @@ def graphrag_endpoint():
api_key = api_keys.get("geminiKey") or config_manager.get("ai_providers.google_genai.api_key", "")
graphrag_api_keys = {"geminiKey": api_key}
provider = "gemini" # Map to GraphRAG service provider name
elif provider == "gemini":
# Support direct "gemini" provider selection from frontend
api_key = api_keys.get("geminiKey") or config_manager.get("ai_providers.google_genai.api_key", "")
graphrag_api_keys = {"geminiKey": api_key}
Comment on lines +1136 to +1139
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is identical to the existing 'google_genai' condition above it (lines 1133-1135). Consider consolidating these conditions using 'elif provider in ["google_genai", "gemini"]:' to avoid code duplication.

Copilot uses AI. Check for mistakes.
elif provider == "anthropic":
api_key = api_keys.get("anthropicKey") or config_manager.get("ai_providers.anthropic.api_key", "")
graphrag_api_keys = {"anthropicKey": api_key}
Expand Down
17 changes: 16 additions & 1 deletion src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Backend API configuration
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL;
// Use environment var if provided; otherwise default to same-origin
const ENV_API_BASE_URL = import.meta.env.VITE_API_BASE_URL as string | undefined;
export const API_BASE_URL = (ENV_API_BASE_URL && ENV_API_BASE_URL.trim() !== "")
? ENV_API_BASE_URL
: window.location.origin;


// API endpoints
Expand All @@ -12,4 +16,15 @@ export const API_ENDPOINTS = {
GENERATE_GRAPH_WITH_EDGES: `${API_BASE_URL}/api/generate-graph-with-edges`,
GET_UNIQUE_REPOS: `${API_BASE_URL}/api/get-unique-repos`,
CREATE_EDGES_ON_GRAPH: `${API_BASE_URL}/api/create-edges-on-graph`,
// GraphRAG endpoints
GRAPHRAG_HEALTH: `${API_BASE_URL}/api/graphrag-health`,
GRAPHRAG_SETUP: `${API_BASE_URL}/api/graphrag-setup`,
GRAPHRAG_PROGRESS: `${API_BASE_URL}/api/graphrag-progress`,
GRAPHRAG_RESET_PROGRESS: `${API_BASE_URL}/api/graphrag-reset-progress`,
GRAPHRAG_CHANGE_PROVIDER: `${API_BASE_URL}/api/graphrag-change-provider`,
GRAPHRAG_UPDATE_README: `${API_BASE_URL}/api/graphrag-update-readme`,
GRAPHRAG_FIX_SCHEMA: `${API_BASE_URL}/api/graphrag-fix-schema`,
GRAPHRAG_QUERY: `${API_BASE_URL}/api/graphrag`,
GRAPHRAG_CLEANUP: `${API_BASE_URL}/api/graphrag-cleanup`,
GRAPHRAG_CHECK_CHANGES: `${API_BASE_URL}/api/graphrag-check-changes`,
} as const;
9 changes: 5 additions & 4 deletions src/views/GraphRAGPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Tooltip } from 'bootstrap';

import { GraphContext } from "../lib/context";
import { useNotifications } from "../lib/notifications";
import { API_ENDPOINTS } from "../lib/config";
import { ANIMATION_DURATION } from "../lib/consts";
import { Coordinates } from "sigma/types";

Expand Down Expand Up @@ -108,7 +109,7 @@ const GraphRAGPanel: FC = () => {
try {
const sessionId = sessionStorage.getItem('graphrag_session_id') || '';
if (sessionId) {
const response = await fetch('/api/graphrag-cleanup', {
const response = await fetch(API_ENDPOINTS.GRAPHRAG_CLEANUP, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -264,7 +265,7 @@ const GraphRAGPanel: FC = () => {
const checkBackendHealth = async () => {
if (graphragState.isReady) {
try {
const response = await fetch('http://localhost:5002/api/graphrag-health', {
const response = await fetch(API_ENDPOINTS.GRAPHRAG_HEALTH, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -613,7 +614,7 @@ const GraphRAGPanel: FC = () => {
const sessionId = `graphrag_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
sessionStorage.setItem('graphrag_session_id', sessionId);

const response = await fetch('http://localhost:5002/api/graphrag-setup', {
const response = await fetch(API_ENDPOINTS.GRAPHRAG_SETUP, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -707,7 +708,7 @@ const GraphRAGPanel: FC = () => {
updateState({ messages: newMessages });

try {
const response = await fetch("/api/graphrag", {
const response = await fetch(API_ENDPOINTS.GRAPHRAG_QUERY, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down