-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(system-prompts): init module (#292)
Ref: #287 Signed-off-by: Tomas Dvorak <[email protected]>
- Loading branch information
Showing
14 changed files
with
889 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
System Prompts | ||
""" |
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,44 @@ | ||
""" | ||
Working with system prompts | ||
The system prompt is a pre-defined prompt that helps cue the model to exhibit the desired behavior for a specific task. | ||
""" | ||
|
||
from pprint import pprint | ||
|
||
from dotenv import load_dotenv | ||
|
||
from genai.client import Client | ||
from genai.credentials import Credentials | ||
|
||
# make sure you have a .env file under genai root with | ||
# GENAI_KEY=<your-genai-key> | ||
# GENAI_API=<genai-api-endpoint> | ||
load_dotenv() | ||
client = Client(credentials=Credentials.from_env()) | ||
|
||
|
||
def heading(text: str) -> str: | ||
"""Helper function for centering text.""" | ||
return "\n" + f" {text} ".center(80, "=") + "\n" | ||
|
||
|
||
print(heading("Create a system prompt")) | ||
prompt_name = "Simple Verbalizer" | ||
prompt_content = """classify { "label 1", "label 2" } Input: {{input}} Output:""" | ||
create_response = client.system_prompt.create(name=prompt_name, content=prompt_content) | ||
system_prompt_id = create_response.result.id | ||
print(f"System Prompt ID: {system_prompt_id}") | ||
|
||
print(heading("Get a system prompt details")) | ||
retrieve_response = client.system_prompt.retrieve(id=system_prompt_id) | ||
pprint(retrieve_response.result.model_dump()) | ||
|
||
print(heading("Show all existing system prompts")) | ||
system_prompt_list_response = client.system_prompt.list(offset=0, limit=10) | ||
print("Total Count: ", system_prompt_list_response.total_count) | ||
print("Results: ", system_prompt_list_response.results) | ||
|
||
print(heading("Delete a system prompt")) | ||
client.system_prompt.delete(id=system_prompt_id) | ||
print("OK") |
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,4 @@ | ||
"""Modules containing functionalities related to system prompts""" | ||
|
||
from genai.system_prompt.schema import * | ||
from genai.system_prompt.system_prompt_service import * |
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,19 @@ | ||
from genai._generated.api import ( | ||
SystemPrompt, | ||
SystemPromptAuthor, | ||
SystemPromptCreateResponse, | ||
SystemPromptIdRetrieveResponse, | ||
SystemPromptIdUpdateResponse, | ||
SystemPromptRetrieveResponse, | ||
SystemPromptType, | ||
) | ||
|
||
__all__ = [ | ||
"SystemPrompt", | ||
"SystemPromptType", | ||
"SystemPromptCreateResponse", | ||
"SystemPromptIdUpdateResponse", | ||
"SystemPromptRetrieveResponse", | ||
"SystemPromptIdRetrieveResponse", | ||
"SystemPromptAuthor", | ||
] |
Oops, something went wrong.