bailed on telemetry

This commit is contained in:
2026-03-06 14:41:31 -07:00
parent 6d5ca55900
commit b9db6408b1
7 changed files with 36 additions and 34 deletions

View File

@@ -56,7 +56,6 @@ defmodule ElixirAi.ChatUtils do
headers = [{"authorization", "Bearer #{api_key}"}]
# Logger.info("sending AI request with body: #{inspect(body)}")
case Req.post(api_url,
json: body,
headers: headers,
@@ -69,7 +68,6 @@ defmodule ElixirAi.ChatUtils do
end
) do
{:ok, _response} ->
# Logger.info("AI request completed with response #{inspect(response)}")
:ok
{:error, reason} ->

View File

@@ -39,9 +39,9 @@ defmodule ElixirAi.AiUtils.StreamLineUtils do
%{
"choices" => [%{"finish_reason" => "stop"}],
"id" => id
} = msg
} = _msg
) do
Logger.info("Received end of AI response stream for id #{id} with message: #{inspect(msg)}")
# Logger.info("Received end of AI response stream for id #{id} with message: #{inspect(msg)}")
send(
server,
@@ -125,7 +125,7 @@ defmodule ElixirAi.AiUtils.StreamLineUtils do
"id" => id
} = message
) do
Logger.info("Received tool_calls_finished with message: #{inspect(message)}")
# Logger.info("Received tool_calls_finished with message: #{inspect(message)}")
send(server, {:ai_tool_call_end, id})
end

View File

@@ -29,11 +29,11 @@ defmodule ElixirAi.ChatRunner do
messages: [],
streaming_response: nil,
pending_tool_calls: [],
tools: tools(self())
tools: tools(self(), name)
}}
end
def tools(server) do
def tools(server, name) do
[
ai_tool(
name: "store_thing",
@@ -53,8 +53,19 @@ defmodule ElixirAi.ChatRunner do
name: "set_background_color",
description:
"set the background color of the chat interface, accepts specified tailwind colors",
function: &ElixirAi.ToolTesting.set_background_color/1,
parameters: ElixirAi.ToolTesting.set_background_color_params(),
function: fn %{"color" => color} ->
Phoenix.PubSub.broadcast(ElixirAi.PubSub, "ai_chat:#{name}", {:set_background_color, color})
end,
parameters: %{
"type" => "object",
"properties" => %{
"color" => %{
"type" => "string",
"enum" => ElixirAiWeb.ChatLive.valid_background_colors()
}
},
"required" => ["color"]
},
server: server
)
]
@@ -182,7 +193,7 @@ defmodule ElixirAi.ChatRunner do
end
def handle_info({:ai_tool_call_end, id}, state) do
Logger.info("ending tool call with tools: #{inspect(state.streaming_response.tool_calls)}")
# Logger.info("ending tool call with tools: #{inspect(state.streaming_response.tool_calls)}")
tool_request_message = %{
role: :assistant,

View File

@@ -39,25 +39,6 @@ defmodule ElixirAi.ToolTesting do
}
end
def set_background_color(%{"color" => color}) do
Phoenix.PubSub.broadcast(ElixirAi.PubSub, "ai_chat", {:set_background_color, color})
end
def set_background_color_params do
valid_tailwind_colors = ElixirAiWeb.ChatLive.valid_background_colors()
%{
"type" => "object",
"properties" => %{
"color" => %{
"type" => "string",
"enum" => valid_tailwind_colors
}
},
"required" => ["color"]
}
end
def read_thing_definition(name) do
%{
"type" => "function",