Help Me Write
「OpenAI」 is so powerful for all kinds services. That's why I try to adopt OpenAI to help Y! Auction's seller submit merchandise quickly.
With <msc-help-me-write />
support, developers just need to set some configs and everything will be all set. All user need to do is just press the trigger and <msc-help-me-write />
will display cool appearance for pick up.
Try to press the 「trigger
」 which in the right-bottom corner of viewport. Then watch what can <msc-help-me-write />
do ?
Basic Usage
<msc-help-me-write />
is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-help-me-write />
's html structure and everything will be all set.
Required Script
Structure
Put <msc-help-me-write />
into HTML document. It will have different functions and looks with attribute mutation.
Otherwise, developers could also choose remoteconfig to fetch config for <msc-help-me-write />
.
JavaScript Instantiation
<msc-help-me-write />
could also use JavaScript to create DOM element. Here comes some examples.
API response
<msc-help-me-write />
will need api response the following payload. Both 「title
」 and 「content
」 need to set in each unit.
Style Customization
Developers could apply styles to decorate <msc-help-me-write />
's looking.
Attributes
<msc-help-me-write />
supports some attributes to let it become more convenience & useful.
l10n
Set localization for <msc-help-me-write />
. It will replace some content & button text to anything you like. It should be JSON string Developers could set title、apply、applied and applyAll here.
- title
:Set window title. Default is Assistant
.
- apply
:Set apply button text. Default is Apply
.
- applied
:Set apply button text(user pressed). Default is Applied
.
- applyAll
:Set apply all button text. This button showed only when results > 1. Default is Apply All
.
webservice
Set web service information for <msc-help-me-write />
. It should be JSON string. Developers could set url、params、headers、method、withCredentials and timeout here.
- url
:api address for upload image. Default is /
.
- params
:Set parameters. Each of them will be attached with fetch. Default is {}
.
- headers
:Set fetch headers. Default is {}
.
- method
:Set method for fetch. Default is POST
.
- withCredentials
:Set withCredentials for fetch. Default is false
.
- timeout
:Set timeout for fetch. Default is 30000
(ms).
Property
Property Name | Type | Description |
---|---|---|
l10n
|
Object | Getter / Setter for l10n. It will replace some UI text to anything you like. Developers could set title 、apply 、applied and applyAll . |
webservice
|
Object | Getter / Setter for web service information. Developers could set url 、params 、headers 、method 、withCredentials and timeout . |
Method
Method Signature | Description |
---|---|
query(params = {})
|
Go fetch suggestions with parameters you liked. Window will pop up when api success response. This is an async method.Such as: element.query({ title:'show me the money' }) |
refresh()
|
Correct trigger's display position. |
dismiss()
|
Dissmiss window. |
Event
Event Signature | Description |
---|---|
msc-help-me-write-apply
|
Fired when user apply suggestion. Developers could get data througn event.detatil (complete API response information). |
msc-help-me-write-error
|
Fired when error occured. |
msc-help-me-write-cancel
|
Fired when window dismiss. |