From 106afa48dd4439aae3f3dfea66f3edf5cd15455c Mon Sep 17 00:00:00 2001 From: yingying Date: Sun, 18 Aug 2024 22:42:13 +0800 Subject: [PATCH 1/4] style: fix the avatar --- client/package.json | 2 +- lui/package.json | 2 +- lui/src/Chat/components/ChatItemRender.tsx | 28 ++++++++++++---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/client/package.json b/client/package.json index 78786048..2ee23741 100644 --- a/client/package.json +++ b/client/package.json @@ -39,7 +39,7 @@ "lottie-react": "^2.4.0", "next": "14.0.1", "openai": "^4.24.7", - "petercat-lui": "0.1.8", + "petercat-lui": "0.1.9", "postcss": "8.4.27", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/lui/package.json b/lui/package.json index 8155e564..7eb50538 100644 --- a/lui/package.json +++ b/lui/package.json @@ -1,6 +1,6 @@ { "name": "petercat-lui", - "version": "0.1.8", + "version": "0.1.9", "description": "A react library developed with dumi", "module": "dist/index.js", "types": "dist/index.d.ts", diff --git a/lui/src/Chat/components/ChatItemRender.tsx b/lui/src/Chat/components/ChatItemRender.tsx index 6feb145e..1104b52b 100644 --- a/lui/src/Chat/components/ChatItemRender.tsx +++ b/lui/src/Chat/components/ChatItemRender.tsx @@ -25,19 +25,21 @@ const ChatItemRender: FC = ({ : 'flex-row-reverse ant-pro-chat-list-item-right' } ant-pro-chat-list-item ant-pro-chat-list-item-message-content gap-[12px] p-[16px] chat_item_container`} > -
- {avatar?.props?.avatar?.title} -
+ {direction === 'start' && ( +
+ {avatar?.props?.avatar?.title} +
+ )}
{title} {content} From df18fa9a7fb910218a0d2f31096536c317279c22 Mon Sep 17 00:00:00 2001 From: yingying Date: Sun, 18 Aug 2024 22:43:02 +0800 Subject: [PATCH 2/4] chore: update the lock --- client/yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/yarn.lock b/client/yarn.lock index fc8c309b..8e02b6ca 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -11824,10 +11824,10 @@ pbkdf2@^3.0.3, pbkdf2@^3.1.2: safe-buffer "^5.0.1" sha.js "^2.4.8" -petercat-lui@0.1.8: - version "0.1.8" - resolved "https://registry.npmjs.org/petercat-lui/-/petercat-lui-0.1.8.tgz#6ce68e95211419b13f3e4168f7ef13745cddaaa4" - integrity sha512-QtFmLRj047mb4PNlqHvOYCs7GVBQHdTmJRWts3gRGj0rRJjhV2WnXSiXF87u9mP/ujhZ1BiLbPGkWel0VsDDTA== +petercat-lui@0.1.9: + version "0.1.9" + resolved "https://registry.npmjs.org/petercat-lui/-/petercat-lui-0.1.9.tgz#0829e066eafb43479da865e52b9347d4f5fc486d" + integrity sha512-USU87SNG/sQPWh/nLyp8zcXnw+wrl5Tx1CqyG5V9X8OjiJcoATqj3tGDfupxrCABtC0OM3q6Z6nBEZefImB50A== dependencies: "@ant-design/icons" "^5.3.5" "@ant-design/pro-chat" "^1.9.0" From 6c65cd184f8428824b49dc6697cf0c82187dff26 Mon Sep 17 00:00:00 2001 From: yingying Date: Sun, 18 Aug 2024 22:51:07 +0800 Subject: [PATCH 3/4] chore: fprmat --- server/event_handler/discussion.py | 52 +++++++++++------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/server/event_handler/discussion.py b/server/event_handler/discussion.py index 9c889414..2820c017 100644 --- a/server/event_handler/discussion.py +++ b/server/event_handler/discussion.py @@ -1,4 +1,3 @@ - import requests from typing import Any from github import Github, Auth @@ -7,7 +6,8 @@ from petercat_utils.data_class import ChatData, Message, TextContentBlock -class DiscussionEventHandler(): + +class DiscussionEventHandler: event: Any auth: Auth.AppAuth installation_id: int @@ -20,12 +20,12 @@ def __init__(self, payload: Any, auth: Auth.AppAuth, installation_id: int) -> No self.installation_id = installation_id self.g: Github = Github(auth=auth) self.graph_url = "https://api.github.com/graphql" - + async def get_discussion_id(self, owner: str, repo: str, discussion_number: int): - access_token= self.auth.token + access_token = self.auth.token headers = { "Authorization": f"Bearer {access_token}", - "Accept": "application/vnd.github.v3+json" + "Accept": "application/vnd.github.v3+json", } query = """ query($owner: String!, $repo: String!, $discussionNumber: Int!) { @@ -39,27 +39,23 @@ async def get_discussion_id(self, owner: str, repo: str, discussion_number: int) variables = { "owner": owner, "repo": repo, - "discussionNumber": discussion_number - } - json_data={ - "query": query, - "variables": variables + "discussionNumber": discussion_number, } + json_data = {"query": query, "variables": variables} response = requests.post(self.graph_url, headers=headers, json=json_data) if response.status_code == 200: print("获取讨论成功!") - return response.json()['data']['repository']['discussion']['id'] + return response.json()["data"]["repository"]["discussion"]["id"] else: print(f"出现错误:{response.status_code}") print(response.json()) - async def create_discussion_comment(self, discussion_id: int, comment_body: str): - access_token= self.auth.token + access_token = self.auth.token headers = { "Authorization": f"Bearer {access_token}", - "Accept": "application/vnd.github.v3+json" + "Accept": "application/vnd.github.v3+json", } query = """ mutation($discussionId: ID!, $body: String!) { @@ -72,15 +68,9 @@ async def create_discussion_comment(self, discussion_id: int, comment_body: str) } } """ - variables = { - "discussionId": discussion_id, - "body": comment_body - } - - json_data={ - "query": query, - "variables": variables - } + variables = {"discussionId": discussion_id, "body": comment_body} + + json_data = {"query": query, "variables": variables} response = requests.post(self.graph_url, headers=headers, json=json_data) if response.status_code == 200: @@ -90,25 +80,21 @@ async def create_discussion_comment(self, discussion_id: int, comment_body: str) print(response.json()) async def handle_discussion_event(self, action: str): - owner = self.event['organization']["login"] - repo = self.event['repository']["name"] + owner = self.event["organization"]["login"] + repo = self.event["repository"]["name"] discussion = self.event["discussion"] discussion_content = f"{discussion['title']}: {discussion['body']}" - text_block = TextContentBlock( - type="text", - text=discussion_content - ) + text_block = TextContentBlock(type="text", text=discussion_content) discussion_number = discussion["number"] message = Message(role="user", content=[text_block]) analysis_result = await agent_chat(ChatData(messages=[message])) discussion_id = await self.get_discussion_id(owner, repo, discussion_number) - await self.create_discussion_comment(discussion_id, analysis_result['output']) + await self.create_discussion_comment(discussion_id, analysis_result["output"]) - async def execute(self): try: - action = self.event['action'] + action = self.event["action"] if action in ["opened", "reopened"]: await self.handle_discussion_event(action) return {"success": True} @@ -119,5 +105,3 @@ async def execute(self): except GithubException as e: print(f"处理 GitHub 请求时出错: {e}") return {"success": False, "error": str(e)} - - \ No newline at end of file From bcddfaadfa9447007ba4dbafbb0e6272df1dbd8d Mon Sep 17 00:00:00 2001 From: yingying Date: Sun, 18 Aug 2024 22:58:00 +0800 Subject: [PATCH 4/4] chore: update the petercat_utils version --- server/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/requirements.txt b/server/requirements.txt index d6499384..9b8e0851 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -26,4 +26,4 @@ fastapi_auth0 requests pytest httpx -petercat_utils>=0.1.26 \ No newline at end of file +petercat_utils