Skip to content

Commit

Permalink
Revert "Master to QA-Production"
Browse files Browse the repository at this point in the history
  • Loading branch information
labski42 authored Feb 6, 2024
1 parent f6af173 commit 95662f2
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 154 deletions.
78 changes: 2 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +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/)

#### 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 @@ -195,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 Expand Up @@ -276,46 +242,6 @@ When text is selected, preset edit prompts are displayed which save users needin
}
```

### Disabling the Generative AI Assistant

To Disable the Generative AI Assistant, add the following parameters:

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

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": {
"disabled": true
}
}
}
}
}
}
}
```

### Enable or disable tools

You can set a whitelist of tools which the user can choose from:
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
50 changes: 19 additions & 31 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,18 +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 { ai: { disabled: boolean } })?.ai?.disabled !== true;

const renderToolbarElement = (idx: number, element: ToolbarElement) => {
switch (element.type) {
Expand Down Expand Up @@ -180,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,8 +49,7 @@ const RichTextEditorAIActionsBar: React.SFC<RichTextEditorAIActionsBarProps> = (
} = useRichTextEditorContext();

const configuration = new AIConfiguration(params);
const isAiToolEnabled =
(params?.tools as { ai: { disabled: boolean } })?.ai?.disabled !== true;
const isAiToolEnabled = isToolEnabled("ai", params);
const editPrompts = configuration.getEditPrompts();

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

0 comments on commit 95662f2

Please sign in to comment.