Skip to content

Commit 84ebf42

Browse files
committed
docs(simplebot)📝: Update the SimpleBot tutorial documentation
- Add detailed sections on AIMessage object, explaining its structure and usage. - Update import paths for SimpleBot to reflect new module structure. - Include additional information on using the Panel app with SimpleBot. - Provide links to linked files in the documentation.
1 parent 3f494d5 commit 84ebf42

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

docs/tutorials/simplebot.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
---
2+
intents:
3+
- Diataxis framework-style tutorial on the usage of SimpleBot.
4+
- Emphasis on the returned data structures from SimpleBot.__call__(), that these are
5+
not strings, but AIMessages.
6+
- Explanation on what an AIMessage is, showing its class structure.
7+
- Creating a Panel app to talk with SimpleBot.
8+
linked_files:
9+
- llamabot/__init__.py
10+
- llamabot/bot/simplebot.py
11+
- llamabot/components/messages.py
12+
---
13+
114
# SimpleBot Tutorial
215

316
!!! note
4-
This tutorial was written by GPT4 and edited by a human.
17+
This tutorial was written by GPT4 and edited by a human.
518

619
In this tutorial, we will learn how to use the `SimpleBot` class, a Python implementation of a chatbot that interacts with OpenAI's GPT-4 model. The `SimpleBot` class is designed to be simple and easy to use, allowing you to create a chatbot that can respond to human messages based on a given system prompt.
720

@@ -10,7 +23,7 @@ In this tutorial, we will learn how to use the `SimpleBot` class, a Python imple
1023
First, let's import the `SimpleBot` class:
1124

1225
```python
13-
from llamabot import SimpleBot
26+
from llamabot.bot.simplebot import SimpleBot
1427
```
1528

1629
### Initializing the SimpleBot
@@ -32,7 +45,21 @@ response = bot(human_message)
3245
print(response.content)
3346
```
3447

35-
### Using the Panel App
48+
## AIMessage
49+
50+
When interacting with the `SimpleBot`, it's important to note that the response returned is not a simple string, but an `AIMessage` object. This object contains the generated response and additional metadata. The structure of an `AIMessage` is as follows:
51+
52+
```python
53+
from llamabot.components.messages import AIMessage
54+
55+
# Example AIMessage structure
56+
{
57+
"content": "Generated response content",
58+
"role": "assistant"
59+
}
60+
```
61+
62+
## Using the Panel App
3663

3764
`SimpleBot` also comes with a built-in Panel app that provides a graphical user interface for interacting with the chatbot. To create the app, call the `panel()` method on your `SimpleBot` instance:
3865

@@ -53,7 +80,7 @@ app.show()
5380
Here's a complete example of how to create and interact with a `SimpleBot`:
5481

5582
```python
56-
from simple_bot import SimpleBot
83+
from llamabot.bot.simplebot import SimpleBot
5784

5885
# Initialize the SimpleBot
5986
system_prompt = "You are an AI assistant that helps users with their questions."
@@ -72,3 +99,7 @@ app.show()
7299
## Conclusion
73100

74101
In this tutorial, we learned how to use the `SimpleBot` class to create a simple chatbot that interacts with OpenAI's GPT-4 model. We also learned how to create a Panel app for a more user-friendly interface. With this knowledge, you can now create your own chatbots and experiment with different system prompts and settings.
102+
103+
## Additional Information
104+
105+
For more detailed information on the `SimpleBot` class and its methods, please refer to the source code and documentation provided in the `llamabot` package.

0 commit comments

Comments
 (0)