Skip to content

Commit

Permalink
feat : create chatbot using openai and springai (#59)
Browse files Browse the repository at this point in the history
* feat : create chatbot using openai and springai

* feat : change permission

* fix : issue with file name

* fix : merge conflicts issue

* feat : clean dead code

* feat : fix compilation issue

* feat : using milvus vector store
  • Loading branch information
rajadilipkolli authored Jun 13, 2024
1 parent 1f45d8d commit 33b1f57
Show file tree
Hide file tree
Showing 21 changed files with 1,016 additions and 4 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/chatbot-openai-springai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: chatbot-openai-springai CI Build

on:
push:
paths:
- "chatbot/chatbot-openai-springai/**"
branches: [main]
pull_request:
paths:
- "chatbot/chatbot-openai-springai/**"
types:
- opened
- synchronize
- reopened

jobs:
build:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: chatbot/chatbot-openai-springai
strategy:
matrix:
distribution: [ 'temurin' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK ${{ matrix.java }}
uses: actions/[email protected]
with:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
cache: 'maven'
- name: Build and analyze
run: ./mvnw clean verify
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import com.example.chatbot.model.request.AIChatRequest;
import com.example.chatbot.model.response.AIChatResponse;
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.DatabindException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
Expand Down Expand Up @@ -38,7 +36,7 @@ void setUp() {
}

@Test
void chat() throws StreamReadException, DatabindException, IOException {
void chat() throws IOException {

Response response = given().contentType(ContentType.JSON)
.body(new AIChatRequest(
Expand Down
33 changes: 33 additions & 0 deletions chatbot/chatbot-openai-springai/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.1
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip
48 changes: 48 additions & 0 deletions chatbot/chatbot-openai-springai/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# chatbot-openapi-springai


## Sequence Diagram

Before Vector Store

```mermaid
sequenceDiagram
participant User
participant ChatbotController
participant ChatbotService
participant ChatModel
participant ChatMemory
User->>ChatbotController: POST /api/ai/chat
ChatbotController->>ChatbotService: chat(message)
ChatbotService->>ChatModel: generateResponse(message)
ChatModel-->>ChatbotService: response
ChatbotService->>ChatMemory: saveInteraction(message, response)
ChatbotService-->>ChatbotController: response
ChatbotController-->>User: response
```

After Vector Store

```mermaid
sequenceDiagram
participant User
participant ChatbotController
participant ChatbotService
participant ChatService
participant ChatMemory
participant VectorStore
User->>ChatbotController: POST /api/ai/chat
ChatbotController->>ChatbotService: chat(message)
ChatbotService->>ChatService: Process Chat Request
ChatService->>ChatMemory: Retrieve Memory
ChatService->>VectorStore: Retrieve Vectors
ChatMemory-->>ChatService: Return Memory Data
VectorStore-->>ChatService: Return Vector Data
ChatService-->>ChatbotService: Processed Response
ChatbotService-->>ChatbotController: response
ChatbotController-->>User: response
```
Loading

0 comments on commit 33b1f57

Please sign in to comment.