feat: added tool support setup for models

This commit is contained in:
2026-05-01 21:49:31 +02:00
parent f8b8ccabbd
commit e4db1d6d62
5 changed files with 90 additions and 8 deletions

View File

@@ -604,6 +604,42 @@ defmodule BDS.AITest do
assert Enum.any?(second_request.messages, fn message -> message["role"] == "tool" end)
end
test "chat does not prompt models to emit textual tool calls when tools are unavailable" do
{:ok, project} = create_project_fixture("No Tool Chat")
_fixtures = seed_project_content(project.id)
assert {:ok, _endpoint} =
BDS.AI.put_endpoint(
:airplane,
%{
url: "http://localhost:11434/v1",
api_key: nil,
model: "llama-plain"
},
secret_backend: FakeSecretBackend
)
assert :ok = BDS.AI.set_airplane_mode(true)
assert :ok = BDS.AI.put_model_preference(:airplane_chat, "llama-plain")
assert {:ok, conversation} = BDS.AI.start_chat(%{model: "llama-plain"})
assert {:ok, _reply} =
BDS.AI.send_chat_message(conversation.id, "Show posts per month",
runtime: FakeRuntime,
test_pid: self(),
project_id: project.id,
secret_backend: FakeSecretBackend
)
assert_received {:runtime_request, _endpoint, first_request}
assert first_request.tools == []
refute Enum.any?(first_request.messages, fn message ->
message["role"] == "system" and
String.contains?(message["content"], "Available blog data tools")
end)
end
test "non-stat chat tools expose concrete project data" do
{:ok, project} = create_project_fixture("Concrete Tools")
%{post: post, media: media} = seed_project_content(project.id)

View File

@@ -770,11 +770,13 @@ defmodule BDS.Desktop.ShellLiveTest do
"online_url" => "https://api.example.test/v1",
"online_api_key" => "online-secret",
"online_chat_model" => "gpt-4.1",
"online_chat_tools" => "true",
"online_title_model" => "gpt-4.1-mini",
"online_image_analysis_model" => "gpt-4.1-vision",
"offline_url" => "http://localhost:11434/v1",
"offline_api_key" => "",
"offline_chat_model" => "llama3.3",
"offline_chat_tools" => "true",
"offline_title_model" => "llama3.2",
"offline_image_analysis_model" => "llava:latest",
"offline_mode" => "true",
@@ -802,6 +804,9 @@ defmodule BDS.Desktop.ShellLiveTest do
assert {:ok, "llama3.3"} = AI.get_model_preference(:airplane_chat)
assert {:ok, "llama3.2"} = AI.get_model_preference(:airplane_title)
assert {:ok, "llava:latest"} = AI.get_model_preference(:airplane_image_analysis)
assert %{supports_tool_calls: true} = BDS.AI.Catalog.model_capabilities("gpt-4.1")
assert %{supports_tool_calls: true} = BDS.AI.Catalog.model_capabilities("llama3.3")
end
test "ai settings refresh models from the configured endpoints" do