Skip to content

Updated app example #201

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fly.toml
__pycache__
storage
venv
node_modules
credentials.json
token.json
*.chainlit
Expand Down
7 changes: 2 additions & 5 deletions langchain-azure-agent/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AZURE_OPENAI_API_VERSION=
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4.1
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME=text-embedding-3-large
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_API_KEY=
Expand All @@ -11,10 +11,7 @@ OAUTH_AZURE_AD_TENANT_ID=
CHAINLIT_AUTH_SECRET=
OAUTH_AZURE_AD_ENABLE_SINGLE_TENANT=true
CHAINLIT_URL=http://localhost:8000/
PTS_STOCKBALANCE_API_KEY=
AZURE_SEARCH_APP_ID=
AZURE_SEARCH_APP_SECRET=
DOCUMENT_INTELLIGENCE_ENDPOINT=
DOCUMENT_INTELLIGENCE_API_KEY=
BING_SEARCH_API_KEY=
BING_SEARCH_ENDPOINT=
DOCUMENT_INTELLIGENCE_API_KEY=
33 changes: 16 additions & 17 deletions langchain-azure-agent/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Chat Application with ToolCallingAgent
# Chainlit application with ReAct agent

This repository contains a Chat Application powered by AI models and tools for interacting with users, processing files, and retrieving relevant information.
This repository contains a chainlit application powered by a LangGraph ReAct agent. The two main challenges for creating an LLM chat app are the python sandbox code execution and performant document loading. There may be better solutions for these in the future.

## Features

- **AI Agent Integration**: Supports AI tools for RAG (Retrieve-then-Answer Generation) search, web search, and file search.
- **Azure AI Integration**: Utilizes Azure AI Document Intelligence for file processing.
- **Memory Management**: Includes conversation summary buffer memory for maintaining context.
- **File Upload Support**: Processes various file types like `.pdf`, `.xlsx`, `.docx`, `.pptx`, `.txt`, images, and more.
- **Custom Handlers**: Implements handlers for streaming AI responses and OAuth integration.
- **AI Agent Integration**: Supports AI tools for Retrieval-augmented generation (RAG), web search, and file upload.
- **Azure AI Integration**: Utilizes Azure AI Document Intelligence as well as local parsers for file processing.
- **Dynamic Context Handling**: Dynamically adjusts context based on user input and uploaded files.

## Supported File Types
Expand All @@ -27,25 +24,27 @@ The application supports the following file types for upload and processing:
- `.heif`
- `.html`

## Setup Instructions
These types are handled differently for performance reasons. While Document Intelligence can also handle text types (parsing the layout as well!), it does so with a large hit to performance. Similarly, Unstructured is an alternative parser for PDF and other file types, but it is approximately twice as slow for large PDFs and results in a very large Docker image (15 GB+), which can be challenging to host. The main challenge for document parsing is not open source code, but compute (GPU resources to parse documents).

Add the following configuration to `.chainlit/config.toml`:
```toml
cot = "tool_call"
```
The approach taken here is similar to Open WebUI and AnythingLLM, using different parsers for different file formats.

# Python code sandbox

The langchain_sandbox library is used here, since it doesn't require hosting of any additional resources.

## Folder Structure

- `tools`: Contains tools for RAG search, web search, and uploaded file search.
- `tools`: Contains tools for RAG search and uploaded file search.
- `services`: Includes Azure integration services.
- `handlers`: Implements custom callback handlers for streaming and OAuth.
- `app.py`: Main application file.

## Usage

1. Start the chat application.
2. Upload files or send messages.
3. Interact with the AI-powered agent for information retrieval, summarization, and dynamic responses.
1. Create a virtual environment using: python -m venv .venv
2. Use the virtual environment using: .venv\Scripts\activate
3. Install the dependencies using pip install -r requirements.txt
4. Install deno: https://docs.deno.com/runtime/getting_started/installation/
5. Run the app from the virtual environment, using: chainlit run app.py

## Extending the Application

Expand Down
Loading