From 4babdcebd90079d862cb70f33b5c6b813ff894db Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 30 Oct 2024 18:28:25 -0400 Subject: [PATCH] Add usage examples for Session class in README to demonstrate reduced repetition --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 03ac728..ffc9042 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,33 @@ To continue the conversation, you can call `conversation.send()` again, which re ``` +### Stop Repeating Yourself + +You can use the `Session` class to + +```python +import simplemind as sm + +# Create a session with defaults +gpt_4o_mini = sm.Session( + llm_provider="openai", + llm_model="gpt-4o-mini" +) + +# Now all calls use these defaults +response = gpt_4o_mini.generate_text("Hello!") +conversation = gpt_4o_mini.create_conversation() +``` + +This maintains the simplicity of the original API while reducing repetition. The session object also supports overriding defaults on a per-call basis: + +```python +response = gpt_4o_mini.generate_text( + "Complex task here", + llm_model="gpt-4" +) +``` + ### Basic Memory Plugin Harnessing the power of Python, you can easily create your own plugins to add additional functionality to your conversations: