fix: added delete buttons on chats and have chat titeling (maybe)
This commit is contained in:
@@ -168,6 +168,9 @@ defmodule BDS.AITest do
|
||||
usage: usage(31, 8, 0, 0)
|
||||
}}
|
||||
end
|
||||
|
||||
:chat_title ->
|
||||
{:ok, %{content: "Blog Stats", usage: usage(12, 3, 0, 0)}}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -615,6 +618,46 @@ defmodule BDS.AITest do
|
||||
end)
|
||||
end
|
||||
|
||||
test "chat generates a short title after the first user turn using the title model" do
|
||||
{:ok, project} = create_project_fixture("Title Chat")
|
||||
_fixtures = seed_project_content(project.id)
|
||||
|
||||
assert {:ok, _endpoint} =
|
||||
BDS.AI.put_endpoint(
|
||||
:online,
|
||||
%{
|
||||
url: "https://api.example.test/v1",
|
||||
api_key: "online-secret",
|
||||
model: "gpt-4o-mini"
|
||||
},
|
||||
secret_backend: FakeSecretBackend
|
||||
)
|
||||
|
||||
assert :ok = BDS.AI.set_airplane_mode(false)
|
||||
assert :ok = BDS.AI.put_model_preference(:title, "title-model")
|
||||
assert {:ok, conversation} = BDS.AI.start_chat(%{model: "gpt-4o-mini"})
|
||||
|
||||
assert {:ok, reply} =
|
||||
BDS.AI.send_chat_message(conversation.id, "How many items are in the blog?",
|
||||
runtime: FakeRuntime,
|
||||
test_pid: self(),
|
||||
project_id: project.id,
|
||||
secret_backend: FakeSecretBackend
|
||||
)
|
||||
|
||||
assert reply.conversation.title == "Blog Stats"
|
||||
assert BDS.AI.get_chat_conversation(conversation.id).title == "Blog Stats"
|
||||
|
||||
assert_received {:runtime_request, _endpoint, %{operation: :chat}}
|
||||
assert_received {:runtime_request, _endpoint, %{operation: :chat}}
|
||||
|
||||
assert_received {:runtime_request, _endpoint, title_request}
|
||||
assert title_request.operation == :chat_title
|
||||
assert title_request.model == "title-model"
|
||||
assert Enum.any?(title_request.messages, &(&1["content"] =~ "2-3 words"))
|
||||
assert Enum.any?(title_request.messages, &(&1["content"] =~ "How many items"))
|
||||
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)
|
||||
|
||||
@@ -248,6 +248,17 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
assert html =~ ~s(data-tab-type="chat")
|
||||
assert html =~ ~s(data-tab-id="#{created_chat.id}")
|
||||
|
||||
html = render_click(view, "select_view", %{"view" => "chat"})
|
||||
assert html =~ ~s(data-testid="sidebar-delete-chat")
|
||||
|
||||
html =
|
||||
view
|
||||
|> element("[data-testid='sidebar-delete-chat'][data-item-id='#{created_chat.id}']")
|
||||
|> render_click()
|
||||
|
||||
refute Repo.get(BDS.AI.ChatConversation, created_chat.id)
|
||||
refute html =~ ~s(data-tab-id="#{created_chat.id}")
|
||||
|
||||
_html = render_click(view, "select_view", %{"view" => "import"})
|
||||
|
||||
html =
|
||||
|
||||
Reference in New Issue
Block a user