-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to pass various models to set_llm. #60
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7e479d8
Allow to pass various models to set_llm.
krystian8207 cfa40c3
Bump version and remove unused functions.
krystian8207 d148e06
First round of R check fixes.
krystian8207 ad123d2
Fix lintr issues.
krystian8207 5b9f925
Fix creation of mocked chat and remove providing direct repo key.
krystian8207 12153a7
Remove integration test prefixes.
krystian8207 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
#' @importFrom R6 R6Class | ||
#' @importFrom httr2 with_verbosity | ||
#' @importFrom lubridate as_datetime | ||
NULL | ||
#' Derive knowledge from GitHub or GitLab repositories with the use of AI/LLM | ||
#' | ||
#' @name GitAI-package | ||
"_PACKAGE" | ||
|
||
#' This function is meant to fix 'Namespaces in Imports field not imported from:' R check note. | ||
#' The note shows up when namespace is used to create package object (not function) or | ||
#' within file marked at '.Rbuildignore' file. | ||
missing_deps_note_fix <- function() { | ||
R6::R6Class | ||
elmer::chat_ollama | ||
lubridate::as_datetime | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,81 @@ | ||
test_mocker <- Mocker$new() | ||
|
||
# Override other methods when needed in the future | ||
ChatMocked <- elmer:::Chat | ||
ChatMocked$public_methods$chat <- function(..., echo = NULL) { | ||
if (self$get_system_prompt() == "You always return only 'Hi there!'") { | ||
return("Hi there!") | ||
} | ||
} | ||
|
||
# This method allows to skip original checks (e.g. for api or other args structure) and returns | ||
# object of class ChatMocked that we can modify for our testing purposes. | ||
mock_chat_method <- function(turns = NULL, | ||
echo = c("none", "text", "all"), | ||
..., | ||
provider_class) { | ||
|
||
provider_args <- rlang::dots_list(...) | ||
provider <- rlang::exec(provider_class, !!!provider_args) | ||
|
||
ChatMocked$new(provider = provider, turns = turns, echo = echo) | ||
} | ||
|
||
chat_openai_mocked <- function(system_prompt = NULL, | ||
turns = NULL, | ||
base_url = "https://api.mocked.com/v1", | ||
api_key = "mocked_key", | ||
model = NULL, | ||
seed = NULL, | ||
api_args = list(), | ||
echo = c("none", "text", "all")) { | ||
|
||
turns <- elmer:::normalize_turns(turns, system_prompt) | ||
model <- elmer:::set_default(model, "gpt-4o") | ||
echo <- elmer:::check_echo(echo) | ||
|
||
if (is.null(seed)) { | ||
seed <- 1014 | ||
} | ||
|
||
mock_chat_method( | ||
turns = turns, | ||
echo = echo, | ||
base_url = base_url, | ||
model = model, | ||
seed = seed, | ||
extra_args = api_args, | ||
api_key = api_key, | ||
provider_class = elmer:::ProviderOpenAI | ||
) | ||
} | ||
|
||
chat_bedrock_mocked <- function(system_prompt = NULL, | ||
turns = NULL, | ||
model = NULL, | ||
profile = NULL, | ||
echo = NULL) { | ||
|
||
credentials <- list( | ||
access_key_id = "access_key_id_mocked", | ||
secret_access_key = "access_key_id_mocked", | ||
session_token = "session_token_mocked", | ||
access_token = "access_token_mocked", | ||
expiration = as.numeric(Sys.time() + 3600), | ||
region = "eu-central-1" | ||
) | ||
|
||
turns <- elmer:::normalize_turns(turns, system_prompt) | ||
model <- elmer:::set_default(model, "model_bedrock") | ||
echo <- elmer:::check_echo(echo) | ||
|
||
mock_chat_method( | ||
turns = turns, | ||
echo = echo, | ||
base_url = "", | ||
model = model, | ||
profile = profile, | ||
credentials = credentials, | ||
provider_class = elmer:::ProviderBedrock | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this approach. Basically
GitStats
looks by itself for best-fit access key whentoken
parameter is set toNULL
(searches through all keys that start withGITLAB_*
). Now, if you leavetoken
parameter empty, tests will pass if you have any key starting withGITLAB_*
that gives access to public GitLab API. If you will use approach withget_gitlab_pat()
, test will fail if user does not have explicitGITLAB_PAT
key as one giving access to public GitLab.My suggestion would be to create
token
parameter on the level ofset_*_repos()
function which value would be then passed toGitStats
set_*_host()
function (here is issue for that: #58). By default it would stayNULL
. For tests we could define it e.g. asGITLAB_PAT_PUBLIC
. We could still leave it empty and pack it intowithr
the way I do inGitStats
to test pulling default token:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I wasn't aware of this functionality of GitStats.
We agreed to add skipping tests directly in the GitStats-related methods.