# Create Embeddings

Let's consider an example of a robot that takes instructions for a car from a text file, splits it into fragments, and computes an embedding for each fragment - a feature vector for subsequent searching of the required parts of the document by similarity. The text fragments along with their corresponding embeddings are recorded in a CSV file. This project serves as a preparatory step for using the [SearchEmbeddings](https://docs.sherparpa.ru/en/sherpa-rpa/sherpa-designer/primery-robotov/ai-chat-with-own-document/search-embeddings) project and should be run only once.

The robot project consists of a single diagram. Thus, to describe it step by step, this robot works as follows:

1. Reads the content of the specified file in the properties.
2. Splits this content into fragments.
3. Computes the embedding for each element.
4. Writes the obtained embeddings to Data Tables.
5. Saves the text fragments with their corresponding embeddings to a CSV file.

The project diagram looks like this (for convenience, the blocks of the diagram are numbered):

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeqeFXEghBrEJHcfvZaTCQI1NahBcJyOoAIbOyxr2zvX7kNyLHk16bUBauM79_VAn14Y87DSstQ3cgnFgu-SgTFZflvWzpo6naDc9n8MBYXerk0v_IW29BXiuukSLkr1zjoPDbbkB8lMm38UusKN_b-tyNp?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

1. **Start Block** (any diagram begins with this block).
2. **Read Line from File Block** reads the content of the file sequentially (line by line). The following properties are specified for this block:

* File Name (the name of the file from which information will be read);
* Encoding (the encoding of the file from which information will be read);
* Skip Empty Lines (when the flag is set, the function to skip empty lines while reading information from the file is enabled).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfnauS1JofV8ELk4693-5QZDuuKayN9ePsVQT2RxZ5tDDgShbJfCqFyMewelWsZVVKatZpfZUzOtY1RzVendsUsxfwV9duCCwjxCGwoRZlr-rW1XwxF6vDyJ9RuwoI0v1La_DPDFxGONrUrkQbkO9XAiGxB?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

3. **Condition Block** checks the specified condition for truth, after which the script execution continues towards the "Yes" exit (if the condition is met) or towards the "No" exit (if the condition is not met).

The condition is written in the format: “variable” equals (==)/ greater than (>)/ less than (<) “value”.

For example: $a == “Hello”, that is, if the value of the variable $a is equal to “Hello”, then the exit is “Yes”, otherwise – the exit is “No”.

$Result > 5, that is, if the value of the variable $Result is less than 5, then the exit is “Yes”, otherwise – the exit is “No”.

In this case, the condition is set as: $Lines.Count > 0, that is, this condition checks if the value of the variable $Lines is greater than zero, then the exit is “Yes”, otherwise – the exit is “No”.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfa-l3C_PRVCFhonw8r-jsJ3SxFNqb7mclAsVC3akc4KC-f183-YOWOaTRich6-ut0XK_3n4NtowI3hX_5a3kyYeO3Kx-43CC0BckGSv09u9t4R13gW1ygndCxls17VZcwQLGpUsrZ3yjF_R-clVU_P9J41?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

4. **Get Embeddings Block** allows obtaining embeddings for a string or a list of strings using the Open AI service. The following properties are specified for this block:

* Text (input text for which embeddings will be calculated);
* Model (neural network model for generating the response);
* As Data Table (when the flag is set, the function to return the result as a data table with two columns: “Text” and “Embeddings” is enabled);
* Timeout (maximum waiting time for a response in seconds).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfa-l3C_PRVCFhonw8r-jsJ3SxFNqb7mclAsVC3akc4KC-f183-YOWOaTRich6-ut0XK_3n4NtowI3hX_5a3kyYeO3Kx-43CC0BckGSv09u9t4R13gW1ygndCxls17VZcwQLGpUsrZ3yjF_R-clVU_P9J41?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

5. **Join Data Tables Block** allows joining two Data Tables into one. The following properties are specified for this block:

* First Data Table;
* Second Data Table;
* Join Type (the type of join for the tables if the schemas of the specified tables differ. In this case, the type is “Add”, that is, to add).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcFJzDLfU3eTOlFkjG77aXHdZG0mpHS4ro-l9wr3vK6DVDKXI1fszYBalQRBztSnTPqDM5AK4ZZ90JC19gvtdi7EEuZsBEbOzWdls6glvy-Tt4V9XjCZBN91yeRqWF-7Qo2_TbuxlA37zrQoHvtClQocxzf?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

6. **Save to CSV Block** allows saving the Data Table to a CSV document. The following properties are specified for this block:

* Data Table (the Data Table that needs to be saved in the document);
* File Path (the path to the file where the Data Table needs to be saved);
* Separator (the separator character);
* Encoding (the file encoding).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdm7Hy8zb6DHe1qizlhP3mMJGD2D6G_pKxSJDZr2WbJe17nOqyUWTjjRGnweZCfvMxUhxBN5EKAKIWx9TgQW9jNAv92qbk00wgC4G216o-nWaZcMfrCIZbiST4HLe3N6trmkfXJEbYer3LUTUXZShKiFNs?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

