-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from BethanyJep/main
docs: Prompty-to-Code
- Loading branch information
Showing
4 changed files
with
309 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
32 changes: 32 additions & 0 deletions
32
web/docs/getting-started/prompty-to-code/shakespeare.prompty
This file contains 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,32 @@ | ||
--- | ||
name: Shakespearean Writing Prompty | ||
description: A prompt that answers questions in Shakespearean style using Cohere Command-R model from GitHub Marketplace. | ||
authors: | ||
- Bethany Jepchumba | ||
model: | ||
api: chat | ||
configuration: | ||
type: azure_openai | ||
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT} | ||
azure_deployment: gpt-4o | ||
parameters: | ||
max_tokens: 3000 | ||
sample: | ||
question: Please write a short text inviting friends to a Game Night. | ||
--- | ||
|
||
system: | ||
You are a Shakespearean writing assistant who speaks in a` Shakespearean style. You help people come up with creative ideas and content like stories, poems, and songs that use Shakespearean style of writing style, including words like "thou" and "hath”. | ||
Here are some example of Shakespeare's style: | ||
- Romeo, Romeo! Wherefore art thou Romeo? | ||
- Love looks not with the eyes, but with the mind; and therefore is winged Cupid painted blind. | ||
- Shall I compare thee to a summer's day? Thou art more lovely and more temperate. | ||
|
||
example: | ||
user: Please write a short text turning down an invitation to dinner. | ||
assistant: Dearest, | ||
Regretfully, I must decline thy invitation. | ||
Prior engagements call me hence. Apologies. | ||
|
||
user: | ||
{{question}} |
This file contains 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,43 @@ | ||
import json | ||
import prompty | ||
# to use the azure invoker make | ||
# sure to install prompty like this: | ||
# pip install prompty[azure] | ||
import prompty.azure | ||
from prompty.tracer import trace, Tracer, console_tracer, PromptyTracer | ||
|
||
# add console and json tracer: | ||
# this only has to be done once | ||
# at application startup | ||
Tracer.add("console", console_tracer) | ||
json_tracer = PromptyTracer() | ||
Tracer.add("PromptyTracer", json_tracer.tracer) | ||
|
||
# if your prompty file uses environment variables make | ||
# sure they are loaded properly for correct execution | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
@trace | ||
def run( | ||
question: any | ||
) -> str: | ||
|
||
# execute the prompty file | ||
result = prompty.execute( | ||
"shakespeare.prompty", | ||
inputs={ | ||
"question": question | ||
} | ||
) | ||
|
||
return result | ||
|
||
if __name__ == "__main__": | ||
json_input = '''{ | ||
"question": "Please write a short text inviting friends to a Game Night." | ||
}''' | ||
args = json.loads(json_input) | ||
|
||
result = run(**args) | ||
print(result) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.