-
Notifications
You must be signed in to change notification settings - Fork 852
chore: breaking out models #225
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
Open
wyattearp
wants to merge
2
commits into
AsyncFuncAI:main
Choose a base branch
from
wyattearp:chore-model-breakout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,122 @@ | ||
from typing import List, Optional, Dict, Any, Literal | ||
from pydantic import BaseModel, Field | ||
|
||
# Wiki related models | ||
class WikiPage(BaseModel): | ||
""" | ||
Model for a wiki page. | ||
""" | ||
id: str | ||
title: str | ||
content: str | ||
filePaths: List[str] | ||
importance: str # Should ideally be Literal['high', 'medium', 'low'] | ||
relatedPages: List[str] | ||
|
||
class ProcessedProjectEntry(BaseModel): | ||
id: str # Filename | ||
owner: str | ||
repo: str | ||
name: str # owner/repo | ||
repo_type: str # Renamed from type to repo_type for clarity with existing models | ||
submittedAt: int # Timestamp | ||
language: str # Extracted from filename | ||
|
||
class RepoInfo(BaseModel): | ||
owner: str | ||
repo: str | ||
type: str | ||
token: Optional[str] = None | ||
localPath: Optional[str] = None | ||
repoUrl: Optional[str] = None | ||
|
||
class WikiStructureModel(BaseModel): | ||
""" | ||
Model for the overall wiki structure. | ||
""" | ||
id: str | ||
title: str | ||
description: str | ||
pages: List[WikiPage] | ||
|
||
class WikiCacheData(BaseModel): | ||
""" | ||
Model for the data to be stored in the wiki cache. | ||
""" | ||
wiki_structure: WikiStructureModel | ||
generated_pages: Dict[str, WikiPage] | ||
repo_url: Optional[str] = None # compatible for old cache | ||
repo: Optional[RepoInfo] = None | ||
provider: Optional[str] = None | ||
model: Optional[str] = None | ||
|
||
class WikiCacheRequest(BaseModel): | ||
""" | ||
Model for the request body when saving wiki cache. | ||
""" | ||
repo: RepoInfo | ||
language: str | ||
wiki_structure: WikiStructureModel | ||
generated_pages: Dict[str, WikiPage] | ||
provider: str | ||
model: str | ||
|
||
class WikiExportRequest(BaseModel): | ||
""" | ||
Model for requesting a wiki export. | ||
""" | ||
repo_url: str = Field(..., description="URL of the repository") | ||
pages: List[WikiPage] = Field(..., description="List of wiki pages to export") | ||
format: Literal["markdown", "json"] = Field(..., description="Export format (markdown or json)") | ||
|
||
# Model configuration related models | ||
class Model(BaseModel): | ||
""" | ||
Model for LLM model configuration | ||
""" | ||
id: str = Field(..., description="Model identifier") | ||
name: str = Field(..., description="Display name for the model") | ||
|
||
class Provider(BaseModel): | ||
""" | ||
Model for LLM provider configuration | ||
""" | ||
id: str = Field(..., description="Provider identifier") | ||
name: str = Field(..., description="Display name for the provider") | ||
models: List[Model] = Field(..., description="List of available models for this provider") | ||
supportsCustomModel: Optional[bool] = Field(False, description="Whether this provider supports custom models") | ||
|
||
class ModelConfig(BaseModel): | ||
""" | ||
Model for the entire model configuration | ||
""" | ||
providers: List[Provider] = Field(..., description="List of available model providers") | ||
defaultProvider: str = Field(..., description="ID of the default provider") | ||
|
||
class AuthorizationConfig(BaseModel): | ||
code: str = Field(..., description="Authorization code") | ||
|
||
# Chat API models | ||
class ChatMessage(BaseModel): | ||
role: str # 'user' or 'assistant' | ||
content: str | ||
|
||
class ChatCompletionRequest(BaseModel): | ||
""" | ||
Model for requesting a chat completion. | ||
""" | ||
repo_url: str = Field(..., description="URL of the repository to query") | ||
messages: List[ChatMessage] = Field(..., description="List of chat messages") | ||
filePath: Optional[str] = Field(None, description="Optional path to a file in the repository to include in the prompt") | ||
token: Optional[str] = Field(None, description="Personal access token for private repositories") | ||
type: Optional[str] = Field("github", description="Type of repository (e.g., 'github', 'gitlab', 'bitbucket')") | ||
|
||
# model parameters | ||
provider: str = Field("google", description="Model provider (google, openai, openrouter, ollama, bedrock, azure)") | ||
model: Optional[str] = Field(None, description="Model name for the specified provider") | ||
|
||
language: Optional[str] = Field("en", description="Language for content generation (e.g., 'en', 'ja', 'zh', 'es', 'kr', 'vi')") | ||
excluded_dirs: Optional[str] = Field(None, description="Comma-separated list of directories to exclude from processing") | ||
excluded_files: Optional[str] = Field(None, description="Comma-separated list of file patterns to exclude from processing") | ||
included_dirs: Optional[str] = Field(None, description="Comma-separated list of directories to include exclusively") | ||
included_files: Optional[str] = Field(None, description="Comma-separated list of file patterns to include exclusively") |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment correctly notes that
importance
should ideally useLiteral
. UsingLiteral
provides better type safety, enables more effective static analysis, and ensures that only valid values ('high', 'medium', 'low') are accepted by Pydantic during validation. This makes the model more robust and self-documenting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally I would agree with this type of change; however, there's a lot of other spots in the code where this is used in both api/ and src/ -- a more correct answer would be to create a pass where this is appropriately handled as a literal in both the python and the typescript.