markhjeffery

markhjeffery

Vector Search with JavaScript: page 8

Title: Name of Book: description (page number)
Example: Programming Flutter: ‘pub get’ command not working (page 15)

I downloaded the sample code, and executed the first example on page 8. Full text output provided:

markjeffery@Mac getting_started_with_vector_search % node name_this_book.js 
(node:23483) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///Users/markjeffery/Downloads/code/getting_started_with_vector_search/name_this_book.js is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /Users/markjeffery/package.json.
(Use `node --trace-warnings ...` to show where the warning was created)
[dotenv@17.1.0] injecting env (0) from .env (tip: ⚙️  write to custom object with { processEnv: myObject })
No cached data found. Starting fresh.
Scraping up to 50 book titles from Pragmatic Bookshelf...
  - Fetching page 1
  - Fetching page 2
  - Fetching page 3
  - Fetching page 4
  - Fetching page 5

    Finished scraping. 50 titles captured.
Generating embeddings for all titles...
  (1/50) A Common-Sense Guide to Data Structures and Algorithms in Python, Volume 2: Level Up Your Core Programming Skills
Generating embedding for: "A Common-Sense Guide to Data Structures and Algorithms in Python, Volume 2: Level Up Your Core Programming Skills"
  (2/50) Advanced Hands-on Rust: Level up Your Coding Skills
Generating embedding for: "Advanced Hands-on Rust: Level up Your Coding Skills"
  (3/50) Ash Framework: Create Declarative Elixir Web Apps
Generating embedding for: "Ash Framework: Create Declarative Elixir Web Apps"
  (4/50) Network Programming in Elixir and Erlang: Write High-Performance, Scalable, and Reliable Apps with TCP and UDP
Generating embedding for: "Network Programming in Elixir and Erlang: Write High-Performance, Scalable, and Reliable Apps with TCP and UDP"
  (5/50) Programming Phoenix LiveView: Interactive Elixir Web Programming Without Writing Any JavaScript
Generating embedding for: "Programming Phoenix LiveView: Interactive Elixir Web Programming Without Writing Any JavaScript"
  (6/50) The Healthy Programmer, Second Edition: Refactor Your Fitness, Improve Your Mind
Generating embedding for: "The Healthy Programmer, Second Edition: Refactor Your Fitness, Improve Your Mind"
  (7/50) Kotlin Brain Teasers: Exercise Your Mind
Generating embedding for: "Kotlin Brain Teasers: Exercise Your Mind"
  (8/50) Real-World Kanban, Second Edition: Do Less, Accomplish More with Lean Thinking
Generating embedding for: "Real-World Kanban, Second Edition: Do Less, Accomplish More with Lean Thinking"
  (9/50) Vector Search with JavaScript: Build Intelligent Search Systems with AI
Generating embedding for: "Vector Search with JavaScript: Build Intelligent Search Systems with AI"
  (10/50) Hotwire Native for Rails Developers: Build Native Mobile Apps Using Your Server
Generating embedding for: "Hotwire Native for Rails Developers: Build Native Mobile Apps Using Your Server"
  (11/50) Kotlin Coroutine Confidence: Untangle Your Async, Ship Safety at Speed
Generating embedding for: "Kotlin Coroutine Confidence: Untangle Your Async, Ship Safety at Speed"
  (12/50) More OCaml: Algorithms, Methods & Diversions
Generating embedding for: "More OCaml: Algorithms, Methods & Diversions"
  (13/50) Agile Web Development with Rails 8
Generating embedding for: "Agile Web Development with Rails 8"
  (14/50) simplicity: sustainable, humane, and effective software development
Generating embedding for: "simplicity: sustainable, humane, and effective software development"
  (15/50) Next-Level A/B Testing: Repeatable, Rapid, and Flexible Product Experimentation
Generating embedding for: "Next-Level A/B Testing: Repeatable, Rapid, and Flexible Product Experimentation"
  (16/50) Cruising Along with Java: Modernize and Modularize with the Latest Features
