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
4 changes: 2 additions & 2 deletions backend/app/agents/devrel/github/github_toolkit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import json
import re
import config
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Qualify config import through backend

Align with the package structure so the module loads reliably.

-import config
+from backend import config
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import config
from backend import config
πŸ€– Prompt for AI Agents
In backend/app/agents/devrel/github/github_toolkit.py around line 4, the
top-level plain "import config" should be qualified through the package path so
Python reliably resolves the module; replace the bare import with a
package-qualified import (e.g., "from backend import config" or "import
backend.config as config"), update any references to use the qualified name if
needed, and run the module/tests to confirm the import resolves under the
project package layout.

from typing import Dict, Any
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.messages import HumanMessage
Expand All @@ -14,7 +14,7 @@

logger = logging.getLogger(__name__)

DEFAULT_ORG = os.getenv("GITHUB_ORG")
DEFAULT_ORG = config.GITHUB_ORG


def normalize_org(org_from_user: str = None) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import os
from typing import Dict, Any, Optional, List, Union
import aiohttp
import asyncio
import config
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Use package-qualified config import

This module runs inside the backend package. With the new config defined under backend/config.py, import config raises ModuleNotFoundError. Import it via the package-qualified path (and mirror that change in the other modules touched in this PR that pull in config).

-import config
+from backend import config
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import config
from backend/app/agents/devrel/github/services/github_mcp_client.py
from backend import config
πŸ€– Prompt for AI Agents
In backend/app/agents/devrel/github/services/github_mcp_client.py around line 5,
the file does a top-level import "import config" which fails because config now
lives at backend/config.py; change the import to the package-qualified path
(e.g., from backend import config or import backend.config as config) and update
other modules modified in this PR that similarly use bare "import config" to use
the package-qualified import to avoid ModuleNotFoundError when running inside
the backend package.


logger = logging.getLogger(__name__)

Expand All @@ -13,7 +13,7 @@ def __init__(self, mcp_server_url: str = "http://localhost:8001"):
self.mcp_server_url = mcp_server_url
self.session: Optional[aiohttp.ClientSession] = None
# Default org pulled from environment
self.org = os.getenv("GITHUB_ORG", "Aossie-org")
self.org = config.GITHUB_ORG

async def __aenter__(self):
# Async context manager entry
Expand Down
11 changes: 3 additions & 8 deletions backend/app/agents/devrel/github/services/github_mcp_server.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import os
import logging
import asyncio
from dotenv import load_dotenv, find_dotenv
import config
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from .github_mcp_service import GitHubMCPService
from typing import Optional

dotenv_path = find_dotenv(usecwd=True)
if dotenv_path:
load_dotenv(dotenv_path=dotenv_path)
else:
load_dotenv()

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = FastAPI(title="GitHub MCP Server", version="1.0.0")

# Load env vars
GITHUB_ORG = os.getenv("GITHUB_ORG")
GITHUB_ORG = config.GITHUB_ORG
if not GITHUB_ORG:
logger.warning("GITHUB_ORG not set in .env β€” defaulting to manual owner input")

github_service: Optional[GitHubMCPService] = None
try:
token = os.getenv("GITHUB_TOKEN") or os.getenv("GH_TOKEN")
token = config.GITHUB_TOKEN
if not token:
logger.warning("GITHUB_TOKEN/GH_TOKEN not set; GitHub API calls may be rate-limited or fail.")
github_service = GitHubMCPService(token=token)
Expand Down
12 changes: 3 additions & 9 deletions backend/app/agents/devrel/github/services/github_mcp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
import requests
import asyncio
from typing import Optional
from dotenv import load_dotenv, find_dotenv

dotenv_path = find_dotenv(usecwd=True)
if dotenv_path:
load_dotenv(dotenv_path=dotenv_path)
else:
load_dotenv()
import config
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Import config from the backend package

Same module-resolution issue hereβ€”import via backend to keep the module loadable.

-import config
+from backend import config
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import config
from backend import config
πŸ€– Prompt for AI Agents
In backend/app/agents/devrel/github/services/github_mcp_service.py around line
5, the file currently does "import config" which fails module resolution; change
the import to use the package path (e.g., "from backend import config" or
"import backend.config as config" consistent with the project's import style)
and update any references accordingly so the module is imported via the backend
package namespace.


class GitHubMCPService:
def __init__(self, token: str = None):
self.token = token or os.getenv("GITHUB_TOKEN")
self.token = token or config.GITHUB_TOKEN
if not self.token:
raise ValueError("GitHub token required; export as GITHUB_TOKEN or place in backend/.env file")
self.base_url = "https://api.github.com"
Expand Down Expand Up @@ -110,7 +104,7 @@ def _headers(self):


def _get_service(token: Optional[str] = None) -> GitHubMCPService:
return GitHubMCPService(token=token or os.getenv("GITHUB_TOKEN"))
return GitHubMCPService(token=token or config.GITHUB_TOKEN)

async def get_org_repositories(org: str):
try:
Expand Down
4 changes: 2 additions & 2 deletions backend/app/agents/devrel/github/tools/github_support.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
import config
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Import config via the backend package

For the same reason noted in the MCP client, this should pull config through backend to avoid ModuleNotFoundError.

-import config
+from backend import config
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import config
from backend import config
πŸ€– Prompt for AI Agents
In backend/app/agents/devrel/github/tools/github_support.py at line 1, the
module currently does a top-level "import config" which can cause
ModuleNotFoundError; change the import to load config through the package
namespace (e.g., "from backend import config" or "import backend.config as
config") and update any usages to reference that imported name so the package
import resolution works correctly.

import re
import logging
from typing import Optional
from app.agents.devrel.github.services import github_mcp_service

logger = logging.getLogger(__name__)

DEFAULT_ORG = os.getenv("GITHUB_ORG", "Aossie-org")
DEFAULT_ORG = config.GITHUB_ORG

GH_URL_RE = re.compile(
r'(?:https?://|git@)github\.com[/:]'
Expand Down
5 changes: 3 additions & 2 deletions backend/app/agents/state.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Dict, Any, List, Optional, Annotated
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime
from operator import add

Expand Down Expand Up @@ -69,5 +69,6 @@ class AgentState(BaseModel):
# Response
final_response: Optional[str] = None

class Config:
model_config = ConfigDict(
arbitrary_types_allowed = True
)
9 changes: 5 additions & 4 deletions backend/app/core/config/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic_settings import BaseSettings
from dotenv import load_dotenv
from pydantic import field_validator
from pydantic import field_validator,ConfigDict
from typing import Optional

load_dotenv()
Expand Down Expand Up @@ -46,9 +46,10 @@ def _not_empty(cls, v, field):
raise ValueError(f"{field.name} must be set")
return v

class Config:
env_file = ".env"
extra = "ignore" # to prevent errors from extra env variables
model_config = ConfigDict(
env_file = ".env",
extra = "ignore"
) # to prevent errors from extra env variables


settings = Settings()
127 changes: 63 additions & 64 deletions backend/app/models/database/weaviate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, ConfigDict
from typing import List, Optional
from datetime import datetime

Expand Down Expand Up @@ -63,67 +63,66 @@ class WeaviateUserProfile(BaseModel):
last_updated: datetime = Field(default_factory=datetime.now,
description="The date and time the profile was last updated.")

class Config:
"""
Pydantic model configuration.
"""
orm_mode = True
schema_extra = {
"example": {
"user_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"github_username": "jane-dev",
"display_name": "Jane Developer",
"bio": "Creator of innovative open-source tools. Full-stack developer with a passion for Rust and WebAssembly.",
"location": "Berlin, Germany",
"repositories": [
{
"name": "rust-web-framework",
"description": "A high-performance web framework for Rust.",
"languages": ["Rust", "TOML"],
"topics": ["rust", "webdev", "performance", "framework"],
"stars": 2500,
"forks": 400
},
{
"name": "data-viz-lib",
"description": "A declarative data visualization library for JavaScript.",
"languages": ["JavaScript", "TypeScript"],
"topics": ["data-visualization", "d3", "charts"],
"stars": 1200,
"forks": 150
}
],
"pull_requests": [
{
"title": "Add async support for database connections",
"body": "This PR adds comprehensive async support for database connections, improving performance by 40%...",
"state": "closed",
"repository": "microsoft/vscode",
"created_at": "2024-01-15T10:30:00Z",
"closed_at": "2024-01-20T14:20:00Z",
"merged_at": "2024-01-20T14:20:00Z",
"labels": ["enhancement", "database", "performance"],
"url": "https://github.com/microsoft/vscode/pull/12345",
},
{
"title": "Fix memory leak in WebAssembly module",
"body": "Fixes a critical memory leak that was causing crashes in production environments...",
"state": "open",
"repository": "facebook/react",
"created_at": "2024-02-01T09:15:00Z",
"closed_at": None,
"merged_at": None,
"labels": ["bug", "wasm", "critical"],
"url": "https://github.com/facebook/react/pull/67890",
}
],
"languages": ["Rust", "JavaScript", "TypeScript", "TOML"],
"topics": ["rust", "webdev", "performance", "framework", "data-visualization", "d3", "charts"],
"followers_count": 1800,
"following_count": 250,
"total_stars_received": 3700,
"total_forks": 550,
"profile_text_for_embedding": "Jane Developer, Creator of innovative open-source tools. Full-stack developer with a passion for Rust and WebAssembly. Repositories: rust-web-framework, A high-performance web framework for Rust. data-viz-lib, A declarative data visualization library for JavaScript. Languages: Rust, JavaScript, TypeScript. Topics: rust, webdev, performance, data-visualization.",
"last_updated": "2025-06-23T12:21:00Z"
}
model_config = ConfigDict(
from_attributes = True,
json_schema_extra = {
"example": {
"user_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"github_username": "jane-dev",
"display_name": "Jane Developer",
"bio": "Creator of innovative open-source tools. Full-stack developer with a passion for Rust and WebAssembly.",
"location": "Berlin, Germany",
"repositories": [
{
"name": "rust-web-framework",
"description": "A high-performance web framework for Rust.",
"languages": ["Rust", "TOML"],
"topics": ["rust", "webdev", "performance", "framework"],
"stars": 2500,
"forks": 400
},
{
"name": "data-viz-lib",
"description": "A declarative data visualization library for JavaScript.",
"languages": ["JavaScript", "TypeScript"],
"topics": ["data-visualization", "d3", "charts"],
"stars": 1200,
"forks": 150
}
],
"pull_requests": [
{
"title": "Add async support for database connections",
"body": "This PR adds comprehensive async support for database connections, improving performance by 40%...",
"state": "closed",
"repository": "microsoft/vscode",
"created_at": "2024-01-15T10:30:00Z",
"closed_at": "2024-01-20T14:20:00Z",
"merged_at": "2024-01-20T14:20:00Z",
"labels": ["enhancement", "database", "performance"],
"url": "https://github.com/microsoft/vscode/pull/12345",
},
{
"title": "Fix memory leak in WebAssembly module",
"body": "Fixes a critical memory leak that was causing crashes in production environments...",
"state": "open",
"repository": "facebook/react",
"created_at": "2024-02-01T09:15:00Z",
"closed_at": None,
"merged_at": None,
"labels": ["bug", "wasm", "critical"],
"url": "https://github.com/facebook/react/pull/67890",
}
],
"languages": ["Rust", "JavaScript", "TypeScript", "TOML"],
"topics": ["rust", "webdev", "performance", "framework", "data-visualization", "d3", "charts"],
"followers_count": 1800,
"following_count": 250,
"total_stars_received": 3700,
"total_forks": 550,
"profile_text_for_embedding": "Jane Developer, Creator of innovative open-source tools. Full-stack developer with a passion for Rust and WebAssembly. Repositories: rust-web-framework, A high-performance web framework for Rust. data-viz-lib, A declarative data visualization library for JavaScript. Languages: Rust, JavaScript, TypeScript. Topics: rust, webdev, performance, data-visualization.",
"last_updated": "2025-06-23T12:21:00Z"
}
}

)
11 changes: 5 additions & 6 deletions backend/app/services/embedding_service/service.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import logging
import os
import config
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Fix config import path

config lives under backend/config.py, so this needs the package-qualified form.

-import config
+from backend import config
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import config
-from backend/app/services/embedding_service/service.py
from backend/app/services/embedding_service/service.py
from backend import config
πŸ€– Prompt for AI Agents
In backend/app/services/embedding_service/service.py around line 2, the bare
import "import config" should be changed to a package-qualified import that
points to backend/config.py; replace it with an absolute import such as "from
backend import config" (or "import backend.config as config") so the module
resolves correctly when running from the project root.

from typing import List, Dict, Any, Optional
import torch
from pydantic import BaseModel
from dotenv import load_dotenv
from sentence_transformers import SentenceTransformer
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.messages import HumanMessage
from app.core.config import settings
from app.models.database.weaviate import WeaviateUserProfile
from app.services.embedding_service.profile_summarization.prompts.summarization_prompt import PROFILE_SUMMARIZATION_PROMPT

load_dotenv()

MODEL_NAME = os.getenv("EMBEDDING_MODEL", "BAAI/bge-small-en-v1.5")
MAX_BATCH_SIZE = int(os.getenv("EMBEDDING_MAX_BATCH_SIZE", "32"))
EMBEDDING_DEVICE = os.getenv("EMBEDDING_DEVICE", "cpu")
MODEL_NAME = config.MODEL_NAME
MAX_BATCH_SIZE = config.MAX_BATCH_SIZE
EMBEDDING_DEVICE = config.EMBEDDING_DEVICE


logger = logging.getLogger(__name__)

Expand Down
16 changes: 16 additions & 0 deletions backend/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dotenv import load_dotenv, find_dotenv
import os


dotenv_path = find_dotenv(usecwd=True)
if dotenv_path:
load_dotenv(dotenv_path=dotenv_path)
else:
load_dotenv()

GITHUB_ORG = os.getenv("GITHUB_ORG", "Aossie-org")
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") or os.getenv("GH_TOKEN")

MODEL_NAME = os.getenv("EMBEDDING_MODEL", "BAAI/bge-small-en-v1.5")
MAX_BATCH_SIZE = int(os.getenv("EMBEDDING_MAX_BATCH_SIZE", "32"))
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add error handling for integer conversion.

int() will raise ValueError if EMBEDDING_MAX_BATCH_SIZE is set to a non-numeric value (e.g., "large", "auto"). This could crash the application on startup with an unclear error message.

Apply this diff to add validation:

-MAX_BATCH_SIZE = int(os.getenv("EMBEDDING_MAX_BATCH_SIZE", "32"))
+try:
+    MAX_BATCH_SIZE = int(os.getenv("EMBEDDING_MAX_BATCH_SIZE", "32"))
+except ValueError:
+    raise ValueError(
+        "EMBEDDING_MAX_BATCH_SIZE must be a valid integer. "
+        f"Got: {os.getenv('EMBEDDING_MAX_BATCH_SIZE')}"
+    )
πŸ€– Prompt for AI Agents
In backend/config.py around line 15, the direct int(os.getenv(...)) conversion
can raise ValueError for non-numeric env values; change it to read the raw env
var, try to convert to int inside a try/except, validate that the parsed value
is a positive integer (>=1), and on failure either fall back to the default 32
and emit a clear warning log message that shows the invalid input, or raise a
new ValueError with a descriptive message β€” ensure you use a defined logger or
the existing logging mechanism and keep the default behavior if the env is
unset.

EMBEDDING_DEVICE = os.getenv("EMBEDDING_DEVICE", "cpu")