Skip to content

Commit

Permalink
Feature: AI chat (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorin95670 authored Sep 9, 2024
2 parents 351b318 + c5ae8ae commit b98e545
Show file tree
Hide file tree
Showing 40 changed files with 1,929 additions and 117 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Once database is setup you can run :

> :warning: **You have to generate keystore.jks before!**, see [README](https://github.com/ditrit/leto-modelizer-api/blob/main/README.md#Generate-certificate-for-HTTPS).
If you do not want to have a real AI, you can use a fake AI:
```shell
docker build -t leto-modelizer-ai-proxy -f ./src/test/resources/ai/Dockerfile ./src/test/resources/ai
docker run -p 8585:8585 -v $(pwd)/src/test/resources/ai:/var/www/html --restart always leto-modelizer-ai-proxy
```

## Run application tests

To run all the application tests (unit and integration), use this command:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ enabling secure and streamlined user authentication.
| CSRF_TOKEN_TIMEOUT | No, default: `3600` | A configuration parameter that specifies the duration (in seconds) for which a Cross-Site Request Forgery (CSRF) token remains valid. This setting is used to prevent CSRF attacks by ensuring that the token used in a client session expires after a certain period, requiring a new token for future requests. |
| USER_SESSION_TIMEOUT | No, default: `3600` | A configuration parameter that defines the time (in seconds) a user's session remains active without any activity. After this period, the user is automatically logged out to help protect against unauthorized access and to manage server resource utilization efficiently. |
| SUPER_ADMINISTRATOR_LOGIN | No | A configuration parameter that defines the username on Github of the SUPER_ADMINISTRATOR. It will create user if it doesn't exist and associate it to the `SUPER_ADMINISTRATOR` role. |
| AI_HOST | No | A configuration parameter that defines the host of the ia server, example: http://localhost:8001/api/. If it's not set, users will not be approve to use ia in application. |
| AI_HOST | No, default: `http://localhost:8585/` | A configuration parameter that defines the host of the ia server, example: http://localhost:8585/api/. If it's not set, users will not be approve to use ia in application. |

> Notes: `GITHUB_ENTERPRISE_*` variables are only required on self-hosted GitHub.
Expand Down Expand Up @@ -275,7 +275,7 @@ LETO_ADMIN_URL=http://localhost:9000/
LIBRARY_HOST_WHITELIST=https://github.com/ditrit/
CSRF_TOKEN_TIMEOUT=3600
USER_SESSION_TIMEOUT=3600
AI_HOST=http://locahost:8001/api/
AI_HOST=http://locahost:8585/api/
```

See Configuration section for more details.
Expand Down
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
id 'checkstyle'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonarqube' version '5.0.0.4638'
id 'org.sonarqube' version '5.1.0.4882'
id 'com.adarshr.test-logger' version '4.0.0'
id 'jacoco'
id 'idea'
Expand Down Expand Up @@ -44,19 +44,19 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.session:spring-session-jdbc:3.2.2'
implementation 'org.flywaydb:flyway-core:10.10.0'
implementation "org.flywaydb:flyway-database-postgresql:10.10.0"
implementation 'org.springframework.session:spring-session-jdbc:3.3.2'
implementation 'org.flywaydb:flyway-core:10.17.3'
implementation "org.flywaydb:flyway-database-postgresql:10.17.3"
implementation 'commons-lang:commons-lang:2.6'
implementation 'commons-beanutils:commons-beanutils:1.9.4'
implementation 'com.github.erosb:json-sKema:0.14.0'
implementation 'com.github.erosb:json-sKema:0.16.0'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql:42.7.3'
runtimeOnly 'org.postgresql:postgresql:42.7.4'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.cucumber:cucumber-java:7.16.1'
testImplementation 'io.cucumber:cucumber-junit:7.16.1'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.10.2'
testImplementation 'io.cucumber:cucumber-java:7.18.1'
testImplementation 'io.cucumber:cucumber-junit:7.18.1'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.11.0'
}

tasks.named('test') {
Expand Down
10 changes: 9 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `GET /api/user/me/roles`, to get its roles.
* `GET /api/user/me/groups`, to get its groups.
* `GET /api/user/me/scopes`, to get its scopes.
* `GET /api/users/me/ai/conversations`, to get its conversations.
* For all users:
* `GET /api/users`, to get all users.
* `GET /api/users/{login}`, to get user by login.
Expand All @@ -29,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `GET /api/users/{login}/scopes`, to get all scopes associated to the user.
* `GET /api/users/{login}/permissions`, to get all permissions associated to the user.
* `GET /api/users/{login}/picture`, to get picture associated to the user.
* `GET /api/users/{login}/ai/conversations`, to get all conversations associated to the user.
* For all roles:
* `GET /api/roles`, to get all roles.
* `POST /api/roles`, to create a role.
Expand Down Expand Up @@ -90,6 +92,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `GET /api/libraries/templates/[TEMPLATE_ID]/schemas/[INDEX]`, to get schema of template.
* `GET /api/libraries/templates/[TEMPLATE_ID]/files/[INDEX]`, to get file of template.
* For AI:
* `GET /api/ia`, to create diagram with AI.
* `GET /api/ai/generate`, to generate diagram with AI.
* `GET /api/ai/conversations`, to get all conversation.
* `POST /api/ai/conversations`, to create a conversation.
* `GET /api/ai/conversations/[CONVERSATION_ID]`, to get a conversation by id.
* `DELETE /api/ai/conversations/[CONVERSATION_ID]`, to delete a conversation.
* `GET /api/ai/conversations/[CONVERSATION_ID]/messages`, to get all messages of a conversations.
* `POST /api/ai/conversations/[CONVERSATION_ID]/messages`, to send a message to AI.
* `/api/login`, to login.
* `/api/redirect`, to redirect with token on leto-modelizer/leto-modelizer-admin.
4 changes: 2 additions & 2 deletions docker-compose-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
ai:
build: ./src/test/resources/ai
ports:
- "8001:80"
- "8585:80"
volumes:
- ./src/test/resources/ai:/var/www/html
restart: always
Expand All @@ -29,7 +29,7 @@ services:
image: leto-modelizer-api:latest
environment:
DATABASE_HOST: db:26257
AI_HOST: http://ai/api/
AI_HOST: http://ai/
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
LIBRARY_HOST_WHITELIST: http://libraries/
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
image: leto-modelizer-api:latest
environment:
DATABASE_HOST: db:26257
AI_HOST: http://ai/api/
AI_HOST: http://ai/
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
LIBRARY_HOST_WHITELIST: http://libraries/
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/ditrit/letomodelizerapi/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public final class Constants {
*/
public static final String DEFAULT_USER_PROPERTY = "login";

/**
* The constant representing the default context property.
*/
public static final String DEFAULT_CONTEXT_PROPERTY = "context";

/**
* The constant representing the default update date property.
*/
public static final String DEFAULT_UPDATE_DATE_PROPERTY = "updateDate";

/**
* Private constructor.
*/
Expand Down
Loading

0 comments on commit b98e545

Please sign in to comment.