国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? Java java?? ?? GeminiAI? JAVA ??

GeminiAI? JAVA ??

Jan 09, 2025 am 06:45 AM

Java? ??????? GeminiAI? ??? ? ?? ??? ? ??? ??? ?? ???? ? ????. ???? Rest API?? Gemini? ??? ??? JSON? ???? ??? ?? ??? ???? ???????. ???

?? ??? ???? ???? ?

  • ?? 17
  • ????? 2024.1.1
  • ??? ??
  • GeminiAI ??? ?

?????

??? ??? ???? ??? ????? ???? POM? ?? ???? ?????

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.36</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.18.2</version>
</dependency>

??? ???? ?? Lombok, RestTemplate ? ObjectMapper? ??? ? ????.

??: ???? ??(??? ???)? ???? ?? ???? ??? ??

RestTemplate: GeminiAI API? http ??

ObjectMapper: Gemini API ??? JSON?? ??

?

???? ??

Java ?????? RestTemplate? ??? ?????. ?? ?? @Configuration ??? ?? ???? Bean? ???? ???? ?????.

@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.build();
    }
}

?

??? ???

GeminiAI? ???? ?? ??? ???? ??? ?????. ? ???? Gemini? ??? ?? ?? ??? ??? ???? ??? ????.

@Service
public class TalkService {
    private final RestTemplate restTemplate;
    private final ObjectMapper objectMapper;

    @Value("${gemini.ai.api.url}")
    private String geminiApiUrl;

    @Value("${gemini.ai.api.key}")
    private String geminiApiKey;

    public TalkService(RestTemplate restTemplate, ObjectMapper objectMapper) {
        this.restTemplate = restTemplate;
        this.objectMapper = objectMapper;
    }

    public String callGeminiAI(TalkRequest input) {
        String url = geminiApiUrl + geminiApiKey;

        GeminiRequest request = new GeminiRequest();
        GeminiRequest.Content content = new GeminiRequest.Content();
        GeminiRequest.Part part = new GeminiRequest.Part();

        part.setText(input.getChat());
        content.setParts(Collections.singletonList(part));
        request.setContents(Collections.singletonList(content));

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity<GeminiRequest> entity = new HttpEntity<>(request, headers);

        ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);

        try {
            GeminiResponse geminiAIResponse = objectMapper.readValue(response.getBody(), GeminiResponse.class);

            if (geminiAIResponse.getCandidates() != null && !geminiAIResponse.getCandidates().isEmpty()) {
                GeminiResponse.Candidate candidate = geminiAIResponse.getCandidates().get(0);
                if (candidate.getContent() != null && candidate.getContent().getParts() != null && !candidate.getContent().getParts().isEmpty()) {
                    return candidate.getContent().getParts().get(0).getText();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "Falha ao processar resposta da API";
    }
}

? ????? POJO? GeminiRequest ? GeminiResponse? ???? ???, ??? ?? ???? ?????

?????

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GeminiRequest {
    private List<Content> contents;

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Content {
        private List<Part> parts;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Part {
        private String text;
    }
}

GeminiResponse

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class GeminiResponse {
    private List<Candidate> candidates;
    private UsageMetadata usageMetadata;
    private String modelVersion;

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Candidate {
        private Content content;
        private String finishReason;
        private double avgLogprobs;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Content {
        private List<Part> parts;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Part {
        private String text;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class UsageMetadata {
        private int promptTokenCount;
        private int candidatesTokenCount;
        private int totalTokenCount;
    }
}

?

???? ??

?? Rest ??? ???? ???? ?? ???? ????? ??? ?????.

@RestController
@RequestMapping("v1")
public class TalkController {
    private final TalkService talkService;

    @Autowired
    public TalkController(final TalkService talkService) {
        this.talkService = talkService;
    }

    @PostMapping("/chat-gemini")
    public TalkResponse talk(@RequestBody TalkRequest talkRequest) {
        TalkResponse response = new TalkResponse();
        response.setResponse(talkService.callGeminiAI(talkRequest));
        return response;
    }
}

?? ?????? POJO? ????. ???? ?? ??? ?????

????

@Getter
@Setter
@AllArgsConstructor
public class TalkRequest {
    private String chat;
}

???

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class TalkResponse {
    private String response;
}

?

??? ?? ??

GeminiAI ??? ?????? ??? ?? ??? ???. ??? ??? ???? ?? ????? ???? ? ??? ?? ??? ??????. ??? ??? ??? ?? ??? ?????

spring.application.name=NOME_DA_SUA_APLICACAO

gemini.ai.api.url=https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=
gemini.ai.api.key=SUA_CHAVE_DE_ACESSO

?

??????????

GeminiAI? ?? ??? ??????? ?? Postman? ???? ??????? ???? ? ????. ?? ?? Intellij?? ??????? ???? ?? ???? ?? Postman?? ??? ??? ? ????.

Comunicando JAVA com o GeminiAI


?? ?
? ??? ??? Java ??????? GeminiAI? Java ??????? ???? ??? ??? ?? ???? ???? ??? ???? ??????. ????? ???, ??? ? ???! ?

? ??? GeminiAI? JAVA ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1783
16
Cakephp ????
1728
56
??? ????
1579
28
PHP ????
1444
31
???
?? ?? ?? ??? ??? ?? ?? ?? ??? ??? Jun 24, 2025 pm 09:41 PM

?? ?? ?? ??? ??? ?? ??? ??, ? ? ?? ? ??? ?????. 1. ??? ?? ???? ?? ???? ???-????, ? ??? ??? ??? ? ????, Hashmap? ???-??? ?? ??? ??? ???? ????. 2. NULL ? ?? ???? HashMap? ??? NULL ?? ?? ? ?? ???? ?? HashTable? NULL ?? ?? ???? ??? NullPointerException? ?????. 3. ????? ??? ????? ?? ??? ?? ?? ? ????? HashTable? ? ??? ?? ?? ??? ????. ?? ConcurrenTashMap? ???? ?? ????.

?? ???? ??? ??? ?????? ?? ???? ??? ??? ?????? Jun 28, 2025 am 01:01 AM

Java? ?? ??? ??? ?? ??? ??? ?? ??? ??? ?? ??? ?? ?? ??? ???? ??? ?? ???? ?????. 1. ??? ???? ??? ?? ?? ? ???? ?? ??? ???? ?? ?? ??? ? ????. 2. ???? ?? ??? ???? ??? ?? ???? ?? ?? ??? ???????. 3. ?? ???? ?? ?? ?? ? ???? ???? ?? NULL ?? ??? ? ????. 4. ?? ???? ??? ?? ?? ? ??? ?????? ?? ??? ??? ?? ?? ??? ????? ??? ??? ??? ??????? ?? ???? ??????.

?????? ?? ???? ?????? ?????? ?? ???? ?????? Jun 24, 2025 pm 10:57 PM

staticmethodsininterfaceswereIntRectionSelffacesswithinteffaceswithinteffaceswithintintinjava8toallowutilityFunctionswithinterfaceitswithinteffaceswithinterfaceffaces

JIT ????? ??? ??? ??????? JIT ????? ??? ??? ??????? Jun 24, 2025 pm 10:45 PM

JIT ????? ??? ???, ??? ?? ? ???, ?? ?? ? ???? ? ? ?? ?? ??? ? ?? ??? ?? ??? ??????. 1. ??? ???? ?? ?? ??? ??? ?? ?? ???? ??? ?? ?????. 2. ??? ?? ? ??? ?? ?? ? ??? ???? ?? ?? ???; 3. ?? ??? ??? ?? ??? ???? ???? ???? ? ?? ?? ??? ?????. 4. ?? ??? ?? ??? ??? ???? ???? ?? ? ??? ???? ?? ??? ?????.

???? ??? ??? ??? ?????? ???? ??? ??? ??? ?????? Jun 25, 2025 pm 12:21 PM

???? ??? ??? Java?? ??? ?? ???? ??? ?? ? ? ??? ??? ???? ? ?????. ?? ???? ??? ??, ??? ?? ??? ?? ?? ??? ??? ????? ???? ????? ?????. ?? ??? ??? ??, ????? ? ??? ????, ?? ??? ??? ?????? ? ?? ? ?? ?????.

??? '??'???? ?????? ??? '??'???? ?????? Jun 24, 2025 pm 07:29 PM

injava, thefinalkeywordpreventsavariable'svalue'svalueffrombeingchangedafterassignment, butitsbehaviordiffersforprimitivesandobjectreences.forprimitivevariables, asinfinalintmax_speed = 100; wherereassoncesanerror.forobjectref

?? ??? ?????? ?? ??? ?????? Jun 24, 2025 pm 11:29 PM

??? ??? ?? ?? ??? ????? ? ???? ????? ???? ?? ???? ?? ???? ?????. ?? ??? ??? ????. ?? ?? ?? ??? ???? ???? ?? ?? ??? ??? ?? ?? ??? ??? ?????. ?? ??? ??? ????. ?? ??? ?? ??? ?? ?? ??? ?? ?? ??? ???? NewClass ()? ??? ?? ???? ????. ?? ??? ?? ??? ???? ?? ??? ?? ? ? ??? ?? ?? ??? ????? ????? ?????. ?? ??, ?? ?????? ?????, ??? ? ?? ????? ??? ?? ?????. ???? ?? ?? ??? ???? ?? ???? ?? ? ??? ???? ?? ??? ?? ?????? ?????. ???? ???? ??? ??, ?? ?? ? ?? ??? ????, ?? ?? ???? ?????.

?? ????? ?????? ?? ????? ?????? Jun 24, 2025 pm 11:09 PM

??? ? ?? ??? ???? : ????? ?? ?. 1. int? ???? ???? ?? ?? ?? ? ??? ???? ?????. 2. ?? ? ???? (int) myDouble ??? ?? ?? ??? ?????. ?? ??? ??? ?? ??? ?? ??, ?? ?? ?? ???? ?? ??? ?? ???? ?? ?????. ???? ? ??? ??? ????. ?? ??? ??? ??? ??? ??? ?? ??? ??? ? ??? ?? ???? ??? ??? ??? ??? ? ??? ?? ??? ?? ??? ?? ?? ? ? ????. ?? ?? ??? ?? ??? ??? ??? ??? ? ??????.

See all articles