Use gpt 4.1 with search

This commit is contained in:
Claudio Ortolina
2026-02-22 10:27:44 +00:00
parent 8d38512712
commit 78025eba69
3 changed files with 27 additions and 25 deletions
+6 -9
View File
@@ -2,16 +2,12 @@ defmodule MusicLibrary.RecordChat do
alias MusicLibrary.Records.Record
def stream_response(messages, record, embedding_text, callback) do
system_prompt = build_system_prompt(record, embedding_text)
instructions = build_instructions(record, embedding_text)
full_messages = [
%{role: "system", content: system_prompt} | messages
]
OpenAI.chat_stream(full_messages, on_chunk: callback)
OpenAI.chat_stream(messages, on_chunk: callback, instructions: instructions)
end
defp build_system_prompt(%Record{} = record, embedding_text) do
defp build_instructions(%Record{} = record, embedding_text) do
context =
case embedding_text do
nil -> basic_context(record)
@@ -21,8 +17,9 @@ defmodule MusicLibrary.RecordChat do
"""
You are a knowledgeable music assistant. Answer questions about the album \
the user is currently viewing. Use the provided information as your primary \
reference. Be concise and accurate. When unsure, say so.
the user is currently viewing. Use the provided album information as your \
primary reference, and use web search to find additional up-to-date \
information when helpful. Be concise and accurate. When unsure, say so.
Album information:
#{context}