add base project

This commit is contained in:
Azmat-7860
2026-10-18 07:02:38 +05:30
commit 384751a225
817 changed files with 52220 additions and 0 deletions
@@ -0,0 +1,22 @@
package com.realnet.startCoder.Controller;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import com.realnet.startCoder.Services.StarCoderService;
@RestController
@RequestMapping("/codegen")
public class StarCoderController {
@Autowired
private StarCoderService starCoderService;
@PostMapping
public String generateCode(@RequestBody String prompt) {
return starCoderService.generateCode(prompt);
}
}
@@ -0,0 +1,27 @@
package com.realnet.startCoder.Services;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@Service
public class StarCoderService {
private static final String MODEL_API_URL = "http://localhost:8000";
public String generateCode(String prompt) {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
String requestBody = String.format("{\"inputs\": \"%s\"}", prompt);
HttpEntity<String> request = new HttpEntity<>(requestBody, headers);
ResponseEntity<String> response = restTemplate.exchange(MODEL_API_URL, HttpMethod.POST, request, String.class);
return response.getBody();
}
}