Skip to content

Commit

Permalink
updated create and update issue code and added new use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dundermain committed Nov 18, 2024
1 parent 0f1cd3c commit 425819a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions cookbook/tools/linear_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@

user_id = "69069"
issue_id = "6969"
team_id = "73"
new_title = "updated title for issue"
new_issue_title = "title for new issue"
desc = "issue description"

agent.print_response("Get all the details of current user")
agent.print_response(f"Show the issue with the issue id: {issue_id}")
agent.print_response(
f"Create a new issue with the title: {new_issue_title} with description: {desc} and team id: {team_id}"
)
agent.print_response(f"Update the issue with the issue id: {issue_id} with new title: {new_title}")
agent.print_response(f"Show all the issues assigned to user id: {user_id}")
agent.print_response("Show all the high priority issues")
11 changes: 5 additions & 6 deletions phi/tools/linear_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def create_issue(self, title: str, description: str, team_id: str) -> Optional[s
"""

query = """
mutation IssueCreate{
mutation IssueCreate ($title: String!, $description: String!, $teamId: String!){
issueCreate(
input: { title: $title, description: $description, teamId: $teamId }
) {
Expand Down Expand Up @@ -192,14 +192,13 @@ def create_issue(self, title: str, description: str, team_id: str) -> Optional[s
logger.error(f"Error creating issue '{title}' for team ID {team_id}: {e}")
raise

def update_issue(self, issue_id: str, title: Optional[str], state_id: Optional[str]) -> Optional[str]:
def update_issue(self, issue_id: str, title: Optional[str]) -> Optional[str]:
"""
Update the title or state of a specific issue by issue ID.
Args:
issue_id (str): The unique identifier of the issue to update.
title (str, optional): The new title for the issue. If None, the title remains unchanged.
state_id (str, optional): The new state identifier for the issue. If None, the state remains unchanged.
Returns:
str or None: A string containing the updated issue's details with issue id, issue title, and issue state (which includes `id` and `name`).
Expand All @@ -210,10 +209,10 @@ def update_issue(self, issue_id: str, title: Optional[str], state_id: Optional[s
"""

query = """
mutation IssueUpdate {
mutation IssueUpdate ($issueId: String!, $title: String!){
issueUpdate(
id: $issueId,
input: { title: $title, stateId: $stateId }
input: { title: $title}
) {
success
issue {
Expand All @@ -227,7 +226,7 @@ def update_issue(self, issue_id: str, title: Optional[str], state_id: Optional[s
}
}
"""
variables = {"issueId": issue_id, "title": title, "stateId": state_id}
variables = {"issueId": issue_id, "title": title}

try:
response = self._execute_query(query, variables)
Expand Down

0 comments on commit 425819a

Please sign in to comment.