Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 secret key>",
api_base="https://api.scaleway.ai/v1",
max_tokens=512,
temperature=0.7,
top_p=1,
presence_penalty=0,
)
```
<Message type="tip">
Make sure to replace `<API secret key>` with your actual API key.
</Message>
```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 secret key>",
api_base="https://api.scaleway.ai/v1",
max_tokens=512,
temperature=0.7,
top_p=1,
presence_penalty=0,
)
```
<Message type="tip">
Make sure to replace `<API secret key>` with your actual API key.
</Message>

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)

Expand Down