-
Notifications
You must be signed in to change notification settings - Fork 233
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 #2269 from Agenta-AI/feature/allow-custom-redact
[Feautre] Add custom redact functionality to SDK
- Loading branch information
Showing
16 changed files
with
401 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import agenta as ag | ||
|
||
ag.init() | ||
|
||
|
||
@ag.entrypoint | ||
@ag.instrument( | ||
spankind="WORKFLOW", | ||
ignore_inputs=True, | ||
ignore_outputs=True, | ||
) | ||
def embed(description: str): | ||
return { | ||
"embedding": "somedata", | ||
"ignored": "ignored", | ||
"cost": 15, | ||
"usage": 20, | ||
} |
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,17 @@ | ||
import agenta as ag | ||
|
||
ag.init() | ||
|
||
|
||
@ag.entrypoint | ||
@ag.instrument( | ||
spankind="WORKFLOW", | ||
ignore_inputs=True, | ||
) | ||
def embed(description: str): | ||
return { | ||
"embedding": "somedata", | ||
"ignored": "ignored", | ||
"cost": 15, | ||
"usage": 20, | ||
} |
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,17 @@ | ||
import agenta as ag | ||
|
||
ag.init() | ||
|
||
|
||
@ag.entrypoint | ||
@ag.instrument( | ||
spankind="WORKFLOW", | ||
ignore_inputs=True, | ||
) | ||
def embed(description: str): | ||
return { | ||
"embedding": "somedata", | ||
"ignored": "ignored", | ||
"cost": 15, | ||
"usage": 20, | ||
} |
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,18 @@ | ||
import agenta as ag | ||
|
||
ag.init() | ||
|
||
|
||
@ag.entrypoint | ||
@ag.instrument( | ||
spankind="WORKFLOW", | ||
ignore_inputs=["description"], | ||
ignore_outputs=["embedding", "ignored"], | ||
) | ||
def embed(description: str, theme: str): | ||
return { | ||
"embedding": "somedata", | ||
"ignored": "ignored", | ||
"cost": 15, | ||
"usage": 20, | ||
} |
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,30 @@ | ||
import agenta as ag | ||
|
||
ag.init() | ||
|
||
|
||
def redact(name, field, io): | ||
print(">", name, field, io) | ||
|
||
if name == "embed" and field == "inputs": | ||
io = {key: value for key, value in io.items() if key not in ("description",)} | ||
|
||
if name == "embed" and field == "outputs": | ||
io = {key: value for key, value in io.items() if key not in ("embedding",)} | ||
|
||
print("<", io) | ||
return io | ||
|
||
|
||
@ag.entrypoint | ||
@ag.instrument( | ||
spankind="WORKFLOW", | ||
redact=redact, | ||
) | ||
def embed(description: str, theme: str): | ||
return { | ||
"embedding": "somedata", | ||
"ignored": "ignored", | ||
"cost": 15, | ||
"usage": 20, | ||
} |
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,31 @@ | ||
import agenta as ag | ||
|
||
|
||
def redact(name, field, io): | ||
print(">", name, field, io) | ||
|
||
if name == "embed" and field == "inputs": | ||
io = {key: value for key, value in io.items() if key not in ("description",)} | ||
|
||
if name == "embed" and field == "outputs": | ||
io = {key: value for key, value in io.items() if key not in ("embedding",)} | ||
|
||
print("<", io) | ||
|
||
return io | ||
|
||
|
||
ag.init(redact=redact) | ||
|
||
|
||
@ag.entrypoint | ||
@ag.instrument( | ||
spankind="WORKFLOW", | ||
) | ||
def embed(description: str, theme: str): | ||
return { | ||
"embedding": "somedata", | ||
"ignored": "ignored", | ||
"cost": 15, | ||
"usage": 20, | ||
} |
Oops, something went wrong.