-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add notice on usage of local models #12298
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ public class AiChatComponent extends VBox { | |
@FXML private Button notificationsButton; | ||
@FXML private ChatPromptComponent chatPrompt; | ||
@FXML private Label noticeText; | ||
@FXML private VBox noticeVbox; | ||
|
||
public AiChatComponent(AiService aiService, | ||
StringProperty name, | ||
|
@@ -109,6 +110,10 @@ private void initializeNotice() { | |
.replaceAll("%0", aiPreferences.getAiProvider().getLabel() + " " + aiPreferences.getSelectedChatModel()); | ||
|
||
noticeText.setText(newNotice); | ||
|
||
if (aiPreferences.isUnsafeModelSelected()) { | ||
noticeVbox.getChildren().add(new Label(Localization.lang("A custom or local AI model is used, JabRef is not responsible for the content generated by the model."))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the other models? Do we take responsibility? I hope not :). Proposal: |
||
} | ||
} | ||
|
||
private void initializeChatPrompt() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -392,7 +392,7 @@ public int getContextWindowSize() { | |
return contextWindowSize.get(); | ||
} else { | ||
return switch (aiProvider.get()) { | ||
case OPEN_AI -> AiDefaultPreferences.getContextWindowSize(AiProvider.OPEN_AI, openAiChatModel.get()); | ||
case OPEN_AI_COMPATIBLE -> AiDefaultPreferences.getContextWindowSize(AiProvider.OPEN_AI_COMPATIBLE, openAiChatModel.get()); | ||
case MISTRAL_AI -> AiDefaultPreferences.getContextWindowSize(AiProvider.MISTRAL_AI, mistralAiChatModel.get()); | ||
case HUGGING_FACE -> AiDefaultPreferences.getContextWindowSize(AiProvider.HUGGING_FACE, huggingFaceChatModel.get()); | ||
case GEMINI -> AiDefaultPreferences.getContextWindowSize(AiProvider.GEMINI, geminiChatModel.get()); | ||
|
@@ -516,7 +516,7 @@ public void addListenerToApiBaseUrls(Runnable runnable) { | |
|
||
public String getSelectedChatModel() { | ||
return switch (aiProvider.get()) { | ||
case OPEN_AI -> | ||
case OPEN_AI_COMPATIBLE -> | ||
openAiChatModel.get(); | ||
case MISTRAL_AI -> | ||
mistralAiChatModel.get(); | ||
|
@@ -532,7 +532,7 @@ public String getSelectedChatModel() { | |
public String getSelectedApiBaseUrl() { | ||
if (customizeExpertSettings.get()) { | ||
return switch (aiProvider.get()) { | ||
case OPEN_AI -> | ||
case OPEN_AI_COMPATIBLE -> | ||
openAiApiBaseUrl.get(); | ||
case MISTRAL_AI -> | ||
mistralAiApiBaseUrl.get(); | ||
|
@@ -570,4 +570,25 @@ public String getTemplate(AiTemplate aiTemplate) { | |
public StringProperty templateProperty(AiTemplate aiTemplate) { | ||
return templates.get(aiTemplate); | ||
} | ||
|
||
/** | ||
* Returns whether the selected model is "not safe" to use. By "safe" it is meant that the model is remote model from | ||
* reputable companies. | ||
* <p> | ||
* This function is made for <a href="https://eur-lex.europa.eu/eli/reg/2024/1689/oj">EU act on AI</a>. LLMs are high-risk systems and may generate harmful content. | ||
* If user connects to a reputable remote model (OpenAI, Gemini, Mistral AI, etc.), then they are safe to use, as they | ||
* are subject to the EU AI act. However, when user selects a local model or models from Hugging Face, then any model | ||
* can be used in JabRef, including uncensored and harmful ones. | ||
*/ | ||
public boolean isUnsafeModelSelected() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to In all cases do NOT use negations in the method name. Use |
||
// Any model can be chosen in GPT4All. | ||
boolean localProvider = getAiProvider() == AiProvider.GPT4ALL; | ||
// Any model can be chosen on HuggingFace. | ||
boolean huggingFace = getAiProvider() == AiProvider.HUGGING_FACE; | ||
// If user changed API base URL from default one, then probably user has connected to a local model provider, | ||
// like `ollama` or `llama.cpp`. | ||
boolean customApiBaseUrl = !getSelectedApiBaseUrl().equals(getAiProvider().getApiUrl()); | ||
|
||
return localProvider || huggingFace || customApiBaseUrl; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the second sentence is redundant after the first is read. Also, the third sentence ends with "before use" - but accuracy can be verified only after the content is generated.
Based on chatgpt:
Three possible suggestions:
Or:
Or:
and other permutations...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! I haven't looked at "Current model:...". But you are right. I rewrote the message a bit now, what do you think about it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This one reads good.