From 9410237903e9481cd24d5a8d8ffd58ca45ff8243 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Fri, 28 Feb 2025 14:32:46 +0100 Subject: [PATCH 1/6] feat(gen-apis): add llamaindex --- ...ing-generative-apis-with-popular-tools.mdx | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx index ad77ff2197..da450854dc 100644 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx @@ -21,6 +21,7 @@ The following table compares AI tools and libraries supported by Scaleway's Gene | --- | --- | --- | --- | | [OpenAI client](#openai-client-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low | | [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications | Inference, embeddings, document indexing and retrieval | Medium | +| [LlamaIndex](#llamaindex-data-framework) | Framework for building powerful LLM (Large Language Model) applications | Knowledge graph building, document retrieval, data indexing | Medium | | [Continue Dev](#continue-dev-ai-coding-assistance) | Library for AI-powered coding assistance | Code completion, code review | Low | | [cURL/Python](#custom-http-integrations) | Direct HTTP API calls for custom integrations | Custom applications, data processing | High | @@ -71,6 +72,46 @@ LangChain is a popular library for building AI applications. Scaleway's Generati - [Implementing Retrieval-Augmented Generation (RAG) with LangChain and Scaleway Generative APIs](/tutorials/how-to-implement-rag-generativeapis/) +## LlamaIndex data framework + +LlamaIndex is an open source is a data framework for building Large Language Models (LLMs) based application. To get started, you'll need to install the LlamaIndex and set up your API key. + +### Configuration + +To use the LlamaIndex framework with Scaleway's Generative APIs, first install the required dependencies: + +```bash + pip install llama-index-llms-openai-like +``` + +Then set the API key and base URL in your OpenAILike-compatible client: + +```python +from llama_index.llms.openai_like import OpenAILike + +llm = OpenAILike( +model="pixtral-12b-2409", +api_key="", +api_base="https://api.scaleway.ai/v1", +max_tokens=512, +temperature=0.7, +top_p=1, +presence_penalty=0, +) +``` + + Make sure to replace `` with your actual API key. + + +### Using LlamaIndex client to chat with the LLM + +```python + response = llm.chat([ChatMessage("could you tell about Scaleway please")]) + print(response) +``` + + + ## Continue Dev (AI coding assistance) Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more. From 3ff1ef83874f63ea3186dfb6b272bceb0526f76d Mon Sep 17 00:00:00 2001 From: Laure-di Date: Mon, 3 Mar 2025 10:02:10 +0100 Subject: [PATCH 2/6] end of tuto --- .../integrating-generative-apis-with-popular-tools.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx index da450854dc..a6b06a9df1 100644 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx @@ -105,13 +105,14 @@ presence_penalty=0, ### Using LlamaIndex client to chat with the LLM +Once the configuration is set up, you can interact with the LLM by sending messages to the model. The following code demonstrates how to chat with the model using LlamaIndex: + ```python response = llm.chat([ChatMessage("could you tell about Scaleway please")]) print(response) ``` - ## Continue Dev (AI coding assistance) Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more. From 457422917dd7a1ca73849d24708eb1a48df27ba9 Mon Sep 17 00:00:00 2001 From: fpagny Date: Mon, 3 Mar 2025 18:46:28 +0100 Subject: [PATCH 3/6] Update integrating-generative-apis-with-popular-tools.mdx Fix snippets and improve wording for LlamaIndex quickstart --- ...ing-generative-apis-with-popular-tools.mdx | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx index a6b06a9df1..6e8f430204 100644 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx @@ -20,8 +20,8 @@ The following table compares AI tools and libraries supported by Scaleway's Gene | Tool/Library | Description | Use cases | Integration effort | | --- | --- | --- | --- | | [OpenAI client](#openai-client-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low | -| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications | Inference, embeddings, document indexing and retrieval | Medium | -| [LlamaIndex](#llamaindex-data-framework) | Framework for building powerful LLM (Large Language Model) applications | Knowledge graph building, document retrieval, data indexing | Medium | +| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications leveraging RAG | Inference, embeddings, document indexing and retrieval | Medium | +| [LlamaIndex](#llamaIndex-advanced-rag-applications) | Library for building advanced AI RAG applications | Knowledge graph building, document retrieval, data indexing | Medium | | [Continue Dev](#continue-dev-ai-coding-assistance) | Library for AI-powered coding assistance | Code completion, code review | Low | | [cURL/Python](#custom-http-integrations) | Direct HTTP API calls for custom integrations | Custom applications, data processing | High | @@ -72,46 +72,47 @@ LangChain is a popular library for building AI applications. Scaleway's Generati - [Implementing Retrieval-Augmented Generation (RAG) with LangChain and Scaleway Generative APIs](/tutorials/how-to-implement-rag-generativeapis/) -## LlamaIndex data framework - -LlamaIndex is an open source is a data framework for building Large Language Models (LLMs) based application. To get started, you'll need to install the LlamaIndex and set up your API key. - -### Configuration +## LlamaIndex (advanced RAG applications) +LlamaIndex is an open source framework for building Large Language Models (LLMs) based application, especially optimizing RAG (Retrieval Augmented Generation) pipelines. To use the LlamaIndex framework with Scaleway's Generative APIs, first install the required dependencies: - ```bash - pip install llama-index-llms-openai-like +pip install llama-index-llms-openai-like ``` -Then set the API key and base URL in your OpenAILike-compatible client: - +Then, create a file `main.py` and add the following code to it to configure `OpenAILike` client and secret key: ```python from llama_index.llms.openai_like import OpenAILike +from llama_index.core.llms import ChatMessage llm = OpenAILike( -model="pixtral-12b-2409", -api_key="", -api_base="https://api.scaleway.ai/v1", -max_tokens=512, -temperature=0.7, -top_p=1, -presence_penalty=0, + model="llama-3.1-8b-instruct", + api_key="", + api_base="https://api.scaleway.ai/v1", + max_tokens=512, + temperature=0.7, + top_p=1, + presence_penalty=0, ) ``` Make sure to replace `` with your actual API key. -### Using LlamaIndex client to chat with the LLM - -Once the configuration is set up, you can interact with the LLM by sending messages to the model. The following code demonstrates how to chat with the model using LlamaIndex: - +You can then interact with the LLM by sending messages to the model with the following code: ```python - response = llm.chat([ChatMessage("could you tell about Scaleway please")]) - print(response) +response = llm.chat([ChatMessage("Could you tell me about Scaleway please ?")]) +print(response) ``` +Finally, run `main.py`: +```python +python main.py +``` +The LLM response should display an answer: +```bash +Generally, Scaleway is a reliable and secure cloud provider that offers a range of services for businesses and developers. +``` ## Continue Dev (AI coding assistance) @@ -166,4 +167,4 @@ print(response.json()["choices"][0]["message"]["content"]) ``` Make sure to replace `` with your actual API key. - \ No newline at end of file + From d6eff2edd91f34d3286b91408b4a44be284d4ca8 Mon Sep 17 00:00:00 2001 From: fpagny Date: Tue, 4 Mar 2025 09:44:20 +0100 Subject: [PATCH 4/6] Update pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx Co-authored-by: Benedikt Rollik --- .../integrating-generative-apis-with-popular-tools.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx index 6e8f430204..af82d26df0 100644 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx @@ -74,7 +74,7 @@ LangChain is a popular library for building AI applications. Scaleway's Generati ## LlamaIndex (advanced RAG applications) -LlamaIndex is an open source framework for building Large Language Models (LLMs) based application, especially optimizing RAG (Retrieval Augmented Generation) pipelines. +LlamaIndex is an open-source framework for building Large Language Models (LLMs) based applications, especially optimizing RAG (Retrieval Augmented Generation) pipelines. To use the LlamaIndex framework with Scaleway's Generative APIs, first install the required dependencies: ```bash pip install llama-index-llms-openai-like From 0fe8bca72353b31b8b4b4588bcd769bc86e4ff86 Mon Sep 17 00:00:00 2001 From: fpagny Date: Tue, 4 Mar 2025 09:44:33 +0100 Subject: [PATCH 5/6] Update pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx Co-authored-by: Benedikt Rollik --- .../integrating-generative-apis-with-popular-tools.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx index af82d26df0..bbb07f5f4a 100644 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx @@ -80,7 +80,7 @@ To use the LlamaIndex framework with Scaleway's Generative APIs, first install t pip install llama-index-llms-openai-like ``` -Then, create a file `main.py` and add the following code to it to configure `OpenAILike` client and secret key: +Then, create a file `main.py` and add the following code to it to configure the `OpenAILike` client and your secret key: ```python from llama_index.llms.openai_like import OpenAILike from llama_index.core.llms import ChatMessage From 0b6af2ae52537c1bc0bf4966c13f2f0c5996391d Mon Sep 17 00:00:00 2001 From: Benedikt Rollik Date: Tue, 4 Mar 2025 10:05:57 +0100 Subject: [PATCH 6/6] Apply suggestions from code review --- .../integrating-generative-apis-with-popular-tools.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx index bbb07f5f4a..a531ca2f54 100644 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx @@ -75,12 +75,12 @@ LangChain is a popular library for building AI applications. Scaleway's Generati ## LlamaIndex (advanced RAG applications) LlamaIndex is an open-source framework for building Large Language Models (LLMs) based applications, especially optimizing RAG (Retrieval Augmented Generation) pipelines. -To use the LlamaIndex framework with Scaleway's Generative APIs, first install the required dependencies: +1. Install the required dependencies to use the LlamaIndex framework with Scaleway's Generative APIs: ```bash pip install llama-index-llms-openai-like ``` -Then, create a file `main.py` and add the following code to it to configure the `OpenAILike` client and your secret key: +2. Create a file `main.py` and add the following code to it to configure the `OpenAILike` client and your secret key: ```python from llama_index.llms.openai_like import OpenAILike from llama_index.core.llms import ChatMessage @@ -99,13 +99,13 @@ llm = OpenAILike( Make sure to replace `` with your actual API key. -You can then interact with the LLM by sending messages to the model with the following code: +3. You can then interact with the LLM by sending messages to the model with the following code: ```python response = llm.chat([ChatMessage("Could you tell me about Scaleway please ?")]) print(response) ``` -Finally, run `main.py`: +4. Finally, run `main.py`: ```python python main.py ```