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

refactor: folder structure #256

Merged
merged 3 commits into from
Aug 24, 2024
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 server/agent/bot_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from petercat_utils.data_class import ChatData

from agent.base import AgentBuilder
from prompts.bot_builder import generate_prompt_by_user_id
from tools import bot_builder
from agent.prompts.bot_builder import generate_prompt_by_user_id
from agent.tools import bot_builder


TOOL_MAPPING = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions server/agent/qa_chat.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import AsyncIterator, Optional
from agent.base import AgentBuilder
from agent.llm import get_llm
from dao.botDAO import BotDAO
from models.bot import Bot
from prompts.bot_template import generate_prompt_by_repo_name
from core.dao.botDAO import BotDAO
from core.models.bot import Bot
from agent.prompts.bot_template import generate_prompt_by_repo_name
from petercat_utils.data_class import ChatData

from tools import issue, sourcecode, knowledge, git_info
from agent.tools import issue, sourcecode, knowledge, git_info


def get_tools(bot: Bot, token: Optional[str]):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion server/tools/issue.py → server/agent/tools/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from github import Auth, Github
from langchain.tools import tool

from tools.helper import need_github_login
from agent.tools.helper import need_github_login

DEFAULT_REPO_NAME = "ant-design/ant-design"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion server/bot/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from petercat_utils.data_class import RAGGitDocConfig
from petercat_utils import git_doc_task

from prompts.bot_template import generate_prompt_by_repo_name
from agent.prompts.bot_template import generate_prompt_by_repo_name

g = Github()

Expand Down
2 changes: 1 addition & 1 deletion server/routers/bot.py → server/bot/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Annotated, Optional

from bot.builder import bot_builder, bot_info_generator
from type_class.bot import BotUpdateRequest, BotCreateRequest
from core.type_class.bot import BotUpdateRequest, BotCreateRequest

router = APIRouter(
prefix="/api/bot",
Expand Down
2 changes: 1 addition & 1 deletion server/routers/chat.py → server/chat/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from petercat_utils.data_class import ChatData

from agent import qa_chat, bot_builder
from verify.rate_limit import verify_rate_limit
from auth.rate_limit import verify_rate_limit
from auth.get_user_info import get_user_access_token, get_user_id


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from petercat_utils.db.client.supabase import get_client

from dao.BaseDAO import BaseDAO
from models.authorization import Authorization
from core.dao.BaseDAO import BaseDAO
from core.models.authorization import Authorization

class AuthorizationDAO(BaseDAO):
client: Client
Expand Down
4 changes: 2 additions & 2 deletions server/dao/botDAO.py → server/core/dao/botDAO.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dao.BaseDAO import BaseDAO
from core.dao.BaseDAO import BaseDAO
from supabase.client import Client

from models.bot import Bot
from core.models.bot import Bot
from petercat_utils.db.client.supabase import get_client

class BotDAO(BaseDAO):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from dao.BaseDAO import BaseDAO
from models.repository import RepositoryConfig
from core.dao.BaseDAO import BaseDAO
from core.models.repository import RepositoryConfig
from supabase.client import Client

from petercat_utils.db.client.supabase import get_client
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions server/core/models/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from datetime import datetime
from typing import Optional
from pydantic import BaseModel

class Bot(BaseModel):
id: str
uid: str
avatar: Optional[str] = ""
description: Optional[str]
prompt: Optional[str] = ""
name: str
llm: Optional[str] = "openai"
created_at: datetime
File renamed without changes.
File renamed without changes.
197 changes: 0 additions & 197 deletions server/docs/test.md

This file was deleted.

2 changes: 1 addition & 1 deletion server/event_handler/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from github import Github, Auth
from github import GithubException

from dao.repositoryConfigDAO import RepositoryConfigDAO
from core.dao.repositoryConfigDAO import RepositoryConfigDAO
from petercat_utils.data_class import ChatData, Message, TextContentBlock

from agent.qa_chat import agent_chat
Expand Down
21 changes: 1 addition & 20 deletions server/utils/github.py → server/github_app/handlers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Union
import boto3
from botocore.exceptions import ClientError

from petercat_utils import get_env_variable
from github import Auth

Expand All @@ -10,24 +9,6 @@

APP_ID = get_env_variable("X_GITHUB_APP_ID")

def get_private_key():
secret_name = "prod/githubapp/petercat/pem"
region_name = "ap-northeast-1"
session = boto3.session.Session()
client = session.client(
service_name='secretsmanager',
region_name=region_name
)
try:
get_secret_value_response = client.get_secret_value(
SecretId=secret_name
)
except ClientError as e:
# For a list of exceptions thrown, see
# https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html
raise e

return get_secret_value_response['SecretString']

def get_handler(event: str, payload: dict, auth: Auth.AppAuth, installation_id: int) -> Union[PullRequestEventHandler, IssueEventHandler, DiscussionEventHandler, None]:
handlers = {
Expand Down
Loading