-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to pass various models to set_llm.
- Loading branch information
1 parent
0ea163e
commit 7e479d8
Showing
17 changed files
with
372 additions
and
145 deletions.
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,4 @@ | ||
#' @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 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
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.