Skip to content

Commit 98707b7

Browse files
authored
Make gradio and langchain optional dependencies (meta-llama#676)
1 parent 3e39ed0 commit 98707b7

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

.github/scripts/spellcheck_conf/wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,3 +1451,4 @@ openhathi
14511451
sarvam
14521452
subtask
14531453
acc
1454+
langchain

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ To use the sensitive topics safety checker install with:
9494
```
9595
pip install llama-recipes[auditnlg]
9696
```
97+
Some recipes require the presence of langchain. To install the packages follow the recipe description or install with:
98+
```
99+
pip install llama-recipes[langchain]
100+
```
97101
Optional dependencies can also be combines with [option1,option2].
98102
99103
#### Install from source

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dynamic = ["dependencies"]
2424
vllm = ["vllm"]
2525
tests = ["pytest-mock"]
2626
auditnlg = ["auditnlg"]
27+
langchain = ["langchain_openai", "langchain", "langchain_community"]
2728

2829
[project.urls]
2930
"Homepage" = "https://github.com/facebookresearch/llama-recipes/"

recipes/quickstart/inference/local_inference/inference.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import time
77

88
import fire
9-
import gradio as gr
109

1110
import torch
1211

@@ -146,6 +145,11 @@ def inference(
146145
user_prompt = "\n".join(sys.stdin.readlines())
147146
inference(user_prompt, temperature, top_p, top_k, max_new_tokens)
148147
else:
148+
try:
149+
import gradio as gr
150+
except ImportError:
151+
raise ImportError("This part of the recipe requires gradio. Please run `pip install gradio`")
152+
149153
gr.Interface(
150154
fn=inference,
151155
inputs=[

requirements.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ py7zr
1414
scipy
1515
optimum
1616
matplotlib
17-
gradio
1817
chardet
1918
openai
2019
typing-extensions==4.8.0
@@ -24,8 +23,5 @@ rouge_score
2423
pyyaml==6.0.1
2524
faiss-gpu; python_version < '3.11'
2625
unstructured[pdf]
27-
langchain_openai
28-
langchain
29-
langchain_community
3026
sentence_transformers
3127
codeshield

0 commit comments

Comments
 (0)