-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add run-cli.sh script; modify readme
- Loading branch information
Showing
15 changed files
with
112 additions
and
36 deletions.
There are no files selected for viewing
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,11 @@ | ||
<configuration> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
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
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
11 changes: 11 additions & 0 deletions
11
jlama-cli/src/main/java/com/github/tjake/jlama/cli/commands/BaseCommand.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,11 @@ | ||
package com.github.tjake.jlama.cli.commands; | ||
|
||
import java.io.File; | ||
|
||
import com.github.tjake.jlama.cli.JlamaCli; | ||
import picocli.CommandLine; | ||
|
||
public class BaseCommand extends JlamaCli { | ||
@CommandLine.Parameters(index = "0", arity = "1", description = "The model location") | ||
protected File model; | ||
} |
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
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
3 changes: 1 addition & 2 deletions
3
...thub/jlama/cli/commands/ServeCommand.java → ...jake/jlama/cli/commands/ServeCommand.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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
package com.github.tjake.jlama.cli.commands; | ||
|
||
import com.github.tjake.jlama.cli.JlamaCli; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command(name = "serve", description = "Starts a rest api for interacting with this model") | ||
public class ServeCommand extends JlamaCli { | ||
public class ServeCommand extends BaseCommand { | ||
} |
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
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
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,42 @@ | ||
#!/bin/bash | ||
|
||
# Function to extract the major version of Java | ||
get_java_major_version() { | ||
local version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') | ||
echo ${version%%.*} | ||
} | ||
|
||
# Verify Java version is JDK 21 | ||
JAVA_MAJOR_VERSION=$(get_java_major_version) | ||
|
||
if [[ "$JAVA_MAJOR_VERSION" != "21" ]]; then | ||
echo "Error: JDK 21 is required to run this application." | ||
exit 1 | ||
fi | ||
|
||
# Define the path of the relative JAR | ||
JLAMA_RELATIVE_JAR="./jlama-cli/target/jlama-cli.jar" | ||
# Path to the logback.xml | ||
LOGBACK_CONFIG="./conf/logback.xml" | ||
|
||
|
||
JLAMA_JVM_ARGS="--add-modules=jdk.incubator.vector --add-exports java.base/sun.nio.ch=ALL-UNNAMED --enable-preview --enable-native-access=ALL-UNNAMED \ | ||
-XX:+PreserveFramePointer -XX:+UnlockDiagnosticVMOptions -XX:CompilerDirectivesFile=./inlinerules.json -XX:+AlignVector" | ||
|
||
# Check if PREINSTALLED_JAR environment variable is set | ||
if [[ -z "$JLAMA_PREINSTALLED_JAR" ]]; then | ||
# If the relative JAR doesn't exist, build it | ||
if [[ ! -f $JLAMA_RELATIVE_JAR ]]; then | ||
echo "The JAR $JLAMA_RELATIVE_JAR is missing. Attempting to build..." | ||
./mvnw clean package -DskipTests | ||
if [[ $? -ne 0 ]]; then | ||
echo "Error building the JAR. Please check your build setup." | ||
exit 1 | ||
fi | ||
fi | ||
# Run the JAR in a relative directory | ||
java $JLAMA_JVM_ARGS -Dlogback.configurationFile=$LOGBACK_CONFIG -jar $JLAMA_RELATIVE_JAR "$@" | ||
else | ||
# If PREINSTALLED_JAR is set, run the JAR specified by the variable | ||
java $JLAMA_JVM_ARGS -jar $JLAMA_PREINSTALLED_JAR "$@" | ||
fi |