Skip to content
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

Project refactor #161

Merged
merged 14 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost
DJANGO_SECRET_KEY=
DEBUG=True
ALLOWED_HOSTS=localhost
SECRET_KEY=
jfrverdasca marked this conversation as resolved.
Show resolved Hide resolved

DATABASE_HOST=localhost
DATABASE_USER=postgres
Expand Down
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ services:
build:
context: .
dockerfile: ./Dockerfile
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BD=redis://redis:6379/0
# environment:
# - CELERY_BROKER_URL=redis://redis:6379/0
# - CELERY_RESULT_BD=redis://redis:6379/0
ports:
- "8000:8000"
depends_on:
Expand Down Expand Up @@ -54,11 +54,11 @@ services:
context: .
dockerfile: ./Dockerfile
command: celery -A config worker --beat --scheduler redbeat.RedBeatScheduler --loglevel=INFO --concurrency=1
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- CELERY_TASK_ALWAYS_EAGER=False
- DATABASE_URL=postgresql://postgres:postgres@labs-db:5432/postgres
# environment:
# - CELERY_BROKER_URL=redis://redis:6379/0
# - CELERY_RESULT_BACKEND=redis://redis:6379/0
# - CELERY_TASK_ALWAYS_EAGER=False
# - DATABASE_URL=postgresql://postgres:postgres@labs-db:5432/postgres
jfrverdasca marked this conversation as resolved.
Show resolved Hide resolved
depends_on:
- redis
- labs-db
Expand Down
4 changes: 2 additions & 2 deletions docs/diagram/class_diagram
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ digraph {
color=lightgrey label="./code_examples/calculator.py" style=filled
Calculator [label="{ Calculator | + add(self, x, y)\l+ subtract(self, x, y)\l }" shape=record]
}
subgraph "cluster_./litellm_service/request.py" {
color=lightgrey label="./litellm_service/request.py" style=filled
subgraph "cluster_./llm/request.py" {
color=lightgrey label="./llm/request.py" style=filled
RequestLiteLLM [label="{ RequestLiteLLM | + __init__(self, litellm_api_key)\l+ completion(self, messages, model)\l+ completion_without_proxy(self, messages, model)\l }" shape=record]
}
}
2 changes: 1 addition & 1 deletion labs/api/codemonkey_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def run_on_repository_endpoint(request: HttpRequest, run_on_repository: Gi
async def run_on_local_repository_endpoint(request: HttpRequest, run_on_local_repository: LocalRepositoryShema):
try:
run_on_local_repository_task(
repository_path=run_on_local_repository.repository_path, issue_text=run_on_local_repository.prompt
repository_path=run_on_local_repository.repository_path, issue_body=run_on_local_repository.prompt
)
except Exception as ex:
logger.exception("Internal server error")
Expand Down
14 changes: 7 additions & 7 deletions labs/api/github_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
async def list_issues_endpoint(request: HttpRequest, params: ListIssuesSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand All @@ -41,7 +41,7 @@ async def list_issues_endpoint(request: HttpRequest, params: ListIssuesSchema):
async def get_issue_endpoint(request: HttpRequest, params: IssueSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand All @@ -57,7 +57,7 @@ async def get_issue_endpoint(request: HttpRequest, params: IssueSchema):
async def create_branch_endpoint(request: HttpRequest, params: BranchSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand All @@ -73,7 +73,7 @@ async def create_branch_endpoint(request: HttpRequest, params: BranchSchema):
async def change_issue_status_endpoint(request: HttpRequest, params: IssueStatusSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand All @@ -89,7 +89,7 @@ async def change_issue_status_endpoint(request: HttpRequest, params: IssueStatus
async def commit_changes_endpoint(request: HttpRequest, params: CommitSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand All @@ -107,7 +107,7 @@ async def commit_changes_endpoint(request: HttpRequest, params: CommitSchema):
async def create_pull_request_endpoint(request: HttpRequest, params: PullRequestSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand All @@ -125,7 +125,7 @@ async def create_pull_request_endpoint(request: HttpRequest, params: PullRequest
async def clone_repository_endpoint(request: HttpRequest, params: GithubSchema):
try:
github_requests = GithubRequests(
github_token=params.token,
token=params.token,
repository_owner=params.repository_owner,
repository_name=params.repository_name,
username=params.username,
Expand Down
8 changes: 4 additions & 4 deletions labs/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from embeddings.embedder import Embedder
from embeddings.ollama import OllamaEmbedder
from embeddings.openai import OpenAIEmbedder
from embeddings.vectorizers.base import Vectorizer
from embeddings.vectorizers.chunk_vectorizer import ChunkVectorizer
from embeddings.vectorizers.python_vectorizer import PythonVectorizer
from litellm_service.llm_requester import Requester
from litellm_service.ollama import OllamaRequester
from litellm_service.openai import OpenAIRequester
from embeddings.vectorizers.vectorizer import Vectorizer
from llm.ollama import OllamaRequester
from llm.openai import OpenAIRequester
from llm.requester import Requester

provider_model_class = {
"OPENAI": {"embedding": OpenAIEmbedder, "llm": OpenAIRequester},
Expand Down
2 changes: 1 addition & 1 deletion labs/embeddings/embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def embed(self, prompt, *args, **kwargs) -> Embeddings:

def retrieve_embeddings(
self, query: str, repository: str, similarity_threshold: int = 0.7, number_of_results: int = 10
) -> List[Embeddings]:
) -> List[Embedding]:
query = query.replace("\n", "")
embedded_query = self.embed(prompt=query).embeddings
if not embedded_query:
Expand Down
16 changes: 8 additions & 8 deletions labs/github/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class GithubRequests:
"""Class to handle Github API requests"""

def __init__(self, github_token, repository_owner, repository_name, username=None):
self.github_token = github_token
def __init__(self, token, repository_owner, repository_name, username=None):
self.token = token
self.repository_owner = repository_owner
self.repository_name = repository_name
self.username = username
Expand Down Expand Up @@ -67,7 +67,7 @@ def list_issues(self, assignee=None, state="open", per_page=100):
url = f"{self.github_api_url}/issues"

headers = {
"Authorization": f"token {self.github_token}",
"Authorization": f"token {self.token}",
"Accept": "application/vnd.github.v3+json",
}
params = {
Expand All @@ -84,7 +84,7 @@ def get_issue(self, issue_number):
# issue_number is the actual number of the issue, not the id.
url = f"{self.github_api_url}/issues/{issue_number}"
headers = {
"Authorization": f"token {self.github_token}",
"Authorization": f"token {self.token}",
"Accept": "application/vnd.github.v3+json",
}
response_json, _ = self._get(url, headers, {})
Expand All @@ -93,7 +93,7 @@ def get_issue(self, issue_number):
def create_branch(self, branch_name, original_branch="main"):
url = f"{self.github_api_url}/git/refs/heads/{original_branch}"
headers = {
"Authorization": f"Bearer {self.github_token}",
"Authorization": f"Bearer {self.token}",
"X-Accepted-GitHub-Permissions": "contents=write",
}
response_json, status_code = self._get(url, headers=headers)
Expand All @@ -110,7 +110,7 @@ def change_issue_status(self, issue_number, status):

url = f"{self.github_api_url}/issues/{issue_number}"
headers = {
"Authorization": f"token {self.github_token}",
"Authorization": f"token {self.token}",
"user-agent": "request",
}
data = {"state": status}
Expand All @@ -121,7 +121,7 @@ def commit_changes(self, message, branch_name, files):
# Step 1: Get the latest commit SHA on the specified branch
url = f"{self.github_api_url}/git/refs/heads/{branch_name}"
headers = {
"Authorization": f"token {self.github_token}",
"Authorization": f"token {self.token}",
"Content-Type": "application/json",
}
response_json, _ = self._get(url, headers)
Expand Down Expand Up @@ -184,7 +184,7 @@ def commit_changes(self, message, branch_name, files):

def create_pull_request(self, head, base="main", title="New Pull Request", body=""):
url = f"{self.github_api_url}/pulls"
headers = {"Authorization": f"token {self.github_token}"}
headers = {"Authorization": f"token {self.token}"}
data = {"title": title, "body": body, "head": head, "base": base}
return self._post(url, headers, data)

Expand Down
153 changes: 0 additions & 153 deletions labs/llm.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions labs/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ def setup_logger():
)
handler.setFormatter(formatter)
logger.addHandler(handler)

except Exception:
pass
6 changes: 3 additions & 3 deletions labs/parsers/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class Step(BaseModel):
content: str


class PullRequest(BaseModel):
class Steps(BaseModel):
steps: list[Step]
jfrverdasca marked this conversation as resolved.
Show resolved Hide resolved


def parse_llm_output(text_output):
return PullRequest.model_validate_json(text_output)
return Steps.model_validate_json(text_output)


def create_file(path, content):
Expand Down Expand Up @@ -47,6 +47,6 @@ def modify_file(path, content):
def is_valid_json(text):
try:
json.loads(text)
return True
except ValueError:
return False
return True
Loading
Loading