Generating embedding for: "Cruising Along with Java: Modernize and Modularize with the Latest Features"
  (17/50) Elixir Patterns: The essential BEAM handbook for the busy developer
Generating embedding for: "Elixir Patterns: The essential BEAM handbook for the busy developer"
  (18/50) Northwind Elixir Traders: Learn Elixir and database modeling with Ecto and SQLite, all in one project
Generating embedding for: "Northwind Elixir Traders: Learn Elixir and database modeling with Ecto and SQLite, all in one project"
  (19/50) Rails Scales!: Practical Techniques for Performance and Growth
Generating embedding for: "Rails Scales!: Practical Techniques for Performance and Growth"
  (20/50) Become an Effective Software Engineering Manager: How to Be the Leader Your Development Team Needs
Generating embedding for: "Become an Effective Software Engineering Manager: How to Be the Leader Your Development Team Needs"
  (21/50) Clojure Brain Teasers: Exercise Your Mind
Generating embedding for: "Clojure Brain Teasers: Exercise Your Mind"
  (22/50) Creating Great Teams, Second Edition: How Self-Selection Lets People Excel
Generating embedding for: "Creating Great Teams, Second Edition: How Self-Selection Lets People Excel"
  (23/50) Agile Web Development with Rails 7.2
Generating embedding for: "Agile Web Development with Rails 7.2"
  (24/50) C# Brain Teasers: Exercise Your Mind
Generating embedding for: "C# Brain Teasers: Exercise Your Mind"
  (25/50) Guiding Star OKRs: A New Approach to Setting and Achieving Goals
Generating embedding for: "Guiding Star OKRs: A New Approach to Setting and Achieving Goals"
  (26/50) Business Success with Open Source: Strengthen Your Business with Free and Open Source Software
Generating embedding for: "Business Success with Open Source: Strengthen Your Business with Free and Open Source Software"
  (27/50) MySQL 9 Essentials
Generating embedding for: "MySQL 9 Essentials"
  (28/50) tmux 3: Productive Mouse-Free Development
Generating embedding for: "tmux 3: Productive Mouse-Free Development"
  (29/50) Real-World Event Sourcing: Distribute, Evolve, and Scale Your Elixir Applications
Generating embedding for: "Real-World Event Sourcing: Distribute, Evolve, and Scale Your Elixir Applications"
  (30/50) The New and Improved Flask Mega-Tutorial
Generating embedding for: "The New and Improved Flask Mega-Tutorial"
  (31/50) Regular Expressions Machinery: The Illustrated Guide
Generating embedding for: "Regular Expressions Machinery: The Illustrated Guide"
  (32/50) The Art of Functional Programming
Generating embedding for: "The Art of Functional Programming"
  (33/50) Engineering Elixir Applications: Navigate Each Stage of Software Delivery with Confidence
Generating embedding for: "Engineering Elixir Applications: Navigate Each Stage of Software Delivery with Confidence"
  (34/50) Jetpack Compose 1.7 Essentials
Generating embedding for: "Jetpack Compose 1.7 Essentials"
  (35/50) The Case of the Crimson Test Suite: An Introduction to Swift Testing
Generating embedding for: "The Case of the Crimson Test Suite: An Introduction to Swift Testing"
  (36/50) Pragmatic Unit Testing in Java with JUnit, Third Edition
Generating embedding for: "Pragmatic Unit Testing in Java with JUnit, Third Edition"
  (37/50) Serverless Apps on Cloudflare: Build Solutions, Not Infrastructure
Generating embedding for: "Serverless Apps on Cloudflare: Build Solutions, Not Infrastructure"
  (38/50) C# 13 Programming Essentials: .NET 9 Edition
Generating embedding for: "C# 13 Programming Essentials: .NET 9 Edition"
  (39/50) Android Studio Koala Essentials-Kotlin Edition
Generating embedding for: "Android Studio Koala Essentials-Kotlin Edition"
  (40/50) Seven Obscure Languages in Seven Weeks: Rediscovering the Tools That Built the Future
