curate_gpt.wrappers package

Subpackages

Submodules

curate_gpt.wrappers.base_wrapper module

Chat with a KB.

class curate_gpt.wrappers.base_wrapper.BaseWrapper(source_locator=None, local_store=None, extractor=None)

Bases: ABC

A virtual store that implements a view over some remote or external source.

chat(query, collection=None, **kwargs)

Chat with a wrapper view (e.g pubmed).

Parameters:
  • query (str)

  • collection (Optional[str])

  • kwargs

Return type:

Any

Returns:

Deprecated since version Use: a chat agent with a wrapper as source instead

create_curie(local_id)

Create a CURIE for the given local ID.

Parameters:

local_id (str)

Return type:

str

Returns:

default_embedding_model = 'openai:'
default_object_type = 'Publication'

Search an external source and return the results.

Parameters:
  • text (str)

  • kwargs

Return type:

List[Dict]

Returns:

extract_concepts_from_text(text, **kwargs)
extractor: Extractor = None
local_store: DBAdapter = None

Adapter to local knowledge base used to cache results.

max_text_length = 3000
name: ClassVar[str] = '__dbview__'
objects(collection=None, object_ids=None, **kwargs)

Return all objects in the view.

Parameters:
  • collection (Optional[str])

  • object_ids (Optional[Iterable[str]]) – Optional list of IDs to fetch

  • kwargs

Return type:

Iterator[Dict]

Returns:

objects_by_ids(object_ids)

Return objects by their IDs.

Parameters:

object_ids (List[str])

Return type:

List[Dict]

Returns:

prefix: ClassVar[str] = None
search(text, collection=None, cache=True, expand=True, limit=None, external_search_limit=None, **kwargs)

Search an external source and cache the results in the local store.

Parameters:
  • text (str)

  • collection (Optional[str]) – used for caching

  • kwargs

Return type:

Iterator[Tuple[DuckDBSearchResult, Dict, float, Optional[Dict]]]

Returns:

search_limit_multiplier: ClassVar[int] = 3
source_locator: Union[str, Path, None] = None
split_objects(objects, text_field='text', id_field='id')

Split objects with text above a certain length into multiple objects.

Parameters:

objects (List[Dict])

Return type:

List[Dict]

Returns:

text_overlap = 200
unwrap_object(obj, store, **kwargs)

Convert an object from the store to the source representation.

reverse transform of as_object

Parameters:
  • obj (Dict[str, Any])

  • store (DBAdapter)

  • kwargs

Return type:

Any

Returns:

wrap_object(obj)

Convert an object from the source representation to the store representation.

Parameters:

obj (Dict)

Return type:

Iterator[Dict]

Returns:

Module contents

Wrappers on top of external data sources.

Wrappers allow for dynamic or static loading of an external data source into a store.

class curate_gpt.wrappers.BaseWrapper(source_locator=None, local_store=None, extractor=None)

Bases: ABC

A virtual store that implements a view over some remote or external source.

chat(query, collection=None, **kwargs)

Chat with a wrapper view (e.g pubmed).

Parameters:
  • query (str)

  • collection (Optional[str])

  • kwargs

Return type:

Any

Returns:

Deprecated since version Use: a chat agent with a wrapper as source instead

create_curie(local_id)

Create a CURIE for the given local ID.

Parameters:

local_id (str)

Return type:

str

Returns:

default_embedding_model = 'openai:'
default_object_type = 'Publication'

Search an external source and return the results.

Parameters:
  • text (str)

  • kwargs

Return type:

List[Dict]

Returns:

extract_concepts_from_text(text, **kwargs)
extractor: Extractor = None
local_store: DBAdapter = None

Adapter to local knowledge base used to cache results.

max_text_length = 3000
name: ClassVar[str] = '__dbview__'
objects(collection=None, object_ids=None, **kwargs)

Return all objects in the view.

Parameters:
  • collection (Optional[str])

  • object_ids (Optional[Iterable[str]]) – Optional list of IDs to fetch

  • kwargs

Return type:

Iterator[Dict]

Returns:

objects_by_ids(object_ids)

Return objects by their IDs.

Parameters:

object_ids (List[str])

Return type:

List[Dict]

Returns:

prefix: ClassVar[str] = None
search(text, collection=None, cache=True, expand=True, limit=None, external_search_limit=None, **kwargs)

Search an external source and cache the results in the local store.

Parameters:
  • text (str)

  • collection (Optional[str]) – used for caching

  • kwargs

Return type:

Iterator[Tuple[DuckDBSearchResult, Dict, float, Optional[Dict]]]

Returns:

search_limit_multiplier: ClassVar[int] = 3
source_locator: Union[str, Path, None] = None
split_objects(objects, text_field='text', id_field='id')

Split objects with text above a certain length into multiple objects.

Parameters:

objects (List[Dict])

Return type:

List[Dict]

Returns:

text_overlap = 200
unwrap_object(obj, store, **kwargs)

Convert an object from the store to the source representation.

reverse transform of as_object

Parameters:
  • obj (Dict[str, Any])

  • store (DBAdapter)

  • kwargs

Return type:

Any

Returns:

wrap_object(obj)

Convert an object from the source representation to the store representation.

Parameters:

obj (Dict)

Return type:

Iterator[Dict]

Returns:

curate_gpt.wrappers.get_wrapper(name, **kwargs)
Return type:

BaseWrapper