microsoft / gpt-review

MIT License
256 stars 48 forks source link

[Bug Report]: ImportError: cannot import name 'BaseCache' from 'langchain' #230

Open mateusz-piasecki opened 7 months ago

mateusz-piasecki commented 7 months ago

Module path

id: review

review-gpt CLI version

0.9.5

Describe the bug

Hello, is this repository / action still alive? I'm trying to run pipeline with this action and it fails on importing

ImportError: cannot import name 'BaseCache' from 'langchain' (/runner/_work/integration-service/integration-service/.env/lib/python3.11/site-packages/langchain/__init__.py)
Error: Process completed with exit code 1.

To be quite honest I'm not sure what else I could do when it fails on such step. Am I doing something wrong?

To reproduce

Run GitHub Action to review PR

Code snippet

name: "AI Code Review"

on:
  pull_request:
    paths-ignore:
      - "*.md"
jobs:
  review:
    runs-on: k8s
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: microsoft/gpt-review@v0.9.5
        name: "Code Review by GPT"
        id: review
        with:
          # Derivative token for using the GitHub REST API
          GITHUB_TOKEN: GITHUB_TOKEN
          # OpenAI API Key
          AZURE_OPENAI_API: ${{ vars.AZURE_OPENAPI_URL }}
          AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAPI_KEY }}

Relevant log output

No response

bacongobbler commented 7 months ago

I am also experiencing the same issue when installing gpt-review 0.9.5 on WSL2. Downgrading to earlier versions of gpt-review does not resolve the issue.

Full stack trace:

><> gpt --help
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/chat_models/__init__.py:31: LangChainDeprecationWarning: Importing chat models from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:

`from langchain_community.chat_models import AzureChatOpenAI`.

To install langchain-community run `pip install -U langchain-community`.
  warnings.warn(
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/chat_models/__init__.py:31: LangChainDeprecationWarning: Importing chat models from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:

`from langchain_community.chat_models import ChatOpenAI`.

To install langchain-community run `pip install -U langchain-community`.
  warnings.warn(
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/embeddings/__init__.py:29: LangChainDeprecationWarning: Importing embeddings from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:

`from langchain_community.embeddings import OpenAIEmbeddings`.

To install langchain-community run `pip install -U langchain-community`.
  warnings.warn(
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/llms/__init__.py:548: LangChainDeprecationWarning: Importing LLMs from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:

`from langchain_community.llms import AzureOpenAI`.

To install langchain-community run `pip install -U langchain-community`.
  warnings.warn(
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/__init__.py:29: UserWarning: Importing Cohere from langchain root module is no longer supported. Please use langchain_community.llms.Cohere instead.
  warnings.warn(
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/__init__.py:29: UserWarning: Importing LLMChain from langchain root module is no longer supported. Please use langchain.chains.LLMChain instead.
  warnings.warn(
/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/__init__.py:29: UserWarning: Importing OpenAI from langchain root module is no longer supported. Please use langchain_community.llms.OpenAI instead.
  warnings.warn(
Traceback (most recent call last):
  File "/home/bacongobbler/.local/bin/gpt", line 5, in <module>
    from gpt_review.main import __main__
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/gpt_review/main.py", line 6, in <module>
    from gpt_review._gpt_cli import cli
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/gpt_review/_gpt_cli.py", line 9, in <module>
    from gpt_review._ask import AskCommandGroup
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/gpt_review/_ask.py", line 12, in <module>
    from gpt_review._llama_index import _query_index
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/gpt_review/_llama_index.py", line 10, in <module>
    from llama_index import (
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/__init__.py", line 19, in <module>
    from llama_index.indices.common.struct_store.base import SQLDocumentContextBuilder
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/indices/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/indices/keyword_table/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/indices/keyword_table/base.py", line 18, in <module>
    from llama_index.indices.base import BaseGPTIndex
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/indices/base.py", line 6, in <module>
    from llama_index.chat_engine.types import BaseChatEngine, ChatMode
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/chat_engine/__init__.py", line 1, in <module>
    from llama_index.chat_engine.condense_question import CondenseQuestionChatEngine
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/chat_engine/condense_question.py", line 5, in <module>
    from llama_index.chat_engine.utils import to_chat_buffer
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/chat_engine/utils.py", line 6, in <module>
    from llama_index.indices.service_context import ServiceContext
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/indices/service_context.py", line 9, in <module>
    from llama_index.indices.prompt_helper import PromptHelper
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/indices/prompt_helper.py", line 13, in <module>
    from llama_index.llm_predictor.base import BaseLLMPredictor
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/llm_predictor/__init__.py", line 4, in <module>
    from llama_index.llm_predictor.base import LLMPredictor
  File "/home/bacongobbler/.local/lib/python3.10/site-packages/llama_index/llm_predictor/base.py", line 11, in <module>
    from langchain import BaseCache, Cohere, LLMChain, OpenAI
ImportError: cannot import name 'BaseCache' from 'langchain' (/home/bacongobbler/.local/lib/python3.10/site-packages/langchain/__init__.py)
bacongobbler commented 7 months ago

Hello, is this repository / action still alive?

My assumption is no... https://github.com/microsoft/gpt-review/commit/f5d17490699f87be9a66181b4460ef73bfc8339d