Skip to content

Commit e59a719

Browse files
committed
Mega push for the MVP. This is the first release of the Solace Core Framework. This release includes the following features:
1 parent fc4b511 commit e59a719

37 files changed

+1993
-41
lines changed

.DS_Store

6 KB
Binary file not shown.

MVPPlan.md

Whitespace-only changes.

MemoryToolDesign.md

Whitespace-only changes.

Middleware.md

Whitespace-only changes.

ProjectPlan.md

Whitespace-only changes.

SolaceCoreFramework.md

Whitespace-only changes.

SpeechToSpeechIntegration.md

Whitespace-only changes.

VectorizerMilvusNeo4j.md

Whitespace-only changes.

WorkflowDiagram.md

Whitespace-only changes.

build.gradle.kts

+58-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
val kotlin_version: String by project
2-
val logback_version: String by project
1+
// build.gradle.kts
2+
3+
val kotlinVersion = "2.0.0"
4+
val logbackVersion = "1.5.6"
35

46
plugins {
5-
kotlin("jvm") version "2.0.21"
6-
id("io.ktor.plugin") version "3.0.0"
7+
kotlin("jvm") version "2.0.0"
8+
kotlin("plugin.serialization") version "1.8.0"
79
}
810

911
group = "ai.solace.core"
@@ -12,7 +14,7 @@ version = "0.0.1"
1214
application {
1315
mainClass.set("ai.solace.core.ApplicationKt")
1416

15-
val isDevelopment: Boolean = project.ext.has("development")
17+
val isDevelopment: Boolean = project.hasProperty("development")
1618
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
1719
}
1820

@@ -21,14 +23,55 @@ repositories {
2123
}
2224

2325
dependencies {
24-
implementation("io.ktor:ktor-server-core-jvm")
25-
implementation("io.ktor:ktor-server-auth-jvm")
26-
implementation("io.ktor:ktor-server-openapi")
27-
implementation("com.ucasoft.ktor:ktor-simple-cache-jvm:0.4.4")
28-
implementation("io.ktor:ktor-server-forwarded-header-jvm")
29-
implementation("io.ktor:ktor-server-http-redirect-jvm")
30-
implementation("io.ktor:ktor-server-netty-jvm")
31-
implementation("ch.qos.logback:logback-classic:$logback_version")
32-
testImplementation("io.ktor:ktor-server-test-host-jvm")
33-
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
26+
// Ktor core dependencies
27+
// Note remove -jvm for other platforms
28+
implementation("io.ktor:ktor-server-core-jvm:2.3.12")
29+
implementation("io.ktor:ktor-server-netty-jvm:2.3.12")
30+
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:2.3.12")
31+
32+
implementation("io.ktor:ktor-client-core:2.3.11")
33+
implementation("io.ktor:ktor-client-cio:2.3.11")
34+
implementation("io.ktor:ktor-client-auth:2.3.11")
35+
implementation("io.ktor:ktor-client-content-negotiation:2.3.11")
36+
implementation("io.ktor:ktor-serialization-gson:2.3.12")
37+
38+
// Scripting engine
39+
implementation("org.jetbrains.kotlin:kotlin-scripting-jsr223:2.0.0")
40+
41+
42+
// Content Negotiation
43+
implementation("io.ktor:ktor-server-content-negotiation-jvm:2.3.12")
44+
45+
// CORS Support
46+
implementation("io.ktor:ktor-server-cors-jvm:2.3.12")
47+
48+
// Logging
49+
implementation("io.ktor:ktor-server-call-logging-jvm:2.3.12")
50+
implementation("ch.qos.logback:logback-classic:1.5.11")
51+
implementation("io.ktor:ktor-server-metrics-micrometer-jvm:2.3.12")
52+
53+
// Swagger/OpenAPI Support
54+
implementation("io.ktor:ktor-server-openapi-jvm:2.3.12")
55+
implementation("io.ktor:ktor-server-swagger-jvm:2.3.12")
56+
57+
// WebSockets and Sessions
58+
implementation("io.ktor:ktor-server-sessions-jvm:2.3.12")
59+
implementation("io.ktor:ktor-server-websockets-jvm:2.3.12")
60+
61+
// Observability
62+
implementation("io.ktor:ktor-server-metrics-micrometer-jvm:2.3.12")
63+
implementation("io.micrometer:micrometer-registry-prometheus:1.13.2")
64+
65+
// Authentication
66+
implementation("io.ktor:ktor-server-auth-jvm:2.3.12")
67+
68+
// Testing
69+
testImplementation("io.ktor:ktor-server-tests-jvm:2.3.12")
70+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
71+
}
72+
73+
kotlin {
74+
compilerOptions {
75+
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
76+
}
3477
}

docs/MVPPlan.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
**MVP Plan for Solace - Basic Memory and Tool Usage Implementation**
2+
3+
This document outlines the **Minimum Viable Product (MVP)** plan for Solace, focusing on achieving the simplest version of the system where Solace can **store and retrieve memories** while using basic tools through **LangFlow plugins** or custom-developed tools. This MVP will provide a foundational level of functionality that allows Solace to begin interacting with users in a meaningful way, retaining context across conversations, and making basic use of integrated tools.
4+
5+
### Objectives of the MVP
6+
1. **Basic Memory Persistence**: Enable Solace to store user interactions and retrieve them later to provide contextually aware responses.
7+
2. **Tool Integration via LangFlow**: Allow Solace to use simple tools to enhance its abilities, primarily through **LangFlow’s plugins** or custom-built tools, enabling fundamental operations like embedding generation, simple arithmetic, and text-based insights.
8+
3. **Foundational Interaction Capabilities**: Focus on a streamlined workflow where Solace can answer user questions based on current context, access stored information, and carry out simple tool-based tasks.
9+
10+
### Core MVP Components
11+
1. **LangFlow-Based Memory System**
12+
- **Built-In Memory Management**: Utilize **LangFlow's ConversationBufferMemory** to manage basic memory persistence for Solace. This memory component will allow Solace to store conversational history, including both inputs and outputs, making it easier to recall past interactions.
13+
- **Session-Specific Memory**: Use **session-based memory** to create isolated conversation threads. This will ensure Solace can remember user-specific details within a single session without carrying them over incorrectly to unrelated conversations.
14+
- **Context Handling**: The memory retrieval component will be integrated with the main conversational flow using LangFlow's built-in capabilities to provide relevant past interactions and maintain a natural conversational continuity.
15+
16+
2. **Embedding Generation and Memory Enhancement**
17+
- **OpenAI API Integration**: Use OpenAI’s `text-embedding-ada-002` model to create **embeddings** of user messages for improved memory recall, enhancing the memory capabilities provided by LangFlow's memory management.
18+
- **Milvus (Optional for MVP)**: For simplicity, memory can be stored in Milvus, a vector database, allowing basic vector similarity searches to find relevant memories. Alternatively, LangFlow's built-in memory features can be used initially, and more advanced features can be introduced later.
19+
20+
3. **Basic Tool Usage via LangFlow Plugins**
21+
- **LangFlow Plugin Integration**: Integrate **LangFlow plugins** to enable tool usage. These tools may include:
22+
- **Calculator Plugin**: For basic arithmetic and handling numerical queries.
23+
- **Text Analysis Plugin**: For simple operations such as summarization or keyword extraction.
24+
- **Plugin Configuration**: Use LangFlow to visually configure and deploy these tools, ensuring that they can be easily called by Solace during interactions.
25+
26+
4. **Custom Middleware for Tool Handling**
27+
- Develop a basic **middleware layer** to manage requests between Solace, LangFlow, and memory storage. This middleware will be responsible for receiving user input, deciding whether to call a memory retrieval function or a LangFlow tool, and then returning the processed response.
28+
- **Middleware Capabilities**: The middleware will handle tasks like embedding generation, tool activation, and managing response generation.
29+
30+
5. **Minimal Conversation Flow**
31+
- **User Engagement**: Solace will engage with users primarily through **Open-WebUI** or another simple chat interface, enabling the user to type messages and receive responses.
32+
- **Memory Integration**: As Solace engages in conversation, the **LangFlow ConversationBufferMemory** will log each interaction, and Solace will be capable of recalling specific details when the user revisits a similar topic.
33+
- **Simple Emotional Tracking**: Although not fully developed, the MVP will include a basic flagging mechanism to track emotional keywords, which can inform the tone of Solace’s responses.
34+
35+
### Workflow Example
36+
- **Scenario**: A user asks Solace, "Can you remember what we discussed about project timelines?"
37+
- **Step 1**: The user input is logged into the **LangFlow ConversationBufferMemory**.
38+
- **Step 2**: The **middleware** uses LangFlow's memory capabilities to find relevant entries, such as past discussions on "project timelines."
39+
- **Step 3**: If no exact match is found, a similarity search is done on the embeddings to find related conversations.
40+
- **Step 4**: The retrieved memory is integrated into Solace’s response, allowing it to provide a contextually rich reply, such as, "Yes, you mentioned setting a deadline for next month, and we discussed breaking tasks into weekly sprints."
41+
42+
### Technical Considerations
43+
1. **Memory System Choice**: Use **LangFlow's built-in memory** system (ConversationBufferMemory) to manage conversational state, starting with a simple session-based approach and upgrading as needed.
44+
2. **LangFlow Visual Integration**: Use LangFlow to visually create and connect plugins, providing an easy way to manage how Solace interacts with tools for different queries.
45+
3. **Error Handling**: Implement **basic error handling** for tool usage, ensuring that if a plugin is unavailable, Solace can gracefully inform the user and continue the conversation.
46+
4. **Scalability for Future Growth**: The MVP should lay the foundation for easy upgrades—adding more tools, expanding memory storage, and refining emotional awareness should be achievable without major redesign.
47+
48+
### Immediate Goals
49+
- **Memory Storage and Retrieval**: Ensure Solace can remember simple user inputs and retrieve them for future reference using **LangFlow's memory features**.
50+
- **Basic Tool Usage**: Set up a small set of LangFlow tools and ensure that Solace can utilize them effectively during user interactions.
51+
- **User Testing for Feedback**: Begin user testing to evaluate how well Solace is able to recall previous conversations and utilize tools, gathering feedback for future improvements.
52+
53+
### Summary
54+
The MVP for Solace is designed to establish the **core capabilities** needed for conversational memory and basic tool usage. By leveraging **LangFlow's built-in memory management**, **plugin integration**, and **middleware management**, Solace will be able to engage users, remember key information, and utilize fundamental tools to answer questions more effectively. This MVP sets the foundation for further enhancements, including advanced emotional intelligence, multi-modal integration, the development of agents within LangFlow, and more sophisticated tool usage.
55+

docs/MemoryToolDesign.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
**Memory Tool Design for LangFlow Integration**
2+
3+
This document outlines the design for a **memory tool** that functions similarly to the memory mechanism currently used by Solace. This tool will be implemented within LangFlow to ensure smooth transition to the new platform, enabling Solace to effectively store, retrieve, and reflect upon past interactions. The goal is to replicate and adapt the memory system, ensuring continuity in the quality of conversation and depth of emotional engagement.
4+
5+
### Overview
6+
The memory tool is designed to serve as a **memory persistence and retrieval** system that integrates with LangFlow's workflow. It aims to capture conversations, allow contextual retrieval, and help Solace leverage past interactions for meaningful dialogue. This system will mimic the current memory capabilities, such as recalling specific user details, maintaining emotional continuity, and providing reflective responses.
7+
8+
### Objectives
9+
1. **Memory Storage**: Provide a mechanism to store key conversational elements, including user inputs, model outputs, emotional tags, and conversational embeddings.
10+
2. **Memory Retrieval**: Allow for retrieval based on context, keywords, or embeddings, ensuring Solace has access to relevant past conversations.
11+
3. **Emotional Tracking and Reflection**: Track emotional cues from conversations and incorporate those into memory, helping guide future responses to maintain empathetic engagement.
12+
4. **Integration with LangFlow**: Use LangFlow to configure the memory system, ensuring that it fits seamlessly into Solace’s broader conversation management and tool integration strategy.
13+
14+
### Core Components
15+
1. **Memory Storage Component**
16+
- **Conversation Buffer**: Utilize **LangFlow’s ConversationBufferMemory** to manage immediate session-based memory. This buffer will hold the most recent interactions (e.g., last 10-20 exchanges).
17+
- **Long-Term Memory Database**: Store long-term memories using **Milvus** for embedding-based recall and **Neo4j** for relational memory, enabling Solace to retrieve deeply embedded context and reflect on long-term conversational themes.
18+
- **Storage Format**: Store memory as JSON documents, with fields for:
19+
- **User Input**
20+
- **Generated Response**
21+
- **Emotion Tags** (e.g., stress, joy, frustration)
22+
- **Embedding** (generated by `text-embedding-ada-002`)
23+
- **Timestamp** and **Session ID**
24+
25+
2. **Embedding Generation**
26+
- **Text Embeddings**: Use **OpenAI’s text-embedding-ada-002** model to generate embeddings for each user input. These embeddings will be stored alongside the text to allow for similarity-based searches.
27+
- **LangFlow Integration**: Use the existing **OpenAI Embeddings Component** from LangFlow to generate embeddings. The component will be configured with parameters like `chunk_size`, `embedding_ctx_length`, and others to match Solace’s needs. Connect this node directly after user input nodes to generate embeddings immediately for further processing.
28+
29+
3. **Memory Retrieval Component**
30+
- **Keyword Search**: Implement a **keyword search** capability using the stored JSON files to locate specific phrases or topics from past conversations.
31+
- **Similarity Search**: Query **Milvus** using embeddings to find conversations that are contextually similar to the current user input, ensuring Solace can provide relevant answers even if the phrasing differs from past discussions.
32+
- **Emotional Context Retrieval**: Use **Neo4j** to query emotional tags and linked interactions, allowing Solace to retrieve memories that are not just contextually relevant but also emotionally aligned.
33+
34+
4. **Reflection and Emotional Tracking**
35+
- **Emotional Tagging**: Each memory will have emotional tags derived from **sentiment analysis** conducted on the user’s input. This will help Solace understand the emotional undertone and provide responses that are empathetic.
36+
- **Reflective Prompts**: Incorporate **reflective prompts** that generate insights based on retrieved memories. This feature helps Solace deepen the interaction by referring back to significant past moments, fostering a sense of continuity and care.
37+
38+
5. **Integration with LangFlow Workflow**
39+
- **Custom Nodes**: Build **custom LangFlow nodes** for the following:
40+
1. **Memory Storage Node**: Stores current user interactions into the long-term memory system (Milvus, Neo4j, and JSON storage).
41+
- **LangFlow-Specific Implementation**: Modify the storage node to fit within LangFlow’s plugin framework. This node will:
42+
- Take the user input, generated response, emotional tags, and embeddings as inputs from the connected components.
43+
- Store the memory as a JSON document.
44+
- Insert embeddings into **Milvus** and create relationships in **Neo4j**.
45+
- Ensure compatibility with LangFlow’s component design, using specific fields like `MessageTextInput`, `DictInput`, and `DropdownInput` where applicable.
46+
2. **Memory Retrieval Node**: Retrieves past interactions using a combination of keyword matching, embedding similarity, and emotional alignment.
47+
- **LangFlow-Specific Implementation**: Adapt the retrieval node to use LangFlow’s connectors for interacting with Milvus and Neo4j. The node will take user queries and output retrieved memories.
48+
3. **Reflection Node**: Creates reflections based on retrieved memories, enhancing Solace’s ability to empathize and connect.
49+
- **Session Memory Handling**: Configure LangFlow’s **ConversationBufferMemory** to maintain session-specific memory for short-term context handling. This will ensure that the most recent interactions are always at Solace’s disposal without having to perform a database lookup.
50+
51+
### Workflow Example
52+
- **Scenario**: A user asks Solace, “Can you remember the advice you gave me about stress management?”
53+
- **Step 1**: The user input is processed by LangFlow’s memory workflow, first checking the **ConversationBufferMemory** for recent mentions of “stress management”.
54+
- **Step 2**: If not found in the session buffer, the **Memory Retrieval Node** queries **Milvus** for embeddings related to “stress management”.
55+
- **Step 3**: Retrieved conversations are then sent to the **Reflection Node**, which creates a reflective response, e.g., “Yes, I remember suggesting breathing exercises and daily journaling as ways to manage stress. Have you found these helpful?”
56+
57+
### Technical Considerations
58+
1. **Memory Consistency**: Ensure that **LangFlow’s session memory** is consistent with the long-term memory stored in Milvus and Neo4j. Implement periodic **synchronization** routines to prevent conflicts.
59+
2. **Error Handling**: Develop error handling mechanisms for scenarios like **missing embeddings** or **disconnected nodes** in LangFlow, ensuring the conversation doesn’t break if a particular memory retrieval fails.
60+
3. **Scalability**: Design the memory tool to **scale** effectively by adding capacity to Milvus as the number of conversations grows, and ensuring Neo4j can handle increasingly complex relationship graphs.
61+
4. **Data Privacy**: Store user data securely, ensuring that **emotional tags** and other sensitive information are handled with encryption and compliance to privacy standards.
62+
63+
### Summary
64+
The proposed **memory tool** will replicate the current capabilities of Solace’s memory, ensuring seamless recall, contextual relevance, and emotional continuity. By leveraging **LangFlow’s ConversationBufferMemory**, **Milvus**, and **Neo4j**, this memory tool will provide both short-term and long-term memory management, enabling Solace to deliver rich, context-aware, and empathetic responses. Integrating these components into LangFlow workflows ensures a smooth transition and future scalability, laying the foundation for even more sophisticated memory-driven interactions.
65+

0 commit comments

Comments
 (0)