Skip to content

Commit

Permalink
update readme, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
pkelaita committed Jun 17, 2024
1 parent 0bf76d1 commit cbd922b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
2 changes: 1 addition & 1 deletion l2m2/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.18.post1"
__version__ = "0.0.19"

0 comments on commit cbd922b

Please sign in to comment.