-
Notifications
You must be signed in to change notification settings - Fork 0
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 #13 from edgararuiz/updates
Converts site to quarto
- Loading branch information
Showing
57 changed files
with
17,506 additions
and
180 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
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,39 @@ | ||
project: | ||
type: website | ||
output-dir: docs | ||
|
||
execute: | ||
freeze: true | ||
|
||
website: | ||
title: mall | ||
navbar: | ||
left: | ||
- sidebar:articles | ||
- href: reference/index.qmd | ||
text: Reference | ||
sidebar: | ||
- id: articles | ||
title: "Articles" | ||
style: "docked" | ||
background: light | ||
collapse-level: 2 | ||
contents: | ||
- text: "Databricks" | ||
href: articles/databricks.qmd | ||
|
||
format: | ||
html: | ||
toc: true | ||
code-copy: true | ||
code-overflow: wrap | ||
code-toos: true | ||
eval: false | ||
theme: | ||
light: [cosmo, theme.scss] | ||
dark: [cosmo, theme-dark.scss] | ||
|
||
knitr: | ||
opts_chunk: | ||
collapse: true | ||
comment: "#>" |
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,64 @@ | ||
--- | ||
title: "Databricks" | ||
--- | ||
|
||
|
||
```{r, include = FALSE} | ||
packageStartupMessage(library(dplyr)) | ||
``` | ||
|
||
This brief example shows how seamless it is to use the same functions, | ||
but against a remote database connection. Today, it works with the following | ||
functions: | ||
|
||
- `llm_sentiment()` / `llm_vec_sentiment()` | ||
- `llm_summarize()` / `llm_vec_summarize()` | ||
|
||
## Examples | ||
|
||
We will start by connecting to the Databricks Warehouse | ||
|
||
```{r} | ||
library(mall) | ||
library(DBI) | ||
con <- dbConnect( | ||
odbc::databricks(), | ||
HTTPPath = Sys.getenv("DATABRICKS_PATH") | ||
) | ||
``` | ||
|
||
Next, we will create a small reviews table | ||
|
||
```{r} | ||
library(dplyr) | ||
reviews <- tribble( | ||
~review, | ||
"This has been the best TV I've ever used. Great screen, and sound.", | ||
"I regret buying this laptop. It is too slow and the keyboard is too noisy", | ||
"Not sure how to feel about my new washing machine. Great color, but hard to figure" | ||
) | ||
tbl_reviews <- copy_to(con, reviews) | ||
``` | ||
|
||
Using `llm_sentiment()` in Databricks will call that vendor's SQL AI function | ||
directly: | ||
|
||
```{r} | ||
tbl_reviews |> | ||
llm_sentiment(review) | ||
``` | ||
|
||
There are some differences in the arguments, and output of the LLM's. Notice | ||
that instead of "neutral", the prediction is "mixed". The AI Sentiment function | ||
does not allow to change the possible options. | ||
|
||
Next, we will try `llm_summarize()`. The `max_words` argument maps to the same | ||
argument in the AI Summarize function: | ||
|
||
```{r} | ||
tbl_reviews |> | ||
llm_summarize(review, max_words = 5) | ||
``` |
Oops, something went wrong.