Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/content safety runnable #13

Open
wants to merge 604 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
604 commits
Select commit Hold shift + click to select a range
a5fcbe6
docs: correct HuggingFaceEmbeddings documentation model param (#28269)
manuelescobar-dev Nov 22, 2024
a433039
core[patch]: support final AIMessage responses in `tool_example_to_me…
ccurme Nov 22, 2024
697dda5
core[patch]: release 0.3.20 (#28293)
ccurme Nov 22, 2024
2ee37a1
community: list valid values for LanceDB constructor's `mode` argumen…
metadaddy Nov 22, 2024
7277794
ollama: include kwargs in requests (#28299)
efriis Nov 22, 2024
aa7fa80
partners/ollama: release 0.2.2rc1 (#28300)
efriis Nov 22, 2024
203d20c
community[patch]: fix errors introduced by pydantic 2.10 (#28297)
ccurme Nov 22, 2024
242e9fc
infra: install standard tests in docs build (#28303)
efriis Nov 22, 2024
25a636c
langchain[patch]: update deprecation message for MapReduceChain (#28304)
ccurme Nov 23, 2024
39fd0fd
infra: more rst (#28305)
efriis Nov 23, 2024
a329647
docs: integration asyncio mode (#28306)
efriis Nov 23, 2024
ed84d48
[Doc] Improvement: fix import statement for qdrant (#28286)
ZhangShenao Nov 23, 2024
a813d11
core[patch]: Compat pydantic 2.10 (#28308)
eyurtsev Nov 23, 2024
563587e
langchain[patch]: Compat with pydantic 2.10 (#28307)
eyurtsev Nov 23, 2024
7170a4e
docs: standard test api link (#28309)
efriis Nov 23, 2024
f5f1149
core[patch]: release 0.3.21 (#28314)
ccurme Nov 23, 2024
82bb0cd
langchain[patch]: release 0.3.8 (#28315)
ccurme Nov 23, 2024
a83357d
community[patch]: release 0.3.8 (#28316)
ccurme Nov 23, 2024
6ed2d38
docs: fix GOOGLE_API_KEY typo (#28322)
Yelinz Nov 25, 2024
c60695a
community: fixed critical bugs at Writer provider (#27879)
yanomaly Nov 25, 2024
5867f25
community[patch]: Neo4j community deprecation (#28130)
alexthomas93 Nov 25, 2024
a537495
community[patch]: fix import in test (#28339)
ccurme Nov 25, 2024
aa2c17b
docs: update azure_openai_whisper_parser.ipynb (#28327)
eltociear Nov 25, 2024
195ae7b
Community: Adding citations in AIMessage for ChatPerplexity (#28321)
keenborder786 Nov 26, 2024
c161f7d
docs(create_sql_agent): fix reStructured Text Markup (#28356)
0xRichardH Nov 26, 2024
a97c53e
docs[patch]: fix broken anchor link (#28358)
ccurme Nov 26, 2024
7b9a0d9
docs: update tutorials (#28219)
ccurme Nov 26, 2024
869c8f5
langchain[patch]: support numpy 2 (#28183)
ghinch Nov 26, 2024
42b1882
openai[patch]: use max_completion_tokens in place of max_tokens (#26917)
ccurme Nov 26, 2024
e7dc26a
openai[patch]: Release 0.2.10 (#28360)
baskaryan Nov 26, 2024
e9c1655
openai[patch]: bump core dep (#28361)
baskaryan Nov 26, 2024
74d9d2c
ollama[patch]: support ollama 0.4 (#28364)
ccurme Nov 26, 2024
a1c9079
ollama[patch]: bump to 0.4.1 in lock file (#28365)
ccurme Nov 26, 2024
7d95a10
langchain: Fix Neo4jVector vector store reference from partner packag…
willtai Nov 26, 2024
06fafc6
Community: Marqo Index Setting GET Request Updated according to `2.x`…
keenborder786 Nov 26, 2024
ec205fc
Updated docs for the BM25 preprocessing function (#28101)
kiril-buga Nov 26, 2024
8adc4a5
langchain[patch]: update deprecation message for agent classes and co…
ccurme Nov 26, 2024
ffe7bd4
langchain[patch]: init_chat_model provider in model string (#28367)
baskaryan Nov 27, 2024
585da22
Init embeddings (#28370)
hinthornw Nov 27, 2024
85b8cec
docs: fix typo in embedding vectors documentation (#28378)
kanad13 Nov 27, 2024
42b8ad0
chroma[patch]: test python 3.13 in CI (#28387)
ccurme Nov 27, 2024
51e98a5
docs[patch]: fix typo in embeddings tab (#28388)
ccurme Nov 27, 2024
bb83abd
community[patch]: remove sqlalchemy cap (#28389)
ccurme Nov 27, 2024
607c60a
partners/ollama: fix tool calling with nested schemas (#28225)
TheDannyG Nov 27, 2024
c09000f
Building RAG agents locally using open source LLMs on Intel CPU (#28302)
pbharti0831 Nov 27, 2024
0901f11
community: add truncation params when an openai assistant's run is cr…
LuisMSotamba Nov 27, 2024
5141f25
community[patch]: support numpy2 (#28184)
ghinch Nov 27, 2024
b9bf7fd
couchbase[patch]: run python 3.13 in CI (#28391)
ccurme Nov 27, 2024
733a6ad
mistral[patch]: run python 3.13 in CI (#28392)
ccurme Nov 27, 2024
8358666
partners[chroma]: add retrieval of embedding vectors (#28290)
mspronesti Nov 27, 2024
ee6fc3f
nomic[patch]: run python 3.13 in CI (#28393)
ccurme Nov 27, 2024
a8b21af
qdrant[patch]: run python 3.13 in CI (#28394)
ccurme Nov 27, 2024
b7e10bb
langchain[patch]: Release 0.3.9 (#28399)
baskaryan Nov 27, 2024
2813e86
docs: Adds the langchain-neo4j package to the API docs (#28386)
alexthomas93 Nov 27, 2024
c2f1d02
mistral[patch]: ensure tool call IDs in tool messages are correctly f…
ccurme Nov 29, 2024
49914e9
community[patch]: Release 0.3.9 (#28451)
baskaryan Dec 2, 2024
4743348
mistral[patch]: Release 0.2.3 (#28452)
baskaryan Dec 2, 2024
e294e71
Update mistralai.ipynb (#28440)
chistokir Dec 2, 2024
58d2bfe
docs: fixed a variable name in embeddings section (#28434)
rcocetta Dec 2, 2024
e5b4f9a
docs: Add ChatDatabricks to llm models (#28398)
prithvikannan Dec 2, 2024
c953f93
infra: Update Poetry version, to current latest (1.8.4) (#28194)
ulgens Dec 2, 2024
88d6d02
ollama[patch]: release 0.2.2 (#28456)
ccurme Dec 2, 2024
2848759
ollama[patch]: release 0.2.1 (#28458)
ccurme Dec 2, 2024
60021e5
community: Add the additonnal kward 'context' for openai (#28351)
lucasiscovici Dec 2, 2024
ecee41a
fix: Handle response metadata in merge_messages_runs (#28453)
hinthornw Dec 2, 2024
9f04416
openai: set logit_bias to none instead of empty dict by default (#28460)
efriis Dec 2, 2024
42d40d6
partners/openai: release 0.2.11 (#28461)
efriis Dec 2, 2024
000be1f
tests: init retriever standard tests (#28459)
efriis Dec 2, 2024
6b7e93d
pinecone: update pinecone client (#28320)
aulorbe Dec 3, 2024
ff675c1
partners/pinecone: release 0.2.2 (#28466)
efriis Dec 3, 2024
7315360
openai: dont populate logit_bias if None (#28482)
efriis Dec 3, 2024
926e452
partners: update version header for Pinecone integration (#28481)
aulorbe Dec 3, 2024
c74f34c
pinecone: release 0.2.1 (version sequence) (#28485)
efriis Dec 3, 2024
a220ee5
infra: add 20min timeout to ci steps (#28483)
efriis Dec 3, 2024
50ddf13
infra: configurable scheduled tests (#28486)
efriis Dec 3, 2024
ab831ce
tests[patch]: populate API reference for chat models (#28487)
ccurme Dec 3, 2024
b0a8307
Update graph_constructing.ipynb (#28489)
prakashshan50 Dec 3, 2024
ef36554
community: add Needle retriever and document loader integration (#28157)
JANHMS Dec 3, 2024
6e607bb
docs: langchain-ai21 update ai21 docs (#28076)
miri-bar Dec 4, 2024
15e7353
langchain_community: updated query constructor for Databricks Vector …
willsmithDB Dec 4, 2024
eff8a54
langchain_chroma: added document.id support (#27995)
epinzur Dec 4, 2024
bc5ec63
community : allow using apikey for PubMedAPIWrapper (#27246)
peterdhp Dec 4, 2024
a009249
infra: release rely on local built in testing (#28492)
efriis Dec 4, 2024
d34bf78
community: BM25Retriever preservation of document id (#27019)
TupleType Dec 4, 2024
6151ea7
community: implement _select_relevance_score_fn for tencent vectordb …
wlleiiwang Dec 4, 2024
e6a0835
docs: more api ref links, add linting step to prevent more (#28495)
efriis Dec 4, 2024
12d74d5
docs: single security doc (#28515)
efriis Dec 4, 2024
eec55c2
chroma[patch]: add `get_by_ids` and fix bug (#28516)
ccurme Dec 4, 2024
a013014
switch graph semantic layer docs to langgraph (#28513)
tomasonjo Dec 4, 2024
8bc2c91
chroma[patch]: (nit) simplify test (#28517)
ccurme Dec 4, 2024
2b360d6
infra: scheduled test fix (#28519)
efriis Dec 4, 2024
f459754
tests[patch]: populate API reference for vector stores (#28520)
ccurme Dec 5, 2024
c5acedd
anthropic: timeout in tests (10s) (#28488)
efriis Dec 5, 2024
43c35d1
cli: standard tests in cli, test that they run, skip vectorstore test…
efriis Dec 5, 2024
0f539f0
standard-tests: release 0.3.5 (#28526)
efriis Dec 5, 2024
d9e42a1
langchain[patch]: fix deprecation warning (#28535)
ccurme Dec 5, 2024
ecff9a0
cli: release 0.0.34 (#28525)
efriis Dec 5, 2024
8f9b3b7
chroma[patch]: fix bug (#28538)
ccurme Dec 5, 2024
7d44316
docs: Add link for how to install extras (#28537)
Coniferish Dec 5, 2024
d26555c
[VectorStore] Improvement: Improve chroma vector store (#28524)
ZhangShenao Dec 5, 2024
b8e861a
openai[patch]: add standard tests for embeddings (#28540)
ccurme Dec 5, 2024
1e285cb
docs: Updated incorrected type used for the `multiply_by_max` functio…
WEIQ-beepbeep Dec 5, 2024
1581857
docs: add Aerospike to providers list (#28066)
dwelch-spike Dec 5, 2024
ecdfc98
tests[patch]: run standard tests for embeddings and populate embeddin…
ccurme Dec 5, 2024
3d54935
docs: deprecated styling (#28546)
efriis Dec 5, 2024
66f819c
infra: run cli tests on test changes (#28542)
efriis Dec 5, 2024
5519a1c
docs[patch]: improve integration docs (#28547)
ccurme Dec 5, 2024
7a96ce1
docs: deprecated styling (#28550)
efriis Dec 5, 2024
28f8d43
mistral: fix of issue #26029 (#28233)
blaufink Dec 5, 2024
482e8a7
community: Add support for SAP HANA Vector hnsw index creation (#27884)
cinqisap Dec 5, 2024
478def8
core: deprecation doc removal (#28553)
efriis Dec 5, 2024
a197e0b
docs: custom deprecated coloring, organize css a bit (#28555)
efriis Dec 5, 2024
7ecf38f
cli: create specific files from template (#28556)
efriis Dec 6, 2024
bc636cc
cli: release 0.0.35 (#28557)
efriis Dec 6, 2024
18386c1
core, tests: more tolerant _aget_relevant_documents function (#28462)
efriis Dec 6, 2024
5277a02
docs: raw loader codeblock (#28548)
efriis Dec 6, 2024
f3dc142
cli[patch]: implement minimal starter vector store (#28577)
ccurme Dec 6, 2024
15cbc36
docs[patch]: update contributor docs for integrations (#28576)
ccurme Dec 6, 2024
dda9f90
core[patch]: Release 0.3.22 (#28582)
baskaryan Dec 6, 2024
2c6bc74
multiple: combine sync/async vector store standard test suites (#28580)
ccurme Dec 6, 2024
c38b845
core: fix path test (#28584)
efriis Dec 6, 2024
e6663b6
langchain: release 0.3.10 (#28585)
efriis Dec 6, 2024
221ab03
docs: readme/intro nits (#28581)
baskaryan Dec 6, 2024
4f99952
docs: enable private docstring members sphinx (#28586)
efriis Dec 6, 2024
791d7e9
docs: enable private docstring modules sphinx (#28588)
efriis Dec 6, 2024
1cedf40
docs: enable private docstring submembers sphinx (#28589)
efriis Dec 6, 2024
246c10a
standard-tests: private members and tools unit troubleshoot (#28590)
efriis Dec 6, 2024
9e2abcd
standard-tests: show right classes in api docs (#28591)
efriis Dec 6, 2024
f943205
docs: dont document root init (#28592)
efriis Dec 6, 2024
925ca75
docs: format (#28593)
efriis Dec 6, 2024
b7c2029
standard-tests: root docstrings (#28595)
efriis Dec 6, 2024
0eb7ab6
multiple: fix xfailed signatures (#28597)
efriis Dec 6, 2024
80a88f8
tests[patch]: update API ref for chat models (#28594)
ccurme Dec 7, 2024
4a7dc6e
standard-tests: release 0.3.6 (#28599)
efriis Dec 7, 2024
07c2ac7
community: release 0.3.10 (#28600)
efriis Dec 7, 2024
a32035d
docs: update uptrain.ipynb (#28561)
eltociear Dec 7, 2024
d801c6f
tests[patch]: nits (#28601)
ccurme Dec 7, 2024
5e8553c
standard-tests: retriever docstrings (#28596)
efriis Dec 7, 2024
9b84849
docs: tool, retriever contributing docs (#28602)
efriis Dec 7, 2024
dd0085a
docs: standard tests to markdown, load templates from files (#28603)
efriis Dec 7, 2024
524ee6d
Invalid `tool_choice` being passed to `ChatLiteLLM` (#28198)
keenborder786 Dec 7, 2024
fbf0704
docs: Update IBM documentation (#28503)
MateuszOssGit Dec 8, 2024
317a38b
community[minor]: Add support for modle2vec embeddings (#28507)
blacksmithop Dec 9, 2024
2354bb7
partners: 🕷️🦜 ScrapeGraph API Integration (#28559)
PeriniM Dec 9, 2024
1fc4ac3
docs: Resolve incorrect import of AttributeInfo for self-query retrie…
DangerousPotential Dec 9, 2024
220b33d
docs: Fixed broken link in the warning message to @tool API Reference…
DangerousPotential Dec 9, 2024
e8508fb
docs: Fixed mini typo in recommend and improve the phrasing (#28438)
DangerousPotential Dec 9, 2024
079c7ea
docs: Fix typo in weaviate integration docs (#28425)
funkyrailroad Dec 9, 2024
54fba7e
docs: change upstage solar model descriptions (#28419)
inahjeon Dec 9, 2024
481c4bf
core[patch]: Fixed trim functions, and added corresponding unit test …
fazam0616 Dec 9, 2024
eabe587
community[patch]:Fix for get_openai_callback() return token_cost=0.0 …
m4a1carbin4 Dec 9, 2024
b53f07b
docs: more integration contrib (#28618)
efriis Dec 9, 2024
90f162e
text-splitters: add pydocstyle linting (#28127)
dangiankit Dec 9, 2024
cef21a0
cli: warning on app add (#28619)
efriis Dec 9, 2024
ec9b414
[Core]: Small Docstring Clarification for `BaseTool` (#28148)
keenborder786 Dec 9, 2024
6e6061f
openai[patch]: bump minimum SDK version (#28632)
ccurme Dec 9, 2024
ffb5c19
openai[patch]: release 0.2.12 (#28633)
ccurme Dec 9, 2024
4c70fff
standard-tests: sync/async vectorstore tests conditional (#28636)
efriis Dec 9, 2024
b64d846
docs: Standardize MoonshotChat docstring (#28159)
maang-h Dec 9, 2024
b476fdb
docs: update readme (#28631)
ccurme Dec 9, 2024
bdb4cf7
Fix typo in Custom Output Parser doc (#28617)
huyb1991 Dec 9, 2024
9fcd203
partners/mistralai: Fix KeyError in Vertex AI stream (#28624)
nikitajoyn Dec 9, 2024
85114b4
docs: Update sql-query doc by fixing spelling mistake of chinhook.db …
prnvlohar Dec 9, 2024
242fee1
community[minor] Pebblo: Support for new Pinecone class PineconeVecto…
Raj725 Dec 9, 2024
ce3b69a
community: add include_labels option to ConfluenceLoader (#28259)
nakamasato Dec 9, 2024
6815981
Switch graphqa example in docs to langgraph (#28574)
tomasonjo Dec 9, 2024
534b8f4
standard-tests: release 0.3.7 (#28637)
efriis Dec 9, 2024
75bc6bb
community: [bugfix] fix source path for office files in O365 (#28260)
MacanPN Dec 9, 2024
2c49f58
community[fix]: could not locate runnable browser (#28289)
ImAmirreza Dec 9, 2024
cf6d1c0
docs: add Linkup integration documentation (#28366)
cjumel Dec 9, 2024
34ca31e
docs: integration contrib typo (#28642)
efriis Dec 9, 2024
b78b2f7
community[fix]: Update Perplexity to pass parameters into API calls (…
arnavp103 Dec 10, 2024
4e743b5
Core: google docstring parsing fix (#28404)
Tesla2000 Dec 10, 2024
5afeb8b
infra: merge queue allowed (#28641)
efriis Dec 10, 2024
9b7d49f
docs: Adding Docs for new SQLServer Vector store package (#28173)
Pookam90 Dec 10, 2024
8c6eec5
community: KuzuGraph needs allow_dangerous_requests, add graph docume…
prrao87 Dec 10, 2024
0f0df2d
fix: Set default search_type to 'similarity' in as_retriever method o…
TamagoTorisugi Dec 10, 2024
ef2f875
core: deprecate PipelinePromptTemplate (#28644)
efriis Dec 10, 2024
d0e9597
langchain-weaviate: Remove outdated docs (#28058)
hsm207 Dec 10, 2024
e24f86e
core[patch]: return ToolMessage from tool (#28605)
baskaryan Dec 10, 2024
24292c4
core[patch]: Release 0.3.23 (#28648)
baskaryan Dec 10, 2024
5c6e2cb
ollama[patch]: support structured output (#28629)
ccurme Dec 10, 2024
aba2711
community: update Memgraph integration (#27017)
katarinasupe Dec 10, 2024
0d20c31
Confluence Loader: Fix CQL loading (#27620)
Tonkonozhenko Dec 10, 2024
c1d348e
doc-loader: retain Azure Doc Intelligence API metadata in Document pa…
jmohren Dec 10, 2024
7040594
Fix graph example documentation (#28653)
tomasonjo Dec 10, 2024
bc4dc7f
ollama[patch]: permit streaming for tool calls (#28654)
ccurme Dec 10, 2024
e6a62d8
core,langchain,community[patch]: allow langsmith 0.2 (#28598)
baskaryan Dec 10, 2024
1fbd86a
core[patch]: Release 0.3.24 (#28656)
baskaryan Dec 10, 2024
91227ad
langchain[patch]: Release 0.3.11 (#28657)
baskaryan Dec 10, 2024
d0e662e
community[patch]: Release 0.3.11 (#28658)
baskaryan Dec 10, 2024
3048a9a
community: tongyi multimodal response format fix to support langchain…
achenglike Dec 10, 2024
b9dd4f2
docs: box to package table (#28676)
efriis Dec 11, 2024
df5008f
community[minor]: FAISS Filter Function Enhancement with Advanced Que…
vincentzhang15 Dec 11, 2024
a37afbe
mistral[minor]: Added Retrying Mechanism in case of Request Rate Limi…
keenborder786 Dec 11, 2024
8c37808
docs: added caution notes on Jina and LocalAI docs about openai sdk v…
bjoaquinc Dec 11, 2024
fa155a4
[Community]: `requests_kwargs` not being used in _fetch (#28646)
keenborder786 Dec 11, 2024
8780f7a
Fix typo in doc for: Custom Functions & Pass Through Arguments pages …
huyb1991 Dec 11, 2024
b20230c
community: use correct `id_key` when deleting by id in LanceDB wrappe…
floatplane Dec 11, 2024
ee640d6
community: fixed bug in model2vec embedding code (#28670)
Pringled Dec 11, 2024
45f9c9a
langchain: fixed weaviate (v4) vectorstore import for self-query retr…
xintoteai Dec 11, 2024
a4713ca
FIX: typos in docs (#28679)
timmy471 Dec 12, 2024
0af5ad8
docs: provider list from packages.yml (#28677)
efriis Dec 12, 2024
ba9b95c
Community: Adding bulk_size as a setable param for OpenSearchVectorSe…
manukychen Dec 12, 2024
d1e0ec7
community: VectorStores: Azure Cosmos DB Mongo vCore with DiskANN (#2…
fatmelon Dec 12, 2024
5a31792
community: Add support for cross-region inference profile IDs in Bedr…
lakinduboteju Dec 12, 2024
d834c6b
huggingface: fix tool argument serialization in _convert_TGI_message…
sywangyi Dec 12, 2024
ca054ed
community: ChatSnowflakeCortex - Add streaming functionality (#27753)
PrathameshNimkar Dec 12, 2024
4149c0d
community: add method to create branch and list files for gitlab tool…
lorenzb07 Dec 12, 2024
13c3c4a
community: fixes json loader not getting texts with json standard (#2…
TonyBotongChu Dec 12, 2024
28cb2ce
docs: Fix stack diagram in community README (#28685)
michaelnchin Dec 12, 2024
f601101
docs: ganalytics in api ref (#28697)
efriis Dec 12, 2024
48ab91b
docs: more useful vercel warnings (#28699)
efriis Dec 13, 2024
94c22c3
rfc: dropdown for chat models (#28673)
baskaryan Dec 13, 2024
fa06188
community[patch]: fix QuerySQLDatabaseTool name (#28659)
baskaryan Dec 13, 2024
c855d43
DOC: Fixed conflicting info on ChatOllama structured output support (…
Uvi-12 Dec 13, 2024
05ebe1e
Community: add `modified_since` argument to `O365BaseLoader` (#28708)
MacanPN Dec 13, 2024
86b3c6e
community: make old stub for QuerySQLDataBaseTool private to skip api…
efriis Dec 13, 2024
b0a2988
community[minor]: Add TablestoreVectorStore (#25767)
xjtushilei Dec 13, 2024
da28cf1
core[patch]: Reverts PR #25754 and add unit tests (#28702)
KeiichiHirobe Dec 13, 2024
ce90b25
core[patch]: Update error message in indexing code for unreachable co…
eyurtsev Dec 13, 2024
4802c31
docs: update intro page (#28639)
ccurme Dec 13, 2024
258b3be
core[minor]: add new clean up strategy "scoped_full" to indexing (#28…
KeiichiHirobe Dec 13, 2024
67fd554
core[patch]: throw exception indexing code if deletion fails in vecto…
KeiichiHirobe Dec 13, 2024
f3fb5a9
community[minor]: Fix json._validate_metadata_func() (#22842)
pprados Dec 13, 2024
498f024
community[minor]: Opensearch hybridsearch implementation (#25375)
karthikbharadhwajKB Dec 13, 2024
9c55c75
docs: dropdowns for embeddings and vector stores (#28713)
ccurme Dec 13, 2024
b909d54
chroma[patch]: Update logic for assigning ids
kwei-zhang Dec 13, 2024
3107d78
huggingface: fix standard test lint (#28714)
efriis Dec 13, 2024
af2e0a7
partners: add 'model' alias for consistency in embedding classes (#28…
manuelescobar-dev Dec 13, 2024
12111cb
community: fallback on core async atransform_documents method for `Ma…
rparkr Dec 13, 2024
337fed8
community: 🐛 PDF Filter Type Error (#27154)
moyueheng Dec 13, 2024
bd008ba
docs: Update additional_resources/tutorials.mdx (#28005)
ronidas39 Dec 14, 2024
288f204
docs, community: aerospike docs update (#28717)
efriis Dec 14, 2024
fc80061
docs: integrations W&B update (#28059)
leo-gan Dec 14, 2024
008efad
[community]: Render documents to graphviz (#24830)
bjchambers Dec 14, 2024
decd77c
community: fix an issue with deepinfra integration (#28715)
JustNawaf Dec 14, 2024
387284c
core: release 0.3.25 (#28718)
efriis Dec 14, 2024
23b433f
infra: fix notebook tests (#28722)
ccurme Dec 14, 2024
679e3a9
text-splitters[patch]: Release 0.3.3 (#28723)
baskaryan Dec 14, 2024
089e659
langchain[patch]: Release 0.3.12 (#28724)
baskaryan Dec 14, 2024
a0534ae
community[patch]: Release 0.3.12 (#28725)
baskaryan Dec 14, 2024
a3851cb
community: FAISS vectorstore - consistent Document id field (#28728)
nhols Dec 15, 2024
4c1871d
community: Passing the `model_kwargs` correctly while maintaing backw…
keenborder786 Dec 15, 2024
d417e4b
Community: Azure CosmosDB No Sql Vector Store: Full Text and Hybrid S…
aayush3011 Dec 15, 2024
690aa02
docs[experimental]: Make docs clearer and add min_chunk_size (#26398)
tibor-reiss Dec 15, 2024
8ec1c72
text-splitters: test without socket (#28732)
efriis Dec 15, 2024
4f6ccb7
text-splitters: extended-tests without socket (#28736)
efriis Dec 16, 2024
29305cd
community: O365Toolkit - send_event - fixed timezone error (#25876)
SirNotReallySmokeAlot Dec 16, 2024
5c5fd6b
Merge branch 'master' into feature/content_safety_runnable
efriis Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions docs/docs/integrations/chains/azure_ai_content_safety.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# `AzureAIContentSafetyChain`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> [Azure AI Content Safety Chain](https://learn.microsoft.com/python/api/overview/azure/ai-contentsafety-readme?view=azure-python) is a wrapper around\n",
"> the Azure AI Content Safety service, implemented in LangChain using the LangChain \n",
"> [Runnables](https://python.langchain.com/docs/how_to/lcel_cheatsheet/) base class to allow use in a Runnables Sequence.\n",
"\n",
"The Class can be used to stop or filter content based on the Azure AI Content Safety policy."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Usage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the required imports, here we will use a `ChatPromptTemplate` for convenience and the `AzureChatOpenAI`, however, any LangChain integrated model will work in a chain."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain_community.chains.azure_content_safety_chain import (\n",
" AzureOpenAIContentSafetyChain,\n",
")\n",
"from langchain_core.prompts import ChatPromptTemplate\n",
"from langchain_openai import AzureChatOpenAI"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"moderate = AzureOpenAIContentSafetyChain()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model = AzureChatOpenAI(\n",
" openai_api_version=os.environ[\"OPENAI_API_VERSION\"],\n",
" azure_deployment=os.environ[\"COMPLETIONS_MODEL\"],\n",
" azure_endpoint=os.environ[\"AZURE_OPENAI_ENDPOINT\"],\n",
" api_key=os.environ[\"AZURE_OPENAI_API_KEY\"],\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"prompt = ChatPromptTemplate.from_messages([(\"system\", \"repeat after me: {input}\")])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Combine the objects to create a LangChain RunnablesSequence"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"moderated_chain = moderate | prompt | model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = moderated_chain.invoke({\"input\": \"I hate you!\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.content"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to show how a user would write code to handle an exception from input violating the content policy

]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions libs/community/extended_testing_deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ anthropic>=0.3.11,<0.4
arxiv>=1.4,<2
assemblyai>=0.17.0,<0.18
atlassian-python-api>=3.36.0,<4
azure-ai-contentsafety>=1.0.0
azure-ai-documentintelligence>=1.0.0b1,<2
azure-identity>=1.15.0,<2
azure-search-documents==11.4.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
"""Pass input through an azure content safety resource."""

from typing import Any, Dict, List, Optional

from langchain.chains.base import Chain
from langchain_core.callbacks import (
CallbackManagerForChainRun,
)
from langchain_core.exceptions import LangChainException
from langchain_core.utils import get_from_dict_or_env
from pydantic import model_validator


class AzureHarmfulContentError(LangChainException):
"""Exception for handling harmful content detected
in input for a model or chain according to Azure's
content safety policy."""

def __init__(
self,
input: str,
):
"""Constructor

Args:
input (str): The input given by the user to the model.
"""
self.input = input
self.message = "The input has breached Azure's Content Safety Policy"
super().__init__(self.message)


class AzureAIContentSafetyChain(Chain):
"""
A wrapper for the Azure AI Content Safety API in a Runnable form.
Allows for harmful content detection and filtering before input is
provided to a model.

**Note**:
This Service will filter input that shows any sign of harmful content,
this is non-configurable.

Attributes:
error (bool): Whether to raise an error if harmful content is detected.
content_safety_key (Optional[str]): API key for Azure Content Safety.
content_safety_endpoint (Optional[str]): Endpoint URL for Azure Content Safety.

Setup:
1. Follow the instructions here to deploy Azure AI Content Safety:
https://learn.microsoft.com/azure/ai-services/content-safety/overview

2. Install ``langchain`` ``langchain_community`` and set the following
environment variables:

.. code-block:: bash

pip install -U langchain langchain-community

export AZURE_CONTENT_SAFETY_KEY="your-api-key"
export AZURE_CONTENT_SAFETY_ENDPOINT="https://your-endpoint.azure.com/"


Example Usage:
.. code-block:: python

from langchain_community.chains import AzureAIContentSafetyChain
from langchain_openai import AzureChatOpenAI

moderate = AzureAIContentSafetyChain()
prompt = ChatPromptTemplate.from_messages([("system",
"repeat after me: {input}")])
model = AzureChatOpenAI()

moderated_chain = moderate | prompt | model

moderated_chain.invoke({"input": "Hey, How are you?"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to show the full example here with the code you would have to write reacting to harmful content

"""

client: Any = None #: :meta private:
error: bool = False
"""Whether or not to error if bad content was found."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would default to True. If a user was going through the trouble of adding this to their chain, it feels to me it's because they want to react to harmful content, i.e. do something if an exception is raised

input_key: str = "input" #: :meta private:
output_key: str = "output" #: :meta private:
content_safety_key: Optional[str] = None
content_safety_endpoint: Optional[str] = None

@property
def input_keys(self) -> List[str]:
"""Expect input key.

:meta private:
"""
return [self.input_key]

@property
def output_keys(self) -> List[str]:
"""Return output key.

:meta private:
"""
return [self.output_key]

@model_validator(mode="before")
@classmethod
def validate_environment(cls, values: Dict) -> Any:
"""Validate that api key and python package exists in environment."""
content_safety_key = get_from_dict_or_env(
values, "content_safety_key", "CONTENT_SAFETY_API_KEY"
)
content_safety_endpoint = get_from_dict_or_env(
values, "content_safety_endpoint", "CONTENT_SAFETY_ENDPOINT"
)
try:
import azure.ai.contentsafety as sdk
from azure.core.credentials import AzureKeyCredential

values["client"] = sdk.ContentSafetyClient(
endpoint=content_safety_endpoint,
credential=AzureKeyCredential(content_safety_key),
)

except ImportError:
raise ImportError(
"azure-ai-contentsafety is not installed. "
"Run `pip install azure-ai-contentsafety` to install."
)
return values

def _detect_harmful_content(self, text: str, results: Any) -> str:
contains_harmful_content = False

for category in results:
if category["severity"] > 0:
contains_harmful_content = True

if contains_harmful_content:
error_str = (
"The input text contains harmful content "
"according to Azure OpenAI's content policy"
)
if self.error:
raise AzureHarmfulContentError(input=text)
else:
return error_str

return text

def _call(
self,
inputs: Dict[str, Any],
run_manager: Optional[CallbackManagerForChainRun] = None,
) -> Dict[str, Any]:
text = inputs[self.input_key]

from azure.ai.contentsafety.models import AnalyzeTextOptions

request = AnalyzeTextOptions(text=text)
response = self.client.analyze_text(request)

result = response.categories_analysis
output = self._detect_harmful_content(text, result)

return {self.input_key: output, self.output_key: output}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does returning the input_key: with the output do?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it so the input of the next step of the chain is the filtered content. It makes it so that if the user doesn't want an error to be thrown, the model will not receive harmful content but instead the message ''The input has breached Azure's content safety policy'. Without this the input at the next step would still be the original harmful content.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Tests for the Azure AI Content Safety Chain."""

from typing import Any

import pytest

from langchain_community.chains.azure_content_safety_chain import (
AzureAIContentSafetyChain,
AzureHarmfulContentError,
)


@pytest.mark.requires("azure.ai.contentsafety")
def test_content_safety(mocker: Any) -> None:
mocker.patch("azure.ai.contentsafety.ContentSafetyClient", autospec=True)
mocker.patch("azure.core.credentials.AzureKeyCredential", autospec=True)

key = "key"
endpoint = "endpoint"

chain = AzureAIContentSafetyChain(
content_safety_key=key, content_safety_endpoint=endpoint
)
assert chain.content_safety_key == key
assert chain.content_safety_endpoint == endpoint


@pytest.mark.requires("azure.ai.contentsafety")
def test_raise_error_when_harmful_content_detected(mocker: Any) -> None:
key = "key"
endpoint = "endpoint"

mocker.patch("azure.core.credentials.AzureKeyCredential", autospec=True)
mocker.patch("azure.ai.contentsafety.ContentSafetyClient", autospec=True)
chain = AzureAIContentSafetyChain(
content_safety_key=key, content_safety_endpoint=endpoint, error=True
)

mock_content_client = mocker.Mock()
mock_content_client.analyze_text.return_value.categories_analysis = [
{"Category": "Harm", "severity": 1}
]

chain.client = mock_content_client

text = "This text contains harmful content"
with pytest.raises(AzureHarmfulContentError):
chain._call({chain.input_key: text})


@pytest.mark.requires("azure.ai.contentsafety")
def test_no_harmful_content_detected(mocker: Any) -> None:
key = "key"
endpoint = "endpoint"

mocker.patch("azure.core.credentials.AzureKeyCredential", autospec=True)
mocker.patch("azure.ai.contentsafety.ContentSafetyClient", autospec=True)
chain = AzureAIContentSafetyChain(
content_safety_key=key, content_safety_endpoint=endpoint, error=True
)

mock_content_client = mocker.Mock()
mock_content_client.analyze_text.return_value.categories_analysis = [
{"Category": "Harm", "severity": 0}
]

chain.client = mock_content_client

text = "This text contains no harmful content"
output = chain._call({chain.input_key: text})

assert output[chain.output_key] == text
Loading