This repository demonstrates how to integrate LlamaIndex with Emergence AI's Web Orchestrator. It uses OpenAI for language model capabilities, and Emergence AI for web automation workflows.
-
llamaindex-integration.py: Main Python file that:- Loads your API keys from a
.envfile. - Defines a function to create and poll an Emergence AI web workflow.
- Wraps that function as a tool for LlamaIndex.
- Uses an OpenAIAgent from LlamaIndex to handle user queries and call the Emergence tool when needed.
- Loads your API keys from a
-
.env: File containing secret keys, likeOPENAI_API_KEYandEMERGENCE_API_KEY. (This file is gitignored so your keys remain private.) -
requirements.txt: Python dependencies.
If you haven’t already:
git clone https://github.com/<your username>/LlamaIndex-Emergence-Integration.git
cd LlamaIndex-Emergence-Integration
(If you’re reading this after pulling changes, just cd into the local folder.)
python3 -m venv venv
source venv/bin/activate(On Windows PowerShell: .\venv\Scripts\activate.)
pip install -r requirements.txtThis installs:
Create a file named .env in the same directory:
OPENAI_API_KEY="<your-openai-key>"
EMERGENCE_API_KEY="<your-emergence-key>"
These environment variables are used by:
llama_index.llms.openai.OpenAIfor LLM calls,- and the Emergence function for web orchestrator API calls.
(Ensure .env is in your .gitignore so you don’t commit secrets.)
python llamaindex-integration.pyWhen prompted, enter a web automation prompt—for instance:
Please go to CNN.com and find the latest AI investment news.
- The LlamaIndex agent uses your OpenAI model to parse the request.
- It calls the Emergence “web orchestrator” tool if it decides it needs web automation.
- The script prints the final answer to your console.
- If you see
No EMERGENCE_API_KEY found..., ensure.envhas the correct key name and value. - If you see “Error creating Emergence workflow,” check your Emergence AI subscription or network status.
- If the agent never calls Emergence, you can guide it in the conversation (e.g. “Use the web orchestrator tool to accomplish this.”).
-
emergence_llamaindex.py
Main entry point. Shows how to:- Load environment variables with
python-dotenv. - Initialize the Emergence web orchestrator function.
- Create a LlamaIndex
OpenAIAgentwith a custom tool.
- Load environment variables with
-
.env
Contains yourOPENAI_API_KEYandEMERGENCE_API_KEY. Not committed to source control if.gitignoreis set up. -
requirements.txt
Defines the Python libraries needed for the project. -
README.md
(This document!) Explains how to set up and run the integration.