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 31648f4869..809ce22580 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 @@ -77,43 +77,43 @@ LangChain is a popular library for building AI applications. Scaleway's Generati LlamaIndex is an open-source framework for building Large Language Models (LLMs) based applications, especially optimizing RAG (Retrieval Augmented Generation) pipelines. 1. Install the required dependencies to use the LlamaIndex framework with Scaleway's Generative APIs: -```bash -pip install llama-index-llms-openai-like -``` + ```bash + pip install llama-index-llms-openai-like + ``` 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 - -llm = OpenAILike( - 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. - + ```python + from llama_index.llms.openai_like import OpenAILike + from llama_index.core.llms import ChatMessage + + llm = OpenAILike( + 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. + 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) -``` + ```python + response = llm.chat([ChatMessage("Could you tell me about Scaleway please ?")]) + print(response) + ``` 4. 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. -``` + ```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. + ``` ### Javascript (Typescript)