pyrompt.mall#
Collection of collections - a “mall” of prompt/template stores.
Provides nested access: mall[‘collection_name’][‘prompt_key’]
Classes
|
Collection of collections - a "mall" of stores. |
- class pyrompt.mall.PromptMall(workspace_name, *, base_path=None, collection_names=None, with_metadata=False)[source]#
Bases:
MappingCollection 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.
Example
>>> mall.add_collection('personas', 'prompt') >>> mall['personas']['analyst'] = "You are a data analyst."
- 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:
- Return type:
- 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}")