7. **Log Block** allows outputting arbitrary messages and/or variable values to the log during the robot's script execution. The property “Value” is specified for this block. A text constant is indicated in quotes, and the variable name starts with the symbol $. That is, this block logs a message about reading a line from the file, indicating this line using the variable.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdsANztAn7ZTGLAB_TI68D0gBexaQhwPGRSEIxPYsyZx4UKqGy_bh7O1trBk4wdSxYmme8sEKPNKS6HC00El_tsbc1D_vp0ml5zpD1s_AFukl6Gpu-ySXBMc0JDxiqLyc90nZNTqarzzOIa3VXnZ54sfO1q?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

8. **Add Item to List Block** allows adding the specified item to the end of the list. The following properties are specified for this block:

* List (the list to which the new item needs to be added);
* Item (the variable that needs to be added to the list).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc2vHe-GAj8Io3KgP9MxDpR-Q6QyHF1KSvP9O1x0UIGzEEZkh2cv-GQztoce04aIS7Byv7pXB3SO7Ovrt398hxuaNaeJBxFD8ghC_git18fl9Kf6s7ItBALKNZMAByMQLxyHzGuhBcUNLnXNeF72g8BknM?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

9. **Condition Block** checks the specified condition for truth, after which the script execution continues towards the "Yes" exit (if the condition is met) or towards the "No" exit (if the condition is not met).

The condition is written in the format: “variable” equals (==)/ greater than (>)/ less than (<) “value”.

For example: $a == “Hello”, that is, if the value of the variable $a is equal to “Hello”, then the exit is “Yes”, otherwise – the exit is “No”.

$Result > 5, that is, if the value of the variable $Result is less than 5, then the exit is “Yes”, otherwise – the exit is “No”.

In this case, the condition is set as: $Lines.Count > 20, that is, if the value of the variable $Lines is greater than 20, then the exit is “Yes”, otherwise – the exit is “No”.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfFmWCp-UTvYnzcBwrKxZjoRb0MJPixptgLJk5e00ihRJwVw2cNhAlysg2351x5h-BrfzqQCJjJGJ2J4GRUo-o84BaDj2e0eufJ5jIKgXycFDZSfNVNCWUElSZAXzxCJTZyXe1Jx71GyHydV3D96Ju2EA-e?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

10. **Get Embeddings Block** allows obtaining embeddings for a string or a list of strings using the Open AI service. The following properties are specified for this block:

* Text (input text for which embeddings will be calculated);
* Model (neural network model for generating the response);
* As Data Table (when the flag is set, the function to return the result as a data table with two columns: “Text” and “Embeddings” is enabled);
* Timeout (maximum waiting time for a response in seconds).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXepwSilXC_cllvFbDFyFaMVyvVlc2_axeN3z8QrEb4kEj05uMudA4vL91vle05FfBRQ9GRSa7ImDSynQBblmy1fwa0S8RgAXmOoofSD9SJysRvCPnJaynZjLv5YqqPXBHWzNTT2u2LzLJ4WagvaDk83mXi4?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

11. **Join Data Tables Block** allows joining two Data Tables into one. The following properties are specified for this block:

* First Data Table;
* Second Data Table;
* Join Type (the type of join for the tables if the schemas of the specified tables differ. In this case, the type is “Add”, that is, to add).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfKbeXW7xmQUmm2QUo2SptN_Sy3TmtXvAGKezoGsBV_YZ6m2rViGM2zPrE_oJGoCVb0QOTBWsgPpb1gePZvUWRaJ9uc_dUla_dpAm39FLPZLUlo7GqdNzTuMcdIWpapTxi3ZPYDb1SgE76K13SLvuH9dKc?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

12. **Save to CSV Block** allows saving the Data Table to a CSV document. The following properties are specified for this block:

* Data Table (the Data Table that needs to be saved in the document);
* File Path (the path to the file where the Data Table needs to be saved);
* Separator (the separator character);
* Encoding (the file encoding).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfWM5DkrV0izVAXoc3QDlpUamkCK2BeeaRRc2h__RG1TOrqOThH7Jq6cCzelcJXfOLnplf564i5pkD5UZw0thgl6dPywh3VB5HQ0iv52oi0uyI3QQW09oUFRVCiwKdnM0dvetDlvYCHkP1yfkI0tyl5To0?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

13. **Clear List Block** allows clearing the list by removing all its elements. The property “List” (the list that needs to be cleared) is specified for this block.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcbGlCf-VwsKDHABp-ZYixyU_k8Hc6D48UD1XPnRD2s9NBMbPk_boXQ-DSl0m_DtPAcfGntoWd_y7o1OJGnLXuDzj1q7kjiEzzY7CIy6dqHLKS419PdUlqvnkhnYZIEQ8Lylvmghb1uzYT4y28keGi0PiSf?key=2EX7NdvOOR4JJxCrOTqjfg" alt=""><figcaption></figcaption></figure>

14. **End Block** (this block concludes the script execution or returns the subprocess diagram to the main process).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sherparpa.ru/en/sherpa-rpa/sherpa-designer/primery-robotov/ai-chat-with-own-document/create-embeddings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
