Skip to content

Commit

Permalink
add support to change model location
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Nov 22, 2023
1 parent 2e167e4 commit c864b84
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ Set the IP address to bind to. Default: localhost (127.0.0.1)
### Port
Set the port to listen. Default: 8080

### Model Location Path
Specify the path to where the LLaMA model file to be downloaded on the server. Default is OPENFIRE_HOME/llama folder. If a model file is already available, copy it here as llama.model.gguf.

### Model URL
Specify the path to the LLaMA model file to be downloaded and used. Default is https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q2_K.gguf?download=true
Specify the URL to the LLaMA model file to be downloaded and used. Default is https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q2_K.gguf?download=true
The first time the plugin starts, it will download this file and cache in OPENFIRE_HOME/llama folder.

### System Prompt
Expand Down
Binary file modified docs/llama-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ <h3 id="host">Bind IP Address/Hostname</h3>
<p>Set the IP address to bind to. Default: localhost (127.0.0.1)</p>
<h3 id="port">Port</h3>
<p>Set the port to listen. Default: 8080</p>
<h3 id="model-path">Model Location Path</h3>
<p>Specify the path to where the LLaMA model file to be downloaded on the server. Default is OPENFIRE_HOME/llama folder. If a model file is already available, copy it here as llama.model.gguf.</p>
<h3 id="model-url">Model URL</h3>
<p>Specify the path to the LLaMA model file to be downloaded and used. Default is <a href="https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q2_K.gguf?download=true">https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q2_K.gguf?download=true</a><br>
The first time the plugin starts, it will download this file and cache in OPENFIRE_HOME/llama folder.</p>
Expand Down
1 change: 1 addition & 0 deletions src/i18n/llama_i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config.page.configuration.top.p.sampling=Top P Sampling
config.page.configuration.temperature=Temperature
config.page.configuration.predictions=Predictions
config.page.configuration.system.prompt=System Prompt
config.page.configuration.model.path=Model Location Path
config.page.configuration.model.url=Model URL
config.page.configuration.alias=Alias
config.page.configuration.username=Username
Expand Down
6 changes: 5 additions & 1 deletion src/java/org/ifsoft/llama/openfire/LLaMA.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public static String getPort() {
return "8080";
}

public static String getModelPath() {
return (JiveGlobals.getHomeDirectory() + File.separator + "llama").replace("\\", "/");
}

public static String getModelUrl() {
return "https://huggingface.co/TheBloke/Llama-2-7b-Chat-GGUF/blob/main/llama-2-7b-chat.Q5_K_M.gguf";
}
Expand Down Expand Up @@ -200,7 +204,7 @@ private void startJSP(File pluginDirectory) {
}

private void setupLLaMA(File pluginDirectory) {
final String path = (JiveGlobals.getHomeDirectory() + File.separator + "llama").replace("\\", "/");
final String path = JiveGlobals.getProperty("llama.model.path", getModelPath());
final String filePath = path + File.separator + "llama.model.gguf";
final File folder = new File(path);

Expand Down
13 changes: 12 additions & 1 deletion src/web/llama-settings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
String alias = request.getParameter("alias");
JiveGlobals.setProperty("llama.alias", alias);
String model_path = request.getParameter("model_path");
JiveGlobals.setProperty("llama.model.path", model_path);
String model_url = request.getParameter("model_url");
JiveGlobals.setProperty("llama.model.url", model_url);
Expand Down Expand Up @@ -92,7 +95,15 @@
<input type="checkbox" name="cache_prompt"<%= (JiveGlobals.getProperty("llama.cache.prompt", "true").equals("true")) ? " checked" : "" %>>
<fmt:message key="config.page.configuration.cache.prompt" />
</td>
</tr>
</tr>
<tr>
<td align="left" width="150">
<fmt:message key="config.page.configuration.model.path"/>
</td>
<td><input type="text" size="100" maxlength="256" name="model_path" required
value="<%= JiveGlobals.getProperty("llama.model.path", plugin.getModelPath()) %>">
</td>
</tr>
<tr>
<td align="left" width="150">
<fmt:message key="config.page.configuration.model.url"/>
Expand Down

0 comments on commit c864b84

Please sign in to comment.