Skip to content

The synchronous interaction library with YandexGPT for Spring Boot apps

License

Notifications You must be signed in to change notification settings

cheernota/yandexgpt-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yandexgpt-client

This library is written in Java 17 and provides a synchronous Java client for Yandex GPT completion API.

1.1 Prerequisites

Created an authorization api-key and folder ID for Yandex Cloud, official doc or here.

1.2 Configuration and Spring Boot dependency

You can leverage the yandexgpt-client library, for this clone the GitHub repository

git clone https://github.com/cheernota/yandexgpt-client

build the library:

mvn clean install

and add it as a dependency to your pom.xml:

<dependency>
    <groupId>com.cheernota</groupId>
    <artifactId>yandexgpt-client</artifactId>
    <version>1.0.0</version>
</dependency>

or build.gradle

implementation 'com.cheernota:yandexgpt-client:1.0.0'

Then add API-key and folder-ID to your application properties file

spring.ai.yandexgpt.folder-id=j39shh ...
spring.ai.yandexgpt.api-key=jkSS82kHH ...

1.3 Use case

After configuring you can autowire bean YandexGptChatClient and use its methods in your project like this:

private final YandexGptChatClient chatClient;

    @Autowired
    public GptService(YandexGptChatClient chatClient) {
        this.chatClient = chatClient;
    }
    
    public String askSimplePrompt() {
        String prompt = "Привет, расскажи насколько суров климат Сибири.";
        return chatClient.generateByPrompt(prompt);
    }

1.4 Other properties

Property Description Default
spring.ai.yandexgpt.base-url Base url. https://llm.api.cloud.yandex.net/foundationModels/v1
spring.ai.yandexgpt.enable-logging Special header for managing the logging of your request data. false

You can also configure the LLM request parameters manually, read the javadoc to the ChatCompletionRequest.

About

The synchronous interaction library with YandexGPT for Spring Boot apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages