devai-api/app/jira.py [37:105]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jira = JiraAPIWrapper()
toolkit = JiraToolkit.from_jira_api_wrapper(jira)
agent = initialize_agent(
    toolkit.get_tools(), 
    llm, 
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, 
    verbose=True,
    handle_parsing_errors=True,
    max_iterations=5,
    return_intermediate_steps=True,
    early_stopping_method="generate",
)


def create_issue(description: str) -> str:
    """Creates a Jira issue"""
    JIRA_USERNAME = os.environ["JIRA_USERNAME"]
    JIRA_API_TOKEN = os.environ["JIRA_API_TOKEN"]
    JIRA_INSTANCE_URL = os.environ["JIRA_INSTANCE_URL"]
    JIRA_PROJECT_KEY = os.environ["JIRA_PROJECT_KEY"]

    summary = "Issue {}".format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))

    issue_type = "Task"
    project_key=JIRA_PROJECT_KEY
    jira = JIRA(basic_auth=(JIRA_USERNAME, JIRA_API_TOKEN), server=JIRA_INSTANCE_URL)

    issue_dict = {
        'project': {'key': project_key},
        'summary': summary,
        'description': description,
        'issuetype': {'name': issue_type},
        
    }
    new_issue = jira.create_issue(fields=issue_dict)
    resp = f'New issue created with key: {new_issue.key}'
    
    print(resp)
    return resp

create_issue_tool = StructuredTool.from_function(create_issue, description="Create a new JIRA issue")

create_agent = initialize_agent(
    [create_issue_tool],
    llm,
    agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, 
    verbose=True,
    handle_parsing_errors=True,
    max_iterations=5,
    return_intermediate_steps=True,
    early_stopping_method="generate",
)

@click.command()
@click.option('-c', '--context', required=False, type=str, default="")
def list(context):
    agent("""
    INSTRUCTIONS:
    Only read data - do not try to create/write/update any data.
    
    List JIRA tickets in the project {}. 
    Print/format output as a list with ticket number use template below,  description and summary.
    Example:
    Issue-1: Issue Description # 1
    Issue-2: Issue Description # 2
    """.format(context))


def create_jira_issue(summary, context):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



devai-cli/src/devai/commands/jira.py [35:103]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jira = JiraAPIWrapper()
toolkit = JiraToolkit.from_jira_api_wrapper(jira)
agent = initialize_agent(
    toolkit.get_tools(), 
    llm, 
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, 
    verbose=True,
    handle_parsing_errors=True,
    max_iterations=5,
    return_intermediate_steps=True,
    early_stopping_method="generate",
)


def create_issue(description: str) -> str:
    """Creates a Jira issue"""
    JIRA_USERNAME = os.environ["JIRA_USERNAME"]
    JIRA_API_TOKEN = os.environ["JIRA_API_TOKEN"]
    JIRA_INSTANCE_URL = os.environ["JIRA_INSTANCE_URL"]
    JIRA_PROJECT_KEY = os.environ["JIRA_PROJECT_KEY"]

    summary = "Issue {}".format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))

    issue_type = "Task"
    project_key=JIRA_PROJECT_KEY
    jira = JIRA(basic_auth=(JIRA_USERNAME, JIRA_API_TOKEN), server=JIRA_INSTANCE_URL)

    issue_dict = {
        'project': {'key': project_key},
        'summary': summary,
        'description': description,
        'issuetype': {'name': issue_type},
        
    }
    new_issue = jira.create_issue(fields=issue_dict)
    resp = f'New issue created with key: {new_issue.key}'
    
    print(resp)
    return resp

create_issue_tool = StructuredTool.from_function(create_issue, description="Create a new JIRA issue")

create_agent = initialize_agent(
    [create_issue_tool],
    llm,
    agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, 
    verbose=True,
    handle_parsing_errors=True,
    max_iterations=5,
    return_intermediate_steps=True,
    early_stopping_method="generate",
)

@click.command()
@click.option('-c', '--context', required=False, type=str, default="")
def list(context):
    agent("""
    INSTRUCTIONS:
    Only read data - do not try to create/write/update any data.
    
    List JIRA tickets in the project {}. 
    Print/format output as a list with ticket number use template below,  description and summary.
    Example:
    Issue-1: Issue Description # 1
    Issue-2: Issue Description # 2
    """.format(context))


def create_jira_issue(summary, context):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



