fix: still fighting crashes on close and weird AI chat behaviou
This commit is contained in:
@@ -385,12 +385,19 @@ defmodule BDS.AI.Chat do
|
||||
|
||||
cond do
|
||||
chat_user_message_count(conversation_id) < 1 ->
|
||||
Logger.debug("Chat title generation skipped reason=:no_user_messages")
|
||||
{:ok, reply}
|
||||
|
||||
not generated_chat_title?(conversation.title, conversation.model) ->
|
||||
Logger.debug(
|
||||
"Chat title generation skipped reason=:conversation_already_titled title=#{inspect(conversation.title)}"
|
||||
)
|
||||
|
||||
{:ok, reply}
|
||||
|
||||
true ->
|
||||
Logger.debug("Chat title generation requested conversation_id=#{conversation_id}")
|
||||
|
||||
case generate_chat_title(user_content, opts) do
|
||||
{:ok, title} when is_binary(title) and title != "" ->
|
||||
now = Persistence.now_ms()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule BDS.AI.OpenAICompatibleRuntime do
|
||||
@moduledoc false
|
||||
|
||||
require Logger
|
||||
|
||||
alias BDS.AI.HttpClient
|
||||
|
||||
def list_models(endpoint, opts \\ []) when is_map(endpoint) and is_list(opts) do
|
||||
@@ -39,6 +41,10 @@ defmodule BDS.AI.OpenAICompatibleRuntime do
|
||||
|> maybe_disable_thinking(request.model)
|
||||
|> maybe_put_tools(Map.get(request, :tools, []))
|
||||
|
||||
Logger.debug(
|
||||
"AI OpenAI-compatible request operation=#{inspect(Map.get(request, :operation))} model=#{inspect(request.model)} url=#{url} tools=#{payload |> Map.get("tools", []) |> length()}"
|
||||
)
|
||||
|
||||
with {:ok, response} <- HttpClient.post(url, headers, Jason.encode!(payload)),
|
||||
200 <- response.status do
|
||||
normalize_response(response.body)
|
||||
|
||||
@@ -66,13 +66,33 @@ defmodule BDS.Desktop.Shutdown do
|
||||
defp start_shutdown_task do
|
||||
Task.start(fn ->
|
||||
MainWindow.persist_now()
|
||||
maybe_hide_window()
|
||||
Process.sleep(50)
|
||||
quit_module().quit()
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
defp maybe_hide_window do
|
||||
module = window_module()
|
||||
|
||||
if function_exported?(module, :hide, 1) do
|
||||
module.hide(MainWindow.window_id())
|
||||
end
|
||||
|
||||
:ok
|
||||
rescue
|
||||
_error -> :ok
|
||||
catch
|
||||
:exit, _reason -> :ok
|
||||
end
|
||||
|
||||
defp quit_module do
|
||||
Application.get_env(:bds, :desktop_window_quit_module, Window)
|
||||
end
|
||||
|
||||
defp window_module do
|
||||
Application.get_env(:bds, :desktop_window_module, Window)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user