Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}} #16197

Closed
4 of 15 tasks
Prince3141 opened this issue Jan 18, 2024 · 1 comment
Closed
4 of 15 tasks
Labels
🔌: aws Primarily related to Amazon Web Services (AWS) integrations 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: models Related to LLMs or chat model modules

Comments

@Prince3141
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.

Example Code

First

import openai
import streamlit as st
from langchain_experimental.agents.agent_toolkits import create_csv_agent
from langchain.chat_models import AzureChatOpenAI
from langchain.llms import AzureOpenAI
from langchain.agents.agent_types import AgentType
from langchain.llms import AzureOpenAI
from dotenv import load_dotenv
import os
import openai
import streamlit as st
import warnings
import pandas as pd
warnings.filterwarnings("ignore")

st.sidebar.title("Powered by: GSC Data & Analytics")
st.sidebar.markdown(
"""
Upload your csv files and do basic query over it
"""
)
st.header("Ask your CSV 📈",divider='rainbow')

def _handle_error(error) -> str:
return str(error)[:200]

csv_files = st.file_uploader("Upload a CSV file", type={"csv"},accept_multiple_files=True)
if csv_files is not None:
selected_file = st.selectbox("Select a CSV file", [file.name for file in csv_files])
selected_index = [file.name for file in csv_files].index(selected_file)
data = pd.read_csv(csv_files[selected_index])
data.to_csv(selected_file)
st.dataframe(data,use_container_width=True)
agent = create_csv_agent(
AzureChatOpenAI(openai_api_type="azure"
,openai_api_key= open_api_key
,openai_api_base = "https://openai-nonfunsbx-pprd-01.openai.azure.com"
,openai_api_version="2023-03-15-preview"
,deployment_name="gpt-35-turbo-0301"
),selected_file, verbose=True,
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=_handle_error)

if "messages" not in st.session_state:
    st.session_state["messages"] = [{"role": "assistant", "content": "How can I help you?"}]

for msg in st.session_state.messages:
    st.chat_message(msg["role"]).write(msg["content"])

if prompt := st.chat_input():
    st.chat_message("user").write(prompt)
    st.session_state.messages.append({"role": "user", "content": prompt})
    with st.chat_message("assistant"):
        st.write(":brain: thinking...")
        response = agent.run(prompt)
        st.session_state["messages"].append({"role": "assistant", "content": response})
        st.write(response)

Description

It works fine in local but when we deploy on ec2 server it is giving error:
NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
Traceback:

File "/home/adm683533/chatcsv/env/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
exec(code, module.dict)
File "/home/adm683533/chatcsv/chatcsv_v2/app7.py", line 80, in
response = agent.run(prompt)
File "/home/adm683533/chatcsv/env/lib/python3.10/site-packages/langchain_core/_api/deprecation.py", line 145, in warning_emitting_wrapper
return wrapped(*args, **kwargs)
File "/home/adm683533/chatcsv/env/lib/python3.10/site-packages/langchain/chains/base.py", line 538, in run
return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
File "/home/adm683533/chatcsv/env/lib/python3.10/site-packages/langchain_core/_api/deprecation.py", line 145, in warning_emitting_wrapper
return wrapped(*args, **kwargs)

System Info

langchain version 0.1.0
python version 3.10

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async
Copy link

dosubot bot commented Jan 18, 2024

🤖

Hi @Prince3141! 🖐️

I'm Dosu, a friendly bot here to lend a helping hand! 🚀 I can assist with troubleshooting bugs, answering queries, or even guiding you towards becoming a great contributor. Consider me your companion while we wait for a human maintainer to chime in.

Let's solve some codes together, shall we? 🧩

The "NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}" error you're encountering when deploying your LangChain application on an EC2 server is likely due to the OpenSearch index not being found or created on the OpenSearch server you're connecting to.

In the provided code, the OpenSearch index is created when the _bulk_ingest_embeddings function is called. This function tries to get the index with the provided index_name and if it doesn't exist, it creates a new one:

try:
    client.indices.get(index=index_name)
except not_found_error:
    client.indices.create(index=index_name, body=mapping)

If the index doesn't exist and cannot be created, a NotFoundError will be raised. This could happen if the OpenSearch server isn't running, isn't accessible from the EC2 server, or if there are permission issues preventing the index from being created.

To resolve this issue, ensure that:

  1. The OpenSearch server is running and accessible from the EC2 server.
  2. The EC2 server has the necessary permissions to create indices on the OpenSearch server.
  3. The index_name provided when calling the _bulk_ingest_embeddings function is correct.

You can find more details about this in the OpenSearch Vector Search file in the LangChain repository.

Regarding the AzureChatOpenAI class, it serves as a wrapper for the Azure OpenAI Chat Completion API. It is designed to interact with a deployed model on Azure OpenAI, and it uses various environment variables or constructor parameters to authenticate and interact with the Azure OpenAI API. You can find more details about this in the Azure file in the LangChain repository.

As for the create_csv_agent function, I wasn't able to find specific information about it in the LangChain repository. It might be a custom function in your code or part of a different library. If you could provide more context or information about this function, I might be able to provide a more accurate answer.

I hope this helps! If you have any more questions or need further clarification, feel free to ask.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added Ɑ: models Related to LLMs or chat model modules 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: aws Primarily related to Amazon Web Services (AWS) integrations labels Jan 18, 2024
@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 18, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔌: aws Primarily related to Amazon Web Services (AWS) integrations 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: models Related to LLMs or chat model modules
Projects
None yet
Development

No branches or pull requests

1 participant