{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "245a954a", "metadata": {}, "source": [ "# Jira\n", "\n", "This notebook goes over how to use the Jira tool.\n", "The Jira tool allows agents to interact with a given Jira instance, performing actions such as searching for issues and creating issues, the tool wraps the atlassian-python-api library, for more see: https://atlassian-python-api.readthedocs.io/jira.html\n", "\n", "To use this tool, you must first set as environment variables:\n", " JIRA_API_TOKEN\n", " JIRA_USERNAME\n", " JIRA_INSTANCE_URL" ] }, { "cell_type": "code", "execution_count": null, "id": "961b3689", "metadata": { "vscode": { "languageId": "shellscript" }, "ExecuteTime": { "start_time": "2023-04-17T10:21:18.698672Z", "end_time": "2023-04-17T10:21:20.168639Z" } }, "outputs": [], "source": [ "%pip install atlassian-python-api" ] }, { "cell_type": "code", "execution_count": 2, "id": "34bb5968", "metadata": { "ExecuteTime": { "start_time": "2023-04-17T10:21:22.911233Z", "end_time": "2023-04-17T10:21:23.730922Z" } }, "outputs": [], "source": [ "import os\n", "from langchain.agents import AgentType\n", "from langchain.agents import initialize_agent\n", "from langchain.agents.agent_toolkits.jira.toolkit import JiraToolkit\n", "from langchain.llms import OpenAI\n", "from langchain.utilities.jira import JiraAPIWrapper" ] }, { "cell_type": "code", "execution_count": 4, "outputs": [], "source": [ "os.environ[\"JIRA_API_TOKEN\"] = \"abc\"\n", "os.environ[\"JIRA_USERNAME\"] = \"123\"\n", "os.environ[\"JIRA_INSTANCE_URL\"] = \"https://jira.atlassian.com\"\n", "os.environ[\"OPENAI_API_KEY\"] = \"xyz\"" ], "metadata": { "collapsed": false, "ExecuteTime": { "start_time": "2023-04-17T10:22:42.499447Z", "end_time": "2023-04-17T10:22:42.505412Z" } }, "id": "b3050b55" }, { "cell_type": "code", "execution_count": 5, "id": "ac4910f8", "metadata": { "ExecuteTime": { "start_time": "2023-04-17T10:22:44.664481Z", "end_time": "2023-04-17T10:22:44.720538Z" } }, "outputs": [], "source": [ "llm = OpenAI(temperature=0)\n", "jira = JiraAPIWrapper()\n", "toolkit = JiraToolkit.from_jira_api_wrapper(jira)\n", "agent = initialize_agent(\n", " toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True\n", ")" ] }, { "cell_type": "code", "execution_count": 9, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", "\u001b[32;1m\u001b[1;3m I need to create an issue in project PW\n", "Action: Create Issue\n", "Action Input: {\"summary\": \"Make more fried rice\", \"description\": \"Reminder to make more fried rice\", \"issuetype\": {\"name\": \"Task\"}, \"priority\": {\"name\": \"Low\"}, \"project\": {\"key\": \"PW\"}}\u001b[0m\n", "Observation: \u001b[38;5;200m\u001b[1;3mNone\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n", "Final Answer: A new issue has been created in project PW with the summary \"Make more fried rice\" and description \"Reminder to make more fried rice\".\u001b[0m\n", "\n", "\u001b[1m> Finished chain.\u001b[0m\n" ] }, { "data": { "text/plain": "'A new issue has been created in project PW with the summary \"Make more fried rice\" and description \"Reminder to make more fried rice\".'" }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.run(\"make a new issue in project PW to remind me to make more fried rice\")" ], "metadata": { "collapsed": false, "ExecuteTime": { "start_time": "2023-04-17T10:23:33.662454Z", "end_time": "2023-04-17T10:23:38.121883Z" } }, "id": "d5461370" } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" }, "vscode": { "interpreter": { "hash": "53f3bc57609c7a84333bb558594977aa5b4026b1d6070b93987956689e367341" } } }, "nbformat": 4, "nbformat_minor": 5 }