Skip to content

Commit 34b2934

Browse files
Laure-difpagnybene2k1
authored
feat(gen-apis): add llamaindex (#4521)
* feat(gen-apis): add llamaindex * end of tuto * Update integrating-generative-apis-with-popular-tools.mdx Fix snippets and improve wording for LlamaIndex quickstart * Update pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx Co-authored-by: Benedikt Rollik <[email protected]> * Update pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx Co-authored-by: Benedikt Rollik <[email protected]> * Apply suggestions from code review --------- Co-authored-by: fpagny <[email protected]> Co-authored-by: Benedikt Rollik <[email protected]>
1 parent df670f2 commit 34b2934

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx

+45-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ The following table compares AI tools and libraries supported by Scaleway's Gene
2020
| Tool/Library | Description | Use cases | Integration effort |
2121
| --- | --- | --- | --- |
2222
| [OpenAI client](#openai-client-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low |
23-
| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications | Inference, embeddings, document indexing and retrieval | Medium |
23+
| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications leveraging RAG | Inference, embeddings, document indexing and retrieval | Medium |
24+
| [LlamaIndex](#llamaIndex-advanced-rag-applications) | Library for building advanced AI RAG applications | Knowledge graph building, document retrieval, data indexing | Medium |
2425
| [Continue Dev](#continue-dev-ai-coding-assistance) | Library for AI-powered coding assistance | Code completion, code review | Low |
2526
| [Chatbox AI](#chatbox-ai) | Desktop client for generative APIs, available on Windows, Mac, Linux | AI copilot for documents, images, or code| Low |
2627
| [cURL/Python](#custom-http-integrations) | Direct HTTP API calls for custom integrations | Custom applications, data processing | High |
@@ -72,6 +73,48 @@ LangChain is a popular library for building AI applications. Scaleway's Generati
7273
Refer to our dedicated documentation for [implementing Retrieval-Augmented Generation (RAG) with LangChain and Scaleway Generative APIs](/tutorials/how-to-implement-rag-generativeapis/)
7374
</Message>
7475

76+
## LlamaIndex (advanced RAG applications)
77+
78+
LlamaIndex is an open-source framework for building Large Language Models (LLMs) based applications, especially optimizing RAG (Retrieval Augmented Generation) pipelines.
79+
1. Install the required dependencies to use the LlamaIndex framework with Scaleway's Generative APIs:
80+
```bash
81+
pip install llama-index-llms-openai-like
82+
```
83+
84+
2. Create a file `main.py` and add the following code to it to configure the `OpenAILike` client and your secret key:
85+
```python
86+
from llama_index.llms.openai_like import OpenAILike
87+
from llama_index.core.llms import ChatMessage
88+
89+
llm = OpenAILike(
90+
model="llama-3.1-8b-instruct",
91+
api_key="<API secret key>",
92+
api_base="https://api.scaleway.ai/v1",
93+
max_tokens=512,
94+
temperature=0.7,
95+
top_p=1,
96+
presence_penalty=0,
97+
)
98+
```
99+
<Message type="tip">
100+
Make sure to replace `<API secret key>` with your actual API key.
101+
</Message>
102+
103+
3. You can then interact with the LLM by sending messages to the model with the following code:
104+
```python
105+
response = llm.chat([ChatMessage("Could you tell me about Scaleway please ?")])
106+
print(response)
107+
```
108+
109+
4. Finally, run `main.py`:
110+
```python
111+
python main.py
112+
```
113+
The LLM response should display an answer:
114+
```bash
115+
Generally, Scaleway is a reliable and secure cloud provider that offers a range of services for businesses and developers.
116+
```
117+
75118
### Javascript (Typescript)
76119

77120
To perform chat conversations with Langchain, first install `langchain` and `@langchain/openai` packages using your node package manager.
@@ -123,6 +166,7 @@ To perform chat conversations with Langchain, first install `langchain` and `@la
123166
124167
Note that other Langchain objects from OpenAI client library are also compatible, such as `OpenAI` and `OpenAIEmbeddings`.
125168
169+
126170
## Continue Dev (AI coding assistance)
127171
128172
Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more.

0 commit comments

Comments
 (0)