-
Notifications
You must be signed in to change notification settings - Fork 132
Feat/64 database configuration #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chandansgowda
merged 6 commits into
AOSSIE-Org:main
from
Eli4479:feat/64-database-configuration
Jun 11, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d04c407
Add Weaviate schema creation and population scripts
Eli4479 e10cf01
Merge branch 'AOSSIE-Org:main' into feat/64-database-configuration
Eli4479 9d098e8
[feat]: implement Weaviate client connection , data population methodβ¦
Eli4479 f04755a
refactor: implemented changes based on feedback from Gemini and CodeRβ¦
Eli4479 a13ca6b
feat: update OAuth login redirect URL and refactor Weaviate populatioβ¦
Eli4479 9b0cde7
refactor: change async functions to synchronous for OAuth and user maβ¦
Eli4479 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| from app.db.supabase.supabase_client import supabase_client | ||
| import os | ||
| def login_with_oauth(provider: str): | ||
| try: | ||
| result = supabase_client.auth.sign_in_with_oauth({ | ||
| "provider": provider, | ||
| "options": { | ||
| "redirect_to": os.getenv("SUPABASE_REDIRECT_URL", "http://localhost:3000/home") | ||
| } | ||
| }) | ||
| return {"url": result.url} | ||
| except Exception as e: | ||
| raise Exception(f"OAuth login failed for {provider}: {str(e)}") | ||
|
|
||
|
|
||
| def login_with_github(): | ||
| return login_with_oauth("github") | ||
|
|
||
| def login_with_discord(): | ||
| return login_with_oauth("discord") | ||
|
|
||
| def logout(access_token: str): | ||
| try: | ||
| supabase_client.auth.set_session(access_token, refresh_token="") | ||
| supabase_client.auth.sign_out() | ||
| return {"message": "User logged out successfully"} | ||
| except Exception as e: | ||
| raise Exception(f"Logout failed: {str(e)}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import os | ||
| from dotenv import load_dotenv | ||
| from supabase import create_client | ||
|
|
||
| load_dotenv() | ||
|
|
||
| SUPABASE_URL = os.getenv("SUPABASE_URL") | ||
| SUPABASE_KEY = os.getenv("SUPABASE_KEY") | ||
|
|
||
| if SUPABASE_URL is None or SUPABASE_KEY is None: | ||
| raise ValueError("SUPABASE_URL and SUPABASE_KEY must be set in environment variables.") | ||
|
|
||
| supabase_client = create_client(SUPABASE_URL, SUPABASE_KEY) | ||
|
|
||
|
|
||
| def get_supabase_client(): | ||
| return supabase_client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import weaviate | ||
|
|
||
| # Connect to local Weaviate instance | ||
| client = weaviate.connect_to_local() | ||
|
|
||
|
|
||
| def get_client(): | ||
| return client |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| from pydantic import BaseModel, Field | ||
| from uuid import UUID | ||
| from typing import Optional, List | ||
| from datetime import datetime | ||
|
|
||
|
|
||
| class User(BaseModel): | ||
| """ | ||
| Represents a user profile with various platform integrations and metadata. | ||
|
|
||
| Attributes: | ||
| id (UUID): Unique identifier for the user. | ||
| created_at (datetime): Timestamp when the user was created. | ||
| updated_at (datetime): Timestamp when the user was last updated. | ||
| discord_id (Optional[str]): Discord user ID, if linked. | ||
| discord_username (Optional[str]): Discord username, if linked. | ||
| github_id (Optional[str]): GitHub user ID, if linked. | ||
| github_username (Optional[str]): GitHub username, if linked. | ||
| slack_id (Optional[str]): Slack user ID, if linked. | ||
| slack_username (Optional[str]): Slack username, if linked. | ||
| display_name (str): Display name of the user. | ||
| email (str): Email address of the user. | ||
| avatar_url (Optional[str]): URL to the user's avatar image. | ||
| bio (Optional[str]): Short biography or description of the user. | ||
| location (Optional[str]): User's location. | ||
| is_verified (bool): Indicates if the user is verified. | ||
| verification_token (Optional[str]): Token used for verifying the user. | ||
| verified_at (Optional[datetime]): Timestamp when the user was verified. | ||
| skills (Optional[List[str]]): List of user's skills. | ||
| github_stats (Optional[dict]): GitHub statistics for the user. | ||
| last_active_discord (Optional[datetime]): Last active time on Discord. | ||
| last_active_github (Optional[datetime]): Last active time on GitHub. | ||
| last_active_slack (Optional[datetime]): Last active time on Slack. | ||
| total_interactions_count (int): Total number of user interactions. | ||
| preferred_languages (List[str]): List of user's preferred programming languages. | ||
| weaviate_user_id (Optional[str]): Associated Weaviate user ID, if any. | ||
| """ | ||
| id: UUID | ||
| created_at: datetime | ||
| updated_at: datetime | ||
| discord_id: Optional[str] = None | ||
| discord_username: Optional[str] = None | ||
| github_id: Optional[str] = None | ||
| github_username: Optional[str] = None | ||
| slack_id: Optional[str] = None | ||
| slack_username: Optional[str] = None | ||
| display_name: str | ||
| email: str | ||
| avatar_url: Optional[str] = None | ||
| bio: Optional[str] = None | ||
| location: Optional[str] = None | ||
| is_verified: bool = False | ||
| verification_token: Optional[str] = None | ||
| verified_at: Optional[datetime] = None | ||
| skills: Optional[List[str]] = None | ||
| github_stats: Optional[dict] = None | ||
| last_active_discord: Optional[datetime] = None | ||
| last_active_github: Optional[datetime] = None | ||
| last_active_slack: Optional[datetime] = None | ||
| total_interactions_count: int = 0 | ||
| preferred_languages: List[str] = Field(default_factory=list) | ||
| weaviate_user_id: Optional[str] = None | ||
|
|
||
| class Repository(BaseModel): | ||
| """ | ||
| Represents a GitHub repository with metadata and indexing status. | ||
|
|
||
| Attributes: | ||
| id (UUID): Unique identifier for the repository. | ||
| created_at (datetime): Timestamp when the repository record was created. | ||
| updated_at (datetime): Timestamp when the repository record was last updated. | ||
| github_id (Optional[int]): GitHub's unique identifier for the repository. | ||
| full_name (str): Full name of the repository (e.g., "owner/name"). | ||
| name (str): Name of the repository. | ||
| owner (str): Owner of the repository. | ||
| description (Optional[str]): Description of the repository. | ||
| stars_count (int): Number of stars the repository has received. | ||
| forks_count (int): Number of times the repository has been forked. | ||
| open_issues_count (int): Number of open issues in the repository. | ||
| language (Optional[str]): Primary programming language used in the repository. | ||
| topics (List[str]): List of topics/tags associated with the repository. | ||
| is_indexed (bool): Indicates if the repository has been indexed. | ||
| indexed_at (Optional[datetime]): Timestamp when the repository was indexed. | ||
| indexing_status (Optional[str]): Current status of the indexing process. | ||
| total_chunks_count (int): Total number of chunks generated during indexing. | ||
| last_commit_hash (Optional[str]): Hash of the last commit indexed. | ||
| indexing_progress (Optional[dict]): Progress details of the indexing process. | ||
| weaviate_repo_id (Optional[str]): Identifier for the repository in Weaviate. | ||
| """ | ||
| id: UUID | ||
| created_at: datetime | ||
| updated_at: datetime | ||
| github_id: Optional[int] = None | ||
| full_name: str | ||
| name: str | ||
| owner: str | ||
| description: Optional[str] = None | ||
| stars_count: int = 0 | ||
| forks_count: int = 0 | ||
| open_issues_count: int = 0 | ||
| language: Optional[str] = None | ||
| topics: List[str] = Field(default_factory=list) | ||
| is_indexed: bool = False | ||
| indexed_at: Optional[datetime] = None | ||
| indexing_status: Optional[str] = None | ||
| total_chunks_count: int = 0 | ||
| last_commit_hash: Optional[str] = None | ||
| indexing_progress: Optional[dict] = None | ||
| weaviate_repo_id: Optional[str] = None | ||
|
|
||
| class CodeChunk(BaseModel): | ||
| """ | ||
| Represents a chunk of code extracted from a file within a repository. | ||
|
|
||
| Attributes: | ||
| id (UUID): Unique identifier for the code chunk. | ||
| repository_id (UUID): Identifier of the repository this chunk belongs to. | ||
| created_at (datetime): Timestamp when the chunk was created. | ||
| file_path (str): Path to the file containing the code chunk. | ||
| file_name (str): Name of the file containing the code chunk. | ||
| file_extension (Optional[str]): Extension of the file (e.g., '.py', '.js'). | ||
| chunk_index (int): Index of the chunk within the file. | ||
| content (str): The actual code content of the chunk. | ||
| chunk_type (Optional[str]): Type of the chunk (e.g., 'function', 'class', 'block'). | ||
| language (Optional[str]): Programming language of the code chunk. | ||
| lines_start (Optional[int]): Starting line number of the chunk in the file. | ||
| lines_end (Optional[int]): Ending line number of the chunk in the file. | ||
| code_metadata (Optional[dict]): Additional metadata related to the code chunk. | ||
| weaviate_chunk_id (Optional[str]): Identifier for the chunk in Weaviate vector database. | ||
| """ | ||
| id: UUID | ||
| repository_id: UUID | ||
| created_at: datetime | ||
| file_path: str | ||
| file_name: str | ||
| file_extension: Optional[str] = None | ||
| chunk_index: int | ||
| content: str | ||
| chunk_type: Optional[str] = None | ||
| language: Optional[str] = None | ||
| lines_start: Optional[int] = None | ||
| lines_end: Optional[int] = None | ||
| code_metadata: Optional[dict] = None | ||
| weaviate_chunk_id: Optional[str] = None | ||
|
|
||
| class Interaction(BaseModel): | ||
| """ | ||
| Represents an interaction within a repository platform, such as a message, comment, or post. | ||
|
|
||
| Attributes: | ||
| id (UUID): Unique identifier for the interaction. | ||
| created_at (datetime): Timestamp when the interaction was created. | ||
| updated_at (datetime): Timestamp when the interaction was last updated. | ||
| user_id (UUID): Unique identifier of the user who performed the interaction. | ||
| repository_id (UUID): Unique identifier of the repository associated with the interaction. | ||
| platform (str): Name of the platform where the interaction occurred (e.g., GitHub, Slack). | ||
| platform_specific_id (str): Platform-specific identifier for the interaction. | ||
| channel_id (Optional[str]): Identifier for the channel where the interaction took place, if applicable. | ||
| thread_id (Optional[str]): Identifier for the thread within the channel, if applicable. | ||
| content (str): The textual content of the interaction. | ||
| interaction_type (str): Type of interaction (e.g., message, comment, issue). | ||
| sentiment_score (Optional[float]): Sentiment analysis score of the interaction content. | ||
| intent_classification (Optional[str]): Classification of the user's intent in the interaction. | ||
| topics_discussed (List[str]): List of topics discussed in the interaction. | ||
| metadata (Optional[dict]): Additional metadata related to the interaction. | ||
| weaviate_interaction_id (Optional[str]): Identifier for the interaction in the Weaviate vector database. | ||
| """ | ||
| id: UUID | ||
| created_at: datetime | ||
| updated_at: datetime | ||
| user_id: UUID | ||
| repository_id: UUID | ||
| platform: str | ||
| platform_specific_id: str | ||
| channel_id: Optional[str] = None | ||
| thread_id: Optional[str] = None | ||
| content: str | ||
| interaction_type: str | ||
| sentiment_score: Optional[float] = None | ||
| intent_classification: Optional[str] = None | ||
| topics_discussed: List[str] = Field(default_factory=list) | ||
| metadata: Optional[dict] = None | ||
| weaviate_interaction_id: Optional[str] = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from pydantic import BaseModel, Field | ||
| from typing import List | ||
|
|
||
|
|
||
| class WeaviateUserProfile(BaseModel): | ||
| """ | ||
| Represents a vectorized user profile for semantic search in Weaviate. | ||
| """ | ||
| supabase_user_id: str = Field(..., alias="supabaseUserId") | ||
| profile_summary: str = Field(..., alias="profileSummary") | ||
| primary_languages: List[str] = Field(..., alias="primaryLanguages") | ||
| expertise_areas: List[str] = Field(..., alias="expertiseAreas") | ||
| embedding: List[float] = Field(..., description="384-dimensional vector") | ||
|
|
||
|
|
||
| class WeaviateCodeChunk(BaseModel): | ||
| """ | ||
| Vectorized representation of code chunks stored in Weaviate. | ||
| """ | ||
| supabase_chunk_id: str = Field(..., alias="supabaseChunkId") | ||
| code_content: str = Field(..., alias="codeContent") | ||
| language: str | ||
| function_names: List[str] = Field(..., alias="functionNames") | ||
| embedding: List[float] = Field(..., description="384-dimensional vector") | ||
|
|
||
|
|
||
| class WeaviateInteraction(BaseModel): | ||
| """ | ||
| Vectorized interaction representation stored in Weaviate. | ||
| """ | ||
| supabase_interaction_id: str = Field(..., alias="supabaseInteractionId") | ||
| conversation_summary: str = Field(..., alias="conversationSummary") | ||
| platform: str | ||
| topics: List[str] | ||
| embedding: List[float] = Field(..., description="384-dimensional vector") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.