bailed on telemetry
This commit is contained in:
@@ -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} ->
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -160,7 +160,7 @@ defmodule ElixirAiWeb.ChatLive do
|
||||
end
|
||||
|
||||
def handle_info(:tool_calls_finished, socket) do
|
||||
Logger.info("Received tool_calls_finished")
|
||||
# Logger.info("Received tool_calls_finished")
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
@@ -168,7 +168,7 @@ defmodule ElixirAiWeb.ChatLive do
|
||||
end
|
||||
|
||||
def handle_info({:tool_request_message, tool_request_message}, socket) do
|
||||
Logger.info("tool request message: #{inspect(tool_request_message)}")
|
||||
# Logger.info("tool request message: #{inspect(tool_request_message)}")
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
@@ -176,8 +176,6 @@ defmodule ElixirAiWeb.ChatLive do
|
||||
end
|
||||
|
||||
def handle_info({:one_tool_finished, tool_response}, socket) do
|
||||
Logger.info("Received one_tool_finished with #{inspect(tool_response)}")
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> update(:messages, &(&1 ++ [tool_response]))}
|
||||
|
||||
@@ -55,7 +55,6 @@ defmodule ElixirAiWeb.HomeLive do
|
||||
"""
|
||||
end
|
||||
|
||||
@spec handle_event(<<_::48>>, map(), any()) :: {:noreply, any()}
|
||||
def handle_event("create", %{"name" => name}, socket) do
|
||||
name = String.trim(name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user