Repository navigation
Commit d6a40f4
committed
AI: Introduce support for generating embeddings
Update the bundled PHP AI Client from 1.3.1 to 1.5.0 and introduce `wp_ai_client_embedding()` and `WP_AI_Client_Embedding_Builder` for generating embedding vectors from text and file inputs. Accept multiple inputs as variadic arguments or a single list, and require an explicit model to keep vectors comparable.
Extract shared prompt and embedding builder behavior into the internal `WP_AI_Client_Builder` base class, including fluent method proxying, `WP_Error` handling, request timeouts, and clone isolation. Add the `wp_ai_client_prevent_embedding` filter and embedding lifecycle actions, and pass the builder type to the existing timeout filter.
Include tests for embedding input handling, model selection, error handling, filters, lifecycle actions, and clone isolation.
Developed in: #12530.
Props jason_the_adams, gziolo, dkotter, jorgefilipecosta, extrachill, ugyensupport, jeffpaul, jorbin, saadtajik, vedantere, arkaprabhachowdhury, jamesbregenzer.
Fixes #65638.
git-svn-id: https://develop.svn.wordpress.org/trunk@64327 602fd350-edb4-49c9-b593-d223f7449a821 parent 10d3940 commit d6a40f4
27 files changed
Lines changed: 3826 additions & 642 deletions
File tree
- src
- wp-includes
- ai-client
- adapters
- php-ai-client/src
- Builders
- Traits
- Events
- Files/Enums
- Messages/Util
- Providers
- ApiBasedImplementation
- Models
- DTO
- EmbeddingGeneration/Contracts
- Enums
- Results/DTO
- Tools/DTO
- tests/phpunit/tests/ai-client
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
60 | 61 | | |
61 | 62 | | |
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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
0 commit comments