Skip to content

feat: add AppwriteEmbeddingAdapter and corresponding tests; update do…#32

Merged
abnegate merged 10 commits into
mainfrom
appwrite-embedding-adapter
May 28, 2026
Merged

feat: add AppwriteEmbeddingAdapter and corresponding tests; update do…#32
abnegate merged 10 commits into
mainfrom
appwrite-embedding-adapter

Conversation

@ArnabChatterjee20k
Copy link
Copy Markdown
Contributor

…cker-compose for embedding service

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 27, 2026

Greptile Summary

This PR introduces a new Appwrite embedding adapter that communicates with a local embedding service, adds an abstract bulkEmbed() method to the Adapter base class, and implements stubs for all non-embedding adapters to satisfy the new contract.

  • src/Agents/Adapters/Appwrite.php: New embedding-only adapter supporting four models (nomic, gemma, minilm, bge-small); embed() delegates to bulkEmbed() for a single text, response validation guards both count mismatch and empty rows.
  • src/Agents/Adapter.php / Agent.php: bulkEmbed() added as an abstract method; modelLoadingDuration marked optional in the embed() phpdoc across the contract and Agent.
  • docker-compose.yml: Adds the appwrite-embedding service with a persistent volume for model caching.

Confidence Score: 5/5

The changes are well-scoped: the new Appwrite adapter correctly validates input, delegates to a single batch HTTP request, and guards response shape. All non-embedding adapters receive minimal throw-stubs that satisfy the new abstract contract without changing existing behavior.

The core logic in Appwrite::bulkEmbed() is sound — count validation, row-shape checks, and null-safe token/duration extraction are all present. The Ollama loop correctly propagates exceptions and handles null fields. No regressions were introduced to existing adapters.

The shared adapter test base (tests/Agents/Adapters/Adapter.php) has no coverage for the new bulkEmbed abstract method, so the behavior of every adapter's implementation is untested at the contract level.

Important Files Changed

Filename Overview
src/Agents/Adapters/Appwrite.php New embedding-only adapter; correctly validates model, delegates embed() to bulkEmbed(), validates response count and row shape, and exposes getEndpoint/setEndpoint for test overrides.
src/Agents/Adapter.php Added abstract bulkEmbed() and made modelLoadingDuration optional in the embed() return-type doc; both changes are consistent with the new adapter design.
src/Agents/Adapters/Ollama.php Added bulkEmbed() that loops over individual embed() calls; sequential N-request design is documented in the method comment.
tests/Agents/Adapters/AppwriteTest.php New integration tests covering invalid-model construction, unsupported send(), single embed, bulk embed count, and order-preservation; requires the docker-compose embedding service to be running.
tests/Agents/AgentTest.php Removed modelLoadingDuration assertions; Ollama still returns this field so the removed assertions were valid coverage for that adapter.

Reviews (7): Last reviewed commit: "updated" | Re-trigger Greptile

Comment thread src/Agents/Adapters/Appwrite.php
Comment thread docker-compose.yml Outdated
$this->assertArrayHasKey('embedding', $result);
$this->assertArrayHasKey('tokensProcessed', $result);
$this->assertArrayHasKey('totalDuration', $result);
$this->assertArrayHasKey('modelLoadingDuration', $result);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing assertion for modelLoadingDuration as its of no use.

… add bulkEmbed method to ConversationFakeAdapter
Comment thread tests/Agents/Adapters/Adapter.php Outdated
@abnegate abnegate merged commit 47fb628 into main May 28, 2026
17 of 21 checks passed
@abnegate abnegate deleted the appwrite-embedding-adapter branch May 28, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants