You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: docs/tutorials/simplebot.md
+35-4Lines changed: 35 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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
+
1
14
# SimpleBot Tutorial
2
15
3
16
!!! 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.
5
18
6
19
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.
7
20
@@ -10,7 +23,7 @@ In this tutorial, we will learn how to use the `SimpleBot` class, a Python imple
10
23
First, let's import the `SimpleBot` class:
11
24
12
25
```python
13
-
from llamabot import SimpleBot
26
+
from llamabot.bot.simplebotimport SimpleBot
14
27
```
15
28
16
29
### Initializing the SimpleBot
@@ -32,7 +45,21 @@ response = bot(human_message)
32
45
print(response.content)
33
46
```
34
47
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
36
63
37
64
`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:
38
65
@@ -53,7 +80,7 @@ app.show()
53
80
Here's a complete example of how to create and interact with a `SimpleBot`:
54
81
55
82
```python
56
-
fromsimple_botimport SimpleBot
83
+
fromllamabot.bot.simplebotimport SimpleBot
57
84
58
85
# Initialize the SimpleBot
59
86
system_prompt ="You are an AI assistant that helps users with their questions."
@@ -72,3 +99,7 @@ app.show()
72
99
## Conclusion
73
100
74
101
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