microsoft / gpt-review

MIT License
249 stars 48 forks source link

[Bug Report]: workflow action fails with ImportError #208

Open bbyong2410 opened 11 months ago

bbyong2410 commented 11 months ago

Module path

gpt github review

review-gpt CLI version

0.9.5

Describe the bug

The workflow fails with following error:

ImportError: cannot import name 'BaseCache' from 'langchain' (/home/runner/work/***/***/.env/lib/python3.11/site-packages/langchain/__init__.py)

Could not import BaseCache from langchain when Run source .env/bin/activate step in Run microsoft/gpt-review@v0.9.5.

To reproduce

Set this workflow .github/workflows/gpt-review.yml

name: GPT Review on Pull Request

on:
  pull_request_target:
    branches: [ 'main' ]

jobs:
  add_pr_comment:
    runs-on: ubuntu-latest
    name: OpenAI PR Comment
    steps:
      - id: review
        uses: microsoft/gpt-review@v0.9.5
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Code snippet

No response

Relevant log output

Run source .env/bin/activate
  source .env/bin/activate

  gpt github review \
    --access-token $GITHUB_TOKEN \
    --pull-request $PATCH_PR \
    --repository $PATCH_REPO
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.11.5/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.5/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.5/x64/lib
    ACTION_REF: v0.9.5
    GIT_COMMIT_HASH: ***
    GITHUB_TOKEN: ***
    LINK: ***
    OPENAI_API_KEY: ***
    OPENAI_ORG_KEY: 
    PR_TITLE: ***
    BRANCH: 
    AZURE_OPENAI_API_KEY: 
    AZURE_OPENAI_API: 
    PATCH_PR: 2
    PATCH_REPO: ***
    FULL_SUMMARY: true
    FILE_SUMMARY: false
    TEST_SUMMARY: false
    BUG_SUMMARY: false
    RISK_SUMMARY: false
    RISK_BREAKING: false
/home/runner/work/***/***/.env/lib/python3.11/site-packages/langchain/__init__.py:38: UserWarning: Importing Cohere from langchain root module is no longer supported.
  warnings.warn(
/home/runner/work/***/***/.env/lib/python3.11/site-packages/langchain/__init__.py:38: UserWarning: Importing LLMChain from langchain root module is no longer supported.
  warnings.warn(
/home/runner/work/***/***/.env/lib/python3.11/site-packages/langchain/__init__.py:38: UserWarning: Importing OpenAI from langchain root module is no longer supported.
  warnings.warn(
Traceback (most recent call last):
  File "/home/runner/work/***/***/.env/bin/gpt", line 5, in <module>
    from gpt_review.main import __main__
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/gpt_review/main.py", line 6, in <module>
    from gpt_review._gpt_cli import cli
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/gpt_review/_gpt_cli.py", line 9, in <module>
    from gpt_review._ask import AskCommandGroup
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/gpt_review/_ask.py", line 12, in <module>
    from gpt_review._llama_index import _query_index
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/gpt_review/_llama_index.py", line 10, in <module>
    from llama_index import (
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/__init__.py", line 19, in <module>
    from llama_index.indices.common.struct_store.base import SQLDocumentContextBuilder
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/indices/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/indices/keyword_table/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/indices/keyword_table/base.py", line 18, in <module>
    from llama_index.indices.base import BaseGPTIndex
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/indices/base.py", line 6, in <module>
    from llama_index.chat_engine.types import BaseChatEngine, ChatMode
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/chat_engine/__init__.py", line 1, in <module>
    from llama_index.chat_engine.condense_question import CondenseQuestionChatEngine
  File "/home/runner/work/***/***/.env/lib/python3.11/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/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/chat_engine/utils.py", line 6, in <module>
    from llama_index.indices.service_context import ServiceContext
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/indices/service_context.py", line 9, in <module>
    from llama_index.indices.prompt_helper import PromptHelper
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/indices/prompt_helper.py", line 13, in <module>
    from llama_index.llm_predictor.base import BaseLLMPredictor
  File "/home/runner/work/***/***/.env/lib/python3.11/site-packages/llama_index/llm_predictor/__init__.py", line 4, in <module>
    from llama_index.llm_predictor.base import LLMPredictor
  File "/home/runner/work/***/***/.env/lib/python3.11/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/runner/work/***/***/.env/lib/python3.11/site-packages/langchain/__init__.py)
Error: Process completed with exit code 1.
VishalHaibatpure1 commented 11 months ago

Any resolution for this issue?

Masaki-U commented 11 months ago

@bbyong2410 @VishalHaibatpure1 This is successfully workaround

          python -m pip install langchain==0.0.301
          python -m pip install pydantic==1.10.13
          python -m pip install gpt-review==v0.9.5
bbyong2410 commented 11 months ago

This seems to be related to the following changes: langchain v0.0.302

mrchief commented 9 months ago

pip install gpt-review==v0.9.5

And we move on to the next error:

The model `gpt-35-turbo` does not exist
khurrambilalaurecon commented 8 months ago

Experiencing the same issue, doesn't work even with installing the old packages (langchain & gpt-review). Any resolution for this?

jiwidi commented 7 months ago

same happening to me when pointing to @latest

GeorgeXCV commented 6 months ago

Also experiencing this issue.

khurrambilalaurecon commented 6 months ago

@bbyong2410 @VishalHaibatpure1 This is successfully workaround

          python -m pip install langchain==0.0.301
          python -m pip install pydantic==1.10.13
          python -m pip install gpt-review==v0.9.5

Doesn't work for me with similar releases.