langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Put Langchain on Conda-forge

Open darabos opened this issue 2 years ago • 9 comments

We manage all our dependencies with a Conda environment file. It would be great if that could cover Langchain too! As Langchain is taking off, there are probably other Conda users in the same shoes.

(Thanks for making Langchain! It's great!)

darabos avatar Feb 24 '23 08:02 darabos

Using grayskull, we can get a possible recipe by running: grayskull pypi --strict-conda-forge langchain

However, some dependencies are not on conda-forge channels (see list at the end of comment). I don't really know if that's an issue.

aleph-alpha-client 
google-search-results 
nlpcloud 
cohere 
tensorflow-text 
qdrant-client 
manifest-ml 
tiktoken 
pinecone-client 
weaviate-client 
wolframalpha 
qdrant-client 
anthropic 
tensorflow-text

Edit: According conda-forge recipe FAQ all packages must be in some channel.

stepp1 avatar Feb 26 '23 03:02 stepp1

For completeness, here's the meta.yaml generated by grayskull

{% set name = "langchain" %}
{% set version = "0.0.94" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/langchain-{{ version }}.tar.gz
  sha256: de1efe486893f2064748366747471854f316a6e9790c0fb6646b8c2e8ed6153f

build:
  entry_points:
    - langchain-server = langchain.server:main
  noarch: python
  script: {{ PYTHON }} -m pip install . -vv
  number: 0

requirements:
  host:
    - python >=3.8,<4.0
    - poetry-core
    - pip
  run:
    - python >=3.8.1,<4.0
    - pydantic ^1
    - sqlalchemy ^1
    - requests ^2
    - pyyaml ^6
    - numpy ^1
    - faiss-cpu ^1optionaltrue
    - wikipedia ^1optionaltrue
    - elasticsearch ^8optionaltrue
    - opensearch-py ^2.0.0optionaltrue
    - redis-py ^4optionaltrue
    - manifest-ml ^0.0.1optionaltrue
    - spacy ^3optionaltrue
    - nltk ^3optionaltrue
    - transformers ^4optionaltrue
    - beautifulsoup4 ^4optionaltrue
    - pytorch ^1optionaltrue
    - jinja2 ^3optionaltrue
    - tiktoken ^0optionaltrue
    - pinecone-client ^2optionaltrue
    - weaviate-client ^3optionaltrue
    - google-api-python-client ==2.70.0optionaltrue
    - wolframalpha ==5.0.0optionaltrue
    - anthropic ^0.2.2optionaltrue
    - qdrant-client ^0.11.7optionaltrue
    - dataclasses-json ^0.5.7
    - tensorflow-text ^2.11.0optionaltrue
    - tenacity ^8.1.0
    - cohere ^3optionaltrue
    - openai ^0optionaltrue
    - nlpcloud ^1optionaltrue
    - huggingface_hub ^0optionaltrue
    - google-search-results ^2optionaltrue
    - sentence-transformers ^2optionaltrue
    - aiohttp ^3.8.3
    - pypdf ^3.4.0optionaltrue
    - networkx ^2.6.3optionaltrue
    - aleph-alpha-client ^2.15.0

test:
  imports:
    - langchain
  commands:
    - pip check
    - langchain-server --help
  requires:
    - pip

about:
  home: https://www.github.com/hwchase17/langchain
  summary: Building applications with LLMs through composability
  license: MIT
  license_file: LICENSE

extra:
  recipe-maintainers:
    - stepp1

stepp1 avatar Feb 26 '23 03:02 stepp1

What's the motivation for publishing a package on Conda Forge in addition to PyPi? I've asked around and it seems unclear what exact benefit this offers users.

dlqqq avatar Mar 19 '23 23:03 dlqqq

what [is the] exact benefit this offers users[?]

Basically it allows you to install and uninstall it with conda. The main motivation for using conda (personally) is that makes it much easier to manage multiple python environments on the same machine. I frequently have 5+ active projects, all with their own dependency constraints, and conda makes it easy to handle that. This is a typical problem for data scientists and lots of other applied ML workers who'd be interested in LangChain.

IMO, being listed on both pypi and conda-forge is just part of being a mature package in the python ecosystem. LangChain is getting there, and will need to do this soon.

Jbollenbacher avatar Mar 20 '23 03:03 Jbollenbacher

For us, we manage all dependencies from zip and make to openjdk and pandas with Conda. Even R packages. (Our conda-env.yml.) It makes it much easier for a new contributor to get set up.

darabos avatar Mar 20 '23 10:03 darabos

I see. I wanted to make sure that there wasn't an obvious practical benefit I was missing, aside from being able to use exclusively conda install *.

dlqqq avatar Mar 20 '23 15:03 dlqqq

I can own this if nobody else is working on it; I've already uploaded Jupyter File ID to Conda Forge in the past.

dlqqq avatar Mar 20 '23 15:03 dlqqq

I did a little bit of digging and this is actually a bit more involved than I had anticipated. Grayskull, the utility used to generate recipes, doesn't actually provide out-of-the-box support for our project for 2 main reasons:

  1. Grayskull doesn't parse optional dependencies correctly. Issue: https://github.com/conda/grayskull/issues/440

  2. Grayskull doesn't recognize Poetry-specific version clauses like ^ or ~, which are non-standard and not present in PEP 440 -- Version Identification and Dependency Specification. Issue: https://github.com/conda/grayskull/issues/441

You can see this clearly in the meta.yaml output @stepp1 posted; openai ^0optionaltrue certainly doesn't look like a well-formed requirement listing 😁

The next steps are either to:

  • Modify our pyproject.toml to let grayskull play nice

    • This isn't necessarily possible, since I don't know of any other way to specify an optional dependency
  • Cut a PR to grayskull to fix it

dlqqq avatar Mar 20 '23 17:03 dlqqq

https://github.com/conda-forge/staged-recipes/pull/22366

Happy to announce LangChain on Conda Forge is coming soon. 🎉

  • Branch I used to build the recipe correctly: https://github.com/conda/grayskull/pull/454

dlqqq avatar Mar 22 '23 22:03 dlqqq

Hi, @darabos. I'm helping the LangChain team manage their backlog and I wanted to let you know that we are marking this issue as stale.

Based on the comments, it seems that the issue has been resolved. Langchain is now available on Conda Forge, making it easier for Conda users to manage dependencies. Initially, there were some complications with grayskull, but dlqqq was able to resolve them and successfully publish Langchain on Conda Forge.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repo. If you do respond, the LangChain team will take a look. Otherwise, the issue will be automatically closed in 7 days.

Thank you for your understanding.

dosubot[bot] avatar Aug 04 '23 17:08 dosubot[bot]

@dosu-beta Please don't close this issue; LangChain is still not on Conda Forge as of yet. I'll follow up with the LangChain team to see if we can make progress on this.

The PR for uploading LangChain onto Conda Forge remains open: https://github.com/conda-forge/staged-recipes/pull/22366

dlqqq avatar Aug 08 '23 20:08 dlqqq

I'm sorry you're still having trouble with the LangChain repository not being available on Conda Forge. It seems that the PR for uploading LangChain onto Conda Forge is still open. @baskaryan, can you please help @dlqqq with this issue?

dosubot[bot] avatar Aug 08 '23 20:08 dosubot[bot]

believe we are in there: https://github.com/conda-forge/staged-recipes/pull/22515 https://anaconda.org/conda-forge/langchain

cc @hinthornw

baskaryan avatar Aug 08 '23 23:08 baskaryan

Oh, I guess somebody beat me to it, haha. This issue should be marked as closed.

dlqqq avatar Aug 09 '23 16:08 dlqqq

I'm getting this error when trying to install langchain from conda, using the command on the install page:

conda install langchain -c conda-forge
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - langchain

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

aparente avatar Nov 03 '23 20:11 aparente

As per the langchain install instructions (the conda tab), you have to specify the conda-forge channel:

conda install langchain -c conda-forge

There are different package versions such as: langchain, langchain-community, and others.

blairtj avatar Dec 28 '23 20:12 blairtj