Impromptu - Classical Music Discovery Chatbot
Chatbot intended to help users discover classical music.
Embabel features:
- Agent-based chatbot with RAG (Neo4j vector storage)
- DICE proposition extraction pipeline for memories about users
- Spotify integration for playlist management
Getting Started
Overview
Impromptu is a conversational AI assistant for classical music discovery, powered by the Embabel Agent Framework. It combines RAG-based knowledge retrieval, multi-platform music integration, and semantic memory extraction to create a personalized music exploration experience.
| Login |
Chat Interface |
 |
 |
Key Capabilities:
- Natural language conversations about classical music with RAG-enhanced responses
- Integration with Spotify (playlists, playback) and YouTube (video search, playback)
- Access to IMSLP (600,000+ public domain scores) and Met Museum art collections
- Automatic extraction and recall of user preferences and interests via DICE memory
- Dynamic concert program and listening guide generation
Architecture
Impromptu is built on the Embabel Agent Framework (documentation) using three architectural pillars: Utility AI for flexible tool orchestration, Matryoshka Tools for progressive disclosure of capabilities, and DICE Memory for semantic knowledge extraction.
graph TB
subgraph User Layer
UI[Vaadin Chat UI]
end
subgraph Chat Layer
CA[ChatActions]
CB[Utility Chatbot]
end
subgraph Tool Layer
MT[Matryoshka Tools]
AT[Agentic Tools]
RAG[RAG Search]
end
subgraph Memory Layer
DICE[DICE Extraction]
PR[Proposition Repository]
end
subgraph Persistence
NEO[(Neo4j Graph + Vector)]
end
UI --> CA
CA --> CB
CB --> MT
CB --> AT
CB --> RAG
CA --> DICE
DICE --> PR
PR --> NEO
RAG --> NEO
Utility AI Chatbot
The chatbot uses the Utility AI pattern from the Embabel Agent Framework, where the LLM autonomously selects which tools to invoke based on user intent. Unlike scripted chatbots, the LLM reasons about the best approach for each query.
sequenceDiagram
participant U as User
participant C as ChatActions
participant L as LLM
participant T as Tools
participant M as Memory
U->>C: "Find me a good recording of Brahms Symphony 4"
C->>M: Load recent propositions (top 10)
C->>L: Send message + tools + memory context
Note over L: LLM reasons about approach
L->>T: Call spotify.searchTracks("Brahms Symphony 4")
T-->>L: Track results with performers
L->>T: Call performanceFinder("Brahms Symphony 4")
T-->>L: Structured Performance objects
L-->>C: Response with recommendations
C-->>U: Display response
C->>M: Async: Extract propositions
Implementation: The AgentProcessChatbot.utilityFromPlatform() creates a chatbot that discovers all @Action methods and makes them available as tools. The LLM decides when to use RAG search, query the database, or call external APIs.
@Bean
Chatbot chatbot(AgentPlatform agentPlatform) {
return AgentProcessChatbot.utilityFromPlatform(agentPlatform);
}
Matryoshka Tools
Matryoshka Tools implement progressive disclosure: the LLM initially sees only high-level "facade" tools. When invoked, these reveal specific sub-tools. This reduces cognitive load while maintaining full capability.
graph LR
subgraph "Initial View (4 tools)"
S[spotify]
I[imslp]
M[metmuseum]
Y[youtube]
end
subgraph "After spotify invoked"
S1[searchTracks]
S2[getPlaylists]
S3[createPlaylist]
S4[addToPlaylist]
S5[getPlaybackState]
end
subgraph "After imslp invoked"
I1[findScores]
I2[searchWorks]
I3[browseByComposer]
end
S -.->|reveals| S1
S -.->|reveals| S2
S -.->|reveals| S3
S -.->|reveals| S4
S -.->|reveals| S5
I -.->|reveals| I1
I -.->|reveals| I2
I -.->|reveals| I3
Available Tool Facades:
| Facade |
Purpose |
Sub-tools |
spotify |
Music playback & playlists |
searchTracks, getPlaylists, createPlaylist, addToPlaylist, play, pause |
imslp |
Public domain scores |
findScores, searchWorks, browseByComposer |
metmuseum |
Art collection |
searchArtworks, getArtwork, browseByDepartment |
youtube |
Video search & playback |
searchVideos, playVideo |
pdf |
Document generation |
generateDocument (programs, guides, biographies) |
Implementation: Tools use the @MatryoshkaTools annotation:
@MatryoshkaTools(name = "spotify", description = "Access Spotify music features")
public class SpotifyTools {
@Tool(description = "Search for tracks")
public List<TrackInfo> searchTracks(String query) { ... }
@Tool(description = "Get user's playlists")
public List<PlaylistInfo> getPlaylists() { ... }
}
Agentic Cypher Query Generation
The CypherQueryTools component (from the embabel-agent-rag-neo-drivine module) is an agentic tool that uses an LLM to dynamically generate Cypher queries from natural language. Unlike simple API wrappers, this tool invokes an LLM internally to translate user questions into valid database queries. Critically, query generation is constrained by the domain schema (DataDictionary), ensuring queries are both safe and valid.
flowchart LR
subgraph "Domain Schema (DataDictionary)"
S[Schema Definition]
E1["Composer
- completeName
- birthYear, deathYear
- popular, recommended"]
E2["Work
- title, subtitle
- searchTerms
- popular, recommended"]
E3["Performer
- name, instrument"]
R["Relationships
COMPOSED, OF_GENRE
OF_EPOCH, PERFORMED"]
end
subgraph "CypherQueryTools"
LLM[LLM Query Generator]
V[Schema Validator]
PM[Persistence Manager]
end
subgraph "Safety Guarantees"
G1[Only known labels]
G2[Only defined properties]
G3[Read-only queries]
G4[Valid relationships]
end
S --> E1
S --> E2
S --> E3
S --> R
E1 --> LLM
E2 --> LLM
E3 --> LLM
R --> LLM
LLM --> V
V --> G1
V --> G2
V --> G3
V --> G4
V --> PM
Why Schema Matters:
The schema serves as a contract between the domain model and the LLM. Without it, the LLM might generate queries that:
- Reference non-existent node labels or properties
- Attempt to create or modify data (injection attacks)
- Use incorrect relationship types
- Return unexpected data structures
By providing the schema to the LLM, it can generate valid queries like:
// "Who composed the most violin concertos?"
MATCH (c:Composer)-[:COMPOSED]->(w:Work)
WHERE w.title CONTAINS 'Violin Concerto'
RETURN c.completeName, count(w) as concertos
ORDER BY concertos DESC
LIMIT 10
Schema Definition:
@Bean
DataDictionary musicSchema() {
return DataDictionary.fromClasses(
"art_music",
Composer.class, // Node label with properties
Work.class, // Linked via COMPOSED relationship
Performer.class, // Artist/musician entities
MusicPlace.class, // Venues, cities
ImpromptuUser.class // User preferences
);
}
Entity classes define the schema through annotations:
@CreationPermitted(false) // LLM cannot create new composers
public interface Composer extends NamedEntity {
String getCompleteName();
Long getBirthYear();
Long getDeathYear();
@Relationship(name = "COMPOSED")
List<Work> getWorks();
}
Tool Usage:
cypherQueryTools.tool("""
Use this tool to query existing entities such as composers and works.
If you are asked questions like "Who composed the most violin concertos?" or
"List saxophone concertos" use this tool
""")
The schema-constrained approach enables powerful natural language queries while preventing the LLM from generating unsafe or invalid database operations.
Graph Exploration and Visualization
The agentic Cypher tool can discover complex relationships across the knowledge graph. For example, finding string quartets composed by those who influenced a particular composer:
// String quartets by Messiaen's influencers
MATCH (influencer:Composer)-[i:INFLUENCED]->(messiaen:Composer {id: 'olivier-messiaen-1908'})
MATCH (influencer)-[c:COMPOSED]->(w:Work)-[sf:SCORED_FOR]->(sq:Ensemble {id: 'string-quartet'})
RETURN influencer, c, w, sf, sq
This query returns graph elements that can be visualized directly in Neo4j Browser or web-based graph libraries:

The graph shows composers who influenced Olivier Messiaen, connected to their string quartet compositions. Each node represents an entity (composer, work, or ensemble) and edges show the relationships between them.
Note: Olivier Messiaen (1908–1992) is widely regarded as one of the most important composers who lived wholly in the 20th century. His unique musical language combined complex rhythms, modes of limited transposition, birdsong transcriptions, and deeply spiritual Catholic mysticism.

Listen to his monumental Turangalîla-Symphonie
The influence relationships shown here are LLM-generated through the Composer Enhancement Pipeline and reviewed by musicologists before being committed to the knowledge graph. The SCORED_FOR relationships linking works to ensembles and instruments are inferred from work titles using pattern matching. Both datasets will continue to be refined and expanded over time.
The agentic tool can answer natural language questions like "Which composers influenced Messiaen and wrote string quartets?" by composing the appropriate Cypher query, executing it, and returning structured results suitable for both textual responses and graph visualization.
Agentic Tools for Performance Discovery
Agentic Tools go beyond simple API calls - they orchestrate multi-step LLM-driven workflows. The Performance Finder demonstrates this: it searches across platforms, parses metadata, and structures results into coherent Performance objects.
flowchart TB
subgraph "Agentic Tool: Performance Finder"
direction TB
Q[User Query: Find Brahms 4 recording]
subgraph "LLM Orchestration"
A[Analyze query intent]
B[Search Spotify tracks]
C[Search YouTube videos]
D[Parse performer metadata]
E[Group into performances]
F[Return structured results]
end
Q --> A
A --> B
A --> C
B --> D
C --> D
D --> E
E --> F
end
subgraph "Output: Performance Objects"
P1["Performance 1
Performer: Kleiber
Ensemble: Vienna Phil
Source: spotify
Tracks: [Mov I, II, III, IV]"]
P2["Performance 2
Performer: Bernstein
Ensemble: NY Phil
Source: youtube
Video: Full concert"]
end
F --> P1
F --> P2
Performance Model: