working on voice control
Some checks failed
CI/CD Pipeline / build (push) Failing after 4s

This commit is contained in:
2026-03-24 15:06:53 -06:00
parent f514012396
commit 86ff82a015
16 changed files with 704 additions and 173 deletions

View File

@@ -1,7 +1,7 @@
defmodule ElixirAi.ChatRunner do
require Logger
use GenServer
alias ElixirAi.{AiTools, Conversation, Message}
alias ElixirAi.{AiTools, Conversation, Message, SystemPrompts}
import ElixirAi.PubsubTopics
import ElixirAi.ChatRunner.OutboundHelpers
@@ -94,6 +94,12 @@ defmodule ElixirAi.ChatRunner do
_ -> "auto"
end
system_prompt =
case Conversation.find_category(name) do
{:ok, category} -> SystemPrompts.for_category(category)
_ -> nil
end
server_tools = AiTools.build_server_tools(self(), allowed_tools)
liveview_tools = AiTools.build_liveview_tools(self(), allowed_tools)
@@ -106,7 +112,7 @@ defmodule ElixirAi.ChatRunner do
ElixirAi.ChatUtils.request_ai_response(
self(),
messages,
messages_with_system_prompt(messages, system_prompt),
server_tools ++ liveview_tools,
provider,
tool_choice
@@ -117,6 +123,7 @@ defmodule ElixirAi.ChatRunner do
%{
name: name,
messages: messages,
system_prompt: system_prompt,
streaming_response: nil,
pending_tool_calls: [],
allowed_tools: allowed_tools,

View File

@@ -10,7 +10,7 @@ defmodule ElixirAi.ChatRunner.ConversationCalls do
ElixirAi.ChatUtils.request_ai_response(
self(),
new_state.messages,
messages_with_system_prompt(new_state.messages, state.system_prompt),
state.server_tools ++ state.liveview_tools,
state.provider,
effective_tool_choice

View File

@@ -18,4 +18,7 @@ defmodule ElixirAi.ChatRunner.OutboundHelpers do
message
end
def messages_with_system_prompt(messages, nil), do: messages
def messages_with_system_prompt(messages, prompt), do: [prompt | messages]
end

View File

@@ -159,7 +159,7 @@ defmodule ElixirAi.ChatRunner.StreamHandler do
ElixirAi.ChatUtils.request_ai_response(
self(),
state.messages ++ [new_message],
messages_with_system_prompt(state.messages ++ [new_message], state.system_prompt),
state.server_tools ++ state.liveview_tools,
state.provider,
state.tool_choice