langchain-ai / langchain

πŸ¦œπŸ”— Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.05k stars 14.65k forks source link

Tests are failing in local development #13081

Closed umair313 closed 6 months ago

umair313 commented 10 months ago

System Info

langchain cloned peortry with python v3.11.4 openai v1.1.1

Who can help?

No response

Information

Related Components

Reproduction

cloned the repositpry cd to libs/langchain

poetry install --with test
make test

output

....
FAILED tests/unit_tests/llms/test_anyscale.py::test_api_key_is_secret_string - AttributeError: module 'openai' has no attribute 'ChatCompletion'
FAILED tests/unit_tests/llms/test_anyscale.py::test_api_key_masked_when_passed_from_env - AttributeError: module 'openai' has no attribute 'ChatCompletion'
FAILED tests/unit_tests/llms/test_anyscale.py::test_api_key_masked_when_passed_via_constructor - AttributeError: module 'openai' has no attribute 'ChatCompletion'
FAILED tests/unit_tests/llms/test_gooseai.py::test_api_key_is_secret_string - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_gooseai.py::test_api_key_masked_when_passed_via_constructor - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_gooseai.py::test_api_key_masked_when_passed_from_env - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_openai.py::test_openai_model_param - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_openai.py::test_openai_model_kwargs - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_openai.py::test_openai_incorrect_field - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_openai.py::test_openai_retries - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/llms/test_openai.py::test_openai_async_retries - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_dump.py::test_serialize_openai_llm - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_dump.py::test_serialize_llmchain - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_dump.py::test_serialize_llmchain_env - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_dump.py::test_serialize_llmchain_with_non_serializable_arg - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_loads_openai_llm - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_loads_llmchain - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_loads_llmchain_env - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_loads_llmchain_with_non_serializable_arg - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_load_openai_llm - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_load_llmchain - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_load_llmchain_env - AttributeError: module 'openai' has no attribute 'Completion'
FAILED tests/unit_tests/load/test_load.py::test_load_llmchain_with_non_serializable_arg - AttributeError: module 'openai' has no attribute 'Completion'
==================================================================================== 23 failed, 1348 passed, 270 skipped, 24 warnings in 16.11s =========================================================

Expected behavior

All tests should pass or skipped without failing.

dosubot[bot] commented 10 months ago

πŸ€–

Hello @umair313,

Nice to talk to you again! I see you're having some trouble with tests failing in your local development environment. I will take a look into this issue and get back to you with a more complete response shortly.

dosubot[bot] commented 10 months ago

πŸ€–

Based on the error messages you've shared, it seems like the version of the OpenAI library you're using (v1.1.1) might not be compatible with the current version of LangChain (v0.0.331rc2). The errors indicate that the 'ChatCompletion' and 'Completion' attributes are not found in the 'openai' module, which suggests that these attributes might have been introduced in a later version of the OpenAI library.

The LangChain framework is compatible with version 1.0.0 and above of the OpenAI library. However, the 'ChatCompletion' and 'Completion' attributes are used extensively in the LangChain codebase, particularly in the 'ChatOpenAI' class and the 'completion_with_retry' and 'acompletion_with_retry' methods. If these attributes are not found in the 'openai' module, it's likely due to an old version of the 'openai' package, and users are advised to upgrade it.

I would recommend updating your OpenAI library to the latest version and then try running the tests again. You can do this by running the following command in your terminal:

pip install --upgrade openai

After upgrading, please try running the tests again and let me know if you're still encountering these issues.

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.

umair313 commented 10 months ago

@dosu-bot what are steps to start contributing?

dosubot[bot] commented 10 months ago

πŸ€–

Sure, I'd be happy to guide you on how to start contributing to the LangChain project. Here are the steps you can follow:

  1. Identify a new feature you want to propose or an existing issue you want to solve.
  2. Go to the LangChain GitHub repository and click on "New issue".
  3. Choose the "Feature request" template.
  4. Fill in the form with the following details:
    • Feature request: Provide a clear and concise description of the feature proposal. Include links to any relevant GitHub repos, papers, or other resources if relevant.
    • Motivation: Outline the motivation for the proposal. If your feature request is related to a problem, describe it here. If this is related to another GitHub issue, link it here too.
    • Your contribution: Describe how you can help, for example, by submitting a PR. Make sure to read the CONTRIBUTING.MD readme

Please note that all fields are required, so make sure to fill in all the information before submitting your feature request.

If you are a first-time contributor, you can start by trying one of the PRs with the β€œgood first issue” tag. You can also become an expert by helping the community answer product questions in Discord. If you have a product that integrates with LangChain, you can become an Integration Maintainer and partner with the LangChain team to ensure your integration stays up-to-date. For these roles, introduce yourself by sending an email to hello@langchain.dev.

Once you have made your changes and are ready to submit a pull request, you can use the create_pull_request method of the GitHubAPIWrapper class. This method takes a string parameter pr_query which contains the PR title and the PR body. The title is the first line in the string, and the body are the rest of the string. Here is the relevant code snippet:

def create_pull_request(self, pr_query: str) -> str:
    """
    Makes a pull request from the bot's branch to the base branch
    Parameters:
        pr_query(str): a string which contains the PR title
        and the PR body. The title is the first line
        in the string, and the body are the rest of the string.
        For example, "Updated README\nmade changes to add info"
    Returns:
        str: A success or failure message
    """
    if self.github_base_branch == self.github_branch:
        return """Cannot make a pull request because 
        commits are already in the master branch"""
    else:
        try:
            title = pr_query.split("\n")[0]
            body = pr_query[len(title) + 2 :]
            pr = self.github_repo_instance.create_pull(
                title=title,
                body=body,
                head=self.github_branch,
                base=self.github_base_branch,
            )
            return f"Successfully created PR number {pr.number}"
        except Exception as e:
            return "Unable to make pull request due to error:\n" + str(e)

This method will return a success message with the PR number if the pull request is created successfully, or an error message if the pull request creation fails.

I hope this helps! If you have any other questions, 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[bot] commented 7 months ago

Hi, @umair313,

I'm helping the LangChain team manage their backlog and am marking this issue as stale. From what I understand, the issue involves failing tests in local development due to missing attributes in the openai module. The recommended solution is to upgrade the OpenAI library to the latest version and rerun the tests. Additionally, there is guidance on proposing new features and submitting pull requests for contributing to the LangChain project.

Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and cooperation. If you have any further questions or need assistance, feel free to reach out.