|
499 | 499 | }, |
500 | 500 | { |
501 | 501 | "cell_type": "code", |
502 | | - "execution_count": 29, |
| 502 | + "execution_count": null, |
503 | 503 | "metadata": {}, |
504 | 504 | "outputs": [], |
505 | 505 | "source": [ |
506 | | - "from adalflow.core.types import Embedding\n", |
| 506 | + "from adalflow.core.types import Embedding, EmbedderOutput\n", |
507 | 507 | "from adalflow.core.functional import normalize_vector\n", |
508 | 508 | "from typing import List\n", |
509 | 509 | "from adalflow.core.component import Component\n", |
|
517 | 517 | " assert self.new_dim < self.old_dim, \"new_dim should be less than old_dim\"\n", |
518 | 518 | "\n", |
519 | 519 | " def call(self, input: List[Embedding]) -> List[Embedding]:\n", |
520 | | - " output: List[Embedding] = deepcopy(input)\n", |
521 | | - " for embedding in output:\n", |
| 520 | + " output: EmbedderOutput = deepcopy(input)\n", |
| 521 | + " for embedding in output.data:\n", |
522 | 522 | " old_embedding = embedding.embedding\n", |
523 | 523 | " new_embedding = old_embedding[: self.new_dim]\n", |
524 | 524 | " if self.normalize:\n", |
525 | 525 | " new_embedding = normalize_vector(new_embedding)\n", |
526 | 526 | " embedding.embedding = new_embedding\n", |
527 | | - " return output\n", |
528 | | - " \n", |
529 | | - " def _extra_repr(self) -> str:\n", |
530 | | - " repr_str = f\"old_dim={self.old_dim}, new_dim={self.new_dim}, normalize={self.normalize}\"\n", |
531 | | - " return repr_str" |
| 527 | + " return output.data" |
532 | 528 | ] |
533 | 529 | }, |
534 | 530 | { |
|
0 commit comments