Skip to content

Commit

Permalink
feat: using petercat.ai (#270)
Browse files Browse the repository at this point in the history
- 感谢金主爸爸 @afc163
  • Loading branch information
RaoHai authored Aug 30, 2024
2 parents 35f7d14 + 5e5757a commit 54d8a91
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 39 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ permissions:
env:
AWS_REGION: ap-northeast-1
REPORT_FILE: md_report.md

WEB_URL: http://127.0.0.1:3000
API_URL: http://127.0.0.1:8000
jobs:
build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.aws.lambda
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" -U --no-cach

# Set NLTK_DATA to load nltk_data
ENV NLTK_DATA=/opt/nltk_data

ENV ENV=production

CMD ["python", "main.py"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.subscriber
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ RUN pip install -r requirements.txt

# Copy function code
COPY . ${LAMBDA_TASK_ROOT}

ENV ENV=production
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "handler.lambda_handler" ]
2 changes: 1 addition & 1 deletion extension/src/components/ChatPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
const ChatPanel = () => {
return (
<Chat
apiDomain="https://api.petercat.chat"
apiDomain="https://api.petercat.ai"
apiUrl="/api/chat/stream_qa"
token="594dc633-acf6-4fed-a52d-c5852c6f4694"
/>
Expand Down
2 changes: 1 addition & 1 deletion lui/docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Step 3, render Assistant component in your project:
...
+ <script>
+ PetercatLUI.initAssistant({
+ apiDomain: 'https://api.petercat.chat',
+ apiDomain: 'https://api.petercat.ai',
+ token: 'your-token',
+ starters: ['介绍下这个项目', '查看贡献指南', '我该怎样快速上手'],
+ clearMessage: true
Expand Down
2 changes: 1 addition & 1 deletion lui/src/icons/SignatureIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
const SignatureIcon = (props: any) => (
<a href="https://www.petercat.chat/" className={props.className}>
<a href="https://www.petercat.ai/" className={props.className}>
<svg xmlns="http://www.w3.org/2000/svg" width={99} height={11} fill="none">
<path
fill="#D1D5DB"
Expand Down
20 changes: 10 additions & 10 deletions petercat_utils/utils/env.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from dotenv import load_dotenv
import os

# Define a method to load an environmental variable and return its value
def get_env_variable(key: str, default=None):
"""
Retrieve the specified environment variable. Return the specified default value if the variable does not exist.
:param key: The name of the environment variable to retrieve.
:param default: The default value to return if the environment variable does not exist.
:return: The value of the environment variable, or the default value if it does not exist.
"""
# Load the .env file
def load_env():
env = os.getenv("ENV", "development")
print(f"load_env={env}")
load_dotenv(verbose=True, override=True)

if env == 'development':
load_dotenv(dotenv_path=".env.local", verbose=True, override=True)

load_env()

# Define a method to load an environmental variable and return its value
def get_env_variable(key: str, default=None):
# Get the environment variable, returning the default value if it does not exist
return os.getenv(key, default)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "petercat_utils"
version = "0.1.30"
version = "0.1.31"
description = ""
authors = ["raoha.rh <[email protected]>"]
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions scripts/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def main():
push_parser = subparsers.add_parser(
"push", help="Push enviroment variables from local .env file to Remote"
)
push_parser.add_argument('--silence', action='store_true', help='Skip confirmation before updating the CloudFormation template')
push_parser.set_defaults(handle=push_envs)

build_parser = subparsers.add_parser(
Expand Down
2 changes: 1 addition & 1 deletion server/agent/tools/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

def need_github_login():
return json.dumps({
"error_info": "你必须先使用 GitHub 登录 petercat 才能使用此功能。 [登录地址](https://api.petercat.chat/api/auth/login)"
"error_info": "你必须先使用 GitHub 登录 petercat 才能使用此功能。 [登录地址](https://api.petercat.ai/api/auth/login)"
})
7 changes: 6 additions & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
API_AUDIENCE = get_env_variable("API_IDENTIFIER")
CLIENT_ID = get_env_variable("AUTH0_CLIENT_ID")
API_URL = get_env_variable("API_URL")
WEB_URL = get_env_variable("WEB_URL")
CALLBACK_URL = f"{API_URL}/api/auth/callback"

is_dev = bool(get_env_variable("IS_DEV"))
Expand Down Expand Up @@ -58,7 +59,11 @@

@app.get("/api/health_checker")
def health_checker():
return { "Hello": "World" }
return {
"API_URL": API_URL,
"WEB_URL": WEB_URL,
"CALLBACK_URL": CALLBACK_URL,
}


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions server/tests/fixtures/github/events/pull_request/create.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -292,7 +292,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -452,7 +452,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
2 changes: 1 addition & 1 deletion server/tests/fixtures/github/events/pull_request/edit.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28864,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -367,7 +367,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28864,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -517,7 +517,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28864,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -360,7 +360,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -508,7 +508,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -330,7 +330,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -479,7 +479,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -330,7 +330,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -478,7 +478,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -280,7 +280,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down Expand Up @@ -559,7 +559,7 @@
"ssh_url": "[email protected]:petercat-ai/petercat.git",
"clone_url": "https://github.com/petercat-ai/petercat.git",
"svn_url": "https://github.com/petercat-ai/petercat",
"homepage": "https://www.petercat.chat/",
"homepage": "https://www.petercat.ai/",
"size": 28857,
"stargazers_count": 3,
"watchers_count": 3,
Expand Down
6 changes: 5 additions & 1 deletion server/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
def test_health_checker():
response = client.get("/api/health_checker")
assert response.status_code == 200
assert response.json() == { "Hello": "World" }
assert response.json() == {
'API_URL': 'http://127.0.0.1:8000',
'CALLBACK_URL': 'http://127.0.0.1:8000/api/auth/callback',
'WEB_URL': 'http://127.0.0.1:3000',
}

0 comments on commit 54d8a91

Please sign in to comment.