Skip to content
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

PromptUI docs v1 #2674

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/features/prompts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,55 @@ Let's say we have an app that generates a short story, where users are able to i
</Tab>
</Tabs>

## Using Prompts created on the UI
If you've created a prompt on the UI, you can easily pull this prompt into your codebase by calling the following API endpoint:
```javascript
export async function getPrompt(
id: string,
variables: Record<string, any>
): Promise<any> {
const getHeliconePrompt = async (id: string) => {
const res = await fetch(
`https://api.helicone.ai/v1/prompt/${id}/template`,
{
headers: {
Authorization: `Bearer ${YOUR_HELICONE_API_KEY}`,
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify({
inputs: variables,
}),
}
);

return (await res.json()) as Result<PromptVersionCompiled, any>;
};

const heliconePrompt = await getHeliconePrompt(id);
if (heliconePrompt.error) {
throw new Error(heliconePrompt.error);
}
return heliconePrompt.data?.filled_helicone_template;
}

async function pullPromptAndRunCompletion() {
const prompt = await getPrompt("my-prompt-id", {
color: "red",
});
console.log(prompt);

const openai = new OpenAI({
apiKey: "YOUR_OPENAI_API_KEY",
baseURL: `https://oai.helicone.ai/v1/${YOUR_HELICONE_API_KEY}`,
});
const response = await openai.chat.completions.create(
prompt satisfies OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming
);
console.log(response);
}

```
## Running Experiments

Once you've set up prompt management, you can leverage Helicone's experimentation features to test and improve your prompts.
Expand Down
Loading