Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions src/oss/python/integrations/providers/all_providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,14 @@ Browse the complete collection of integrations available for Python. LangChain P
Unified API for multiple AI services.
</Card>

<Card
title="Egnyte"
href="/oss/integrations/providers/egnyte"
icon="link"
>
Cloud content collaboration and AI-powered search platform.
</Card>

<Card
title="Elasticsearch"
href="/oss/integrations/providers/elasticsearch"
Expand Down
105 changes: 105 additions & 0 deletions src/oss/python/integrations/providers/egnyte.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Egnyte
---

[Egnyte](https://www.egnyte.com) is a cloud-based content collaboration and file sharing platform that enables organizations to securely store, share, and govern their files. Egnyte combines the power of cloud content management with advanced security, compliance, and AI-powered search capabilities.

This package provides a LangChain integration for Egnyte's hybrid search API, which combines semantic and keyword search to help you find and retrieve documents from your Egnyte instance.

## Installation and setup

<CodeGroup>
```bash pip
pip install -U egnyte-langchain-connector
```

```bash uv
uv add egnyte-langchain-connector
```
</CodeGroup>

# egnyte-langchain-connector

This package contains the LangChain integration with Egnyte. For more information about Egnyte, check out the [Egnyte developer documentation](https://developers.egnyte.com/).

## Prerequisites

In order to integrate with Egnyte, you need:

* An Egnyte account — If you are not a current Egnyte customer or want to test outside of your production Egnyte instance, you can use a [free developer account](https://developers.egnyte.com/member/register).
* An Egnyte app — This is configured in the [developer console](https://developers.egnyte.com/), and must have the appropriate scopes enabled.
* The app must be enabled by the administrator.

## Authentication

The `egnyte-langchain-connector` package uses Bearer token authentication with Egnyte user tokens.

### Generating a User Token

To generate an Egnyte user token for authentication:

1. **Register for a Developer Account**
- Visit [https://developers.egnyte.com/member/register](https://developers.egnyte.com/member/register)
- Create your free developer account

2. **Generate User Token**
- Use your API key to generate a user token following the [Public API Authentication guide](https://developers.egnyte.com/docs/read/Public_API_Authentication)
- **Important**: Use the scope `Egnyte.ai` when generating the token to ensure proper access to AI-powered search features

### Using the Token

You can pass the token directly to the retriever:

```python
import getpass

egnyte_user_token = getpass.getpass("Enter your Egnyte User Token: ")
domain = "company.egnyte.com" # Your Egnyte domain (without https://)
```

Or use environment variables:

```python
import os
from dotenv import load_dotenv

load_dotenv()

egnyte_user_token = os.getenv("EGNYTE_USER_TOKEN")
domain = os.getenv("EGNYTE_DOMAIN")
```

## Retrievers

### EgnyteRetriever

[See usage example](/oss/python/integrations/retrievers/egnyte)

```python
from langchain_egnyte import EgnyteRetriever

retriever = EgnyteRetriever(domain="company.egnyte.com")
```

## Utilities

### EgnyteSearchOptions

Configure advanced search parameters:

```python
from langchain_egnyte import EgnyteSearchOptions

search_options = EgnyteSearchOptions(
limit=50,
folderPath="/policies",
excludeFolderPaths=["/temp", "/archive"],
createdAfter=1640995200000, # Unix timestamp in milliseconds
createdBefore=1672531200000
)
```

## Help

If you have questions, you can check out the [Egnyte developer documentation](https://developers.egnyte.com/) or reach out to us in our developer community.

198 changes: 198 additions & 0 deletions src/oss/python/integrations/retrievers/egnyte.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
title: EgnyteRetriever
---

This will help you get started with the Egnyte [retriever](/oss/langchain/retrieval). For detailed documentation of all EgnyteRetriever features and configurations head to the [API reference](https://github.com/egnyte/egnyte-langchain-connector).

# Overview

The `EgnyteRetriever` class helps you search and retrieve documents from Egnyte using hybrid search capabilities that combine semantic and keyword search. This retriever is fully compliant with LangChain standards and supports both synchronous and asynchronous operations.

### Integration details

Bring-your-own data (i.e., index and search a custom corpus of documents):

| Retriever | Self-host | Cloud offering | Package |
| :--- | :--- | :---: | :---: |
[EgnyteRetriever](https://github.com/egnyte/egnyte-langchain-connector) | ❌ | ✅ | egnyte-langchain-connector |

## Setup

In order to use the Egnyte package, you will need:

* An Egnyte account — If you are not a current Egnyte customer or want to test outside of your production Egnyte instance, you can use a [free developer account](https://developers.egnyte.com/member/register).
* An Egnyte app — This is configured in the [developer console](https://developers.egnyte.com/), and must have the appropriate scopes enabled.
* The app must be enabled by the administrator. For free developer accounts, this is whoever signed up for the account.

### Credentials

For these examples, we will use Bearer token authentication with an Egnyte user token. To generate a user token:

1. Register for a developer account at [https://developers.egnyte.com/member/register](https://developers.egnyte.com/member/register)
2. Generate a user token following the [Public API Authentication guide](https://developers.egnyte.com/docs/read/Public_API_Authentication)
3. **Important**: Use the scope `Egnyte.ai` when generating the token

```python
import getpass
import os

egnyte_user_token = getpass.getpass("Enter your Egnyte User Token: ")
domain = input("Enter your Egnyte domain (e.g., company.egnyte.com): ")
```

If you want to get automated tracing from individual queries, you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:

```python
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
os.environ["LANGSMITH_TRACING"] = "true"
```

### Installation

This retriever lives in the `egnyte-langchain-connector` package:

```bash
pip install -qU egnyte-langchain-connector
```

```output
Note: you may need to restart the kernel to use updated packages.
```

## Instantiation

Now we can instantiate our retriever:

```python
from langchain_egnyte import EgnyteRetriever

retriever = EgnyteRetriever(domain=domain, k=100)
```

## Usage

### Basic Search

```python
query = "machine learning policies"

documents = retriever.invoke(query, egnyte_user_token=egnyte_user_token)

for doc in documents:
print(f"Title: {doc.metadata.get('title', 'N/A')}")
print(f"Content: {doc.page_content[:200]}...")
print("---")
```

### Advanced Search with Options

For more granular search, you can use `EgnyteSearchOptions` to filter results by folder path, date range, and more:

```python
from langchain_egnyte import EgnyteRetriever, EgnyteSearchOptions

search_options = EgnyteSearchOptions(
limit=50,
folderPath="/policies",
excludeFolderPaths=["/temp", "/archive"],
createdAfter=1640995200000, # Unix timestamp in milliseconds (Jan 1, 2022)
createdBefore=1672531200000 # Unix timestamp in milliseconds (Jan 1, 2023)
)

retriever = EgnyteRetriever(
domain=domain,
k=50,
search_options=search_options
)

documents = retriever.invoke(
"compliance requirements",
egnyte_user_token=egnyte_user_token
)
```

### Async Usage

The retriever supports asynchronous operations:

```python
import asyncio

async def search_async():
documents = await retriever.ainvoke(
"data privacy guidelines",
egnyte_user_token=egnyte_user_token
)
return documents

# Run async search
documents = asyncio.run(search_async())
```

### Batch Operations

You can process multiple queries in batch:

```python
queries = [
"security policies",
"employee handbook",
"compliance guidelines"
]

# Synchronous batch
results = retriever.batch(
queries,
config={"configurable": {"egnyte_user_token": egnyte_user_token}}
)

# Asynchronous batch
results = await retriever.abatch(
queries,
config={"configurable": {"egnyte_user_token": egnyte_user_token}}
)
```

## Use as an agent tool

Like other retrievers, EgnyteRetriever can be added to a LangGraph agent as a tool.

```python
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain.tools.retriever import create_retriever_tool
from langchain_openai import ChatOpenAI

retriever = EgnyteRetriever(domain=domain, k=50)

egnyte_search_tool = create_retriever_tool(
retriever,
"egnyte_search_tool",
"This tool searches Egnyte and retrieves documents that match the search criteria using hybrid search"
)

tools = [egnyte_search_tool]

prompt = hub.pull("hwchase17/openai-tools-agent")
llm = ChatOpenAI(temperature=0)

agent = create_openai_tools_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools)

result = agent_executor.invoke({
"input": "Find all documents related to data privacy policies"
})

print(result['output'])
```

---

## API reference

For detailed documentation of all EgnyteRetriever features and configurations, visit the [GitHub repository](https://github.com/egnyte/egnyte-langchain-connector).

## Help

If you have questions, check out the [Egnyte developer documentation](https://developers.egnyte.com/) or reach out to the Egnyte developer community.

1 change: 1 addition & 0 deletions src/oss/python/integrations/retrievers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The below retrievers will search over an external index (e.g., constructed from
<Card title="Dria" icon="link" href="/oss/integrations/retrievers/dria_index" arrow="true" cta="View guide" />
<Card title="ElasticSearch BM25" icon="link" href="/oss/integrations/retrievers/elastic_search_bm25" arrow="true" cta="View guide" />
<Card title="Elasticsearch" icon="link" href="/oss/integrations/retrievers/elasticsearch_retriever" arrow="true" cta="View guide" />
<Card title="Egnyte" icon="link" href="/oss/integrations/retrievers/egnyte" arrow="true" cta="View guide" />
<Card title="Embedchain" icon="link" href="/oss/integrations/retrievers/embedchain" arrow="true" cta="View guide" />
<Card title="FlashRank reranker" icon="link" href="/oss/integrations/retrievers/flashrank-reranker" arrow="true" cta="View guide" />
<Card title="Fleet AI Context" icon="link" href="/oss/integrations/retrievers/fleet_context" arrow="true" cta="View guide" />
Expand Down