-
Notifications
You must be signed in to change notification settings - Fork 10k
[AIG] Initial documentation for prompt management #19804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
50e51e5
Initial documentation for prompt management
daisyfaithauma eda361d
Update prompt-management.mdx
kathayl 7126095
Moved prompting to a separate page
daisyfaithauma 52baaab
Merge branch 'aig-prompt-management' of https://github.com/cloudflare…
daisyfaithauma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
src/content/docs/ai-gateway/configuration/prompt-management.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| --- | ||
| pcx_content_type: configuration | ||
| title: Prompt Management | ||
| sidebar: | ||
| order: 8 | ||
| --- | ||
|
|
||
| Prompts are essential for fine-tuning AI model behavior, where even small changes in wording can significantly impact responses. AI Gateway makes it easy for developers to create, manage, and optimize prompts at scale, improving application performance and user experiences. | ||
|
|
||
| ## How to create a prompt | ||
|
|
||
| Creating prompts in AI Gateway is done via the Cloudflare Dashboard or API. | ||
|
|
||
| ### Using the Dashboard: | ||
|
|
||
| 1. Log into the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account. | ||
|
|
||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 2. Go to the **Prompts** tab. | ||
|
|
||
| 3. Create a new prompt: | ||
|
|
||
| - Click on the **New Prompt** button. | ||
| - Provide the following details: | ||
| - Prompt name: A unique name to identify the prompt. | ||
| - Prompt : The instructions or text for the AI model. | ||
| - Tags: (Optional) Add tags to organize and search prompts easily. | ||
|
|
||
| 4. Save the Prompt: | ||
|
|
||
| - Click **Create Prompt** to store your prompt. | ||
|
|
||
| :::note[Note] | ||
|
|
||
| Creating a new prompt will also generate a new prompt version. By default, this new version will be set as the active version and used to process requests made to the Gateway. | ||
|
|
||
| ::: | ||
|
|
||
| 5. Copy the code snippet: | ||
| - After saving, a code snippet will be available: | ||
|
|
||
| ``` | ||
| curl https://gateway.ai.cloudflare.com/v1/0d37909e38d3e99c29fa2cd343ac421a/{gateway_id}/workers-ai/@cf/meta/llama-3.1-8b-instruct \ | ||
| --header 'Authorization: Bearer {cf_api_token}' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --data '{"prompt": "<cf-aig-prompt id=\"workers-ai-prompt\"/>"}' | ||
| ``` | ||
|
|
||
| - Test this prompt by sending the cURL request or copying the snippet to add directly to your code. | ||
|
|
||
| 5. Prompt ID: | ||
| - Here is an example of the prompt ID generated: | ||
|
|
||
| ``` | ||
| <cf-aig-prompt id="workers-ai-prompt"/> | ||
| ``` | ||
|
|
||
| 6. Confirmation: | ||
| - A success page will confirm that your prompt has been created. | ||
|
|
||
| ## Managing Prompt versions | ||
|
|
||
| AI Gateway allows you to maintain prompt versions to test changes and roll back if needed. | ||
|
|
||
| 1. Create a new version: | ||
|
|
||
| - Make changes to an existing prompt (for example tweak wording). | ||
| - Save the changes as a new version. | ||
| - By default, the newly saved version will become the active version. | ||
|
|
||
| 2. Track versions: | ||
|
|
||
| - The dashboard shows all versions, indicating which is active and which are older. | ||
| - Compare versions to see changes and their impact by ticking the `show diff` box. | ||
|
|
||
| 3. Version control benefits: | ||
|
|
||
| - Easily roll back to a previous version if a new prompt doesn't perform well. | ||
|
|
||
| 4. Search and tagging: | ||
|
|
||
| - Quickly find prompts by searching names or filtering by tags. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.