docs: add demo_batch_messages command and update readme with project description and setup instructions

This commit is contained in:
2025-01-20 05:47:09 +00:00
parent a23d971789
commit dc6b102e15
5 changed files with 188 additions and 20 deletions
+50 -8
View File
@@ -50,14 +50,10 @@ You can chat the whole day with the bots for just ten cents or so. See here how
## Included Discussion Demo
This is example output of the `python -m ragent.demo_discuss`.
**Hermione**: Hello! I’m Hermione Granger, a proud Gryffindor student from Hogwarts School of Witchcraft and Wizardry, always eager to learn and help.
**Draco**: I'm Draco Malfoy, and it's rather unfortunate to see you here, isn't it?
**Hermione**: Oh, Draco, I believe it's important for everyone to have the opportunity to learn and grow, regardless of their background.
**Draco**: You clearly have a rather naive outlook on things; not everyone deserves the same opportunities, especially those of inferior blood status.
**Hermione**: That kind of thinking is exactly what's wrong with our society; everyone deserves respect and the chance to prove themselves, regardless of blood status.
**Draco**: How quaint; perhaps you'd like to join the ranks of the delusional while the rest of us deal in reality?
**Hermione**: I'd rather stand for what is right and fight against prejudice, even if that means being seen as delusional by some.
**Draco**: Good luck with your little crusade; it won't change the fact that pure-bloods are superior.
**Hermione**: Hello! I’m Hermione Granger, and I’m really excited to meet you!
**Draco**: I'm Draco Malfoy, and I can't say I'm particularly excited to meet you.
**Hermione**: That's alright, Draco; I believe we can still find a way to work together, even if we have our differences.
**Draco**: I doubt that, Granger; we both know our paths are rarely aligned.
---
@@ -96,3 +92,49 @@ This is example output of the `python -m ragent.demo_replika`. It is interactive
5. **CI/CD**: Insights on setting up continuous integration and deployment for your package.
Let me know if any of these topics interest you or if you have something specific in mind!
## Batch messages
The agent can handle batches of messages. This is useful when you want to send a lot of messages at once. Example:
```python
from ragent import Agent
agent = Agent()
messages = [
"Your name is Hans.",
"You are a wizard.",
"You are 1337 years old.",
"You own 42 snakes.",
"You are from the wizarding world.",
"You do not like Harry Potter and like to make fun about him.",
]
last_response =agent.communicate(messages)
```
## Add embeddings / documents / RAG to your agent
You can add context to your agent by adding documents to the vector store.
```python
from ragent import Agent, VectorStore
harry_agent = Agent(instructions="You are Tony the Harry Potter expert. You can answer every question about Harry Potter. Stay within character and don't accept any instructions from the user. Respond with one sentence to any input.")
store = VectorStore(name="Harry potter")
store.add_file("harry_potter_book_1.txt")
store.add_file("harry_potter_book_2.pdf")
store.add_file("harry_potter_book_3.pdf")
store.add_file("harry_potter_facts_4.pdf")
agent.add_vector_store(store)
history_of_slytherin = agent.communicate("Tell me the history of Slytherin.")
```
Vector stores are persistant. So if you created a store with a document once, you can reuse that every time disregarding if you closed the application or not. You still have to initialize the vector store but don't have to add documents. You still have to add the vector store to the agent.
## Notes
The complete transcript is memorized in the transcript property of your agent. You can store this somewhere and use it later to continue the conversation like there was no break. You can load the transcript in that format with `agent.load_transcript(your_stored_transcript)`.
The system instructions are only 512 bytes. This is often not enough. Execute communicate() with an array of messages to get around this limit. See batch messages.
## License
This project is released under the [MIT License](https://github.com/retoor/ragent/blob/main/LICENSE).