Skip to content
Snippets Groups Projects
Commit a2c32781 authored by chris's avatar chris
Browse files

rename method

parent 75a2cda5
No related branches found
No related tags found
1 merge request!466Chatgpt demo
...@@ -29,7 +29,7 @@ import { DefaultSchema } from 'wax-prosemirror-core'; ...@@ -29,7 +29,7 @@ import { DefaultSchema } from 'wax-prosemirror-core';
import invisibles, { hardBreak } from '@guardian/prosemirror-invisibles'; import invisibles, { hardBreak } from '@guardian/prosemirror-invisibles';
const API_KEY = ''; const API_KEY = '';
async function AnyStyleTransformation(prompt) { async function ExternalAPIContentTransformation(prompt) {
const response = await fetch('https://api.openai.com/v1/chat/completions', { const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST', method: 'POST',
headers: { headers: {
...@@ -62,7 +62,7 @@ async function AnyStyleTransformation(prompt) { ...@@ -62,7 +62,7 @@ async function AnyStyleTransformation(prompt) {
return prompt; return prompt;
} }
// async function AnyStyleTransformation(prompt) { // async function ExternalAPIContentTransformation(prompt) {
// const response = await fetch('https://api.openai.com/v1/completions', { // const response = await fetch('https://api.openai.com/v1/completions', {
// method: 'POST', // method: 'POST',
// headers: { // headers: {
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
}, },
], ],
AnyStyleService: { AnyStyleService: {
AnyStyleTransformation: AnyStyleTransformation, ExternalAPIContentTransformation: ExternalAPIContentTransformation,
}, },
SchemaService: DefaultSchema, SchemaService: DefaultSchema,
......
...@@ -31,7 +31,8 @@ class AnyStyleTool extends Tools { ...@@ -31,7 +31,8 @@ class AnyStyleTool extends Tools {
const context = useContext(WaxContext); const context = useContext(WaxContext);
const anyStyle = replaceText( const anyStyle = replaceText(
view, view,
this.config.get('config.AnyStyleService').AnyStyleTransformation, this.config.get('config.AnyStyleService')
.ExternalAPIContentTransformation,
this.pmplugins.get('anyStylePlaceHolder'), this.pmplugins.get('anyStylePlaceHolder'),
context, context,
); );
......
...@@ -15,7 +15,7 @@ const elementFromString = string => { ...@@ -15,7 +15,7 @@ const elementFromString = string => {
export default ( export default (
view, view,
AnyStyleTransformation, ExternalAPIContentTransformation,
placeholderPlugin, placeholderPlugin,
context, context,
) => data => { ) => data => {
...@@ -33,7 +33,7 @@ export default ( ...@@ -33,7 +33,7 @@ export default (
view.dispatch(tr); view.dispatch(tr);
AnyStyleTransformation(data).then( ExternalAPIContentTransformation(data).then(
text => { text => {
const pos = findPlaceholder(view.state, id, placeholderPlugin); const pos = findPlaceholder(view.state, id, placeholderPlugin);
// If the content around the placeholder has been deleted, drop // If the content around the placeholder has been deleted, drop
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment