-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
60 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 |
---|---|---|
|
@@ -402,6 +402,65 @@ The secret word is... corge! | |
|
||
Similarly to `call_custom`, `call_custom_async` and `call_custom_concurrent` are provided as the custom counterparts to `call_async` and `call_concurrent`, with similar usage. `AsyncLLMClient` also supports memory in the same way as `LLMClient`. | ||
|
||
### Tools: Prompt Loader | ||
|
||
L2M2 provides an optional prompt-loading utility that's useful for loading prompts with variables from a file. Usage is simple: | ||
|
||
_prompt.txt_ | ||
|
||
``` | ||
Your name is {{name}} and you are a {{profession}}. | ||
``` | ||
|
||
```python | ||
# example_prompt_loader.py | ||
|
||
from l2m2.tools import PromptLoader | ||
|
||
loader = PromptLoader() | ||
prompt = loader.load_prompt( | ||
prompt_file="prompt.txt", | ||
variables={"name": "Pierce", "profession": "software engineer"}, | ||
) | ||
print(prompt) | ||
``` | ||
|
||
``` | ||
>> python3 example_prompt_loader.py | ||
Your name is Pierce and you are a software engineer. | ||
``` | ||
|
||
You can also optionally specify a prompt directory or customize the variable delimiters if needed. | ||
|
||
_path/to/prompts/prompt.txt_ | ||
|
||
``` | ||
Your name is <<name>> and you are a <<profession>>. | ||
``` | ||
|
||
```python | ||
# example_prompt_loader.py | ||
|
||
from l2m2.tools import PromptLoader | ||
|
||
loader = PromptLoader( | ||
prompts_base_dir="path/to/prompts", | ||
variable_delimiters=("<<", ">>"), | ||
) | ||
prompt = loader.load_prompt( | ||
prompt_file="prompt.txt", | ||
variables={"name": "Pierce", "profession": "software engineer"}, | ||
) | ||
print(prompt) | ||
``` | ||
|
||
``` | ||
>> python3 example_prompt_loader.py | ||
Your name is Pierce and you are a software engineer. | ||
``` | ||
|
||
## Contact | ||
|
||
If you'd like to contribute, have feature requests, or have any other questions about l2m2 please shoot me a note at [[email protected]](mailto:[email protected]), open an issue on the [Github repo](https://github.com/pkelaita/l2m2/issues), or DM me on the GenAI Collective [Slack Channel](https://join.slack.com/t/genai-collective/shared_invite/zt-285qq7joi-~bqHwFZcNtqntoRmGirAfQ). |
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 @@ | ||
__version__ = "0.0.18.post1" | ||
__version__ = "0.0.19" |