Skip to content

Commit

Permalink
Merge pull request #75 from kaybenleroll/talk-genai
Browse files Browse the repository at this point in the history
Talk genai
  • Loading branch information
kaybenleroll authored Nov 5, 2024
2 parents 015a45b + f4b7179 commit 230f7c2
Show file tree
Hide file tree
Showing 17 changed files with 2,776 additions and 0 deletions.
12 changes: 12 additions & 0 deletions talk_chatbot_genai_202411/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
README.md

data/*

scraped_files/*

.Rproj.user/*

nlp_workshop.Rproj

*.qmd
*.html
8 changes: 8 additions & 0 deletions talk_chatbot_genai_202411/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.Rproj.user

output.log

temp*.R

*_files/*
*_cache/*
85 changes: 85 additions & 0 deletions talk_chatbot_genai_202411/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
FROM rocker/tidyverse:4.4.1

WORKDIR /tmp

COPY build/docker_install_sys_rpkgs.R /tmp
RUN Rscript /tmp/docker_install_sys_rpkgs.R

RUN git clone https://github.com/lindenb/makefile2graph.git \
&& cd makefile2graph \
&& make \
&& make install


RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
byobu \
clang \
ditaa \
graphviz \
htop \
less \
libclang-dev \
libglpk-dev \
libgsl-dev \
libnlopt-dev \
p7zip-full \
pbzip2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p $HOME/.R \
&& echo "" > $HOME/.R/Makevars \
&& echo "CXX=clang++" >> $HOME/.R/Makevars \
&& echo "CXXFLAGS=-Os" >> $HOME/.R/Makevars \
&& echo "CXXFLAGS+= -Wno-unused-variable -Wno-unused-function" >> $HOME/.R/Makevars \
&& echo "CXXFLAGS+= -Wno-unknown-pragmas -Wno-macro-redefined" >> $HOME/.R/Makevars \
&& echo "" >> $HOME/.R/Makevars \
&& echo "CXX14=clang++" >> $HOME/.R/Makevars \
&& echo "CXX14FLAGS=-Os" >> $HOME/.R/Makevars \
&& echo "CXX14FLAGS+= -Wno-unused-variable -Wno-unused-function" >> $HOME/.R/Makevars \
&& echo "CXX14FLAGS+= -Wno-unknown-pragmas -Wno-macro-redefined" >> $HOME/.R/Makevars \
&& echo "" >> $HOME/.R/Makevars \
&& install2.r --error \
anytime \
conflicted \
cowplot \
DataExplorer \
directlabels \
fs \
loo \
markdown \
parallelly \
pryr \
quarto \
sessioninfo \
snakecase \
tictoc


RUN cp -r $HOME/.R /home/rstudio \
&& chown -R rstudio:rstudio /home/rstudio/.R


WORKDIR /home/rstudio
USER rstudio

COPY build/conffiles.7z /tmp
RUN 7z x /tmp/conffiles.7z \
&& cp conffiles/.bash* . \
&& cp conffiles/.gitconfig . \
&& cp conffiles/.Renviron . \
&& cp conffiles/.Rprofile . \
&& mkdir -p .config/rstudio \
&& cp conffiles/rstudio-prefs.json .config/rstudio/ \
&& rm -rfv conffiles/ \
&& touch /home/rstudio/.bash_eternal_history

COPY build/docker_install_user_rpkgs.R /tmp
RUN Rscript /tmp/docker_install_user_rpkgs.R


USER root

RUN chown -R rstudio:rstudio /home/rstudio

99 changes: 99 additions & 0 deletions talk_chatbot_genai_202411/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
### repo variables
PROJECT_USER=kaybenleroll
PROJECT_NAME=talk_chatbot_genai
PROJECT_TAG=latest

IMAGE_TAG=${PROJECT_USER}/${PROJECT_NAME}:${PROJECT_TAG}

DOCKER_USER=rstudio
DOCKER_PASS=CHANGEME
DOCKER_UID=$(shell id -u)
DOCKER_GID=$(shell id -g)

RSTUDIO_PORT=8787

PROJECT_FOLDER=genai_talk


### Set GITHUB_USER with 'gh config set gh_user <<user>>'
GITHUB_USER=$(shell gh config get gh_user)

CONTAINER_NAME=genai-talk

### Project build targets
.SUFFIXES: .qmd .html .dot .png

QMD_FILES := $(wildcard *.qmd)
HTML_FILES := $(patsubst %.qmd,%.html,$(RMD_FILES))

all-html: $(HTML_FILES)

.qmd.html:
echo "TIMESTAMP:" `date` "- Rendering script $<" >> output.log 2>&1
Rscript -e 'quarto::quarto_render("$<")' >> output.log 2>&1
echo "TIMESTAMP:" `date` "- Finished $*.html" >> output.log 2>&1


.dot.png:
dot -Tpng -o$*.png $<

full_deps.dot:
makefile2graph all-html > full_deps.dot

depgraph: full_deps.png




mrproper: clean-cache clean-data clean-html clean-models
rm -fv data/*.xlsx
rm -fv *.dot
rm -fv output.log

clean-data:
rm -fv data/*.rds
rm -fv data/*.csv

clean-html:
rm -fv *.html

clean-cache:
rm -rfv *_cache
rm -rfv *_files

clean-models:
rm -fv stan_models/*


### Docker targets
docker-build-image: Dockerfile
docker build -t ${IMAGE_TAG} -f Dockerfile .

docker-run:
docker run --rm -d \
-p ${RSTUDIO_PORT}:8787 \
-e USER=${DOCKER_USER} \
-e PASSWORD=${DOCKER_PASS} \
-e USERID=${DOCKER_UID} \
-e GROUPID=${DOCKER_GID} \
-v "${PWD}":"/home/${DOCKER_USER}/${PROJECT_FOLDER}":rw \
--name ${CONTAINER_NAME} \
${IMAGE_TAG}

docker-bash:
docker exec -it -u ${DOCKER_USER} ${CONTAINER_NAME} bash

docker-stop:
docker stop ${CONTAINER_NAME}

docker-rm:
docker rm ${CONTAINER_NAME}

docker-start:
docker start ${CONTAINER_NAME}

docker-clean: docker-stop-all
docker rm $(shell docker ps -q -a)

docker-pull:
docker pull ${IMAGE_TAG}
Empty file.
Binary file added talk_chatbot_genai_202411/build/conffiles.7z
Binary file not shown.
1 change: 1 addition & 0 deletions talk_chatbot_genai_202411/build/docker_install_sys_rpkgs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
17 changes: 17 additions & 0 deletions talk_chatbot_genai_202411/build/test_report.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "Temporary Quarto Document"
author: "Mick Cooney <[email protected]>"
date: "`r Sys.Date()`"
---


```{r knit_opts, include = FALSE}
library(tidyverse)
options(
width = 80L,
warn = 1
)
set.seed(42)
```
18 changes: 18 additions & 0 deletions talk_chatbot_genai_202411/genai_talk.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: knitr
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Makefile
Empty file.
Binary file added talk_chatbot_genai_202411/img/describedata.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added talk_chatbot_genai_202411/img/fourtheorem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions talk_chatbot_genai_202411/lib_utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
resolve_conflicts <- function(pkg_priority) {
get_index <- function(pkg_name) {
idx <- str_which(pkg_priority, pkg_name)

if(length(idx) == 0) { idx <- 0L }

return(idx)
}

conflict_lst <- conflict_scout()

for(func_name in names(conflict_lst)) {
pkg_index <- map_int(conflict_lst[[func_name]], get_index)

pkg_index <- pkg_index[pkg_index > 0]

if(length(pkg_index) == 0) {
pkg_use <- conflict_lst[[func_name]][1]
} else {
pkg_use <- pkg_priority[pkg_index |> min()]
}

conflict_prefer(func_name, pkg_use)
}

return(conflict_lst)
}


gamma_mucv2shaperate <- function(mu, cv) {
shape <- 1 / (cv^2)
rate <- 1 / (cv^2 * mu)

return(c(shape = shape, rate = rate))
}


gamma_shaperate2mucv <- function(shape, rate) {
mu <- shape / rate
cv <- 1 / sqrt(shape)

return(c(mu = mu, cv = cv))
}


rgamma_mucv <- function(n, mu, cv, ...) {
params <- gamma_mucv2shaperate(mu, cv)

rgamma(n = n, shape = params[1], rate = params[2], ...)
}

18 changes: 18 additions & 0 deletions talk_chatbot_genai_202411/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* {
text-align: center;
}

.reveal table {
font-size: 80%;
}

.custom-small table {
font-size: .5em
}

h1.title {
background-image: url(img/describedata.png), url(img/fourtheorem.png);
background-repeat: no-repeat;
background-position: left, right;
background-size: 300px, 300px;
}
Loading

0 comments on commit 230f7c2

Please sign in to comment.