# Walkthrough & Examples
### Table of Contents
1. [Walkthrough](#Walkthrough)
2. [Shell Examples](#shell-examples)
3. [Python Script Examples](#python-script-examples)
> **Heads up on installation:** if you don't want to think about which extras to install, use `uvx wdoc[full]` everywhere. The plain `wdoc` package only includes PDF and URL/web loaders, so commands that touch youtube, audio, anki, office formats (word/powerpoint/epub) or logseq need their extras. `[full]` bundles all of those at once. The examples below sometimes use plain `uvx wdoc` when the base install is enough (pdf, url, ddg), but you can always replace it with `uvx wdoc[full]` to be safe. See the [installation section](https://github.com/thiswillbeyourgithub/wdoc/blob/main/README.md#direct-installation) for the full list of extras.
Note that there is [an official open-webui Tool](https://openwebui.com/t/qqqqqqqqqqqqqqqqqqqq/wdoctool) that is even simpler to use.
## Walkthrough
1. Say you want to ask a question about one pdf, that's simple:
```bash
uvx wdoc --task="query" --path="my_file.pdf" --filetype="pdf" --model='openai/gpt-4o'
```
Note that you could have just let `--filetype="auto"` and it would have worked the same.
* *Note: By default `wdoc` tries to parse args as kwargs so `uvx wdoc query mydocument What's the age of the captain?` is parsed as `uvx wdoc --task=query --path=mydocument --query "What's the age of the captain?"`. Likewise for summaries. This does not always work so use it only after getting comfortable with `wdoc`.*
2. You have several pdf? Say you want to ask a question about any pdf contained in a folder, that's not much more complicated:
```bash
uvx wdoc --task="query" --path="my/other_dir" --pattern="**/*pdf" --filetype="recursive_paths" --recursed_filetype="pdf" --query="My question about those documents"
```
So basically you give as path the path to the dir, as pattern the globbing pattern used to find the files relative to the path, set as filetype "recursive_paths" so that `wdoc` knows what arguments to expect, and specify as recursed_filetype "pdf" so that `wdoc` knows that each found file must be treated as a pdf. You can use the same idea to glob any kind of file supported by `wdoc` like markdown etc. You can even use "auto"! Note that you can either directly ask your question with `--query="my question"`, or wait for an interactive prompt to pop up, or just pass the question as *args like so `uvx wdoc [your kwargs] here is my question`.
3. You want more? You can write a `.json` file where each line (`#comments` and empty lines are ignored) will be parsed as a list of argument. For example one line could be:
```json
{"path": "my/other_dir", "pattern": "**/*pdf", "filetype": "recursive_paths", "recursed_filetype": "pdf"}
```
This way you can use a single json file to specify easily any number of sources. `.toml` files are also supported.
4. You can specify a "source_tag" metadata to help distinguish between documents you imported. It is EXTREMELY recommended to include a source_tag to any document you want to save: especially if using recursive filetypes. This is because after loading all documents `wdoc` use the source_tag to see if it should continue or crash. If you want to load 10_000 pdf in one go as I do, then it makes sense to continue if some failed to crash but not if a whole source_tag is missing.
5. Now say you do this with many many documents, as I do, you of course can't wait for the indexing to finish every time you have a question (even though the embeddings are cached). You should then add
```bash
--save_embeds_as=your/saving/path
```
to save all this index in a file. Then simply do
```bash
--load_embeds_from=your/saving/path
```
to quickly ask queries about it!
6. To know more about each argument supported by each filetype,
```bash
uvx wdoc --help
```
7. There is a specific recursive filetype I should mention: `--filetype="link_file"`. Basically the file designated by `--path` should contain in each line (`#comments` and empty lines are ignored) one url, that will be parsed by `wdoc`. I made this so that I can quickly use the "share" button on android from my browser to a text file (so it just appends the url to the file), this file is synced via [syncthing](https://github.com/syncthing/syncthing) to my browser and `wdoc` automatically summarize them and add them to my [Logseq](https://github.com/logseq/logseq/). Note that the url is parsed in each line, so formatting is ignored, for example it works even in markdown bullet point list.
8. If you want to only use local models, here's an example with [ollama](https://ollama.com/):
```bash
uvx wdoc --model="ollama/qwen3:8b" --query_eval_model="ollama/qwen3:8b" --embed_model="ollama/snowflake-arctic-embed2" --task summarize --path https://situational-awareness.ai/
```
You can always add `--private` to add additional safety nets that no data will leave your local network. You can also override specific API endpoints using
```bash
--llms_api_bases='{"model": "http://localhost:11434", "query_eval_model": "http://localhost:11434", "embeddings": "http://localhost:1434"}'
```
9. Now say you just want to summarize [Tim Urban's TED talk on procrastination](https://www.youtube.com/watch?v=arj7oStGLkU):
```bash
uvx wdoc[youtube] --task=summary --path='https://www.youtube.com/watch?v=arj7oStGLkU' --youtube_language="en" --disable_md_printing
```
Click to see the output
> # Summary
> ## https://www.youtube.com/watch?v=arj7oStGLkU
> - Let me take a deep breath and summarize this TED talk about procrastination:
> - [0:00-3:40] Personal experience with procrastination in college:
> - Author's pattern with papers: planning to work steadily but actually doing everything last minute
> - 90-page senior thesis experience:
> - Planned to work steadily over a year
> - Actually wrote 90 pages in 72 hours with two all-nighters
> - *Jokingly implies* it was brilliant, then admits it was 'very, very bad'
> - [3:40-6:45] Brain comparison between procrastinators and non-procrastinators:
> - Both have a **Rational Decision-Maker**
> - Procrastinator's brain also has an **Instant Gratification Monkey**:
> - Lives entirely in present moment
> - Only cares about 'easy and fun'
> - Works fine for animals but problematic for humans in advanced civilization
> - **Rational Decision-Maker** capabilities:
> - Can visualize future
> - See big picture
> - Make long-term plans
> - [6:45-10:55] The procrastinator's system:
> - **Dark Playground**:
> - Where leisure activities happen at wrong times
> - Characterized by guilt, dread, anxiety, self-hatred
> - **Panic Monster**:
> - Only thing monkey fears
> - Awakens near deadlines or threats of public embarrassment
> - Enables last-minute productivity
> - Personal example with TED talk preparation:
> - Procrastinated for months
> - Only started working when panic set in
> - [10:55-13:05] Two types of procrastination:
> - Deadline-based procrastination:
> - Effects contained due to Panic Monster intervention
> - Less harmful long-term
> - Non-deadline procrastination:
> - More dangerous
> - Affects important life areas without deadlines:
> - Entrepreneurial pursuits
> - Family relationships
> - Health
> - Personal relationships
> - Can cause long-term unhappiness and regrets
> - [13:05-14:04] Concluding thoughts:
> - *Author believes* no true non-procrastinators exist
> - Presents **Life Calendar**:
> - Shows 90 years in weekly boxes
> - Emphasizes limited time available
> - Call to action: need to address procrastination 'sometime soon'
> - Key audience response moments:
> - Multiple instances of '(Laughter)' noted throughout
> - Particularly strong response from PhD students relating to procrastination issues
> - Received thousands of emails after blog post about procrastination
> Tokens used for https://www.youtube.com/watch?v=arj7oStGLkU: '4936' (in: 4307, out: 629, cost: $0.00063)
> Total cost of those summaries: 4936 tokens for $0.00063 (estimate was $0.00030)
> Total time saved by those summaries: 8.8 minutes
> Done summarizing.