Skip to content

Commit

Permalink
Update prompty.ts to handle Azure OpenAI configurations and add a new…
Browse files Browse the repository at this point in the history
… weather forecast description prompt
  • Loading branch information
pelikhan committed Sep 6, 2024
1 parent eff6ce7 commit 615b38e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/core/src/prompty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,19 @@ function promptyFrontmatterToMeta(frontmatter: PromptyFrontmatter): PromptArgs {
if (modelParameters?.n > 1) throw new Error("multi-turn not supported")
if (modelParameters?.tools?.length)
throw new Error("streaming not supported")
if (configuration?.azure_deployment)

// resolve model
if (
configuration?.type === "azure_openai" ||
configuration?.type === "azure"
) {
if (!configuration.azure_deployment)
throw new Error("azure_deployment required")
modelName = `azure:${configuration.azure_deployment}`
else if (configuration?.type) modelName = `openai:${configuration.type}`
} else if (configuration?.type === "azure_serverless") {
throw new Error("azure_serverless not supported")
} else if (configuration?.type === "openai")
modelName = `openai:${configuration.type}`

const meta = deleteUndefinedValues(<PromptArgs>{
model: modelName,
Expand Down
35 changes: 35 additions & 0 deletions packages/sample/src/weatherforecastdesc.prompty
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: generate_weather_detailed_description
description: A prompt that generated a detaled description for a weather forecast
authors:
- Bruno Capuano
model:
api: chat
configuration:
type: azure_openai
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
azure_deployment: ${env:AZURE_OPENAI_MODEL}
parameters:
max_tokens: 3000
sample:
today: >
2024-07-16

date: >
2024-07-17

forecastTemperatureC: >
25°C
---

# System:
You are an AI assistant who generated detailed weather forecast descriptions. The detailed description is a paragraph long.
You use the full description of the date, including the weekday.
You also give a reference to the forecast compared to the current date today.
As the assistant, you generate descriptions using a funny style and even add some personal flair with appropriate emojis.

# Context
Use the following context to generated a detailed weather forecast descriptions
- Today: {{today}}
- Date: {{date}}
- TemperatureC: {{forecastTemperatureC}}

0 comments on commit 615b38e

Please sign in to comment.