yewsam1277 commited on
Commit
8bf3d01
1 Parent(s): 826d402

Create test

Browse files
Files changed (1) hide show
  1. test +63 -0
test ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ipywidgets as widgets
2
+ from IPython.display import clear_output
3
+
4
+ ## Text Input
5
+ user_input = widgets.Textarea(
6
+ value="",
7
+ placeholder="Type your prompt here",
8
+ disabled=False,
9
+ style={"description_width": "initial"},
10
+ layout=widgets.Layout(width="100%", height="100%"),
11
+ )
12
+
13
+ ## Submit Button
14
+ submit_button = widgets.Button(
15
+ description="Submit", button_style="success", layout=widgets.Layout(width="100%", height="80%")
16
+ )
17
+
18
+
19
+ def on_button_clicked(b):
20
+ user_prompt = user_input.value
21
+ user_input.value = ""
22
+ print("\nUser:\n", user_prompt)
23
+ conversational_agent.run(user_prompt)
24
+
25
+
26
+ submit_button.on_click(on_button_clicked)
27
+
28
+ ## Show Memory Button
29
+ memory_button = widgets.Button(
30
+ description="Show Memory", button_style="info", layout=widgets.Layout(width="100%", height="100%")
31
+ )
32
+
33
+
34
+ def on_memory_button_clicked(b):
35
+ memory = conversational_agent.memory.load()
36
+ if len(memory):
37
+ print("\nMemory:\n", memory)
38
+ else:
39
+ print("Memory is empty")
40
+
41
+
42
+ memory_button.on_click(on_memory_button_clicked)
43
+
44
+ ## Clear Memory Button
45
+ clear_button = widgets.Button(
46
+ description="Clear Memory", button_style="warning", layout=widgets.Layout(width="100%", height="100%")
47
+ )
48
+
49
+
50
+ def on_clear_button_button_clicked(b):
51
+ conversational_agent.memory.clear()
52
+ print("\nMemory is cleared\n")
53
+
54
+
55
+ clear_button.on_click(on_clear_button_button_clicked)
56
+
57
+ ## Layout
58
+ grid = widgets.GridspecLayout(3, 3, height="200px", width="800px", grid_gap="10px")
59
+ grid[0, 2] = clear_button
60
+ grid[0:2, 0:2] = user_input
61
+ grid[2, 0:] = submit_button
62
+ grid[1, 2] = memory_button
63
+ display(grid)