Skip to content

Commit

Permalink
Code for AI integration for initial testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aiupbw3_amway authored and aiupbw3_amway committed Jun 17, 2024
1 parent 777ae4e commit 6a10f6e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 859 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

textarea {
width: 100%;
height: 100px;
height: 500px;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ export class QualityCheckComponent {
}

checkQuality() {
const prompt = 'Review blog with the following content';

const prompt = 'Review blog with the following content' + this.postData;
this.blogService.getBlogQuality(prompt).subscribe(
response => {
this.qualityResult = response;
Expand Down
5 changes: 2 additions & 3 deletions blogs-analyzer-ui/src/app/services/blog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { map, Observable } from 'rxjs';
providedIn: 'root'
})
export class BlogService {
private baseUrl = 'http://localhost:8080/api';
private baseUrl = 'http://localhost:8888/api';


constructor(private http: HttpClient) {
Expand Down Expand Up @@ -41,7 +41,6 @@ export class BlogService {

getBlogQuality(prompt: string): Observable<any> {
const url = `${this.baseUrl}/gemini/v1/review`;
const params = new HttpParams().set('prompt', prompt);
return this.http.get(url, { params, responseType: 'text' });
return this.http.post(url, prompt, { responseType: 'text' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import com.google.cloud.vertexai.generativeai.ChatSession;
import com.google.cloud.vertexai.generativeai.ResponseHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
Expand All @@ -19,10 +18,10 @@
public class GeminiController {
private final ChatSession chatSession;

@GetMapping("/v1/review")
public String fromBody(@RequestParam String prompt) throws IOException {
// GenerateContentResponse generateContentResponse = this.chatSession.sendMessage(prompt);
// return ResponseHandler.getText(generateContentResponse);
return String.valueOf(new ResponseEntity<>("Hello World!", HttpStatus.OK));
@PostMapping("/v1/review")
public String fromBodyPost(@RequestBody String prompt) throws IOException {
GenerateContentResponse generateContentResponse = this.chatSession.sendMessage(prompt);
return ResponseHandler.getText(generateContentResponse);
// return new ResponseEntity<>("Hello World!", HttpStatus.OK);
}
}
1 change: 1 addition & 0 deletions blogs-analyzer/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
spring.application.name=blogsAnalyzer
server.port=8888
Loading

0 comments on commit 6a10f6e

Please sign in to comment.