Skip to content

Commit b0d3ad2

Browse files
authored
Add langchain Azure OpenAI test (#317)
* Add langchain Azure OpenAI test. * Update readme.
1 parent 8a2ea45 commit b0d3ad2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ This package integrates Large Language Models (LLMs) into [spaCy](https://spacy.
1616
- **[OpenAI](https://platform.openai.com/docs/api-reference/)**
1717
- **[Cohere](https://docs.cohere.com/reference/generate)**
1818
- **[Anthropic](https://docs.anthropic.com/claude/reference/)**
19+
- **[PaLM](https://ai.google/discover/palm2/)**
1920
- Supports open-source LLMs hosted on Hugging Face 🤗:
2021
- **[Falcon](https://huggingface.co/tiiuae)**
2122
- **[Dolly](https://huggingface.co/databricks)**
2223
- **[Llama 2](https://huggingface.co/meta-llama)**
2324
- **[OpenLLaMA](https://huggingface.co/openlm-research)**
2425
- **[StableLM](https://huggingface.co/stabilityai)**
26+
- **[Mistral](https://huggingface.co/mistralai)**
2527
- Integration with [LangChain](https://github.com/hwchase17/langchain) 🦜️🔗 - all `langchain` models and features can be used in `spacy-llm`
2628
- Tasks available out of the box:
2729
- Named Entity Recognition
@@ -31,6 +33,9 @@ This package integrates Large Language Models (LLMs) into [spaCy](https://spacy.
3133
- Sentiment analysis
3234
- Span categorization
3335
- Summarization
36+
- Soon:
37+
- Entity linking
38+
- Semantic role labeling
3439
- Easy implementation of **your own functions** via [spaCy's registry](https://spacy.io/api/top-level#registry) for custom prompting, parsing and model integrations
3540

3641
## 🧠 Motivation

spacy_llm/tests/models/test_langchain.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import os
2+
13
import pytest
24
import spacy
35

46
from spacy_llm.compat import has_langchain
7+
from spacy_llm.tests.compat import has_azure_openai_key
58

69
PIPE_CFG = {
710
"model": {
@@ -21,3 +24,29 @@ def test_initialization():
2124
nlp = spacy.blank("en")
2225
nlp.add_pipe("llm", config=PIPE_CFG)
2326
nlp("This is a test.")
27+
28+
29+
@pytest.mark.external
30+
@pytest.mark.skipif(has_langchain is False, reason="LangChain is not installed")
31+
@pytest.mark.skipif(
32+
has_azure_openai_key is False, reason="Azure OpenAI key not available"
33+
)
34+
def test_initialization_azure_openai():
35+
"""Test initialization and simple run with Azure OpenAI."""
36+
os.environ["OPENAI_API_KEY"] = os.environ["AZURE_OPENAI_KEY"]
37+
_pipe_cfg = {
38+
"model": {
39+
"@llm_models": "langchain.AzureOpenAI.v1",
40+
"name": "gpt-35-turbo",
41+
"config": {
42+
"deployment_name": "gpt-35-turbo",
43+
"openai_api_version": "2023-05-15",
44+
"openai_api_base": "https://explosion.openai.azure.com/",
45+
},
46+
},
47+
"task": {"@llm_tasks": "spacy.NoOp.v1"},
48+
}
49+
50+
nlp = spacy.blank("en")
51+
nlp.add_pipe("llm", config=_pipe_cfg)
52+
nlp("This is a test.")

0 commit comments

Comments
 (0)