langchain-ai / langserve

LangServe 🦜️🏓
Other
1.75k stars 184 forks source link

Feature Request: run poetry install including dependencies of the examples #678

Open codekiln opened 2 weeks ago

codekiln commented 2 weeks ago

1 - Feature request - be able to run examples after installing all extras

It would be really nice if I could clone the repository, create a new virtualenv, run poetry install --all-extras, and run any example. That doesn't work today:

(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ poetry show langchain

Package langchain not found
(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ poetry show langchain_openai

Package langchain_openai not found
(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ grep "from langchain_openai" examples/**/*.py | wc -l
      16
(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ grep "from langchain\." examples/**/*.py | wc -l
      17

Note, there are many other packages not listed in the examples dependency group, such as langchain-anthropic or langchain-community, etc.

2 - Contextual information - v0.2.2, adding langchain succeeds, adding langchain-openai fails because of constraints

(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ git describe --tags
v0.2.2

(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ poetry add langchain
Using version ^0.2.3 for langchain
...

Writing lock file
(langserve) ➜  langserve git:(mn/deps-for-examples) ✗ poetry add langchain-openai
Using version ^0.1.8 for langchain-openai

Updating dependencies
Resolving dependencies... (0.0s)

Because no versions of langchain-openai match >0.1.8,<0.2.0
 and langchain-openai (0.1.8) depends on openai (>=1.26.0,<2.0.0), langchain-openai (>=0.1.8,<0.2.0) requires openai (>=1.26.0,<2.0.0).
So, because langserve depends on both langchain-openai (^0.1.8) and openai (^0.28.0), version solving failed.

I resolved this by updating [tool.poetry.group.examples.dependencies] to include openai = ">=1.26.0,<2.0.0" as well as

langchain-openai = "^0.1.8"
langchain = "^0.2.3"
codekiln commented 2 weeks ago

Mentioned in Optimize for MTTRE: Mean Time To Running Examples · langchain-ai/langserve · Discussion #679