Created
April 23, 2024 10:48
-
-
Save datancoffee/b0c46d9d04c5584ce2a1847f515de2eb to your computer and use it in GitHub Desktop.
This file contains 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
from typing import Any, List | |
from core.actions import Action | |
class GithubIssueToChat(Action): | |
def __init__(self, actionname: str = None): | |
super().__init__(actionname) | |
def do(self, issues:List, comments:List, *args:Any, **kwargs: Any) -> List: | |
issue_body = issues[0]['body'] | |
issue_author = issues[0]['user▶login'] | |
messages = [] | |
messages.append({"role": "user", "content": issue_body}) | |
for comment in comments: | |
author_association = comment['author_association'] | |
comment_author = comment['user▶login'] | |
if author_association == 'COLLABORATOR' and issue_author != comment_author: | |
role = 'assistant' | |
else: | |
role = 'user' | |
comment_body = comment['body'] | |
messages.append({"role": role, "content": comment_body}) | |
return messages | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment