Skip to content

Commit

Permalink
feat: add github client
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Jul 7, 2024
1 parent a6033b1 commit 2e020eb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,28 @@
*/
package ch.xxx.aidoclibchat.adapter.client;

import java.util.List;
import java.util.Arrays;

import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient;

import ch.xxx.aidoclibchat.domain.model.dto.GithubClient;
import ch.xxx.aidoclibchat.domain.model.dto.GithubSource;

@Component
public class GithubRestClient implements GithubClient {
private final RestClient restClient;

public GithubRestClient(RestClient restClient) {
this.restClient = restClient;
}
public List<String> readSourceFile(String baseUrl, String url) {

public GithubSource readSourceFile(String baseUrl, String url) {
var result = this.restClient.get().uri("{baseUrl}{url}", baseUrl, url).retrieve().body(String.class);
return result.lines().toList();
var sourceName = Arrays.asList(url.split("/")).reversed().get(0).split(".")[0].trim();
var resultLines = result.lines().toList();
var sourcePackage = resultLines.stream().filter(myLine -> myLine.contains("package")).findFirst().orElseThrow()
.split(" ")[1].split(";")[0].trim();
return new GithubSource(sourceName, sourcePackage, resultLines);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
*/
package ch.xxx.aidoclibchat.domain.model.dto;

import java.util.List;

public interface GithubClient {
public static final String GITHUB_BASE_URL = "https://raw.githubusercontent.com";

List<String> readSourceFile(String baseUrl, String url);
GithubSource readSourceFile(String baseUrl, String url);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2023 Sven Loesekann
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ch.xxx.aidoclibchat.domain.model.dto;

import java.util.List;

public record GithubSource(String sourceName, String sourcePackage, List<String> lines) {

}
4 changes: 2 additions & 2 deletions backend/src/main/resources/application-ollama.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spring.liquibase.change-log=classpath:/dbchangelog/db.changelog-master-ollama.xm
# falcon model config free production use
#spring.ai.ollama.chat.model=falcon:40b
# beluga model config only for non production/commercial use
spring.ai.ollama.chat.model=stable-beluga:13b
#spring.ai.ollama.chat.model=stable-beluga:13b

# function calling
#spring.ai.ollama.chat.model=mixtral:8x7b-text-v0.1-q6_K
Expand All @@ -26,6 +26,6 @@ spring.ai.ollama.chat.model=stable-beluga:13b
#spring.ai.ollama.embedding.options.model=mxbai-embed-large:335m #test with Spring AI 1.0

# generate code
#spring.ai.ollama.chat.model=granite-code:20b
spring.ai.ollama.chat.model=granite-code:20b
#spring.ai.ollama.chat.options.num-thread=8
#spring.ai.ollama.chat.options.keep_alive=1s

0 comments on commit 2e020eb

Please sign in to comment.