diff --git a/langchain/tools/jira/__init__.py b/langchain/tools/jira/__init__.py
index ef6b8a2aa6..06cd8cbcd9 100644
--- a/langchain/tools/jira/__init__.py
+++ b/langchain/tools/jira/__init__.py
@@ -1 +1 @@
-"""Zapier Tool."""
+"""Jira Tool."""
diff --git a/langchain/tools/jira/prompt.py b/langchain/tools/jira/prompt.py
index eb97b818b6..a50c373c9a 100644
--- a/langchain/tools/jira/prompt.py
+++ b/langchain/tools/jira/prompt.py
@@ -32,3 +32,10 @@ JIRA_CATCH_ALL_PROMPT = """
self.jira.projects()
For more information on the Jira API, refer to https://atlassian-python-api.readthedocs.io/jira.html
"""
+
+JIRA_CONFLUENCE_PAGE_CREATE_PROMPT = """This tool is a wrapper around atlassian-python-api's Confluence
+atlassian-python-api API, useful when you need to create a Confluence page. The input to this tool is a dictionary
+specifying the fields of the Confluence page, and will be passed into atlassian-python-api's Confluence `create_page`
+function. For example, to create a page in the DEMO space titled "This is the title" with body "This is the body. You can use
+HTML tags!", you would pass in the following dictionary: {{"space": "DEMO", "title":"This is the
+title","body":"This is the body. You can use HTML tags!"}} """
diff --git a/langchain/utilities/jira.py b/langchain/utilities/jira.py
index af6b38a855..3f3719437e 100644
--- a/langchain/utilities/jira.py
+++ b/langchain/utilities/jira.py
@@ -5,6 +5,7 @@ from pydantic import BaseModel, Extra, root_validator
from langchain.tools.jira.prompt import (
JIRA_CATCH_ALL_PROMPT,
+ JIRA_CONFLUENCE_PAGE_CREATE_PROMPT,
JIRA_GET_ALL_PROJECTS_PROMPT,
JIRA_ISSUE_CREATE_PROMPT,
JIRA_JQL_PROMPT,
@@ -17,6 +18,7 @@ class JiraAPIWrapper(BaseModel):
"""Wrapper for Jira API."""
jira: Any #: :meta private:
+ confluence: Any
jira_username: Optional[str] = None
jira_api_token: Optional[str] = None
jira_instance_url: Optional[str] = None
@@ -42,6 +44,11 @@ class JiraAPIWrapper(BaseModel):
"name": "Catch all Jira API call",
"description": JIRA_CATCH_ALL_PROMPT,
},
+ {
+ "mode": "create_page",
+ "name": "Create confluence page",
+ "description": JIRA_CONFLUENCE_PAGE_CREATE_PROMPT,
+ },
]
class Config:
@@ -69,7 +76,7 @@ class JiraAPIWrapper(BaseModel):
values["jira_instance_url"] = jira_instance_url
try:
- from atlassian import Jira
+ from atlassian import Confluence, Jira
except ImportError:
raise ImportError(
"atlassian-python-api is not installed. "
@@ -82,7 +89,16 @@ class JiraAPIWrapper(BaseModel):
password=jira_api_token,
cloud=True,
)
+
+ confluence = Confluence(
+ url=jira_instance_url,
+ username=jira_username,
+ password=jira_api_token,
+ cloud=True,
+ )
+
values["jira"] = jira
+ values["confluence"] = confluence
return values
@@ -151,7 +167,7 @@ class JiraAPIWrapper(BaseModel):
)
return parsed_projects_str
- def create(self, query: str) -> str:
+ def issue_create(self, query: str) -> str:
try:
import json
except ImportError:
@@ -161,6 +177,16 @@ class JiraAPIWrapper(BaseModel):
params = json.loads(query)
return self.jira.issue_create(fields=dict(params))
+ def page_create(self, query: str) -> str:
+ try:
+ import json
+ except ImportError:
+ raise ImportError(
+ "json is not installed. Please install it with `pip install json`"
+ )
+ params = json.loads(query)
+ return self.confluence.create_page(**dict(params))
+
def other(self, query: str) -> str:
context = {"self": self}
exec(f"result = {query}", context)
@@ -173,8 +199,10 @@ class JiraAPIWrapper(BaseModel):
elif mode == "get_projects":
return self.project()
elif mode == "create_issue":
- return self.create(query)
+ return self.issue_create(query)
elif mode == "other":
return self.other(query)
+ elif mode == "create_page":
+ return self.page_create(query)
else:
raise ValueError(f"Got unexpected mode {mode}")
diff --git a/tests/integration_tests/utilities/test_jira_api.py b/tests/integration_tests/utilities/test_jira_api.py
index 9be6c88a75..fa44a6014d 100644
--- a/tests/integration_tests/utilities/test_jira_api.py
+++ b/tests/integration_tests/utilities/test_jira_api.py
@@ -27,3 +27,17 @@ def test_create_ticket() -> None:
output = jira.run("create_issue", issue_string)
assert "id" in output
assert "key" in output
+
+
+def test_create_confluence_page() -> None:
+ """Test for getting projects on JIRA"""
+ jira = JiraAPIWrapper()
+ create_page_dict = (
+ '{"space": "ROC", "title":"This is the title",'
+ '"body":"This is the body. You can use '
+ 'HTML tags!"}'
+ )
+
+ output = jira.run("create_page", create_page_dict)
+ assert "type" in output
+ assert "page" in output