langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
88.3k stars 13.85k forks source link

Jira toolkit prompt for create ticket does not include project ID #20084

Open samuelbirocchi opened 2 months ago

samuelbirocchi commented 2 months ago

Checked other resources

Example Code

import os

from langchain_community.llms import Ollama
from langchain.agents import AgentType, initialize_agent
from langchain_community.agent_toolkits.jira.toolkit import JiraToolkit
from langchain_community.utilities.jira import JiraAPIWrapper
from langchain_core.prompts import ChatPromptTemplate

os.environ["JIRA_API_TOKEN"] = "token"
os.environ["JIRA_USERNAME"] = "user"
os.environ["JIRA_INSTANCE_URL"] = "https://jira.atlassian.net"

llm = Ollama(model="llama2:13b")

jira = JiraAPIWrapper()
toolkit = JiraToolkit.from_jira_api_wrapper(jira)
agent = initialize_agent(
    toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)

# chain = prompt | chat

resp = agent.invoke(
    "make a new issue in project id 'MUG' to remind me to make more fried rice"
)

Error Message and Stack Trace (if applicable)

LangChainDeprecationWarning: The function `initialize_agent` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc. instead.
  warn_deprecated(

> Entering new AgentExecutor chain...
  Question: make a new issue in project id 'MUG' to remind me to make more fried rice

Thought: I should create a new issue in the MUG project to remind myself to make more fried rice.

Action: Create Issue

Action Input: {
"summary": "Reminder to make more fried rice",
"description": "I want to make more fried rice, this is a reminder.",
"issuetype": {"name": "Task"},
"priority": {"name": "Low"}
}Creating issue "Reminder to make more fried rice"
Traceback (most recent call last):
  File "/Users/samuelbirocchi/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/samuelbirocchi/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/samuelbirocchi/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/Users/samuelbirocchi/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/Users/samuelbirocchi/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/samuelbirocchi/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/Users/samuelbirocchi/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/samuelbirocchi/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "./main.py", line 45, in <module>
    resp = agent.invoke(
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/chains/base.py", line 163, in invoke
    raise e
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/chains/base.py", line 153, in invoke
    self._call(inputs, run_manager=run_manager)
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1432, in _call
    next_step_output = self._take_next_step(
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1138, in _take_next_step
    [
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1138, in <listcomp>
    [
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1223, in _iter_next_step
    yield self._perform_agent_action(
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1245, in _perform_agent_action
    observation = tool.run(
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain_core/tools.py", line 422, in run
    raise e
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain_core/tools.py", line 381, in run
    self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain_community/tools/jira/tool.py", line 44, in _run
    return self.api_wrapper.run(self.mode, instructions)
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain_community/utilities/jira.py", line 168, in run
    return self.issue_create(query)
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/langchain_community/utilities/jira.py", line 139, in issue_create
    return self.jira.issue_create(fields=dict(params))
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/atlassian/jira.py", line 1537, in issue_create
    return self.post(url, data={"fields": fields})
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/atlassian/rest_client.py", line 388, in post
    response = self.request(
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/atlassian/rest_client.py", line 312, in request
    self.raise_for_status(response)
  File "/Users/samuelbirocchi/langchain/.venv/lib/python3.10/site-packages/atlassian/rest_client.py", line 549, in raise_for_status
    raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError

Description

I'm trying to create a Jira ticket following the documentation

System Info

langchain==0.1.14 langchain-community==0.0.31 langchain-core==0.1.40 langchain-text-splitters==0.0.1

Python 3.10.13

dverma12 commented 1 month ago

Same issue for me . Search is working fine but create issue is failing

adirmom commented 3 weeks ago

Same issue for me as well, have you tried any other way or do you have any suggestions please let me know