File size: 5,487 Bytes
0bd62e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<script context="module">

	import { Template, Story } from "@storybook/addon-svelte-csf";

	import Chatbot from "./Index.svelte";

	import { allModes } from "../storybook/modes";



	export const meta = {

		title: "Components/Chatbot",

		component: Chatbot,

		parameters: {

			chromatic: {

				modes: {

					desktop: allModes["desktop"],

					mobile: allModes["mobile"]

				}

			}

		},

		argTypes: {

			label: {

				control: "text",

				description: "The textbox label",

				name: "label"

			},

			show_label: {

				options: [true, false],

				description: "Whether to show the label",

				control: { type: "boolean" },

				defaultValue: true

			},

			rtl: {

				options: [true, false],

				description: "Whether to render right-to-left",

				control: { type: "boolean" },

				defaultValue: false

			}

		}

	};

</script>



<Template let:args>

	<Chatbot

		value={[

			[

				"Can you write a function in Python?",

				"```py\ndef test():\n\tprint(x)\n```"

			],

			["Can you do math?", "$$1+1=2$$"],

			["Can you say nothing?", null]

		]}

		{...args}

	/>

</Template>



<Story

	name="Chatbot with math enabled"

	args={{ latex_delimiters: [{ left: "$$", right: "$$", display: true }] }}

/>



<Story

	name="Chatbot with math disabled, small height"

	args={{ latex_delimiters: [], height: 200 }}

/>



<Story

	name="Chatbot with text rendered right-to-left"

	args={{

		rtl: true,

		latex_delimiters: [{ left: "$$", right: "$$", display: true }],

		value: [

			[

				"حلّت التجارية عرض لم, كرسي قادة دار كل. ما خيار ماذا بمحاولة به،. كما عن تونس إيطاليا. يتم بـ لأداء حادثة معزّزة.",

				"إعادة احداث اعلان بين قد, ما القوى الحكومة التغييرات جهة. قبل و يذكر الإمتعاض, أوسع وشعار إستعمل بعد تم. سبتمبر الصفحة عل أضف, أي وفي الدمج تشكيل وصافرات. حيث قد بقسوة هاربر بأيدي, أملاً نتيجة الثالث ما على, ثم مدن للسيطرة بالتوقيع. هذه ان حقول أخرى."

			],

			[

				"أي وتنصيب الصعداء انه. تاريخ بالجانب هو فصل, أخذ لمحاكم الإتفاقية ان. كنقطة بالعمل التكاليف شيء مع, وجزر الهادي كان و, أي حدى يطول الحكومة اليابان. حيث كرسي لتقليعة الاندونيسية تم, للصين وبغطاء بال بل. ٣٠ لهذه قتيل، ارتكبها كلا. سابق وبدأت تم ذات.",

				"اليف نفس. ما يتبقّ لبولندا، استراليا، دول."

			]

		]

	}}

/>



<Story

	name="Chatbot with copy button"

	args={{

		latex_delimiters: [{ left: "$$", right: "$$", display: true }],

		show_copy_button: true

	}}

/>



<Story

	name="Chatbot with chat bubble full width disabled"

	args={{

		bubble_full_width: false

	}}

/>



<Story

	name="Chatbot with panel layout enabled"

	args={{

		bubble_full_width: false,

		layout: "panel"

	}}

/>



<Story

	name="Chatbot with panel layout enabled and avatars"

	args={{

		layout: "panel",

		avatar_images: [

			{ url: "https://avatars.githubusercontent.com/u/100000?v=4" },

			{ url: "https://avatars.githubusercontent.com/u/100000?v=4" }

		]

	}}

/>



<Story

	name="Chatbot with bubble layout enabled and avatars"

	args={{

		bubble_full_width: true,

		layout: "bubble",

		avatar_images: [

			{ url: "https://avatars.githubusercontent.com/u/100000?v=4" },

			{ url: "https://avatars.githubusercontent.com/u/100000?v=4" }

		]

	}}

/>



<Story

	name="Chatbot with percentage height"

	args={{

		bubble_full_width: false,

		layout: "panel",

		height: "50%"

	}}

/>



<Story

	name="Chatbot with placeholder"

	args={{

		value: [],

		placeholder:

			"**Gradio Helper**\n\nThis Chatbot can help you on *any topic related to Gradio*."

	}}

/>



<Story

	name="Chatbot with headers and lists"

	args={{

		value: [

			[

				`# Markdown Example



This document is a showcase of various Markdown capabilities.`

			],

			[

				`## Table of Contents



1. [Text Formatting](#text-formating)

2. [Code Blocks](#code-blocks)

3. [Tables](#tables)

4. [Lists](#lists)

5. [Links and Images](#links-and-images)

6. [Quotes](#quotes)`

			]

		]

	}}

/>



<Story

	name="Chatbot with headers and lists"

	args={{

		value: [

			[

				`# Markdown Example



This document is a showcase of various Markdown capabilities.`,

				`## Table of Contents



1. [Text Formatting](#text-formating)

2. [Code Blocks](#code-blocks)

3. [Tables](#tables)`

			]

		]

	}}

/>



<Story

	name="Chatbot with tables and nested lists"

	args={{

		value: [

			[

				`Creating tables in Markdown is straightforward:



| Header 1 | Header 2 | Header 3 |

|----------|----------|----------|

| Row 1, Cell 1 | Row 1, Cell 2 | Row 1, Cell 3 |

| Row 2, Cell 1 | Row 2, Cell 2 | Row 2, Cell 3 |

| Row 3, Cell 1 | Row 3, Cell 2 | Row 3, Cell 3 |`,

				`### Unordered List



- Item 1

- Item 2

  - Subitem 2.1

  - Subitem 2.2

- Item 3



### Ordered List



1. First Item

2. Second Item

   1. Subitem 2.1

   2. Subitem 2.2

3. Third Item`

			]

		]

	}}

/>



<Story

	name="Chatbot with image in markdown"

	args={{

		value: [

			[

				`![A cheetah](https://cdn.britannica.com/02/92702-120-6A02E613/Cheetah.jpg)`

			]

		]

	}}

/>