Skip to content

Commit 9ff9c34

Browse files
fpagnyjcirinosclwy
andauthored
Apply suggestions from code review
Co-authored-by: Jessica <[email protected]>
1 parent 4cffe5a commit 9ff9c34

File tree

1 file changed

+27
-22
lines changed
  • tutorials/how-to-implement-rag-generativeapis

1 file changed

+27
-22
lines changed

tutorials/how-to-implement-rag-generativeapis/index.mdx

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ Then, we will embed them as vectors and store these vectors in your PostgreSQL d
214214
Note that the configuration should be similar to the one used in `embed.py` to ensure vectors will be read in the same format as the one used to create and store them.
215215
</Message>
216216

217-
218-
### Configure LLM client and create a basic RAG pipeline
217+
### Configure the LLM client and create a basic RAG pipeline
219218

220219
3. Edit `rag.py` to configure LLM client using `ChatOpenAI` and create a simple RAG pipeline:
221220

@@ -256,7 +255,6 @@ Then, we will embed them as vectors and store these vectors in your PostgreSQL d
256255
scw instance server stop example-28f3-4e91-b2af-4c3502562d72
257256

258257
This will shut down the Instance with the specified instance-uuid. Note that this command stops the Instance but does not shut it down completely.
259-
```
260258

261259
This command is correct and can be used with the Scaleway CLI.
262260
Note that vector embedding enabled the system to retrieve proper document chunks even if the Scaleway cheatsheet never mentions `shut down` but only `power off`.
@@ -265,7 +263,8 @@ Then, we will embed them as vectors and store these vectors in your PostgreSQL d
265263
```sh
266264
scaleway instance shutdown --instance-uuid example-28f3-4e91-b2af-4c3502562d72
267265
```
268-
This is command is not correct at all, and "hallucinate" in several ways to fit the question prompt content: `scaleway` instead of `scw`, `instance` instead of `instance server`, `shutdown` instead of `stop` and `--instance-uuid` parameter doesn't exist.
266+
267+
This command is incorrect and 'hallucinates' in several ways to fit the question prompt content: `scaleway` instead of `scw``instance` instead of `instance server``shutdown` instead of `stop`, and the `--instance-uuid` parameter does not exist.
269268

270269
### Query the RAG system with your own prompt template
271270

@@ -317,9 +316,9 @@ Personalizing your prompt template allows you to tailor the responses from your
317316
print(r, end="", flush=True)
318317
```
319318
320-
- `PromptTemplate` enables you to customize how retrieved context and question are passed through LLM prompt.
319+
- `PromptTemplate` enables you to customize how the retrieved context and question are passed through the LLM prompt.
321320
- `retriever.invoke` lets you customize which part of the LLM input is used to retrieve documents.
322-
- `create_stuff_documents_chain` provides the prompt template to the llm.
321+
- `create_stuff_documents_chain` provides the prompt template to the LLM.
323322
324323
6. You can now execute your custom RAG pipeline with:
325324
@@ -329,27 +328,33 @@ Personalizing your prompt template allows you to tailor the responses from your
329328
330329
Note that with Scaleway cheatsheets example, the CLI answer should be similar, but without additional explanations regarding the command line performed.
331330
332-
Congratulations! You built a custom RAG pipeline to improve LLM answers based on specific documentation.
331+
Congratulations! You have built a custom RAG pipeline to improve LLM answers based on specific documentation.
333332
334-
You can now go further by:
335-
- Specializing your RAG pipeline for your use case (whether it's providing better answers for Customer support, finding relevant content through Internal Documentation, helping user generate more creative and personalized content, or much more)
336-
- Storing chat history to increase prompt relevancy.
337-
- Adding a complete testing pipeline to test which prompt, models and retrieval strategy to provide a better experience for your users. You can for instance leverage [Serverless Jobs](https://console.scaleway.com/serverless-jobs/jobs/fr-par) to do so.
333+
## Going further
334+
- Specialize your RAG pipeline for your use case, such as providing better answers for customer support, finding relevant content through internal documentation, helping users generate more creative and personalized content, and much more.
335+
- Store chat history to increase prompt relevancy.
336+
- Add a complete testing pipeline to test which prompt, models, and retrieval strategy provide a better experience for your users. You can, for instance, leverage [Serverless Jobs](https://www.scaleway.com/en/serverless-jobs/) to do so.
338337
339338
## Troubleshooting
340339
341-
If you happen to encounter any issues, first check that you meet all the requirements:
340+
If you happen to encounter any issues, first ensure that you have:
341+
342+
- The necessary [IAM permissions](/identity-and-access-management/iam/reference-content/policy/), specifically **ContainersRegistryFullAccess**, **ContainersFullAccess**
343+
- An [IAM API key capable of interacting with Object Storage](/identity-and-access-management/iam/api-cli/using-api-key-object-storage/)
344+
- Stored the right credentials in your `.env` file allowing to connect to your [Managed Database Instance with admin rights](/managed-databases/postgresql-and-mysql/how-to/add-users/)
342345
343-
- You have the right [IAM permissions](/identity-and-access-management/iam/reference-content/policy/), specifically **ContainersRegistryFullAccess**, **ContainersFullAccess**
344-
- You created an [IAM API Key capable of interacting with Object Storage](https://www.scaleway.com/en/docs/identity-and-access-management/iam/api-cli/using-api-key-object-storage/).
345-
- You stored the right credentials in your `.env` file, especially credentials allowing to connect to your [Managed Database Instance with admin rights](https://www.scaleway.com/en/docs/managed-databases/postgresql-and-mysql/how-to/add-users/).
346+
Below are some known error messages and their corresponding solutions:
346347
347-
If you encounter the following error message, try corresponding solutions:
348348
349-
- `botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the ListObjectsV2 operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.`
350-
- **Solution:** Ensure your `SCW_BUCKET_NAME`, `SCW_REGION`, `SCW_BUCKET_ENDPOINT` and `SCW_SECRET_KEY` are properly configured, that corresponding IAM Principal have the proper rights and that your [IAM API Key can interact with Object Storage]
351-
- `urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)>`
352-
- On MacOS, ensure your Python version has loaded certificates trusted by MacOS. You can fix this by `Applications/Python 3.X` (where X is your version number), and double click on `Certificates.command`.
353-
- `ERROR:root:An error occurred: bge-multilingual-gemma2 is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
349+
**Error**: `botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the ListObjectsV2 operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.`
350+
**Solution**: Ensure that your `SCW_BUCKET_NAME`, `SCW_REGION`, `SCW_BUCKET_ENDPOINT`, and `SCW_SECRET_KEY` are properly configured, the corresponding IAM Principal has the necessary rights, and that your [IAM API key can interact with Object Storage](/identity-and-access-management/iam/api-cli/using-api-key-object-storage/).
351+
352+
**Error**: `urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)>`
353+
354+
**Solution**: On MacOS, ensure your Python version has loaded certificates trusted by MacOS.
355+
You can fix this with `Applications/Python 3.X` (where `X` is your version number), and double click on `Certificates.command`.
356+
357+
**Error**: `ERROR:root:An error occurred: bge-multilingual-gemma2 is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
354358
If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>``
355-
- This is caused by Langchain OpenAI adapter trying to tokenize content. Ensure you set `check_embedding_ctx_length=False` in OpenAIEmbedding configuration to avoid tokenizing content (as tokenization will be performed server-side, in Generative APIs).
359+
360+
**Solution**: This is caused by the LangChain OpenAI adapter trying to tokenize content. Ensure you set `check_embedding_ctx_length=False` in OpenAIEmbedding configuration to avoid tokenizing content, as tokenization will be performed server-side in Generative APIs.

0 commit comments

Comments
 (0)