-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Solución de error al ejecutar con maven por consola -Control de excepciones desde App -Creación de Readme
- Loading branch information
1 parent
a6f9b6c
commit 4829370
Showing
5 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
App/src/main/java/com/marco/com/marco/exception/GlobalControllerAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.marco.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class GlobalControllerAdvice { | ||
@ExceptionHandler(RuntimeException.class) | ||
public ResponseEntity captureUnknownContentTypeException | ||
(RuntimeException e){ | ||
return ResponseEntity | ||
.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.body(e.getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# [OpenAiAssistantApi](https://github.com/Marc0Franc0/OpenAiAssistantApi#openaiassistantapi) | ||
|
||
API REST diseñada para implementar y facilitar el uso de la API de OpenAI en un sistema de chat basado en texto. | ||
Permite interactuar con el sistema de chat mediante dos endpoints principales. | ||
|
||
## Características | ||
- Consumo de API OpenAI: Integración con la API de OpenAI para procesar y | ||
generar respuestas coherentes y contextualizadas utilizando tecnologías avanzadas | ||
de NLP (Procesamiento del Lenguaje Natural). | ||
|
||
## Tecnologías | ||
- Spring Boot 3.2.4 | ||
- Spring AI 0.8.1 | ||
- Maven | ||
|
||
## Endpoints | ||
|
||
### GET /generateText | ||
|
||
Este endpoint permite enviar mensajes de texto al sistema de chat para su procesamiento utilizando la API de OpenAI y obtener una respuesta coherente en formato de cadena de texto. | ||
```shell | ||
curl http://localhost:8080/api/v1/ai/generateText?message=Hola | ||
``` | ||
- Response | ||
``` | ||
{"generation":"Texto generado por api"} | ||
``` | ||
|
||
### GET /generateTextStream | ||
|
||
Este endpoint permite enviar mensajes de texto al sistema de chat para su procesamiento utilizando la API de OpenAI y obtener una respuesta coherente en formato de flujo de datos. | ||
```shell | ||
curl http://localhost:8080/api/v1/ai/generateTextStream?message=Hola | ||
``` | ||
- Response | ||
``` | ||
"Texto generado por api" | ||
``` | ||
## Instalación y configuración | ||
Sigue estos pasos para instalar y configurar la API: | ||
1. Clonar repositorio | ||
```shell | ||
git clone https://github.com/Marc0Franc0/OpenAiAssistantApi | ||
``` | ||
2. Configura la API de OpenAI: | ||
- Regístrate en OpenAI para obtener una clave API. | ||
- Dirigite a: OpenAIAssistantAPI/App/src/main/resources/application.yml | ||
- Configura la clave API en el archivo de configuración: | ||
Modifica el valor de ${SPRING_AI_OPENAI_APIKEY} con tu clave API | ||
3. Seguir pasos para ejecución con Maven | ||
|
||
## Ejecución con Maven | ||
|
||
Para construir y ejecutar la aplicación necesita: | ||
|
||
- [JDK 21+](https://www.oracle.com/java/technologies/downloads/#java21) | ||
- [Maven 3+](https://maven.apache.org) | ||
|
||
Ejecutar localmente | ||
1. Instala las dependencias | ||
```shell | ||
cd OpenAiAssistantApi | ||
mvn clean install | ||
``` | ||
2. Inicia la app | ||
```shell | ||
cd App | ||
mvn spring-boot:run | ||
``` | ||
|
||
Dirigirse a: | ||
- [Documentación en formato JSON](http://localhost:8080/api/v3/api-docs) | ||
- [Documentación Swagger con interfaz gráfica](http://localhost:8080/doc/swagger-ui/index.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters