-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generative AI support for Spring Petclinic Microservices #281
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ target/ | |
|
||
# Branch switching | ||
generated/ | ||
|
||
**/.DS_Store | ||
**/creds.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.springframework.samples.petclinic.api.boundary.web; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class FallbackController { | ||
|
||
@RequestMapping("/fallback") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed |
||
public ResponseEntity<String> fallback() { | ||
return ResponseEntity.status(HttpStatus.SC_SERVICE_UNAVAILABLE) | ||
.body("Chat is currently unavailable. Please try again later."); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,16 @@ spring: | |
import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} | ||
cloud: | ||
gateway: | ||
default-filters: | ||
- name: CircuitBreaker | ||
args: | ||
name: defaultCircuitBreaker | ||
fallbackUri: forward:/fallback | ||
- name: Retry | ||
args: | ||
retries: 1 | ||
statuses: SERVICE_UNAVAILABLE | ||
methods: GET, POST | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like it, yes. |
||
routes: | ||
- id: vets-service | ||
uri: lb://vets-service | ||
|
@@ -24,8 +34,13 @@ spring: | |
- Path=/api/customer/** | ||
filters: | ||
- StripPrefix=2 | ||
|
||
|
||
- id: genai-service | ||
uri: lb://genai-service | ||
predicates: | ||
- Path=/api/genai/** | ||
filters: | ||
- StripPrefix=2 | ||
- CircuitBreaker=name=genaiCircuitBreaker,fallbackUri=/fallback | ||
|
||
--- | ||
spring: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: we need to offer a solution to developers who don't have an Azure or OpenAI account and don't want to pay for it: either enable fallback by default, or disable chat, or have a local solution with ollama. What do you think @odedia ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I began with using Llama 3.1, but the chat client became incredibly verbose and not as useful as OpenAI, that's why I switched to it.