Skip to content

Commit

Permalink
Revert "Release 1.10.0"
Browse files Browse the repository at this point in the history
  • Loading branch information
labski42 authored Jan 30, 2024
1 parent 70f2457 commit 52d8186
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 146 deletions.
72 changes: 2 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,52 +169,10 @@ Powered by ChatGPT, the AI Assistant allows users to quickly generate and edit c

![Generate content from prompt](media/aiPrompt.png)

You can use the Generative AI Assistant with Amplience credits or your own OpenAI account.
To get started, you will need to provide your own OpenAI API key which will be used by the extension to communicate with the ChatGPT API. Note, ChatGPT is not affiliated with Amplience and therefore any impact to ChatGPT services such as updates, busy periods, or outages are outside of Amplience control.

By using this feature, you are solely responsible for ensuring that AI generated content complies with internal company policies, applicable laws and [OpenAI's Terms](https://openai.com/policies).

#### Using Amplience credits

Amplience credits provide an easy way to start using our AI features without the need for your own OpenAI account. See [Amplience credits](https://amplience.com/developers/docs/ai-services/credits/)

To use Amplience credits with the Generative AI Assistant, add the following to the extension parameters:

```json
{
"tools": {
"ai": {}
}
}
```

For example:

```json
{
"properties": {
"text": {
"title": "Markdown text",
"description": "Markdown text",
"type": "string",
"minLength": 0,
"maxLength": 32000,
"ui:extension": {
"url": "https://rich-text.extensions.content.amplience.net",
"params": {
"tools": {
"ai": {}
}
}
}
}
}
}
```

#### Using your own Open AI account

To get started, you will need to provide your own OpenAI API key which will be used by the extension to communicate with the ChatGPT API. Note, ChatGPT is not affiliated with Amplience and therefore any impact to ChatGPT services such as updates, busy periods, or outages are outside of Amplience control.

To create your key, you first need an OpenAI account which you can create [here](https://platform.openai.com/signup). Once you have an account you can create an API key [here](https://platform.openai.com/account/api-keys).

Once you have your API key, you can enable the AI Assistant feature by adding your API key to the extension parameters as follows:
Expand All @@ -229,33 +187,7 @@ Once you have your API key, you can enable the AI Assistant feature by adding yo
}
```

For example:

```json
{
"properties": {
"text": {
"title": "Markdown text",
"description": "Markdown text",
"type": "string",
"minLength": 0,
"maxLength": 32000,
"ui:extension": {
"url": "https://rich-text.extensions.content.amplience.net",
"params": {
"tools": {
"ai": {
"key": "<OpenAI key>"
}
}
}
}
}
}
}
```

#### Using ChatGPT 4
#### ChatGPT 4

If you have access to ChatGPT 4 or wish to use a different OpenAI model, you can choose the specific model the system should use as follows:

Expand Down
Binary file modified media/aiPrompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 0 additions & 24 deletions packages/extension/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,8 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<!-- Google Tag Manager -->
<script>
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != "dataLayer" ? "&l=" + l : "";
j.async = true;
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, "script", "dataLayer", "GTM-MFBCGD8R");
</script>
<!-- End Google Tag Manager -->
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript
><iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-MFBCGD8R"
height="0"
width="0"
style="display: none; visibility: hidden"
></iframe
></noscript>
<!-- End Google Tag Manager (noscript) -->
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ProseMirrorTool } from "@dc-extension-rich-text/common";
import FormatBold from "@material-ui/icons/FormatBold";
import {
computeToolbarState,
ProseMirrorToolbarState,
ProseMirrorToolbarState
} from "./ProseMirrorToolbarState";

// tslint:disable-next-line
Expand All @@ -25,34 +25,34 @@ const tools: ProseMirrorTool[] = [
label: "Bold",
displayIcon: <FormatBold />,
isActive: (state: any) => isMarkActive(state, schema.marks.strong),
apply: toggleMark(schema.marks.strong),
},
apply: toggleMark(schema.marks.strong)
}
];

const layout: ToolbarElement[] = [
{
type: "button",
toolName: "strong",
toolName: "strong"
},

{
type: "group",
children: [
{
type: "button",
toolName: "strong",
toolName: "strong"
},
{
type: "button",
toolName: "strong",
},
],
toolName: "strong"
}
]
},

{
type: "dropdown",
toolNames: ["strong"],
},
toolNames: ["strong"]
}
];

const Editor: React.SFC<{}> = (props: any) => {
Expand All @@ -70,11 +70,7 @@ const Editor: React.SFC<{}> = (props: any) => {

return (
<div>
<ProseMirrorToolbar
toolbarState={toolbarState}
layout={layout}
params={{}}
/>
<ProseMirrorToolbar toolbarState={toolbarState} layout={layout} />
<ProseMirror schema={schema} onUpdateState={handleUpdateState} />
</div>
);
Expand Down
49 changes: 19 additions & 30 deletions packages/extension/src/ProseMirrorToolbar/ProseMirrorToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
createStyles,
withStyles,
} from "@material-ui/core";
import { isToolEnabled } from "@dc-extension-rich-text/common";

import { ProseMirrorToolbarContext } from ".";
import { ProseMirrorToolbarIconButton } from "../ProseMirrorToolbarIconButton";
Expand Down Expand Up @@ -66,17 +65,15 @@ export interface ProseMirrorToolbarProps extends WithStyles<typeof styles> {
toolbarState: ProseMirrorToolbarState | undefined;
layout: ToolbarElement[];
isLocked?: boolean;
params: Record<string, unknown>;
}

const ProseMirrorToolbar: React.SFC<ProseMirrorToolbarProps> = (
props: ProseMirrorToolbarProps
) => {
const { classes, layout, toolbarState, params } = props;
const { classes, layout, toolbarState } = props;
const richTextEditorContext = useRichTextEditorContext();
const group1 = layout.slice(0, 3);
const group2 = layout.slice(3);
const isAiToolEnabled = (params?.tools as Record<string, unknown>)?.ai;

const renderToolbarElement = (idx: number, element: ToolbarElement) => {
switch (element.type) {
Expand Down Expand Up @@ -179,32 +176,24 @@ const ProseMirrorToolbar: React.SFC<ProseMirrorToolbarProps> = (
>
<MaterialToolbar className={classes.root} disableGutters={true}>
<div className={classes.group}>
{isAiToolEnabled ? (
<>
<Button
disabled={richTextEditorContext.isLocked}
onClick={showAIGenerateDialog}
className={classes.button}
size="small"
startIcon={
!richTextEditorContext.isLocked && (
<SparklesIcon
style={{ width: 15, height: 15 }}
></SparklesIcon>
)
}
>
{richTextEditorContext.isLocked ? (
<Loader></Loader>
) : (
"AI Assistant"
)}
</Button>
<div className={classes.divider}></div>
</>
) : (
""
)}
<Button
disabled={richTextEditorContext.isLocked}
onClick={showAIGenerateDialog}
className={classes.button}
size="small"
startIcon={
!richTextEditorContext.isLocked && (
<SparklesIcon style={{ width: 15, height: 15 }}></SparklesIcon>
)
}
>
{richTextEditorContext.isLocked ? (
<Loader></Loader>
) : (
"AI Assistant"
)}
</Button>
<div className={classes.divider}></div>
{group1.map((value, idx) => renderToolbarElement(idx, value))}
</div>
<div className={classes.group}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
ProseMirrorTool,
ProseMirrorToolState,
RichTextEditorContextProps,
RichTextEditorContextProps
} from "@dc-extension-rich-text/common";

export interface ProseMirrorToolbarState {
tools: ProseMirrorTool[];
toolStates: { [toolName: string]: ProseMirrorToolState };
params: Record<string, unknown>;
}

export function computeToolbarState(
Expand All @@ -22,7 +21,7 @@ export function computeToolbarState(
active: false,
enabled: true,
visible: true,
...tool,
...tool
};

if (tool.isActive) {
Expand All @@ -42,7 +41,6 @@ export function computeToolbarState(

return {
tools,
toolStates,
params: {},
toolStates
};
}
1 change: 0 additions & 1 deletion packages/extension/src/RichTextEditor/RichTextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ const RichTextEditor: React.SFC<RichTextEditorProps> = (
toolbarState={toolbarState}
layout={toolbarLayout}
isLocked={editorContext.isLocked}
params={params}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const RichTextEditorAIActionsBar: React.SFC<RichTextEditorAIActionsBarProps> = (
} = useRichTextEditorContext();

const configuration = new AIConfiguration(params);
const isAiToolEnabled = (params?.tools as Record<string, unknown>)?.ai;
const isAiToolEnabled = isToolEnabled("ai", params);
const editPrompts = configuration.getEditPrompts();

const handleEditPrompt = async (prompt: any) => {
Expand Down

0 comments on commit 52d8186

Please sign in to comment.