Skip to content

Conversation

dsblank
Copy link
Member

@dsblank dsblank commented Sep 1, 2025

This WIP PR is designed to add a library of well-designed functions for chatbots, and perhaps other uses.

It is based on initial code by @MelleKoning

Goals:

  1. Use cached values when available
  2. Use raw data dicts to save time
  3. Don't overwhelm the caller with too much information
  4. Be consistent in all functions
  5. WIP: Don't use SimpleAccess or other expensive functions

Example use:

>>> from gramps.gen.db.utils import open_database
>>> db = open_database("Gramps Example", force_unlock=True)
>>> chat_db = ChatFunctions(db)
>>> tool_dict = chat_db.tools
>>> chat_db.find_people_by_name("Elizabeth")
{'handles': ['0MNKQC4STYXCRR1OV9',
  '0MVKQC8TKZIUOU43D1',
  '0N5KQCOL9V736M3WN4',
  '0PWJQCZYFXOS0HGREE',
  '14LKQCYZJEAXTS3XX',
  '1U6KQCBEC0LQKJRB7L',
  '274KQCCGGPRCM07JFX',
  '3K4KQCVYX5YU850Q3Z',
  '3PCKQC79CKJ9CVILU3',
  '3XXKQCNYIPE8OBN1J7',
  '47IKQCKIPBSO0NVZX8',
  '4M7KQCV9KPB6ULMFC',
  '6SOKQCKO2ZIW88CAZ',
  '7HZJQCK2XOH4RPJZSM',
  '7RPKQC1Y4KDHK2VUMU',
  '8PIKQCK6LASSBFJFWH',
  '9AWKQCBNBUNW4UVG7Z',
  'A99KQCNCKNWLGM2W6K',
  'AVWKQCFEVZ1VAPVY8O',
  'AZVKQCKR0GCKRZ0GAL',
  'BBUKQC5GPRPDJHJAWU',
  'BHVJQCYNVES2ZING51',
  'BOVJQCDMWND9J66TFT',
  'CV1KQC38YN9X7A1N9Y',
  'DRVKQCWBHRA73FRCOK'],
 'page': 1,
 'page_size': 25,
 'has_more': True}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant