LlamaIndex Integration
A developer building AI apps can now access highly optimized LLMs and Embeddings models on OctoAI.
Introduction
LlamaIndex strives to help manage the interactions between your language modles and private DataTransfer. If you are building your application and using LlamaIndex you benefit from the vast ecosystem of integrations, and top LLMs amd Embeddings models hosted by OctoAI.
OctoAI’s LLMs and Embeddings classes in LlamaIndex
Get started reviewing more about LlamaIndex.
LlamaIndex has both Python and TypScript libraries. OctoAI is available in the Python SDK.
Using the LlamaIndex integration class for OctoAI LLMs
To use OctoAI LLM endpoints with LlamaIndex start with the code below using Llama 3 8B as the LLM.
Using the LlamaIndex integration class for OctoAI Embeddings
To use OctoAI Embedding endpoints with llamaindex you can use the code below to get started. We’re using GTE large in the example below (default model).
Building LlamaIndex Agents with OctoAI endpoints
There are different types of agent classes in LlamaIndex. Each one of these classes implement different types of agentic programming patterns. In the following section we will take a look at how to build two types of agents with OctoAI endpoints:
- ReAct Agents
- OpenAI Agents
OpenAILike
class instead of the OctoAI
class used above.LlamaIndex ReAct Agents with OctoAI
ReAct agents are based in an execution cycle comprised of three steps: Reason, Obersve, Act. This is outlined by the ReAct research paper. One can build ReAct agents in LlamaIndex by using the OpenAILike
and ReActAgent
classes like so:
ReAct agents are very convenient and popular to create. One consideration to have is that this class in particular does not use the tool’s API for the LLM requests, so prompting may need to be adjusted in order to meet your performance requirements. You can see a fully working example of this pattern in this Jupyter Notebook written by Yujian Tang.
LlamaIndex OpenAI Agents with OctoAI
OpenAI agents are a good class to use to develop agents based on OSS models. In particular, this class makes use of the tools API of our LLM endpoints, which will provide better behavior than a prompt-only approach. One can build OpenAI agents in LlamaIndex by using the OpenAILike
and OpenAIAgent
classes like so:
OpenAI agents are the prefered way to create LlamaIndex agents using OctoAI LLM endpoints. This will guarantee that your requests will benefit from using the enhances and adaptations distributed through our API. For a fully functioning script of the above example take a look at out Text-Gen Cookbook Recipe.
The details matter
If you take a closer look at the constructor of the agent classses on the snippets above you will notice that we are using quite a few parameters:
Setting these parameters is important to guarantee good behavior. Setting a lower temperature, or too few output tokens, will severily hinder the performance of the model.
Learn with our shared resources
- Learn how to use LLMs and Embedding APIs with OctoAI’s documentation.
- Take a look at other LlamaIndex Cookbook recipes in GitHub, here.
- Learn how to build agents, indexes, parse documents, and more, at the LlamaIndex resources here.