Commit ba805bb
authored
feat: implement search with ✨jAI (#202)
## Description
<!-- Please add PR description (don't leave blank) - example: This PR
[adds/removes/fixes/replaces] the [feature/bug/etc] -->
This pull request introduces a new "Search with ✨jAI" feature to the
word search experience; before this, whenever a word was searched and it
didn't exist in the dictionary, we'd get a `No Result Found` feedback,
but now we get this options replacing the no found with search for the
word with ✨jAI.
This feature enable us route to a page where the meaning to that word is
generated on the fly using ✨jAI.
### Notable Changes
**1. AI-powered word definitions and prompt improvements**
- Added a new dedicated prompt template (`SEARCH_WORD`) in
`jai-prompts.js` for generating structured, SEO-friendly definitions,
and moved the original personality prompt to this file.
(`apps/jai/lib/jai-prompts.js`, `apps/jai/lib/jai-prompt.js` removed,
`apps/jai/index.js`, `apps/jai/README.md`)
[[1]](diffhunk://#diff-815b78cdf6ccc854f55ec0c701767e3969f07ce877749fb919892873cdc28712R1-R74)
[[2]](diffhunk://#diff-82c094682b612a0966e5684b3ad170b5814750d54ff6d0c8be39f8aa6d2f52ecL1-L36)
[[3]](diffhunk://#diff-5439cc07d5881e2e44a6e29b3126ebe43820b54254eca7a57282cf3bca01b122L3-R6)
[[4]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6L52-R65)
- Updated documentation to describe the new AI-powered word definition
feature and explain the structure and style of generated definitions.
(`apps/jai/README.md`)
[[1]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6R15)
[[2]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6L52-R65)
**2. New React UI components for ✨jAI integration**
- Added `logo.jsx`, a reusable SVG React component for ✨jAI branding.
(`apps/jai/components/logo.jsx`)
- Added `word-search.jsx`, a React component for generating and
displaying AI-powered word definitions, including error handling,
loading states, and a trigger component for UI integration.
(`apps/jai/components/word-search.jsx`)
- Integrated the `JAIWordSearchTrigger` into the main search UI for easy
access to AI-powered definitions. (`src/components/islands/search.jsx`)
**3. Documentation and architecture updates**
- Expanded the `README.md` to clarify the module structure, document new
components, and explain the updated integration flow, including the new
`/api/jai/search` endpoint. (`apps/jai/README.md`)
[[1]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6R36-R40)
[[2]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6R87-R108)
[[3]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6L114-R159)
**4. Model selection and configuration**
- Changed the default OpenAI chat model to `gpt-4.1-mini` for both local
development (`.env.example`) and documentation, and added detailed notes
about model selection strategy for different ✨jAI features.
(`.env.example`, `apps/jai/lib/model.js`, `apps/jai/README.md`)
[[1]](diffhunk://#diff-a3046da0d15a27e89f2afe639b25748a7ad4d9290af3e7b1b6c1a5533c8f0a8cL16-R16)
[[2]](diffhunk://#diff-f74c575d26128dd8394213eb0a7cdb8be7e0618fba3bfc1254ac1dbcf3c3942eR1-R29)
[[3]](diffhunk://#diff-b9fdf9d9f9a7a0c8030ced20f610c30cf1ddddb9918ea834e387e3e6f5e8adf6R87-R108)
**5. Minor cleanups**
- Removed unused or problematic files from `.prettierignore` to reduce
noise in formatting tools. (`.prettierignore`)
These changes collectively enhance the user experience, developer
clarity, and the overall flexibility of the `apps/jai` module for future
features and scaling.
## Related Issue
<!-- Please prefix the issue number with Fixes/Resolves - example: Fixes
#123 or Resolves #123 -->
Fixes jargonsdev/roadmap#8
## Screenshots/Screencasts
<!-- Please provide screenshots or video recording that demos your
changes (especially if it's a visual change) -->
[screen-capture
(5).webm](https://github.com/user-attachments/assets/ff67fd8d-1d3f-4ab3-bbea-04588228dfb8)
### Search for word that a not technical term or not related to
software, programming ec. fields
<img width="1128" height="671" alt="image"
src="https://github.com/user-attachments/assets/ab943964-ce0f-4ed8-a4fd-bdbf0cb5b16d"
/>
## Notes to Reviewer
<!-- Please state here if you added a new npm packages, or any extra
information that can help reviewer better review you changes -->
- Confirm presence of the ✨jAI related environmental variables for this
to work in production1 parent dc19203 commit ba805bb
File tree
16 files changed
+512
-83
lines changed- apps/jai
- components
- lib
- public
- src
- components
- islands
- pages
- api/jai
- browse/with-jai
16 files changed
+512
-83
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | | - | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | | - | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
81 | 101 | | |
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
85 | 105 | | |
86 | 106 | | |
87 | 107 | | |
88 | | - | |
| 108 | + | |
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
| |||
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
114 | | - | |
| 134 | + | |
115 | 135 | | |
116 | 136 | | |
117 | 137 | | |
118 | 138 | | |
119 | 139 | | |
120 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
121 | 150 | | |
122 | | - | |
| 151 | + | |
123 | 152 | | |
124 | 153 | | |
125 | 154 | | |
126 | 155 | | |
127 | | - | |
128 | | - | |
129 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
130 | 160 | | |
131 | 161 | | |
132 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
This file was deleted.
0 commit comments