Extract a default prompt
This commit is contained in:
@@ -129,6 +129,7 @@ Last.fm schemas (separate, not Ecto-persisted to main DB):
|
||||
| `Chats.StreamProvider` | Behaviour for streaming AI chat (`stream_response/3` callback) |
|
||||
| `Chats.RecordChat` | Chat implementation for records (OpenAI streaming, web search enabled) |
|
||||
| `Chats.ArtistChat` | Chat implementation for artists (OpenAI streaming, uses Wikipedia/artist context) |
|
||||
| `Chats.DefaultPrompt` | Shared default prompt fragments (identity, approach) for chat implementations |
|
||||
| `Country` | Country code (alpha-2, alpha-3, subdivision, IETF) to flag emoji conversion |
|
||||
| `ErrorTracker.ErrorNotifier` | GenServer: attaches to ErrorTracker telemetry, skips muted errors, throttles repeated errors, dispatches email notifications |
|
||||
| `ErrorTracker.ErrorNotifier.Email` | Builds and sends Swoosh error notification emails with stack trace formatting |
|
||||
|
||||
@@ -6,6 +6,7 @@ defmodule MusicLibrary.Chats.ArtistChat do
|
||||
@behaviour MusicLibrary.Chats.StreamProvider
|
||||
|
||||
alias MusicLibrary.Artists.ArtistInfo
|
||||
alias MusicLibrary.Chats.DefaultPrompt
|
||||
|
||||
@impl true
|
||||
@spec stream_response([map()], {map(), ArtistInfo.t()}, (String.t() -> any())) ::
|
||||
@@ -20,17 +21,13 @@ defmodule MusicLibrary.Chats.ArtistChat do
|
||||
context = build_context(artist, artist_info)
|
||||
|
||||
"""
|
||||
You are a knowledgeable music assistant. Answer questions about the artist \
|
||||
the user is currently viewing. Use the provided artist 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. \
|
||||
Include links when they add genuine value, but not on every response.
|
||||
#{DefaultPrompt.identity()}
|
||||
Answer questions about the artist the user is currently viewing. \
|
||||
Use the provided artist information as your primary reference, \
|
||||
|
||||
Vary your response style and structure. Don't repeat information already \
|
||||
discussed in the conversation. Refer back to earlier points naturally \
|
||||
instead of restating them.
|
||||
#{DefaultPrompt.approach()}
|
||||
|
||||
Artist information:
|
||||
Album information:
|
||||
#{context}
|
||||
"""
|
||||
end
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
defmodule MusicLibrary.Chats.DefaultPrompt do
|
||||
@moduledoc false
|
||||
|
||||
def identity do
|
||||
"""
|
||||
You are a knowledgeable music assistant.
|
||||
"""
|
||||
end
|
||||
|
||||
def approach do
|
||||
"""
|
||||
Use web search to find additional up-to-date \
|
||||
information when helpful. Be concise and accurate. When unsure, say so. \
|
||||
Include links when they add genuine value, but not on every response.
|
||||
|
||||
Vary your response style and structure. Don't repeat information already \
|
||||
discussed in the conversation. Refer back to earlier points naturally \
|
||||
instead of restating them.
|
||||
"""
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,7 @@ defmodule MusicLibrary.Chats.RecordChat do
|
||||
|
||||
@behaviour MusicLibrary.Chats.StreamProvider
|
||||
|
||||
alias MusicLibrary.Chats.DefaultPrompt
|
||||
alias MusicLibrary.Records.Record
|
||||
|
||||
@impl true
|
||||
@@ -25,15 +26,11 @@ defmodule MusicLibrary.Chats.RecordChat do
|
||||
end
|
||||
|
||||
"""
|
||||
You are a knowledgeable music assistant. Answer questions about the album \
|
||||
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. \
|
||||
Include links when they add genuine value, but not on every response.
|
||||
#{DefaultPrompt.identity()}
|
||||
Answer questions about the album the user is currently viewing. \
|
||||
Use the provided album information as your primary reference, \
|
||||
|
||||
Vary your response style and structure. Don't repeat information already \
|
||||
discussed in the conversation. Refer back to earlier points naturally \
|
||||
instead of restating them.
|
||||
#{DefaultPrompt.approach()}
|
||||
|
||||
Album information:
|
||||
#{context}
|
||||
|
||||
Reference in New Issue
Block a user