-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
150 additions
and
23 deletions.
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
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
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
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 @@ | ||
# Copyright (c) 2024 by Microsoft Corporation. | ||
# Author: Chaofan Lin ([email protected]) | ||
|
||
from parrot import P | ||
|
||
vm = P.VirtualMachine( | ||
core_http_addr="http://localhost:9000", | ||
mode="debug", | ||
) | ||
|
||
|
||
@P.semantic_function() | ||
def tell_me_a_joke(topic: P.Input, joke: P.Output): | ||
"""Tell the me a joke about {{topic}}: {{joke}}.""" | ||
|
||
|
||
@P.native_function() | ||
def format_joke(joke: P.Input, formatted_joke: P.Output): | ||
ret = ( | ||
"Here is the joke for you\n---\n" + joke | ||
) # Directly use string built-in methods | ||
formatted_joke.set(ret) # Use `set` to assign value to output | ||
|
||
|
||
def main(): # Orchestrator function | ||
joke = tell_me_a_joke(topic="chicken") | ||
joke1 = format_joke(joke) | ||
joke_str = joke1.get() | ||
print(joke_str) | ||
|
||
|
||
vm.run(main) |
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
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
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
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