-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup of hello programs and changes to README (#18)
* update to hello examples and readme Signed-off-by: Mandana Vaziri <[email protected]> * cleanup Signed-off-by: Mandana Vaziri <[email protected]> --------- Signed-off-by: Mandana Vaziri <[email protected]>
- Loading branch information
Showing
51 changed files
with
268 additions
and
312 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
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 was deleted.
Oops, something went wrong.
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,16 @@ | ||
source_code: | ||
| | ||
@SuppressWarnings("unchecked") | ||
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException { | ||
Map<String, String> offsetMap; | ||
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { | ||
offsetMap = new HashMap<>(); | ||
} else { | ||
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); | ||
} | ||
return offsetMap; | ||
} | ||
repo_info: | ||
repo: streamsets/datacollector | ||
path: stagesupport/src/main/java/com/.../OffsetUtil.java | ||
function_name: OffsetUtil.deserializeOffsetMap |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
This code is used to deserialize a JSON string into a map. The function takes in a string `lastSourceOffset` and returns a map. If the `lastSourceOffset` is null or empty, it creates a new empty map. Otherwise, it uses the `JSON_MAPPER` to deserialize the `lastSourceOffset` into a map. The `@SuppressWarnings("unchecked")` annotation is used to suppress warnings about unchecked type conversions. | ||
The function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is null or empty. If it is, it creates a new empty map and returns it. Otherwise, it uses the Jackson library to parse the input string into a map and returns it. | ||
|
||
The `@SuppressWarnings("unchecked")` annotation is used to suppress the warning that the type of the parsed map is not checked. This is because the Jackson library is used to parse the input string into a map, but the specific type of the map is not known at compile time. Therefore, the warning is suppressed to avoid potential issues. |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ document: | |
import string | ||
result = random.choice(string.ascii_lowercase) | ||
- '!' | ||
- "\n" |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
description: Hello world | ||
# Call with pdl --data '"something": "ABC"' | ||
description: Hello world with data | ||
document: | ||
- def: stutter | ||
function: | ||
return: | ||
- "{{ something }}" | ||
- "Hello World!\n" | ||
- call: stutter | ||
- "\n" | ||
|
||
|
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
description: Hello world with variable use | ||
document: | ||
- Hello, | ||
- model: ibm/granite-20b-code-instruct-v2 | ||
parameters: | ||
- model: ibm/granite-34b-code-instruct | ||
params: | ||
decoding_method: greedy | ||
stop_sequences: | ||
- '!' | ||
include_stop_sequence: true | ||
include_stop_sequence: false | ||
def: NAME | ||
- | | ||
|
||
Who is{{ NAME }}? | ||
- "\n" |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
description: Hello function | ||
description: Hello world with defs | ||
defs: | ||
hello: | ||
function: | ||
name: str | ||
return: Hello {{ name }}! | ||
document: | ||
- call: hello | ||
args: | ||
name: World | ||
- call: hello | ||
args: | ||
name: World | ||
- "\n" |
10 changes: 5 additions & 5 deletions
10
examples/hello/hello16.pdl → examples/hello/hello-for-loop.pdl
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,10 @@ | ||
description: Hello world with function definition and call | ||
document: | ||
- def: hello | ||
function: | ||
name: str | ||
return: Hello {{ name }}! | ||
- call: hello | ||
args: | ||
name: World | ||
- "\n" |
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,8 @@ | ||
description: Hello world with iteration | ||
document: | ||
- Hello, world! | ||
- "\n" | ||
- repeat: | ||
"This is your first PDL program\n" | ||
num_iterations: 3 | ||
- "\n" |
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,8 @@ | ||
description: Hello world with LiteLLM | ||
document: | ||
- Hello, | ||
- model: watsonx/ibm/granite-34b-code-instruct | ||
parameters: | ||
stop: | ||
- "," | ||
- "\n" |
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,9 @@ | ||
description: Hello world with model input | ||
document: | ||
- model: ibm/granite-34b-code-instruct | ||
input: "Hello," | ||
params: | ||
stop_sequences: | ||
- '!' | ||
include_stop_sequence: true | ||
- "\n" |
File renamed without changes.
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,33 @@ | ||
description: Creating JSON Data | ||
defs: | ||
data: | ||
read: examples/hello/hello21_data.yaml | ||
parser: yaml | ||
spec: { "questions": ["str"], "answers": ["obj"] } | ||
document: | ||
- model: ibm/granite-34b-code-instruct | ||
def: model_output | ||
spec: {"name": str, "age": int} | ||
input: | ||
document: | ||
- for: | ||
question: "{{ data.questions }}" | ||
answer: "{{ data.answers }}" | ||
repeat: | ||
- | | ||
{{ question }} | ||
{{ answer }} | ||
as: document | ||
- > | ||
Question: Create a JSON object with fields 'name' and 'age' | ||
and set them appropriately. | ||
parser: yaml | ||
params: | ||
decoding_method: greedy | ||
stop_sequences: | ||
- '}' | ||
include_stop_sequence: true | ||
- "\n" | ||
|
||
|
||
|
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,16 @@ | ||
description: Hello world with parser using regex | ||
document: | ||
- model: ibm/granite-34b-code-instruct | ||
input: "Hello," | ||
params: | ||
decoding_method: greedy | ||
stop_sequences: | ||
- '!' | ||
include_stop_sequence: false | ||
spec: {"name": str} | ||
parser: | ||
spec: | ||
name: str | ||
regex: '\s*(?P<name>.*)\s*' | ||
- "\n" | ||
|
7 changes: 3 additions & 4 deletions
7
examples/hello/hello27.pdl → examples/hello/hello-roles-array.pdl
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
description: Model call with explicit messages input | ||
sequence: | ||
document: | ||
- def: prompt | ||
array: | ||
- role: system | ||
content: You are a helpful software engineer. You write clear, concise, well-commented code. | ||
- role: user | ||
content: Write a Python function that implement merge sort. | ||
show_result: false | ||
- model: watsonx/ibm/granite-8b-code-instruct | ||
platform: litellm | ||
- model: ibm/granite-8b-code-instruct | ||
input: "{{ prompt }}" | ||
parameters: | ||
params: | ||
decoding_method: greedy |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.