pyrompt.mall#

Collection of collections - a “mall” of prompt/template stores.

Provides nested access: mall[‘collection_name’][‘prompt_key’]

Classes

PromptMall(workspace_name, *[, base_path, ...])

Collection of collections - a "mall" of stores.

class pyrompt.mall.PromptMall(workspace_name, *, base_path=None, collection_names=None, with_metadata=False)[source]#

Bases: Mapping

Collection of collections - a “mall” of stores.

Provides nested access: mall[‘collection_name’][‘prompt_key’]

Examples

>>> mall = PromptMall('my_workspace')
>>> mall['system']['python_expert'] = "You are a Python expert."
>>> mall['templates']['greeting'] = "Hello {name}!"
>>> list(mall.keys())
['system', 'templates']
>>> results = mall.search('python')
add_collection(name, collection_type='prompt')[source]#

Add a new collection to the mall.

Parameters:
  • name (str) – Collection name

  • collection_type (str) – ‘prompt’ or ‘template’

Example

>>> mall.add_collection('personas', 'prompt')
>>> mall['personas']['analyst'] = "You are a data analyst."
get_collection_type(name)[source]#

Get the type of a collection.

Parameters:

name (str) – Collection name

Return type:

Optional[str]

Returns:

‘prompt’, ‘template’, or None if not found

items()[source]#

Get (name, collection) pairs.

keys()[source]#

Get collection names.

remove_collection(name)[source]#

Remove a collection from the mall.

Note

This only removes it from the mall, not from disk.

Parameters:

name (str) – Collection name

search(query, collections=None, **search_kwargs)[source]#

Search across multiple collections.

Parameters:
  • query (str) – Search query

  • collections (Optional[List[str]]) – Collection names to search (None = all)

  • **search_kwargs – Additional args for SemanticIndex.search

Return type:

Dict[str, List[tuple]]

Returns:

Dict mapping collection_name -> search results

Example

>>> results = mall.search('python expert', top_k=3)
>>> for coll_name, matches in results.items():
...     print(f"\n{coll_name}:")
...     for key, score in matches:
...         print(f"  {key}: {score:.3f}")
values()[source]#

Get collections.