Skip to content

Commit 4460319

Browse files
authored
Recipes/redisvl for java semantic caching and routing (#118)
* Adding recipes for RedisVL for Java: - Semantic Classification - Semantic Tool Calling - Semantic Guardrails - Pre generated Semantic Caching - Semantic Caching with LangCache
1 parent 386619c commit 4460319

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4391
-16
lines changed

.github/ignore-notebooks.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ spring_ai_redis_rag.ipynb
99
00_litellm_proxy_redis.ipynb
1010
04_redisvl_benchmarking_basics.ipynb
1111
06_hnsw_to_svs_vamana_migration.ipynb
12-
07_flat_to_svs_vamana_migration.ipynb
12+
07_flat_to_svs_vamana_migration.ipynb
13+
1_pre_generated_semantic_caching.ipynb
14+
2_semantic_caching_with_langcache.ipynb
15+
1_semantic_classification.ipynb
16+
2_semantic_tool_calling.ipynb
17+
3_semantic_guardrails.ipynb

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,16 @@ A set of Java recipes can be found under [/java-recipes](/java-recipes/README.md
162162

163163
#### Notebooks
164164

165-
| Notebook | Description |
166-
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
167-
| [notebooks/RAG/spring_ai_redis_rag.ipynb](./java-recipes/notebooks/RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-ba sed beer recommendation chatbot using Spring AI and Redis as the vector store |
165+
| Notebook | Description |
166+
|------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
167+
| [notebooks/RAG/spring_ai_redis_rag.ipynb](./java-recipes/notebooks/RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-ba sed beer recommendation chatbot using Spring AI and Redis as the vector store |
168+
| [RAG/spring_ai_redis_rag.ipynb](./RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-based beer recommendation chatbot using Spring AI and Redis as the vector store |
169+
| [semantic-routing/1_semantic_classification.ipynb](./semantic-routing/1_semantic_classification.ipynb) | Demonstrates how to perform text classification with vector search (RedisVL) instead of LLMs |
170+
| [semantic-routing/2_semantic_tool_calling.ipynb](./semantic-routing/2_semantic_tool_calling.ipynb) | Demonstrates how to perform tool selection with vector search (RedisVL) instead of LLMs |
171+
| [semantic-routing/3_semantic_guardrails.ipynb](./semantic-routing/3_semantic_guardrails.ipynb) | Demonstrates how to implement guardrails with vector search (RedisVL) |
172+
| [semantic-caching/1_pre_generated_semantic_caching.ipynb](./semantic-caching/1_pre_generated_semantic_caching.ipynb) | Demonstrates how to perform pre generated semantic caching with RedisVL |
173+
| [semantic-caching/2_semantic_caching_with_langcache.ipynb](./semantic-caching/2_semantic_caching_with_langcache.ipynb) | Demonstrates how to perform pre generated semantic caching with LangCache |
174+
168175

169176
#### Applications
170177

java-recipes/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ There are two types of Java Recipes: Notebooks and Applications. Notebooks are i
2626

2727
Notebooks require a Jupyter Notebook environment to run. Check out the [Setup Instructions & Implementation Details](./notebooks/README.md) for more details on how to set up your environment.
2828

29-
| Notebook | Description |
30-
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
31-
| [notebooks/RAG/spring_ai_redis_rag.ipynb](./notebooks/RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-ba sed beer recommendation chatbot using Spring AI and Redis as the vector store |
29+
| Notebook | Description |
30+
|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
31+
| [RAG/spring_ai_redis_rag.ipynb](./RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-based beer recommendation chatbot using Spring AI and Redis as the vector store |
32+
| [semantic-routing/1_semantic_classification.ipynb](./semantic-routing/1_semantic_classification.ipynb) | Demonstrates how to perform text classification with vector search (RedisVL) instead of LLMs |
33+
| [semantic-routing/2_semantic_tool_calling.ipynb](./semantic-routing/2_semantic_tool_calling.ipynb) | Demonstrates how to perform tool selection with vector search (RedisVL) instead of LLMs |
34+
| [semantic-routing/3_semantic_guardrails.ipynb](./semantic-routing/3_semantic_guardrails.ipynb) | Demonstrates how to implement guardrails with vector search (RedisVL) |
35+
| [semantic-caching/1_pre_generated_semantic_caching.ipynb](./semantic-caching/1_pre_generated_semantic_caching.ipynb) | Demonstrates how to perform pre generated semantic caching with RedisVL |
36+
| [semantic-caching/2_semantic_caching_with_langcache.ipynb](./semantic-caching/2_semantic_caching_with_langcache.ipynb) | Demonstrates how to perform pre generated semantic caching with LangCache |
3237

3338
## Applications
3439

java-recipes/notebooks/RAG/resources/beers.json.gz

Whitespace-only changes.

java-recipes/notebooks/RAG/spring_ai_redis_rag.ipynb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@
3030
},
3131
{
3232
"cell_type": "code",
33-
"execution_count": 1,
3433
"id": "f0483426-9a2a-4fc1-a184-9ba3343d2bf9",
35-
"metadata": {},
36-
"outputs": [],
34+
"metadata": {
35+
"jupyter": {
36+
"is_executing": true
37+
}
38+
},
3739
"source": [
3840
"%mavenRepo spring_milestones https://repo.spring.io/milestone/ \n",
3941
"%maven \"org.springframework.ai:spring-ai-openai:1.0.0-M6\"\n",
4042
"%maven \"org.springframework.ai:spring-ai-transformers:1.0.0-M6\"\n",
4143
"%maven \"org.springframework.ai:spring-ai-redis-store:1.0.0-M6\"\n",
4244
"%maven \"org.slf4j:slf4j-simple:2.0.17\" \n",
4345
"%maven \"redis.clients:jedis:5.2.0\""
44-
]
46+
],
47+
"outputs": [],
48+
"execution_count": null
4549
},
4650
{
4751
"cell_type": "markdown",
@@ -268,7 +272,7 @@
268272
"String[] KEYS = { \"name\", \"abv\", \"ibu\", \"description\" };\n",
269273
"\n",
270274
"// Data path\n",
271-
"String filePath = \"../resources/beers.json.gz\";\n",
275+
"String filePath = \"./resources/beers.json.gz\";\n",
272276
"\n",
273277
"// Check if embeddings are already loaded\n",
274278
"Map<String, Object> indexInfo = vectorStore.getJedis().ftInfo(\"beers\");\n",

java-recipes/notebooks/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
This project uses Docker Compose to set up a complete environment for running Java-based AI applications with Redis. The environment includes:
2626

27-
- A Jupyter Notebook server with Java kernel support
27+
- A Jupyter Notebook server with Java kernel support (For notebooks that based on Java)
2828
- Redis Stack (includes Redis and RedisInsight)
2929
- Pre-installed dependencies for AI/ML workloads
3030

@@ -79,9 +79,15 @@ OPENAI_API_KEY=your_openai_api_key_here
7979

8080
## Notebooks
8181

82-
| Notebook | Description |
83-
| --- | --- |
84-
| [RAG/spring_ai_redis_rag.ipynb](./RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-based beer recommendation chatbot using Spring AI and Redis as the vector store |
82+
| Notebook | Description |
83+
|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
84+
| [RAG/spring_ai_redis_rag.ipynb](./RAG/spring_ai_redis_rag.ipynb) | Demonstrates building a RAG-based beer recommendation chatbot using Spring AI and Redis as the vector store |
85+
| [semantic-routing/1_semantic_classification.ipynb](./semantic-routing/1_semantic_classification.ipynb) | Demonstrates how to perform text classification with vector search (RedisVL) instead of LLMs |
86+
| [semantic-routing/2_semantic_tool_calling.ipynb](./semantic-routing/2_semantic_tool_calling.ipynb) | Demonstrates how to perform tool selection with vector search (RedisVL) instead of LLMs |
87+
| [semantic-routing/3_semantic_guardrails.ipynb](./semantic-routing/3_semantic_guardrails.ipynb) | Demonstrates how to implement guardrails with vector search (RedisVL) |
88+
| [semantic-caching/1_pre_generated_semantic_caching.ipynb](./semantic-caching/1_pre_generated_semantic_caching.ipynb) | Demonstrates how to perform pre generated semantic caching with RedisVL |
89+
| [semantic-caching/2_semantic_caching_with_langcache.ipynb](./semantic-caching/2_semantic_caching_with_langcache.ipynb) | Demonstrates how to perform pre generated semantic caching with LangCache |
90+
8591

8692
## Project Structure
8793

-28 MB
Binary file not shown.

0 commit comments

Comments
 (0)