Skip to content

Commit

Permalink
feat: ✨ Add Natural Language Processing demo in Java section (#81)
Browse files Browse the repository at this point in the history
* conf: 🛠️ set dependencies version

* conf: 🛠️ Exclude some Python config files

* feat: ✨ Java NLP example: sentiments analysis
  • Loading branch information
philippart-s authored Oct 2, 2024
1 parent 59e85f3 commit e200443
Show file tree
Hide file tree
Showing 9 changed files with 594 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ venv/
.venv/
__pycache__/


# JS
node_modules/

Expand Down
3 changes: 2 additions & 1 deletion ai/ai-endpoints/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Don't hesitate to use the source code and give us feedback.

### ☕️ Java demos ☕️

- [Natural Language Processing](./java-nlp)
- [Chatbot with LangChain4j](./java-langchain4j-chatbot/): blocking mode, streaming mode and RAG mode.
- [Blocking chatbot](./quarkus-langchain4j/) with LangChain4j and Quarkus
- [Streaming chatbot](./quarkus-langchain4j-streaming/) with langChain4j and Quarkus.
Expand All @@ -27,7 +28,7 @@ Don't hesitate to use the source code and give us feedback.
- [Audio Virtual Assistant](./audio-virtual-assistant/) by putting ASR, LLM and TTS working together
- [Conversational Memory for chatbot](./python-langchain-conversational-memory/) by using Mistral7B and LangChain Memory module
- [Video Translator](./speech-ai-video-translator) with ASR, NMT and TTS to subtitle and dub video voices
- [ASR features](./asr-features) to better understand how Automtic Speech Recognition models work
- [ASR features](./asr-features) to better understand how Automatic Speech Recognition models work
- [TTS features](./tts-features) to be able to use all Text To Speech models easily

### 🕸️ Javascript 🕸️
Expand Down
130 changes: 130 additions & 0 deletions ai/ai-endpoints/java-nlp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.ovhcloud.examples.aiendpoints</groupId>
<artifactId>nlp</artifactId>
<version>1.0.0-SNAPSHOT</version>

<name>nlp</name>
<url>https://endpoints.ai.cloud.ovh.net/</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler-plugin.version>3.12.1</compiler-plugin.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.2.5</surefire-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.ovhcloud.examples.aiendpoints.nlp.sentiment;

import org.eclipse.microprofile.rest.client.annotation.ClientHeaderParam;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;

@Path("/api")
@RegisterRestClient(baseUri = "https://roberta-base-go-emotions.endpoints.kepler.ai.cloud.ovh.net")
@ClientHeaderParam(name = "Authorization", value = "Bearer ${ovhcloud.ai-endpoints.token}")
@ClientHeaderParam(name = "Content-Type", value = "application/json")
public interface AISentimentService {

@POST
@Path("text2emotions")
EmotionEvaluation text2emotions(String text);

}
Loading

0 comments on commit e200443

Please sign in to comment.