php-llm / llm-chain

PHP library for building LLM-based features and applications.
MIT License
12 stars 3 forks source link

refactor: split `Document` into `TextDocument` and `VectorDocument` #110

Closed chr-hertel closed 1 month ago

chr-hertel commented 1 month ago

Based on

Goal

TextDocument and VectorDocument - both have an UUID and Metadata

/**
 * @param TextDocument|TextDocument[] $documents
 */
DocumentEmbedder::create(TextDocument|array $documents, ...): void

// only converting than

$vectorDocuments[] = new VectorDocument($vectors[$i], $document->id, $document->metadata);

// and drop text in store context completely

/**
 * @param VectorDocument|VectorDocument[] $documents
 **/
StoreInterface::add(VectorDocument ...$documents): void;

/**
 * @return VectorDocument[]
 */
VectorStoreInterface::query(Vector $vector, array $options = []): array;
OskarStark commented 1 month ago

I like this PR

chr-hertel commented 1 month ago

from my side ready to merge - any final thoughts?