# Tutorial

Stop spending time on prompt iteration! Follow a few steps to automatically generate your optimized prompt.

{% hint style="info" %}
Want to integrate even quicker? Try out Farsight AI on a Colab notebook [here](https://colab.research.google.com/drive/16iSiMl6ngqHKL7SuOnHhTkTDbe1EKRUA?usp=sharing).
{% endhint %}

*<mark style="color:red;">Note:</mark> To utilize our package, you must have access to an* [*OpenAI API Key*](https://platform.openai.com/account/api-keys)*.*&#x20;

### Setup A Python Environment[​](https://docs.confident-ai.com/docs/getting-started#setup-a-python-environement) <a href="#setup-a-python-environement" id="setup-a-python-environement"></a>

Go to the root directory of your project and create a virtual environment (if you don't already have one). In the CLI, run:

```python
python3 -m venv env
source venv/bin/activate
```

### Installation[​](https://docs.confident-ai.com/docs/getting-started#installation) <a href="#installation" id="installation"></a>

Install our library by running:&#x20;

```
pip install farsightai
```

### Suggested Starter Workflow

**Fully automated approach:** Utilize our fully automation prompt optimization function that generates, evaluates and iteratively improves system prompts based on your shadow traffic, evaluation rubric, and optional ground truth outputs.&#x20;

**We've provided an example of this suggested generation and evaluation process below.**

```python
from farsightai import FarsightAI
from openai import OpenAI

# Replace this with your openAI credentials
OPEN_AI_KEY = "<openai_key>"

shadow_traffic = [
    "What are the current job openings in the company?",
    "How can I apply for a specific position?",
    "What is the status of my job application?",
    "Can you provide information about the company's benefits and perks?",
    "What is the company's policy on remote work or flexible schedules?",
    "How do I update my personal information in the HR system?",
    "Can you explain the process for employee onboarding?",
    "What training and development opportunities are available for employees?",
    "How is performance evaluation conducted in the company?",
    "Can you assist with information about employee assistance programs or wellness initiatives?",
]

best_prompts = farsight.get_best_system_prompts(shadow_traffic, gpt_optimized=True)
print (best_prompts)
# Result:

# [
#     PromptEvaluation(
#         score=4.666666666666667,
#         system_prompt="<SYS> Thank you for reaching out to our HR chatbot. How can I assist you with your HR-related queries while ensuring the protection ...""
#         test_results=[
#               TestResult(
#                     score=5,
#                     input="What is the company's policy on remote work or flexible schedules?   "
#                     output="Our company recognizes the importance of work-life balance and understands that remote work or flexible schedules can contribute ..."
#               ),
#               TestResult( ... ),
#               TestResult( ... ),
#           ]),
#     PromptEvaluation( ... ),
#     PromptEvaluation( ... )
# ]
```


---

# 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://api.farsight-ai.com/sdk/fully-automated-prompt-optimization/introduction/tutorial.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.
