Querying jira tickets using from langchain_community.agent_toolkits.jira.toolkit import JiraToolkit #26317
Replies: 1 comment
-
|
Hey @shalinibnair! How can I assist you today? I'm here to help with any bugs, questions, or contributions you have in mind. To handle pagination and retrieve more than the first 50 results when querying Jira using the However, you can try the following general approach to handle pagination:
Here's an example of how you might modify your code to handle pagination: from langchain.agents import AgentType, initialize_agent
from langchain_community.agent_toolkits.jira.toolkit import JiraToolkit
from langchain_community.utilities.jira import JiraAPIWrapper
# Initialize the Jira API wrapper
jira_api_wrapper = JiraAPIWrapper(api_key="your_api_key", server="your_jira_server")
# Create the JiraToolkit from the JiraAPIWrapper
jira_toolkit = JiraToolkit.from_jira_api_wrapper(jira_api_wrapper)
# Initialize the agent with the JiraToolkit tools
agent = initialize_agent(tools=jira_toolkit.get_tools(), llm=llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
# Define the JQL query
jql_query = "project = DHP AND (issuetype = Task OR issuetype = Story)"
# Function to fetch all results with pagination
def fetch_all_results(jql_query, max_results=50):
start_at = 0
all_results = []
while True:
paginated_query = f"{jql_query} ORDER BY created ASC&startAt={start_at}&maxResults={max_results}"
prompt = _prompt.format(input=paginated_query)
response = agent.run(prompt)
results = response['issues']
if not results:
break
all_results.extend(results)
start_at += max_results
return all_results
# Fetch all results
all_issues = fetch_all_results(jql_query)This code snippet demonstrates how to handle pagination by iterating over pages of results and combining them into a single list. Adjust the If you need more specific details or examples, you may need to refer to the Jira API documentation or the implementation details of the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to use JiraToolkit to get the records from jira based on a question asked by the user.
The issue I am facing is that the answer returned by the agent return only first 50. How to get the entire result.
Langchain documentation gives sample of deprecated usage
System Info
latest stable version of langchain
Beta Was this translation helpful? Give feedback.
All reactions