\n";
/*
// Actualiza la BBDD si procede antes de meterse en faena
if ( aicc_requiere_actualizar_db() ) {
aicc_actualizar_db();
}
*/
$deshabilitado = '';
if ( ! aicc_conf_apikoai() ) {
$mensaje = __( 'You have not configured your API Key yet.', 'ai-content-creator' );
$mensaje .= ' ';
$mensaje .= sprintf( __('Go to %shelp section%s and follow the procedure to create one.', 'ai-content-creator' ), '', '' );
echo aicc_admin_notice( $mensaje, 'error' );
//aicc_mostrar_notificacion( $mensaje, 'error' );
$deshabilitado = ' disabled';
}
$generar = false;
$regenerar = false;
$titulo = '';
$contexto = '';
$directrices_adicionales = '';
// Generar es el proceso completo con creación de la AI
// Regenerar es solamente mostrar el formulario para poder luego pulsar y generar
if ( isset( $_POST['generar'] ) ) {
$generar = true;
} elseif ( isset( $_GET['accion'] ) ) {
if ( 'regenerar' == $_GET['accion'] ) {
$regenerar = true;
}
}
// Commas, quotes and symbols are welcome, will use stripslashes to allow them.
// Database usage
// Tanto al generar como al regenerar, hay datos previos considerable para cargar en el form.
if ( $generar ) {
if ( isset( $_POST['titulo'] ) ) {
// Aquí perdemos la posibilidad de títulos como "¿Debo utilizar o ?"
$titulo = sanitize_text_field( $_POST['titulo'] );
// Revertir las magic_quotes, que siempre actúan en WP
$titulo = stripslashes( $titulo );
// Sanea y valida el título para determinar que la generación es válida.
$titulo = aicc_sanea_titulo( $titulo );
if ( ! aicc_valida_titulo( $titulo ) ) {
$generar = false;
}
}
if ( isset( $_POST['contexto'] ) ) {
$contexto = sanitize_textarea_field( $_POST['contexto'] );
// Revertir las magic_quotes, que siempre actúan en WP
$contexto = stripslashes( $contexto );
if ( ! aicc_sanea_contexto( $contexto ) ) {
$generar = false;
}
}
if ( isset( $_POST['directrices_adicionales'] ) ) {
$directrices_adicionales = sanitize_textarea_field( $_POST['directrices_adicionales'] );
// Revertir las magic_quotes, que siempre actúan en WP
$directrices_adicionales = stripslashes( $directrices_adicionales );
if ( ! aicc_sanea_directrices_adicionales( $directrices_adicionales ) ) {
$generar = false;
}
}
}
if ( $regenerar ) {
/*
Cargar ID o indicar error
Cargar cada campo que exista
*/
if ( isset( $_GET['id'] ) ) {
$id = aicc_valida_id_articulo( sanitize_text_field( $_GET['id'] ) );
$aicc_generacion_anterior = new AIccGeneracion();
if ( $aicc_generacion_anterior->cargar( $id ) ) {
$titulo = $aicc_generacion_anterior->titulo();
$contexto = $aicc_generacion_anterior->contexto();
$directrices_adicionales = $aicc_generacion_anterior->directrices_adicionales();
} else {
aicc_admin_notice( __('Could not load the specified article.', 'ai-content-creator' ), 'error' );
}
} else {
aicc_admin_notice( __('You have not specified based on which article you want to create another one.', 'ai-content-creator' ), 'error' );
}
}
echo wp_kses( aicc_formulario_crear_html( $titulo, $contexto, $directrices_adicionales, $deshabilitado ), aicc_permitidos_kses_formulario() );
echo aicc_imagen_espera_html();
?>
';
$modelo = aicc_conf_modelo();
$aicc_generacion = new AIccGeneracion();
$aicc_generacion = aicc_generar_contenido( $modelo, $titulo, $contexto, $directrices_adicionales );
// Al terminar de generar, oculta la animación de nuevo
?>
ver_errores_html();
//if ( '!' == $contenido || '' == $contenido ) {
if ( ! $aicc_generacion->contenido() ) {
echo aicc_admin_notice( __( 'Something went wrong while trying to generate the content.', 'ai-content-creator' ), 'warning' );
}
else{
echo __( 'Content', 'ai-content-creator' ) . ":\n";
echo $aicc_generacion->iframe_contenido_html();
echo $aicc_generacion->bloque_operaciones_html();
}
echo '';
}
?>
' . __( "Let's go step by step", 'ai-content-creator' ) . ".
\r\n
";
$prompt .= $inicio_respuesta;
return $prompt;
}
function aicc_prompt_solicitar( $titulo, $contexto = '', $directrices_adicionales = '' ) {
//$longitud = aicc_conf_longitud();
// Caracteristicas adicionales a indicar en el prompt.
$caracteristicas_adicionales = array();
$separador = "\n•";
//$caracteristicas_adicionales[] = "Tener una longitud de $longitud palabras.";
//$caracteristicas_adicionales[] = 'Redactado en idioma ' . aicc_nombre_idioma( aicc_conf_idioma() ) . '.';
//$caracteristicas_adicionales[] = 'Imprescindible que sea en formato HTML.';
//$caracteristicas_adicionales[] = "Asegúrate de que el contenido del artículo esté relacionado únicamente con el tema \"$titulo\".";
if ( aicc_conf_tablacontenidos() ) {
$caracteristicas_adicionales[] = __( 'Place a table of contents based on the titles and subtitles after a first introduction paragraph.', 'ai-content-creator' );
}
$caracteristicas_adicionales[] = __( 'Make sure to include the necessary tags to structure the content into main titles and subtitles using the
and
tags, respectively.', 'ai-content-creator' );
$caracteristicas_adicionales[] = __( 'Also use the
and
tags to create lists and and
to enumerate necessary steps. Use the
tag to separate content into paragraphs, to indicate line breaks and any other convenient tags.', 'ai-content-creator' );
$caracteristicas_adicionales[] = __( 'Never use