-
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.
Merge pull request #74 from r-world-devs/waisk/63/demo
Waisk/63/demo
- Loading branch information
Showing
15 changed files
with
291 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.Rproj.user | ||
.Renviron | ||
docs | ||
inst/demo-app/rsconnect/ |
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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
run_demo <- function() { | ||
|
||
app_folder <- system.file("demo-app", package = "GitAI") | ||
|
||
shiny::runApp(app_folder) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
rstudioapi::restartSession() | ||
|
||
rsconnect::setAccountInfo( | ||
name = 'kalimu', | ||
token = Sys.getenv("SHINYAPPSIO_TOKEN"), | ||
secret = Sys.getenv("SHINYAPPSIO_SECRET") | ||
) | ||
|
||
# pak::pkg_install("r-world-devs/GitAI") | ||
|
||
rsconnect::deployApp( | ||
appDir = "inst/demo", | ||
account = "kalimu", | ||
appName = "GitAI-demo" | ||
) | ||
|
||
# https://kalimu.shinyapps.io/GitAI-demo/ |
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,92 +1,73 @@ | ||
my_project <- | ||
initialize_project("gitai-demo") |> | ||
my_project <- initialize_project("gitai-demo") |> | ||
set_database( | ||
provider = "Pinecone", | ||
index = "gitai", | ||
namespace = NULL | ||
) |> | ||
set_llm(seed = 1014, api_args = list(temperature = 0)) | ||
|
||
my_project <- | ||
my_project |> | ||
set_github_repos(repos = c( | ||
"r-world-devs/GitStats", | ||
"r-world-devs/GitAI", | ||
"openpharma/DataFakeR" | ||
)) |> | ||
add_files(files = c("README.md")) | ||
|
||
my_project <- | ||
my_project |> | ||
set_prompt(paste( | ||
"Write two paragraphs of summary for a project based on given input.", | ||
"Highlight business value of the project, its functionality, main features,", | ||
"and use cases." | ||
my_project <- my_project |> | ||
set_github_repos( | ||
# repos = c( | ||
# "r-world-devs/GitStats", | ||
# "r-world-devs/GitAI", | ||
# "r-world-devs/cohortBuilder", | ||
# "r-world-devs/shinyCohortBuilder", | ||
# "r-world-devs/shinyQueryBuilder", | ||
# "r-world-devs/queryBuilder", | ||
# "r-world-devs/shinyGizmo", | ||
# "r-world-devs/shinyTimelines", | ||
# "openpharma/DataFakeR" | ||
# ) | ||
orgs = c( | ||
"insightsengineering", | ||
"openpharma", | ||
"pharmaverse", | ||
"tidymodels", | ||
"r-lib", | ||
"rstudio", | ||
"tidyverse" | ||
) | ||
) |> | ||
add_files(c( | ||
"DESCRIPTION", | ||
"*.md", | ||
"*.Rmd" | ||
)) | ||
|
||
my_project <- my_project |> | ||
set_prompt(r"( | ||
Write up to ten paragraphs of summary for a project based on given input. | ||
Be precise and to the point in your answers. | ||
Mention core functionality and all main features of the project. | ||
If available, mention brifly the technology used in the project | ||
(like R, Python, etc). | ||
If available, mention brifly if a project is an R package, shiny app, | ||
or other type of tool. | ||
)") | ||
|
||
custom_function <- function(provider, req) { | ||
|
||
req |> | ||
httr2::req_timeout(60) |> | ||
httr2::req_perform() |> | ||
httr2::resp_body_json() | ||
} | ||
unlockBinding("chat_perform_value", asNamespace("elmer")) | ||
assign("chat_perform_value", custom_function, envir = asNamespace("elmer")) | ||
lockBinding("chat_perform_value", asNamespace("elmer")) | ||
|
||
results <- process_repos(my_project) | ||
|
||
results |> dplyr::glimpse() | ||
purrr::map(results, ~.$text) | ||
|
||
|
||
|
||
|
||
|
||
|
||
# my_project <- | ||
# initialize_project(project_id = "gitai-demo") |> | ||
# set_database(index = "gitai") | ||
|
||
my_project |> find_records("I'm looking for an R package to create synthetic datasets.") | ||
|
||
my_project |> find_records("How can I check statisting of git repositories.") | ||
|
||
my_project |> find_records("Can I somehow extract information from code from git repositories?") | ||
|
||
my_project |> find_records("What are the tools that can help me in my work as a Data Scientist?") | ||
# results |> dplyr::glimpse() | ||
# purrr::map(results, ~.$text) | ||
|
||
my_project |> | ||
find_records("As a Manager I look for tools which let me learn what tools can be reused in my company", top_k = 2) | ||
|
||
my_project |> find_records("Which data products could have large impact in global company that maintains many repositories?", top_k = 3) | ||
find_records("How can I create synthetic datasets?", top_k = 3) | ||
|
||
my_project |> find_records("Szukam narzędzi które wykorzystują sztuczną inteligencję?") | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
my_chatbot <- | ||
initialize_project("gitai-demo") |> | ||
set_database(index = "gitai") |> | ||
set_llm(seed = 1014, api_args = list(temperature = 0)) |> | ||
set_prompt(paste( | ||
"As a helpful assistant, answer user question using only the provided input." | ||
)) | ||
|
||
get_answer <- function(my_chatbot, query) { | ||
|
||
cat("\n") | ||
my_chatbot$llm$chat(paste( | ||
"User query:", query, "\n\n", | ||
"Known input for the answer:", | ||
my_project$db$find_records(query = query, top_k = 1) | ||
)) |> | ||
cat() | ||
} | ||
|
||
my_chatbot |> | ||
get_answer("I'm looking for an R package to create synthetic datasets.") | ||
|
||
my_chatbot |> | ||
get_answer("How can I check statisting of git repositories?") | ||
|
||
my_chatbot |> | ||
get_answer("Can I somehow extract information from code from git repositories?") | ||
my_project |> | ||
find_records("How can I check statisting of git repositories.", top_k = 3) | ||
|
||
my_chatbot |> | ||
get_answer("I would love to use AI to process code files. Is it possible? Give me the answer writting in one sentence with very funny style.") | ||
my_project |> | ||
find_records("Can I somehow extract information from file content from git repositories using LLM?") | ||
|
||
run_demo() |
Oops, something went wrong.