@@ -43,9 +43,9 @@ class while customizing it with any plugins.
4343from genkit .blocks .retriever import IndexerRef , IndexerRequest , RetrieverRef
4444from genkit .core .action import ActionRunContext
4545from genkit .core .action .types import ActionKind
46+ from genkit .core .plugin import Plugin
4647from genkit .core .typing import (
4748 BaseDataPoint ,
48- BaseEvalDataPoint ,
4949 EmbedRequest ,
5050 EmbedResponse ,
5151 EvalRequest ,
@@ -61,8 +61,7 @@ class while customizing it with any plugins.
6161 ToolChoice ,
6262)
6363
64- from ._base import GenkitBase
65- from ._plugin import Plugin
64+ from ._base_async import GenkitBase
6665from ._server import ServerSpec
6766
6867
@@ -328,7 +327,7 @@ async def retrieve(
328327 Args:
329328 retriever: Optional retriever name or reference to use.
330329 query: Text query or a DocumentData containing query text.
331- options: retriever options
330+ options: Optional retriever-specific options.
332331
333332 Returns:
334333 The generated response with documents.
@@ -349,11 +348,20 @@ async def retrieve(
349348 if isinstance (query , str ):
350349 query = Document .from_text (query )
351350
352- final_options = {** (retriever_config or {}), ** (options or {})}
351+ request_options = {** (retriever_config or {}), ** (options or {})}
353352
354- retrieve_action = self .registry .lookup_action (ActionKind .RETRIEVER , retriever_name )
353+ retrieve_action = await self .registry .resolve_action (ActionKind .RETRIEVER , retriever_name )
354+ if retrieve_action is None :
355+ raise ValueError (f'Retriever "{ retriever_name } " not found' )
355356
356- return (await retrieve_action .arun (RetrieverRequest (query = query , options = final_options ))).response
357+ return (
358+ await retrieve_action .arun (
359+ RetrieverRequest (
360+ query = query ,
361+ options = request_options if request_options else None ,
362+ )
363+ )
364+ ).response
357365
358366 async def index (
359367 self ,
@@ -366,7 +374,7 @@ async def index(
366374 Args:
367375 indexer: Optional indexer name or reference to use.
368376 documents: Documents to index.
369- options: indexer options
377+ options: Optional indexer-specific options.
370378 """
371379 indexer_name : str
372380 indexer_config : dict [str , Any ] = {}
@@ -381,11 +389,18 @@ async def index(
381389 else :
382390 raise ValueError ('Indexer must be specified as a string name or an IndexerRef.' )
383391
384- final_options = {** (indexer_config or {}), ** (options or {})}
392+ req_options = {** (indexer_config or {}), ** (options or {})}
385393
386- index_action = self .registry .lookup_action (ActionKind .INDEXER , indexer_name )
394+ index_action = await self .registry .resolve_action (ActionKind .INDEXER , indexer_name )
395+ if index_action is None :
396+ raise ValueError (f'Indexer "{ indexer_name } " not found' )
387397
388- await index_action .arun (IndexerRequest (documents = documents , options = final_options ))
398+ await index_action .arun (
399+ IndexerRequest (
400+ documents = documents ,
401+ options = req_options if req_options else None ,
402+ )
403+ )
389404
390405 async def embed (
391406 self ,
@@ -410,7 +425,9 @@ async def embed(
410425 # Merge options passed to embed() with config from EmbedderRef
411426 final_options = {** (embedder_config or {}), ** (options or {})}
412427
413- embed_action = self .registry .lookup_action (ActionKind .EMBEDDER , embedder_name )
428+ embed_action = await self .registry .resolve_action (ActionKind .EMBEDDER , embedder_name )
429+ if embed_action is None :
430+ raise ValueError (f'Embedder "{ embedder_name } " not found' )
414431
415432 return (await embed_action .arun (EmbedRequest (input = documents , options = final_options ))).response
416433
@@ -445,7 +462,9 @@ async def evaluate(
445462
446463 final_options = {** (evaluator_config or {}), ** (options or {})}
447464
448- eval_action = self .registry .lookup_action (ActionKind .EVALUATOR , evaluator_name )
465+ eval_action = await self .registry .resolve_action (ActionKind .EVALUATOR , evaluator_name )
466+ if eval_action is None :
467+ raise ValueError (f'Evaluator "{ evaluator_name } " not found' )
449468
450469 if not eval_run_id :
451470 eval_run_id = str (uuid .uuid4 ())
0 commit comments