{"id":24259098,"url":"https://github.com/arafkarsh/ms-springboot-ai","last_synced_at":"2025-09-23T20:31:24.381Z","repository":{"id":233005356,"uuid":"785759293","full_name":"arafkarsh/ms-springboot-ai","owner":"arafkarsh","description":"Java 23, SpringBoot 3.4.1 Examples using Deep Learning 4 Java \u0026 LangChain4J for Generative AI using ChatGPT LLM, RAG and other open source LLMs. Sentiment Analysis, Application Context based ChatBots. Custom Data Handling. LLMs - GPT 3.5 / 4o, Gemini, Claude 3, Llama3, Phi-3, Gemma, Falcon 2, Mistral, Wizard Math","archived":false,"fork":false,"pushed_at":"2025-01-06T12:53:21.000Z","size":23311,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-06T13:47:11.343Z","etag":null,"topics":["chatgpt-api","chatgpt3","chatgpt4","claude-3","convolutional-neural-network","falcon","gemini","gemini-ai","gemma","gemma-7b","generative-ai","langchain","langchain4j","llama2","mistral-7b","multilayer-perceptron-network","ollama","rag","recurrent-neural-network","retrieval-augmented-generation"],"latest_commit_sha":null,"homepage":"https://www.arafkarsh.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arafkarsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-12T15:05:22.000Z","updated_at":"2025-01-06T12:53:25.000Z","dependencies_parsed_at":"2024-06-15T06:47:26.931Z","dependency_job_id":null,"html_url":"https://github.com/arafkarsh/ms-springboot-ai","commit_stats":null,"previous_names":["arafkarsh/ms-springboot-324-ai","arafkarsh/ms-springboot-ai"],"tags_count":0,"template":true,"template_full_name":"arafkarsh/ms-springboot-324-java-22-jakarta-ee-10","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arafkarsh%2Fms-springboot-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arafkarsh%2Fms-springboot-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arafkarsh%2Fms-springboot-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arafkarsh%2Fms-springboot-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arafkarsh","download_url":"https://codeload.github.com/arafkarsh/ms-springboot-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233996273,"owners_count":18763211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt-api","chatgpt3","chatgpt4","claude-3","convolutional-neural-network","falcon","gemini","gemini-ai","gemma","gemma-7b","generative-ai","langchain","langchain4j","llama2","mistral-7b","multilayer-perceptron-network","ollama","rag","recurrent-neural-network","retrieval-augmented-generation"],"created_at":"2025-01-15T05:53:20.250Z","updated_at":"2025-09-23T20:31:17.707Z","avatar_url":"https://github.com/arafkarsh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI/ML \u0026 Gen Ai -  Langchain4J \u0026 Deep Learning 4J\n## Java 23, Springboot 3.4.1 Examples\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-springboot-324-ai\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-springboot-324-ai)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-springboot-324-ai\u0026metric=bugs)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-springboot-324-ai)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-springboot-324-ai\u0026metric=code_smells)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-springboot-324-ai)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=arafkarsh_ms-springboot-324-ai\u0026metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=arafkarsh_ms-springboot-324-ai)\n\n- Java 23\n- SpringBoot 3.4.1\n- LangChain4J 0.36.0\n- Deep Learning 4J 1.0.0-M2.1\n\nGenerative AI refers to a subset of artificial intelligence that can generate new content based \non input data. This encompasses models that can create text, images, music, and even videos. \nExamples of generative AI include language models like OpenAI's GPT-3 and DALL-E, which can \ngenerate human-like text and images from textual descriptions, respectively.\n\nGenerative AI models are typically trained on vast datasets and use deep learning techniques to \nlearn patterns and structures in the data. They have a wide range of applications, including:\n\n- Natural Language Processing (NLP): Generating human-like text for chatbots, translations, and content creation.\n- Creative Arts: Creating artwork, music, and design elements.\n- Data Augmentation: Generating additional data for training other machine learning models.\n- Healthcare: Assisting in medical imaging and creating personalized treatment plans.\n\n## How LangChain4J Gen AI API Helps Developers Build Spring Boot AI Apps\n\nLangChain4J is a Java library designed to simplify the integration of large language models \n(LLMs) and AI capabilities into Java applications, including those built with Spring Boot. \nHere’s how it helps developers:\n\n- Unified API for LLMs: LangChain4J provides a unified API that supports multiple LLM providers like OpenAI and Google Vertex AI. This abstraction allows developers to switch between different LLMs without changing their codebase significantly.\n- Embedding Store Integration: It integrates with various embedding stores, enabling efficient handling of vectorized data. This is particularly useful for retrieval-augmented generation (RAG) tasks, where relevant information is fetched from a knowledge base to enhance AI responses.\n- Toolbox of Features: The library includes a comprehensive set of tools for prompt templating, memory management, and output parsing. These tools help in building complex AI applications by providing high-level abstractions and ready-to-use components.\n- Spring Boot Integration: LangChain4J supports Spring Boot, making it easier for developers to create robust and scalable AI applications. The integration allows seamless incorporation of AI services into Spring Boot applications, leveraging Spring's dependency injection and configuration management features.\n- Examples and Documentation: LangChain4J offers extensive documentation and examples, guiding developers through various use cases and demonstrating how to implement AI-powered functionalities in their applications.\n\n## Case Study: Health Care App - Gen Ai Enabled Diagnosis Microservices\n\n![Ai RAG-0](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/diagrams/Ai-Case-Study-Architecture.jpg)\n\n## Setup Database Password Encryption\n\nThis ai-service template offers a range of built-in functionalities. To simplify the demonstration of\nvarious features, an encrypted password is utilized for connecting to H2 and PostgreSQL databases.\nThe template includes utilities for encrypting and decrypting passwords, ensuring that the encryption\nkey is securely stored outside the application’s runtime context.\n\nEncrypted H2 (In Memory) Database Password. Uses H2 database in Dev (Profile) mode.\n![Package Structure](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/encrypt/Security-H2-psd.jpg)\nEncrypted PostgreSQL Database Password. Uses PostgreSQL DB in Staging \u0026 Prod (profile) mode.\n![Package Structure](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/encrypt/Security-PostgreSQL-psd.jpg)\nPassword can be decrypted only using an Encryption Key stored in System Enviornment variable\n![Package Structure](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/encrypt/Security-Encryption-pro.jpg)\nIf the Quality Gate check fails, it's because the password is encrypted within the application’s\nproperties file, with the encryption key stored externally, outside the application’s context.\n\nHowever, quality standards mandate that passwords should be securely stored in a vault, such as\nHashiCorp Vault, for enhanced security. To know more about how to setup these passwords (for H2 \n\u0026 PostgreSQL) and environment variables checkout Session 1.2\n\n### AI-Service Package Structure\n\n![Package Structure](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/MS-Pkg-Structure.jpg)\n\nio.fusion.air.microservice\n1. adapters (All the Implementations from App/Service perspective)\n2. ai (All AI Code Examples. ML, Gen AI Examples)\n3. domain (All Entities, Models, Interfaces for the implementations)\n4. security (All Security related modules)\n5. server (Managing the Service - from a server perspective, Setups (DB, Configs)\n6. utils (Standard Utilities)\n\n# Gen AI Examples\n\n## Gen AI Examples: Comparison of 8 LLMs (3 Cloud based \u0026 5 Local) on Enterprise Features\n\nFollowing comparison is based on the features available in LangChain4J API (which supported by OpenAI ChatGPT). These features are essential for Gen AI based Enterprise App Development.\n\n\n| #   | Example             | GPT 4o             | Meta Llama3     | Mistral          | Microsoft Phi-3  | Google Gemma     | TII Falcon 2    | Claude 3       | Gemini 1.5     |\n|-----|---------------------|--------------------|-----------------|------------------|------------------|------------------|-----------------|----------------|----------------|\n| 1.  | Hello World         | :green_circle:     | :green_circle:  | :green_circle:   | :green_circle:   | :green_circle:   | :green_circle:  | :green_circle: | :green_circle: |\n| 2.  | Complex World       | :green_circle:     | :green_circle:  | :red_circle: M1  | :green_circle:   | :green_circle:   | :green_circle:  | :green_circle: | :green_circle: |\n| 3.  | Custom Data         | :green_circle:     | :green_circle:  | :green_circle:   | :green_circle:   | :green_circle:   | :red_circle: F1 | :green_circle: | :green_circle: |\n| 4.  | Image Generation    | :green_circle:     | :red_circle: L1 | :red_circle: M2  | :red_circle: P1  | :orange_circle:  | :red_circle: F2 | :yellow_circle:| :yellow_circle:|\n| 5.  | Prompt Template     | :green_circle:     | :green_circle:  | :red_circle: M3  | :green_circle:   | :green_circle:   | :green_circle:  | :green_circle: | :green_circle: |\n| 6.  | Tools               | :green_circle:     | :red_circle: L2 | :red_circle: M4  | :red_circle: P2  | :red_circle: G1  | :red_circle: F3 | :green_circle: | :red_circle: G1|\n| 7.  | Chat Memory         | :green_circle:     | :green_circle:  | :green_circle:   | :red_circle: P3  | :red_circle: G2  | :green_circle:  | :green_circle: | :red_circle: G2|\n| 8.  | FewShot             | :green_circle:     | :green_circle:  | :red_circle: M5  | :green_circle:   | :green_circle:   | :green_circle:  | :green_circle: | :red_circle: G3|\n| 9.  | Language Translator | :green_circle:     | :green_circle:  | :red_circle: M6  | :green_circle:   | :green_circle:   | :green_circle:  | :green_circle: | :green_circle: |\n| 10. | Sentiment Analyzer  | :green_circle:     | :green_circle:  | :green_circle:   | :green_circle:   | :green_circle:   | :green_circle:  | :green_circle: | :green_circle: |\n| 11. | Data Extractor      | :orange_circle: O1 | :red_circle: L3 | :red_circle: M7  | :red_circle: P4  | :red_circle: G3  | :red_circle: F4 | :green_circle: | :red_circle: G4|\n| 12. | Persistent Store    | :green_circle:     | :green_circle:  | :red_circle: M8  | :red_circle: P5  | :red_circle: G4  | :green_circle:  | :green_circle: | :green_circle: |\n\n## Retrieval Augmented Generation (RAG) Examples of 8 LLMs\n\n\n| #   | Example                     | GPT 4o         | Meta Llama3     | Mistral         | Microsoft Phi-3 | Google Gemma    | TII Falcon 2    | Claude 3       | Gemini 1.5     |\n|-----|-----------------------------|----------------|-----------------|-----------------|-----------------|-----------------|-----------------|----------------|----------------|\n| 51. | Simple                      | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle: | :green_circle: |\n| 52. | Segments                    | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :orange_circle: | :green_circle: | :green_circle: |\n| 53. | Query Transformer           | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle: | :green_circle: |\n| 54. | Query Router                | :green_circle: | :red_circle: L4 | :red_circle: M9 | :red_circle: P6 | :red_circle: G4 | :red_circle: F5 | :green_circle: | :red_circle: G5|\n| 55. | Re-Ranking                  | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :orange_circle: | :green_circle: | :green_circle: |\n| 56. | MetaData                    | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :orange_circle: | :green_circle: | :green_circle: |\n| 57. | Multiple Content Retrievers | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :orange_circle: | :green_circle: | :green_circle: |\n| 58. | Skipping Content Retrieval  | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle: | :green_circle: |\n| 59. | Health Care App             | :green_circle: | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle:  | :green_circle: | :green_circle: |\n\n## Top LLM Rankings based on Enterprise Features\n\n| # | Rank | Company     | LLM                   | Score | Category |\n|---|------|-------------|-----------------------|-------|----------|\n| 1 |  1   | Anthropic   | Claude 3 Haiku        | 21/21 | Cloud    |\n| 2 |  2   | Open AI     | Chat GPT 4o           | 20/21 | Cloud    |\n| 3 |  3   | Meta        | Llama 3               | 17/21 | Local    |\n| 4 |  4   | TII         | Falcon 2              | 16/21 | Local    |\n| 5 |  4   | Google      | Gemini 1.5 Pro        | 16/21 | Cloud    |\n| 6 |  4   | Google      | Gemma                 | 16/21 | Local    |\n| 7 |  5   | Microsoft   | PHI 3                 | 15/21 | Local    |\n| 8 |  6   | Mistral     | Mistral               | 12/21 | Local    |\n\nNote: Cloud-based LLMs will have more than 500 billion parameter support while the local LLMs are mostly based on 8 Billion parameters.\n\nCheckout more details on \u003ca href=\"https://github.com/arafkarsh/ms-springboot-324-ai/blob/main/LLM_Testing.md\"\u003eTesting Scores\u003c/a\u003e\n\n## Install Local LLMs\n\nTo Install the Local LLMs using Ollama \n1. Meta Llama3\n2. Google Gemma\n3. Microsoft PHI-3\n4. TII Falcon 2\n5. Mistral\n6. Wizard Math\n\nCheck out the \u003ca href=\"https://github.com/arafkarsh/ms-springboot-324-ai/blob/main/llms/README_LOCAL_LLMS.md\"\u003einstallation guide.\u003c/a\u003e\n\n## Get the Keys for Testing Cloud LLMs\n\n### Register to get the API Keys \n\n1. Open AI - ChatGPT (API Key can be created here: https://platform.openai.com/api-keys)\n2. Anthropic - Claude 3 (API key can be created here: https://console.anthropic.com/settings/keys)\n3. Google Cloud - (https://console.cloud.google.com/ - Check AiConstants.java for Instructions) \n4. Cohere - (API key here:  https://dashboard.cohere.com/welcome/register)\n5. HuggingFace - (API key here: https://huggingface.co/settings/tokens)\n6. Rapid - (API key here: https://rapidapi.com/judge0-official/api/judge0-ce)\n\n### Set these Keys in your environment\n```\n    // API Keys -----------------------------------------------------------------------\n    // OpenAI API key here: https://platform.openai.com/account/api-keys\n    public static final String OPENAI_API_KEY = System.getenv(\"OPENAI_API_KEY\");\n    \n    // Cohere API key here: // https://dashboard.cohere.com/welcome/register\n    public static final String COHERE_API_KEY = System.getenv(\"COHERE_API_KEY\");\n    \n    // Anthropic API key here:: https://console.anthropic.com/settings/keys\n    public static final String ANTHROPIC_API_KEY = System.getenv(\"ANTHROPIC_API_KEY\");\n    \n    // HuggingFace API key here: https://huggingface.co/settings/tokens\n    public static final String HF_API_KEY = System.getenv(\"HF_API_KEY\");\n    \n    // Judge0 RapidAPI key here: https://rapidapi.com/judge0-official/api/judge0-ce\n    public static final String RAPID_API_KEY = System.getenv(\"RAPID_API_KEY\");\n```\n\n## Gen AI - Code Package Structure \n\n### Package io.fusion.air.microservice.ai.genai \n\n1. controllers (Rest Endpoints for testing the examples)\n2. core\n   1. assistants (Based on LangChain4J AiService)\n   2. models (Data Models used in the code)\n   3. prompts (Structured Prompts to have specific outputs)\n   4. services (LLM Specific Business Logic re-used across all the examples. )\n   5. tools (Functions getting invoked based on LLM search)\n3. examples (Claude 3, Falcon 2, GPT 4o, Gemini, Gemma, Llama3,  Mistral, Phi-3, Wizard Math)\n4. utils (Generic Code to create ChatLanguageModels and Configurations, API Keys and Console Runner)\n\n### Code Structure\n\n![Ai-Code](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/diagrams/Ai-Code-Base.jpg)\n\n## Quick Test after starting the SpringBoot App\n![Ai Prompt](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Prompt.jpg)\n\n## Sentiment Analysis using ChatGPT 4o\n\n![Ai Sentiment](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Ex-Sentiment-2.jpg)\n\n## Content Moderation using ChatGPT 4o\n\n![Ai-Content](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Ex-Content-Moderation.jpg)\n\n## ChatBot using RAG (Custom Data) - Case Study: Car Rental Service\n\n### RAG Architecture\n\nRetrieval-Augmented Generation (RAG) enhances the output of large language models (LLMs) by \nincorporating authoritative external knowledge bases. While LLMs are trained on vast datasets \nand utilize billions of parameters to generate responses for tasks like question answering, language \ntranslation, and text completion, RAG optimizes these outputs by referencing specific, up-to-date\ninformation sources beyond the model's training data. This process significantly extends the capabilities \nof LLMs to cater to specialized domains or an organization's internal knowledge without necessitating \nmodel retraining. Consequently, RAG provides a cost-effective solution to ensure that the generated \ncontent remains relevant, accurate, and contextually appropriate.\n\n#### Large Language Models (LLMs) face several challenges:\n\n- They may provide false information when they lack the correct answer.\n- They can deliver outdated or generic information when specific, current responses are expected by the user.\n- They might generate responses based on non-authoritative sources.\n- They can produce inaccurate responses due to terminology confusion, where different training sources use the same terms to describe different concepts.\n\nRetrieval-Augmented Generation (RAG) addresses several challenges associated with LLMs by \ndirecting the model to fetch relevant information from authoritative, pre-determined knowledge \nsources. This approach allows organizations to exert more control over the content generated by \nthe model, ensuring accuracy and relevance. Additionally, it provides users with clearer insights \ninto the sources and processes the LLM uses to formulate its responses.\n\n![Ai RAG-1](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/diagrams/Ai-Case-Study-Architecture.jpg)\n\n### Conversation using LLM with (Custom Data) Car Rental Service Agreement\n\n![Ai ChatBot-1](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Ex-RAG-OZO-1.jpg)\n![Ai ChatBot-2](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Ex-RAG-OZO-2.jpg)\n![Ai ChatBot-3](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Ex-RAG-OZO-3.jpg)\n\n## Data Extractions using ChatGPT 4o\n\n![Ai Sentiment](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/ai/Ai-Ex-DataExtractor.jpg)\n\n## LangChain4J operates on two levels of abstraction:\n\n- Low level. At this level, you have the most freedom and access to all the low-level components such as ChatLanguageModel, UserMessage, AiMessage, EmbeddingStore, Embedding, etc. These are the \"primitives\" of your LLM-powered application. You have complete control over how to combine them, but you will need to write more glue code.\n- High level. At this level, you interact with LLMs using high-level APIs like AiServices and Chains, which hides all the complexity and boilerplate from you. You still have the flexibility to adjust and fine-tune the behavior, but it is done in a declarative manner.\n\n![LangChain4J](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/langchain4j-components.png)\nRead more... \u003ca href=\"https://docs.langchain4j.dev/intro\"\u003eLangChain4J Introduction\u003c/a\u003e\n\n# Package Structure\n\n![Package Structure](https://raw.githubusercontent.com/arafkarsh/ms-springboot-324-ai/main/diagrams/MS-Pkg-Structure.jpg)\n\n### Pre-Requisites\n\n1. Java 23\n2. SpringBoot 3.4.1\n3. LangChain4J 0.30.0\n4. Jakarta EE 10 (jakarta.servlet.*, jakarta.persistence.*, javax.validation.*)\n\n## 1. Setting up the Template\n\n### Step 1.1 - Getting Started\n\n1. git clone [https://github.com/arafkarsh/ms-springboot-324-ai.git](https://github.com/arafkarsh/ms-springboot-324-ai.git)\n2. cd ms-springboot-324-ai\n\n###  Step 1.2 - Setup Encrypted DB Password in Property files\n\n#### 1.2.1 Encrypt the Database passwords for H2 and PostgreSQL\n\nIf you dont encrypt the password with your Encryption Key it will throw an exception saying unable to decrypt the password.\nHere are the steps to encrypt the password.\n\nRun the follwing command line option\n```\n$ source encrypt your-db-password your-encrypton-key\n```\n![Passowrd-Gen](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/Password-Gen.jpg)\n\nYour encryption key will be set in the following Environment variable. SpringBoot Will automatically\npickup the encryption key from this environment variable.\n```\nJASYPT_ENCRYPTOR_PASSWORD=your-encrypton-key\n```\n\n#### 1.2.2 Update the Database passwords for H2 and PostgreSQL in the Property files\n\nUpdate the property file in the local file\n```\nspring.datasource.password=ENC(kkthRIyJ7ogLJP8PThfXjqko33snTUa9lY1GkyFpzr7KFRVhRVXLOMwNSIzr4EjFGAOWLhWTH5cAWzRzAfs33g==)\n```\nAND\n- the property template in src/main/resources/app.props.tmpl\n- dev src/main/resources/application-dev.properties\n```\nspring.datasource.password=ENC(kkthRIyJ7ogLJP8PThfXjqko33snTUa9lY1GkyFpzr7KFRVhRVXLOMwNSIzr4EjFGAOWLhWTH5cAWzRzAfs33g==)\n```\nAND\nthe property files for\n- staging src/main/resources/application-staging.properties\n- prod src/main/resources/application-prod.properties\n```\nspring.datasource.password=ENC(/J0gRHIdlhBHFwpNo3a+1q3+8Uig5+uSNQHO/lCGOrfg/e8Wt2o3v1eC4TaquaDVGREOEFphpw1B84lOtxgeIA==)\n```\n#### 1.2.3 - Generating the Encrypted Text from REST Endpoint\n\nYou can use the following REST Endpoint to encrypt the sensitive data. This will work only after setting\nthe environment variable JASYPT_ENCRYPTOR_PASSWORD and creating the first DB password\nusing the command line options.\n\n![Passowrd-Van](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/ms-vanilla-encrypt.jpg)\n\n###  Step 1.3 - Compile (Once your code is ready)\n\n#### 1.3.1 Compile the Code\nExecute the \"compile\" from ms-springboot-334-vanilla\n1. compile OR ./compile (Runs in Linux and Mac OS)\n2. mvn clean; mvn -e package; (All Platforms)\n3. Use the IDE Compile options\n\n#### 1.3.2 What the \"Compile\" Script will do\n\n1. Clean up the target folder\n2. Generate the build no. and build date (takes application.properties backup)\n3. build final output SpringBoot fat jar and maven thin jar\n4. copy the jar files (and dependencies) to src/docker folder\n5. copy the application.properties file to current folder and src/docker folder\n\nIn Step 1.3.2 application.properties file will be auto generated by the \"compile\" script. This is a critical step.\nWithout generated application.properties file the service will NOT be running. There is pre-built application properties file.\nFollowing three property files are critical (to be used with Spring Profiles)\n\n1. application.properties\n2. application-dev.properties\n3. application-staging.properties\n4. application-prod.properties\n\n### Step 1.4 - Run the Application\n\n#### 1.4.1 - Spring Profiles\n\n1. dev (Development Mode)\n2. staging (Staging Mode)\n3. prod (Production Mode)\n\n#### 1.4.2 - Start the Service\n1. Linux or Mac OS - Profiles (dev, staging, or prod)\n```aiignore\nrun \n```\n```aiignore\nrun dev \n```\n```aiignore\nrun staging \n```\n```aiignore\nrun prod \n```\n\n2. All Platforms - Profiles (dev, staging, or prod)\n```aiignore\n mvn spring-boot:run -Dspring-boot.run.profiles=dev\n```\n```aiignore\n mvn spring-boot:run -Dspring-boot.run.profiles=staging\n```\n```aiignore\n mvn spring-boot:run -Dspring-boot.run.profiles=prod\n```\n\n3. Microsoft Windows - Profiles (dev, staging, or prod)\n```aiignore\njava -jar target/ai-service-*-spring-boot.jar --spring.profiles.active=dev  -Djava.security.manager=java.lang.SecurityManager -Djava.security.policy=./vanilla.policy\n```\n```aiignore\njava -jar target/ai-service-*-spring-boot.jar --spring.profiles.active=staging  -Djava.security.manager=java.lang.SecurityManager -Djava.security.policy=./vanilla.policy\n```\n```aiignore\njava -jar target/ai-service-*-spring-boot.jar --spring.profiles.active=prod  -Djava.security.manager=java.lang.SecurityManager -Djava.security.policy=./vanilla.policy\n```\n\n#### 1.4.3 - Test the Service\n1. test OR ./test (Runs in Linux or Mac OS)\n2. Execute the curl commands directly (from the test script)\n\n#### 1.4.4 - Running through IDE\nCheck the application.properties (in the project root directory) to change the profile Ex. spring.profiles.default=dev\n\n#### 1.4.5 - $ run prod (Result)\n![Run Results](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/MS-Run-Result.jpg)\n\n\n#### 1.4.6 - MS Cache Swagger UI Docs for Testing\n![Swagger Docs](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/MS-Vanilla-Swagger-UI.jpg)\n\n### Step 1.5 - Testing the APIs Using Swagger API Docs or Postman\n\nTo test the APIs (in secure mode - you will see a lock icon in the Swagger Docs). These test tokens are generated\nbased on the flag server.token.test=true in the application.properties file. (Change the app.props.tmpl if you want to\nchange in the build process.) In the Production environment, this flag should be false. These tokens can be generated only in\nan Auth Service. All the services need not generate these tokens unless for the developers to test it out.\nIn a real world scenario, disable (Comment out the function generateTestToken() from the code  java file\nServiceEventListener.java in the package documentation io.fusion.air.microservice.server.service)  this feature for\nproduction environment.\n\n#### Step 1.5.1: Copy the Auth Token\n![Authorize Request](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/ms-vanilla-with-Test-Tokens.jpg)\n\n#### Step 1.5.2: Click on the Authorize Button (Top Left the Swagger UI)\n\n![Authorize Request](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/ms-vanilla-with-Test-Tokens-2.jpg)\n\n#### Step 1.5.3: Enter the Token and Click Authorize\n\n![Authorize Request](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/ms-vanilla-with-Test-Tokens-3.jpg)\n\n#### Step 1.5.4: Enter the Refresh Token \u0026 Tx Token with every request that needs authorization\n\n![Authorize Request](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/ms-vanilla-with-Test-Tokens-4.jpg)\n\n### Step 1.6 -  Import Swagger API Docs Into Postman\n\nWhat is Postman?\n- Postman is an API platform for building and using APIs. Postman simplifies each step of the API\n  lifecycle and streamlines collaboration so you can create better APIs—faster.\n- Download Postman for Windows, Mac \u0026 Linux. https://www.postman.com/\n\n#### Step 1.6.1: Swagger Open API 3.0 Docs JSON Format\n![Swagger JSON](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/Import-API-into-Postman-0.jpg)\n\n#### Step 1.6.2: Import Into Postman - Set the Link\n![Postman Import](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/Import-API-Into-Postman-1.jpg)\n\n#### Step 1.6.3: Import Into Postman - Confirm\n![Postman Import](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/Import-API-into-Postman-2.jpg)\n![Postman Import](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/Import-API-into-Postman-3.jpg)\n\n#### Step 1.6.4: Test the API\n![Postman Import](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/Import-API-into-Postman-4.jpg)\n\n### Step 1.7 - JWT Token Validation example\n\n####  1.7.1 Public API (Without Token Validation) - ...adapters.controllers.open.*\n![No-Authorizet](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/JWT-Public.jpg)\n\n#### 1.7.2 Secure API with a Single Token (Primarily to be used by ADMIN)\n![Authorizet-Single](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/JWT-Single.jpg)\n\n#### 1.7.3 Secure API with an Additional Tx Token which contains App Specific Claims.\n![Authorize-Tx](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/JWT-Tx.jpg)\n\n#### 1.7.4 All the APIs under the Secure Package (under ...adapters.controllers.secured.*)\n![Secured-Pkg](https://raw.githubusercontent.com/arafkarsh/ms-springboot-334-vanilla/master/diagrams/JWT-Secured-Pkg.jpg)\n\n# LangChain 4 J\n\n## Chat Models\n\n- OpenAI (Examples available)\n- Ollama - run AI models on your local machine (Examples available)\n- Azure Open AI\n- Amazon Bedrock\n    - Cohere's Command\n    - AI21 Labs' Jurassic-2\n    - Meta's LLama 2\n    - Amazon's Titan\n- Google Vertex AI Palm\n- Google Gemini\n- HuggingFace - access thousands of models, including those from Meta such as Llama2\n- MistralAI\n\n## Text-to-image Models\n\n- OpenAI with DALL-E (Examples available)\n- StabilityAI\n\n## Transcription (audio to text) Models\n\n- OpenAI\n\n## Embedding Models\n\n- OpenAI\n- Ollama\n- Azure OpenAI\n- ONNX\n- PostgresML\n- Bedrock Cohere\n- Bedrock Titan\n- Google VertexAI\n- Mistal AI\n\nThe Vector Store API provides portability across different providers, featuring a novel SQL-like metadata filtering API that maintains portability.\n\n## Vector Databases\n\n- Azure Vector Search\n- Chroma\n- Milvus\n- Neo4j\n- PostgreSQL/PGVector\n- PineCone\n- Redis\n- Weaviate\n- Qdrant\n\n## Models supported are\n\n- OpenAI\n- Azure OpenAI\n- VertexAI\n- Mistral AI\n\n## Checkout the CRUD Operation Examples \n\n1. Setting up Postman with REST Endpoints for Testing\n2. CRUD Examples\n3. JWT Token Examples\n\nCheck the \u003ca href=\"https://github.com/arafkarsh/ms-springboot-324-ai/blob/main/CRUD_Examples.md\"\u003eCRUD_Examples\u003c/a\u003e.md\u003c/a\u003e\n\n(C) Copyright 2024-25 : Apache 2 License : Author: Araf Karsh Hamid\n\n\u003cpre\u003e\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *   http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farafkarsh%2Fms-springboot-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farafkarsh%2Fms-springboot-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farafkarsh%2Fms-springboot-ai/lists"}