mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-11-23 23:49:08 -06:00
Pass endpoint URL to openai
This commit is contained in:
@@ -1842,13 +1842,13 @@ current backend. If not supplied, defaults to "gpt-3.5-turbo" for OpenAI and "ll
|
|||||||
|
|
||||||
#### [`PAPERLESS_AI_LLM_API_KEY=<str>`](#PAPERLESS_AI_LLM_API_KEY) {#PAPERLESS_AI_LLM_API_KEY}
|
#### [`PAPERLESS_AI_LLM_API_KEY=<str>`](#PAPERLESS_AI_LLM_API_KEY) {#PAPERLESS_AI_LLM_API_KEY}
|
||||||
|
|
||||||
: The API key to use for the AI backend. This is required for the OpenAI backend only.
|
: The API key to use for the AI backend. This is required for the OpenAI backend (optional for others).
|
||||||
|
|
||||||
Defaults to None.
|
Defaults to None.
|
||||||
|
|
||||||
#### [`PAPERLESS_AI_LLM_ENDPOINT=<str>`](#PAPERLESS_AI_LLM_ENDPOINT) {#PAPERLESS_AI_LLM_ENDPOINT}
|
#### [`PAPERLESS_AI_LLM_ENDPOINT=<str>`](#PAPERLESS_AI_LLM_ENDPOINT) {#PAPERLESS_AI_LLM_ENDPOINT}
|
||||||
|
|
||||||
: The endpoint / url to use for the AI backend. This is required for the Ollama backend only.
|
: The endpoint / url to use for the AI backend. This is required for the Ollama backend (optional for others).
|
||||||
|
|
||||||
Defaults to None.
|
Defaults to None.
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class AIClient:
|
|||||||
elif self.settings.llm_backend == "openai":
|
elif self.settings.llm_backend == "openai":
|
||||||
return OpenAI(
|
return OpenAI(
|
||||||
model=self.settings.llm_model or "gpt-3.5-turbo",
|
model=self.settings.llm_model or "gpt-3.5-turbo",
|
||||||
|
api_base=self.settings.llm_endpoint or None,
|
||||||
api_key=self.settings.llm_api_key,
|
api_key=self.settings.llm_api_key,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -47,11 +47,13 @@ def test_get_llm_openai(mock_ai_config, mock_openai_llm):
|
|||||||
mock_ai_config.llm_backend = "openai"
|
mock_ai_config.llm_backend = "openai"
|
||||||
mock_ai_config.llm_model = "test_model"
|
mock_ai_config.llm_model = "test_model"
|
||||||
mock_ai_config.llm_api_key = "test_api_key"
|
mock_ai_config.llm_api_key = "test_api_key"
|
||||||
|
mock_ai_config.llm_endpoint = "http://test-url"
|
||||||
|
|
||||||
client = AIClient()
|
client = AIClient()
|
||||||
|
|
||||||
mock_openai_llm.assert_called_once_with(
|
mock_openai_llm.assert_called_once_with(
|
||||||
model="test_model",
|
model="test_model",
|
||||||
|
api_base="http://test-url",
|
||||||
api_key="test_api_key",
|
api_key="test_api_key",
|
||||||
)
|
)
|
||||||
assert client.llm == mock_openai_llm.return_value
|
assert client.llm == mock_openai_llm.return_value
|
||||||
|
|||||||
Reference in New Issue
Block a user