You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: polyglot-chat-app/README.md
+23-17
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Polyglot Chat Application
2
2
3
3
This example demonstrates how to integrate Python on GraalVM with a Micronaut application.
4
+
The application uses the nltk module to analyze text sentiment.
4
5
The application uses the Gradle build tool.
5
6
6
7
## Preparation
@@ -15,36 +16,39 @@ The application uses the Gradle build tool.
15
16
16
17
2. Download and install the latest GraalPy as described in the [Getting Started guide](https://www.graalvm.org/latest/reference-manual/python/#installing-graalpy). For example on Linux:
4. (Optional) Download and install GraalVM JDK for Java 21 or later to run Python with runtime compilation and to build a native image.
34
-
The demo will work on any OpenJDK distribution, but will be much faster on GraalVM JDK.
37
+
4. (Optional) [Download and install GraalVM JDK for Java 21](https://www.graalvm.org/downloads/) or later to run Python with runtime compilation and to build a native image.
38
+
The demo will work with any OpenJDK distribution, but will be much faster on GraalVM JDK.
35
39
36
-
## Building and Running the Application:
40
+
## Building and Running the Application
37
41
38
-
1. Build application with Gradle:
42
+
1. Build and run the application using Gradle:
39
43
```bash
40
44
./gradlew run
41
45
```
42
46
43
47
2. Navigate to [http://localhost:12345/#/chat/bob](http://localhost:12345/#/chat/bob).
44
48
45
49
You can connect from multiple browsers and chat via websockets.
46
-
The Python code will load a language model in the background.
47
-
Once it is ready, it will analyse the sentiments of all messages and add an emoji to the message to indicate the feelings conveyed.
50
+
The Python code loads a language model in the background—this can take up to 5 minutes.
51
+
Once it is ready, it analyzes the sentiments of messages and add an emoji to each message to indicate the feelings conveyed.
48
52
A chat may look like this (newest message at the top):
49
53
50
54
```
@@ -53,17 +57,19 @@ The demo will work on any OpenJDK distribution, but will be much faster on Graal
53
57
[bob 💬] still loading the sentiment model I believe
54
58
```
55
59
56
-
## Building a Native Image
60
+
## (Optional) Building a Native Executable
61
+
62
+
> Note: this requires [Download and install GraalVM JDK for Java 21](https://www.graalvm.org/downloads/) or later.
57
63
58
-
The application can be AOT compiled using GraalVM Native Image.
59
-
The Python code has to be shipped in a _resources_ directory that is kept next to the native executable.
64
+
The application can be compiled ahead-of-time to a native executable using GraalVM Native Image.
65
+
The Python code must be copied to the _build/_ directory that is kept next to the native executable.
60
66
61
-
1. Build a native executable with the Micronaut AOT support:
67
+
1. Build a native executable using Micronaut AOT support:
62
68
```bash
63
69
./gradlew nativeCompile
64
70
```
65
71
66
-
2. Copy the venv into the output _resources_ directory:
72
+
2. Copy the _venv_ directory into the output _resources_ directory:
0 commit comments