Tutorial

Find your optimized system prompt automatically

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

Want to integrate even quicker? Try out Farsight AI on a Colab notebook here.

Note: To utilize our package, you must have access to an OpenAI API Key.

Setup A Python Environment

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

python3 -m venv env
source venv/bin/activate

Installation

Install our library by running:

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.

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

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( ... )
# ]

Last updated