mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-06-07 22:29:45 +00:00
Enhancement (beta): add direct LLM language setting (#12906)
This commit is contained in:
@@ -201,6 +201,7 @@ class AIConfig(BaseConfig):
|
||||
llm_model: str = dataclasses.field(init=False)
|
||||
llm_api_key: str = dataclasses.field(init=False)
|
||||
llm_endpoint: str = dataclasses.field(init=False)
|
||||
llm_output_language: str = dataclasses.field(init=False)
|
||||
llm_allow_internal_endpoints: bool = dataclasses.field(init=False)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
@@ -224,6 +225,9 @@ class AIConfig(BaseConfig):
|
||||
self.llm_model = app_config.llm_model or settings.LLM_MODEL
|
||||
self.llm_api_key = app_config.llm_api_key or settings.LLM_API_KEY
|
||||
self.llm_endpoint = app_config.llm_endpoint or settings.LLM_ENDPOINT
|
||||
self.llm_output_language = (
|
||||
app_config.llm_output_language or settings.LLM_OUTPUT_LANGUAGE
|
||||
)
|
||||
self.llm_allow_internal_endpoints = settings.LLM_ALLOW_INTERNAL_ENDPOINTS
|
||||
|
||||
@property
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.2.6 on 2026-06-02
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("paperless", "0011_applicationconfiguration_llm_embedding_chunk_size"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="applicationconfiguration",
|
||||
name="llm_output_language",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
max_length=32,
|
||||
null=True,
|
||||
verbose_name="Sets the LLM output language",
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -359,6 +359,13 @@ class ApplicationConfiguration(AbstractSingletonModel):
|
||||
max_length=256,
|
||||
)
|
||||
|
||||
llm_output_language = models.CharField(
|
||||
verbose_name=_("Sets the LLM output language"),
|
||||
blank=True,
|
||||
null=True,
|
||||
max_length=32,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("paperless application settings")
|
||||
permissions = [
|
||||
|
||||
@@ -227,6 +227,8 @@ class ApplicationConfigurationSerializer(
|
||||
data["barcode_tag_mapping"] = None
|
||||
if "language" in data and data["language"] == "":
|
||||
data["language"] = None
|
||||
if "llm_output_language" in data and data["llm_output_language"] == "":
|
||||
data["llm_output_language"] = None
|
||||
if "llm_api_key" in data and data["llm_api_key"] is not None:
|
||||
if data["llm_api_key"] == "":
|
||||
data["llm_api_key"] = None
|
||||
|
||||
@@ -1202,6 +1202,7 @@ LLM_BACKEND = os.getenv("PAPERLESS_AI_LLM_BACKEND") # "ollama" or "openai-like"
|
||||
LLM_MODEL = os.getenv("PAPERLESS_AI_LLM_MODEL")
|
||||
LLM_API_KEY = os.getenv("PAPERLESS_AI_LLM_API_KEY")
|
||||
LLM_ENDPOINT = os.getenv("PAPERLESS_AI_LLM_ENDPOINT")
|
||||
LLM_OUTPUT_LANGUAGE = os.getenv("PAPERLESS_AI_LLM_OUTPUT_LANGUAGE")
|
||||
LLM_ALLOW_INTERNAL_ENDPOINTS = get_bool_from_env(
|
||||
"PAPERLESS_AI_LLM_ALLOW_INTERNAL_ENDPOINTS",
|
||||
"true",
|
||||
|
||||
Reference in New Issue
Block a user