fmegahed commited on
Commit
992f008
·
verified ·
1 Parent(s): 720387b
Files changed (8) hide show
  1. .gitattributes +4 -35
  2. .gitignore +1 -0
  3. Dockerfile +24 -0
  4. README.md +93 -10
  5. app.R +18 -0
  6. data/data_desc.md +22 -0
  7. data/extra_instructions.md +9 -0
  8. data/scout.db +3 -0
.gitattributes CHANGED
@@ -1,35 +1,4 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.db filter=lfs diff=lfs merge=lfs -text
2
+ Dockerfile text eol=lf
3
+ *.R text eol=lf
4
+ *.md text eol=lf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .Renviron
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM rocker/shiny:4.6.0
2
+
3
+ # querychat, ellmer, and RSQLite need these system libraries;
4
+ # libuv1t64 is missing from rocker/shiny:4.6.0 but its fs package needs it
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ libcurl4-openssl-dev libssl-dev libxml2-dev libuv1t64 \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # One dated CRAN snapshot so every build installs the same versions
10
+ RUN echo 'options(repos = c(CRAN = "https://p3m.dev/cran/__linux__/noble/2026-09-01"))' \
11
+ >> /usr/local/lib/R/etc/Rprofile.site
12
+
13
+ # DT is a Suggests of querychat but app_obj() needs it at runtime; ggsql powers the visualize tool
14
+ RUN R -q -e "install.packages(c('shiny', 'bslib', 'DBI', 'RSQLite', 'ellmer', 'shinychat', 'querychat', 'DT', 'ggsql'))"
15
+
16
+ # Fail the build now, not at runtime, if anything is missing
17
+ RUN R -q -e "stopifnot(requireNamespace('querychat'), requireNamespace('RSQLite'), requireNamespace('DT'), requireNamespace('ggsql'), requireNamespace('fs')); cat(R.version.string, as.character(packageVersion('querychat')), '\n')"
18
+
19
+ WORKDIR /app
20
+ COPY app.R app.R
21
+ COPY data/ data/
22
+
23
+ EXPOSE 7860
24
+ CMD ["R", "-q", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 7860)"]
README.md CHANGED
@@ -1,10 +1,93 @@
1
- ---
2
- title: Testing
3
- emoji: 😻
4
- colorFrom: gray
5
- colorTo: blue
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ sdk: docker
3
+ app_port: 7860
4
+ title: ISA 401 Job Scout Chat
5
+ emoji: 🔎
6
+ colorFrom: red
7
+ colorTo: gray
8
+ pinned: false
9
+ license: mit
10
+ short_description: Ask questions about ChatISA Job Scout postings
11
+ ---
12
+
13
+ # ISA 401 Job Scout Chat
14
+
15
+ **Ask a question in plain English, get the SQL and a table back**
16
+
17
+ A twelve-line [querychat](https://github.com/posit-dev/querychat) app built in ISA 401 (Miami University) on the job postings that [ChatISA](https://chatisa.fsb.miamioh.edu) Job Scout collected. It is the starting point for Assignment 05, where you deploy this app to Hugging Face Spaces and then improve it.
18
+
19
+ ---
20
+
21
+ ## What is this app?
22
+
23
+ The app connects to a SQLite database (`data/scout.db`), hands the `scout_postings` table to querychat, and lets an LLM translate your question into SQL. Every answer shows the query it ran, so you can check the logic and reuse the SQL yourself.
24
+
25
+ **Example queries:**
26
+ - "How many of the postings are remote?"
27
+ - "Which ten companies have the most postings?"
28
+ - "Show the internship postings in Ohio."
29
+
30
+ ---
31
+
32
+ ## Dataset Information
33
+
34
+ **Dataset:** `scout_postings` table in `data/scout.db` (1,891 rows, 19 columns)
35
+ **Source:** ChatISA Job Scout, which harvested the postings from public job boards between July 29 and August 23, 2026 (the `source` column records the board: `activejobs` or `usajobs`)
36
+ **Data dictionary:** `data/data_desc.md` (started in class; you complete it in Assignment 05)
37
+ **Query rules for the LLM:** `data/extra_instructions.md` (one starter rule; you add more)
38
+
39
+ ### Key Fields
40
+
41
+ | Field | Description |
42
+ |-------|-------------|
43
+ | `title` | Job title as it appeared on the board |
44
+ | `company` | Employer name |
45
+ | `location_city` | City of the posting (blank for 61 rows) |
46
+ | `location_state` | Two-letter state code (blank for 30 rows) |
47
+ | `remote` | `1` if the posting is remote, `0` otherwise |
48
+ | `category` | `fulltime`, `federal`, or `internship` |
49
+
50
+ ---
51
+
52
+ ## Required Secret
53
+
54
+ The app calls OpenAI (`gpt-5.6-luna (reasoning off)`) through [ellmer](https://ellmer.tidyverse.org/), so it needs one environment variable:
55
+
56
+ ```bash
57
+ export OPENAI_API_KEY="your-api-key-here"
58
+ ```
59
+
60
+ On Hugging Face Spaces, add it under **Settings > Variables and secrets** as a secret named `OPENAI_API_KEY`. Never commit the key; `.Renviron` is listed in `.gitignore` for that reason.
61
+
62
+ ---
63
+
64
+ ## Running Locally
65
+
66
+ **With R (4.6.0, querychat 0.3.0):**
67
+ ```r
68
+ # from inside apps/job_scout_chat/
69
+ shiny::runApp(".", port = 7860)
70
+ ```
71
+
72
+ **With Docker:**
73
+ ```bash
74
+ docker build -t job_scout_chat .
75
+ docker run --rm -p 7860:7860 -e OPENAI_API_KEY=$OPENAI_API_KEY job_scout_chat
76
+ ```
77
+
78
+ Then open http://localhost:7860.
79
+
80
+ ---
81
+
82
+ ## Technology Stack
83
+
84
+ - **[Shiny](https://shiny.posit.co/)** - Web application framework for R
85
+ - **[querychat](https://github.com/posit-dev/querychat)** - Natural language data querying
86
+ - **[ellmer](https://ellmer.tidyverse.org/)** - LLM client for R
87
+ - **[RSQLite](https://rsqlite.r-dbi.org/)** - SQLite driver for R
88
+
89
+ ---
90
+
91
+ ## Course Information
92
+
93
+ This application was developed for **ISA 401** at **Miami University**. The polished version of the same idea, built on BLS wage data, is the [OEWS Jobs Explorer](https://huggingface.co/spaces/fmegahed/querychat_demo).
app.R ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ISA 401 Job Scout Chat: ask questions, get SQL, a table, or a chart back
2
+ library(querychat)
3
+
4
+ con = DBI::dbConnect(RSQLite::SQLite(), "data/scout.db")
5
+
6
+ client = ellmer::chat_openai(
7
+ model = "gpt-5.6-luna",
8
+ params = ellmer::params(reasoning_effort = "none")
9
+ )
10
+
11
+ qc = querychat(
12
+ con, "scout_postings",
13
+ client = client,
14
+ tools = c("filter", "query", "visualize"), # visualize: charts in the chat (needs ggsql)
15
+ greeting = "Ask me about the 1,891 job postings ChatISA Job Scout collected."
16
+ )
17
+
18
+ qc$app_obj()
data/data_desc.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ChatISA Job Scout Postings: Data Dictionary
2
+
3
+ **Dataset:** `scout_postings` table in `scout.db` (SQLite), 1,891 rows and 19 columns
4
+ **Source:** ChatISA Job Scout (https://chatisa.fsb.miamioh.edu), postings harvested from public job boards between July 29 and August 23, 2026
5
+ **Course:** ISA 401, Miami University
6
+
7
+ > One row is one job posting. Empty cells are stored as SQL `NULL`.
8
+
9
+ ---
10
+
11
+ ## Field Definitions
12
+
13
+ | Field | Type | Description |
14
+ |---|---|---|
15
+ | `id` | text | Primary key. A 36-character UUID that identifies the posting; unique across the table. |
16
+ | `title` | text | Job title exactly as it appeared on the job board (for example "Data Analyst - Remote"). Never empty. |
17
+ | `company` | text | Employer name as posted. Never empty. 1,042 distinct companies. |
18
+ | `location_city` | text | City of the posting (for example "Atlanta"). `NULL` for 61 rows. |
19
+ | `location_state` | text | Two-letter U.S. state code in upper case (for example "GA"). 46 distinct codes; `NULL` for 30 rows. |
20
+ | `remote` | integer | `1` if the posting is remote, `0` otherwise (127 remote rows). Stored as an integer, not a boolean. |
21
+
22
+ Continue the table for the remaining columns (Assignment 05): `source`, `external_id`, `fingerprint`, `category`, `apply_url`, `description`, `posted_at`, `harvested_at`, `last_seen_at`, `skills_json`, `taxonomy_version`, `active`, `visa_sponsorship`.
data/extra_instructions.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Extra Instructions
2
+
3
+ Rules the LLM follows when it writes SQL for `scout_postings`.
4
+
5
+ - When the user asks about a state, match `location_state` by its two-letter code (for example, "Ohio" means `location_state = 'OH'`).
6
+
7
+ <!-- Add more rules below (Assignment 05 asks for at least three). Good candidates:
8
+ how to treat `remote`, how to filter by `category`, how to search `title`
9
+ and `description` case-insensitively, and how to parse `skills_json`. -->
data/scout.db ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41abc87edb49f282b3091e5318d93635647e5683d1e5e05d68175dffa7a7add2
3
+ size 13340672