Generating embedding for: "Seven Obscure Languages in Seven Weeks: Rediscovering the Tools That Built the Future"
  (41/50) iOS 18 App Development Essentials
Generating embedding for: "iOS 18 App Development Essentials"
  (42/50) Escape Velocity: Better Metrics for Agile Teams
Generating embedding for: "Escape Velocity: Better Metrics for Agile Teams"
  (43/50) Test-Driven React, Second Edition: Find Problems Early, Fix Them Quickly, Code with Confidence
Generating embedding for: "Test-Driven React, Second Edition: Find Problems Early, Fix Them Quickly, Code with Confidence"
  (44/50) Android Studio Koala Essentials-Java Edition
Generating embedding for: "Android Studio Koala Essentials-Java Edition"
  (45/50) Become a Great Engineering Leader: Build Effective Skills to Lead and Grow
Generating embedding for: "Become a Great Engineering Leader: Build Effective Skills to Lead and Grow"
  (46/50) Machine Learning in Elixir: Learning to Learn with Nx and Axon
Generating embedding for: "Machine Learning in Elixir: Learning to Learn with Nx and Axon"
  (47/50) Automate Your Home Using Go: Build a Personal Data Center with Raspberry Pi, Docker, Prometheus, and Grafana
Generating embedding for: "Automate Your Home Using Go: Build a Personal Data Center with Raspberry Pi, Docker, Prometheus, and Grafana"
  (48/50) Server-Driven Web Apps with htmx: Any Language, Less Code, Simpler Code
Generating embedding for: "Server-Driven Web Apps with htmx: Any Language, Less Code, Simpler Code"
  (49/50) The Stress Equation: Reduce Burnout, Increase Happiness and Productivity
Generating embedding for: "The Stress Equation: Reduce Burnout, Increase Happiness and Productivity"
  (50/50) A Common-Sense Guide to Data Structures and Algorithms in JavaScript, Volume 1: Level Up Your Core Programming Skills
Generating embedding for: "A Common-Sense Guide to Data Structures and Algorithms in JavaScript, Volume 1: Level Up Your Core Programming Skills"
file:///Users/markjeffery/Downloads/code/getting_started_with_vector_search/name_this_book.js:50
  return data.data[0].embedding;
                  ^

TypeError: Cannot read properties of undefined (reading '0')
    at getEmbedding (file:///Users/markjeffery/Downloads/code/getting_started_with_vector_search/name_this_book.js:50:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Promise.all (index 1)
    at async embedTitles (file:///Users/markjeffery/Downloads/code/getting_started_with_vector_search/name_this_book.js:119:3)
    at async main (file:///Users/markjeffery/Downloads/code/getting_started_with_vector_search/name_this_book.js:148:13)

Node.js v23.11.0

It looks like it fails at the last book!

Does this look like an error on my side, or yours?

Most Liked

hummusonrails

hummusonrails

Author of Vector Search with JavaScript

Hi @markhjeffery

So glad to hear it is working for you now!

I investigated the issue earlier today and added a few more error handlers to the script’s ingestion of titles from PragProg, making it more resilient. I also updated the package.json to remove that initial error you saw.

You can find the latest code on the book’s GitHub repository. Nothing substantially changed, except for the addition of error handlers and the removal of the initial warning.

Appreciate you bringing it up here!

Ben

markhjeffery

markhjeffery

Thanks for the changes. I had to do a bit of debugging to find the error, good to see that it is handled differently now.

Looking forward to the rest of the book!

Mark

Where Next?

Popular Pragmatic Bookshelf topics Top

jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
New
raul
Page 28: It implements io.ReaderAt on the store type. Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt? ...
New
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
PragmaticBookshelf
Free and open source software is the default choice for the technologies that run our world, and it’s built and maintained by people like...
New
PragmaticBookshelf
Write Elixir tests that you can be proud of. Dive into Elixir’s test philosophy and gain mastery over the terminology and concepts that u...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser. ...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New

Sub Categories: