Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

ImportError: cannot import name 'StructuredTool' from 'langchain.tools' #142

Open
vipervs opened this issue Aug 24, 2023 · 3 comments
Open

Comments

@vipervs
Copy link

vipervs commented Aug 24, 2023

trying on a MacBook M2

(venv_pdfGPT)  ~/pdfGPT/ [main*] lc-serve deploy local api --platform linux/amd64
Traceback (most recent call last):
File "/opt/homebrew/bin/lc-serve", line 5, in
from lcserve.main import serve
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/init.py", line 16, in
from .backend.slackbot import SlackBot
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/slackbot/init.py", line 1, in
from .slackbot import SlackBot
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/slackbot/slackbot.py", line 24, in
from langchain.tools import StructuredTool
ImportError: cannot import name 'StructuredTool' from 'langchain.tools' (/Users/andi/Library/Python/3.11/lib/python/site-packages/langchain/tools/init.py)
(venv_pdfGPT)  ~/pdfGPT/ [main*] lc-serve deploy local api
Traceback (most recent call last):
File "/opt/homebrew/bin/lc-serve", line 5, in
from lcserve.main import serve
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/init.py", line 16, in
from .backend.slackbot import SlackBot
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/slackbot/init.py", line 1, in
from .slackbot import SlackBot
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/slackbot/slackbot.py", line 24, in
from langchain.tools import StructuredTool
ImportError: cannot import name 'StructuredTool' from 'langchain.tools' (/Users/andi/Library/Python/3.11/lib/python/site-packages/langchain/tools/init.py)

@zac-li
Copy link
Member

zac-li commented Aug 29, 2023

What's langchain version in your venv? Looks like this is a dependency issue.
BTW you don't need --platform linux/amd64 when running in local.

@vipervs
Copy link
Author

vipervs commented Aug 29, 2023

somehow the problem changed:

(venv_pdfGPT)  ~/pdfGPT/ [main*] lc-serve deploy local api
Traceback (most recent call last):
File "/opt/homebrew/bin/lc-serve", line 5, in
from lcserve.main import serve
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/init.py", line 15, in
from .backend import download_df, job, serving, slackbot, upload_df
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/init.py", line 3, in
from .gateway import LangchainFastAPIGateway, PlaygroundGateway, ServingGateway
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/gateway.py", line 36, in
from .langchain_helper import (
File "/opt/homebrew/lib/python3.11/site-packages/lcserve/backend/langchain_helper.py", line 9, in
from fastapi import WebSocket
File "/opt/homebrew/lib/python3.11/site-packages/fastapi/init.py", line 7, in
from .applications import FastAPI as FastAPI
File "/opt/homebrew/lib/python3.11/site-packages/fastapi/applications.py", line 16, in
from fastapi import routing
File "/opt/homebrew/lib/python3.11/site-packages/fastapi/routing.py", line 22, in
from fastapi import params
File "/opt/homebrew/lib/python3.11/site-packages/fastapi/params.py", line 5, in
from pydantic.fields import FieldInfo, Undefined
ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/opt/homebrew/lib/python3.11/site-packages/pydantic/fields.py)

(venv_pdfGPT)  ~/pdfGPT/ [main*] pip show langchain
Name: langchain
Version: 0.0.275
Summary: Building applications with LLMs through composability
Home-page: https://github.com/langchain-ai/langchain
Author:
Author-email:
License: MIT
Location: /Users/andi/pdfGPT/venv_pdfGPT/lib/python3.11/site-packages
Requires: aiohttp, dataclasses-json, langsmith, numexpr, numpy, pydantic, PyYAML, requests, SQLAlchemy, tenacity
Required-by: langchain-serve
(venv_pdfGPT)  ~/pdfGPT/ [main*] pip show langchain-serve
Name: langchain-serve
Version: 0.0.61
Summary: Langchain Serve - serve your langchain apps on Jina AI Cloud.
Home-page: https://github.com/jina-ai/langchain-serve/
Author: Jina AI
Author-email: hello@jina.ai
License: Apache 2.0
Location: /Users/andi/pdfGPT/venv_pdfGPT/lib/python3.11/site-packages
Requires: click, jcloud, jina, jina-hubble-sdk, langchain, nest-asyncio, requests, slack-bolt, textual, toml
Required-by:
(venv_pdfGPT)  ~/pdfGPT/ [main*] pip show fastapi
pip show pydantic
Name: fastapi
Version: 0.103.0
Summary: FastAPI framework, high performance, easy to learn, fast to code, ready for production
Home-page:
Author:
Author-email: Sebastián Ramírez tiangolo@gmail.com
License:
Location: /Users/andi/pdfGPT/venv_pdfGPT/lib/python3.11/site-packages
Requires: pydantic, starlette, typing-extensions
Required-by: gradio, jina
Name: pydantic
Version: 2.3.0
Summary: Data validation using Python type hints
Home-page:
Author:
Author-email: Samuel Colvin s@muelcolvin.com, Eric Jolibois em.jolibois@gmail.com, Hasan Ramezani hasan.r67@gmail.com, Adrian Garcia Badaracco 1755071+adriangb@users.noreply.github.com, Terrence Dorsey terry@pydantic.dev, David Montague david@pydantic.dev
License:
Location: /Users/andi/pdfGPT/venv_pdfGPT/lib/python3.11/site-packages
Requires: annotated-types, pydantic-core, typing-extensions
Required-by: fastapi, gradio, jina, langchain, langsmith

@zac-li
Copy link
Member

zac-li commented Aug 30, 2023

hmm I thought the lc-serve should be from venv_pdfGPT (/Users/andi/pdfGPT/venv_pdfGPT/bin/lc-serve), not /opt/homebrew/bin/lc-serves?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants