core / action / action_library¶
core.action.action_library
¶
Updated ActionLibrary that delegates database operations to the new DatabaseInterface.
Created on Thu Mar 27 21:29:03 2025 Author: zfoong
ActionLibrary
¶
Manages storing, retrieving, and modifying actions via DatabaseInterface.
Source code in core\action\action_library.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
__init__(llm_interface, db_interface)
¶
Initialize the library responsible for persisting actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm_interface
|
LLM client used elsewhere for generating actions. |
required | |
db_interface
|
DatabaseInterface
|
Database gateway that handles MongoDB/ChromaDB storage. |
required |
Source code in core\action\action_library.py
23 24 25 26 27 28 29 30 31 32 | |
store_action(action)
¶
Persist an action definition and stamp its update time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action
|
Action instance to serialize and store. |
required |
Source code in core\action\action_library.py
34 35 36 37 38 39 40 41 42 43 | |
retrieve_action(action_name)
¶
Fetch a single action by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_name
|
str
|
Case-insensitive name of the action to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Action]
|
Optional[Action]: Hydrated action instance if found, otherwise |
Source code in core\action\action_library.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
retrieve_default_action()
¶
Retrieve actions marked as defaults. These actions are always available to the agents regardless of the mode.
Returns:
| Type | Description |
|---|---|
List[Action]
|
List[Action]: All default actions stored in the database. |
Source code in core\action\action_library.py
60 61 62 63 64 65 66 67 68 69 | |
search_action(query, top_k=50)
¶
Search for actions using vector similarity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Natural-language description of the desired action. |
required |
top_k
|
Maximum number of action names to return. |
50
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Ranked list of matching action names. |
Source code in core\action\action_library.py
77 78 79 80 81 82 83 84 85 86 87 88 | |
delete_action(action_name)
¶
Deletes an action from both MongoDB and ChromaDB.
Source code in core\action\action_library.py
90 91 92 | |