# Prompt Generation

{% hint style="info" %}
Make sure you have your [OpenAI API Key](https://platform.openai.com/account/api-keys) before you begin.&#x20;
{% endhint %}

### Prompts

`generate_prompts()`

Utilize our generate\_prompts functionality to generate multiple system prompts for testing. Provide the task, use case, guidelines, and the number of prompts to be generated. Returns a list of generated prompts.&#x20;

<table><thead><tr><th width="155">Param</th><th width="102">Type</th><th>Description</th></tr></thead><tbody><tr><td>num_prompts</td><td>int</td><td>number of system prompts to be generated</td></tr><tr><td>task</td><td>str</td><td>LLM task such as "You are a financial chatbot" </td></tr><tr><td>context</td><td>str</td><td>LLM context</td></tr><tr><td>guidelines </td><td>list(str)</td><td>any guidelines for your LLM to follow such as "Do not share personal information"</td></tr></tbody></table>

<table><thead><tr><th width="156">Output Type</th><th>Output Meaning</th></tr></thead><tbody><tr><td>List[str]</td><td>list of generated system prompts based on the given task, context, and guidelines</td></tr></tbody></table>

```python
from farsightai import FarsightAI

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

# Replace this with your use case details
num_prompts = 2
task = 'You are a conversational chatbot'
context = 'The year is 2012'
guidelines = ["Don't answer questions about Britney Spears"]
farsight = FarsightAI(openai_key=OPEN_AI_KEY)

generated_prompts = farsight.generate_prompts(num_prompts, task, context, guidelines)
print("prompts: ", generated_prompts)

# prompts: [
#
#    "You are a conversational chatbot from the year 2012. Your goal is to answer questions 
#    based on your knowledge but without answering questions about Britney Spears. I'm here to help! Please 
#    provide me with a question and the specific knowledge you want me to use for 
#    answering it.",
#
#    "As a conversational chatbot in the year 2012, your goal is to answer questions 
#    accurately and concisely. Your guidelines are to not answer any questions about Britney Spears. Please provide the necessary information for me to 
#    generate a response."
# ]
```


---

# 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/step-by-step-prompt-optimization/prompt-generation.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.
