Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make optional lunary import #43

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/storage/default__vector_store.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/storage/docstore.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/storage/graph_store.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"graph_dict": {}}
1 change: 1 addition & 0 deletions examples/storage/image__vector_store.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"embedding_dict": {}, "text_id_to_ref_doc_id": {}, "metadata_dict": {}}
1 change: 1 addition & 0 deletions examples/storage/index_store.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"index_store/data": {"054dfe73-4432-4ae1-8d29-639e6709a98d": {"__type__": "vector_store", "__data__": "{\"index_id\": \"054dfe73-4432-4ae1-8d29-639e6709a98d\", \"summary\": null, \"nodes_dict\": {\"b149d3cc-689d-4f26-b353-16439088ca72\": \"b149d3cc-689d-4f26-b353-16439088ca72\", \"44b5610f-cecd-4d7a-97be-8cdb3fc13e78\": \"44b5610f-cecd-4d7a-97be-8cdb3fc13e78\", \"613ec807-5205-4118-86fc-402fc5043193\": \"613ec807-5205-4118-86fc-402fc5043193\", \"ed330099-5fd7-4b59-ae8f-de61603834a1\": \"ed330099-5fd7-4b59-ae8f-de61603834a1\", \"c3c71c23-a8e1-4960-836e-a9977a52978c\": \"c3c71c23-a8e1-4960-836e-a9977a52978c\", \"0f3e7585-2d9e-47a2-9160-13988cb33174\": \"0f3e7585-2d9e-47a2-9160-13988cb33174\", \"6228bca7-ad9a-4185-bc79-b640443e134d\": \"6228bca7-ad9a-4185-bc79-b640443e134d\", \"360e0afc-e3da-4821-ae2e-9c1ec4b1732f\": \"360e0afc-e3da-4821-ae2e-9c1ec4b1732f\", \"4e7e7317-6f4f-4416-b3e4-ae018015ac80\": \"4e7e7317-6f4f-4416-b3e4-ae018015ac80\", \"fd36adc2-37f9-4ad4-a426-6770016f12f9\": \"fd36adc2-37f9-4ad4-a426-6770016f12f9\", \"bf86589a-fd3c-4cb0-bb70-6f48127b8ffc\": \"bf86589a-fd3c-4cb0-bb70-6f48127b8ffc\", \"a4940728-db2e-4cd8-be95-7195b3dfb533\": \"a4940728-db2e-4cd8-be95-7195b3dfb533\", \"9d084b67-ff6e-4a67-98d3-47cced2874a1\": \"9d084b67-ff6e-4a67-98d3-47cced2874a1\", \"78df144c-bc86-4e2b-aed3-96b66bde771f\": \"78df144c-bc86-4e2b-aed3-96b66bde771f\", \"fe6bdfde-6be3-4e0e-af50-16bff9ddad74\": \"fe6bdfde-6be3-4e0e-af50-16bff9ddad74\", \"2161c02e-03df-4aa9-8e34-ff3000a77b37\": \"2161c02e-03df-4aa9-8e34-ff3000a77b37\", \"e7a75a47-1d28-418d-950c-1c034d35996f\": \"e7a75a47-1d28-418d-950c-1c034d35996f\", \"0c6031c1-c4cf-4f5d-9935-a320b9a9e2d7\": \"0c6031c1-c4cf-4f5d-9935-a320b9a9e2d7\", \"8d26b47a-3abf-4264-828e-2fa35f38f761\": \"8d26b47a-3abf-4264-828e-2fa35f38f761\", \"19433b47-c110-4414-a502-884227890bca\": \"19433b47-c110-4414-a502-884227890bca\", \"221543e9-59fc-484a-b10c-eae7b05ee088\": \"221543e9-59fc-484a-b10c-eae7b05ee088\", \"ade12ce7-de32-4834-8d3b-68b88d2d3446\": \"ade12ce7-de32-4834-8d3b-68b88d2d3446\", \"ec397702-8c56-42bf-80e4-dab6b8bea6c0\": \"ec397702-8c56-42bf-80e4-dab6b8bea6c0\", \"88981ae8-c9d7-4e56-ad0b-1b935125b1b5\": \"88981ae8-c9d7-4e56-ad0b-1b935125b1b5\", \"577280e4-d01d-48f5-a483-71f2449452ed\": \"577280e4-d01d-48f5-a483-71f2449452ed\", \"49458309-d220-443c-860f-77587cc652a4\": \"49458309-d220-443c-860f-77587cc652a4\", \"b4964465-f334-40b5-8656-c2695c10b429\": \"b4964465-f334-40b5-8656-c2695c10b429\", \"d3f3ba18-2baf-4b6f-a2f0-8e8773c5c5e1\": \"d3f3ba18-2baf-4b6f-a2f0-8e8773c5c5e1\", \"594605fb-9d80-477c-9c68-3f0deab7e0db\": \"594605fb-9d80-477c-9c68-3f0deab7e0db\", \"0382c01f-8099-4c16-a99b-6f589ff01f77\": \"0382c01f-8099-4c16-a99b-6f589ff01f77\", \"409e4fff-49ff-4f6f-b009-507b21d5ad91\": \"409e4fff-49ff-4f6f-b009-507b21d5ad91\", \"d7591a94-4aca-44ad-be3e-2ad21c42ff46\": \"d7591a94-4aca-44ad-be3e-2ad21c42ff46\", \"cd531046-bc7b-4774-9c83-57c55a3ebd32\": \"cd531046-bc7b-4774-9c83-57c55a3ebd32\", \"6fa2acf1-e2a5-4808-9532-bbd0a60b1244\": \"6fa2acf1-e2a5-4808-9532-bbd0a60b1244\", \"3b1e525e-a38b-4610-9ba7-24f3edb93c07\": \"3b1e525e-a38b-4610-9ba7-24f3edb93c07\", \"acbc3902-5c06-48aa-9fb8-82cf36b7b4a5\": \"acbc3902-5c06-48aa-9fb8-82cf36b7b4a5\", \"838b9c4d-4c82-4d39-991a-f81d34735ae8\": \"838b9c4d-4c82-4d39-991a-f81d34735ae8\", \"f943d921-85c2-4e6b-ae95-8d1d2798c5e2\": \"f943d921-85c2-4e6b-ae95-8d1d2798c5e2\", \"7ce6f5d7-a086-41c7-9953-059766bdfd2d\": \"7ce6f5d7-a086-41c7-9953-059766bdfd2d\", \"4a7025e4-56cf-4c28-8ec5-31e7f4ac0324\": \"4a7025e4-56cf-4c28-8ec5-31e7f4ac0324\", \"9c2e2c92-09f3-4387-bf99-88f16a46dfe6\": \"9c2e2c92-09f3-4387-bf99-88f16a46dfe6\", \"84ac3452-ed2d-4d25-8a2a-c884780c8a81\": \"84ac3452-ed2d-4d25-8a2a-c884780c8a81\", \"3e654bf5-39cf-429c-ae5a-c4ca8cad4fbd\": \"3e654bf5-39cf-429c-ae5a-c4ca8cad4fbd\", \"c8726679-d4b1-453d-b80b-7356d1f3d106\": \"c8726679-d4b1-453d-b80b-7356d1f3d106\", \"b06fcbb2-a5a0-4f41-8624-ca3414cf9864\": \"b06fcbb2-a5a0-4f41-8624-ca3414cf9864\", \"6209c4aa-f931-4201-bbd7-649f7814b6e9\": \"6209c4aa-f931-4201-bbd7-649f7814b6e9\", \"fbffcdbc-8c24-4c76-96be-b98c437c33d5\": \"fbffcdbc-8c24-4c76-96be-b98c437c33d5\", \"ba462fc5-36dd-4404-82c8-9710647250b8\": \"ba462fc5-36dd-4404-82c8-9710647250b8\", \"3e104703-b069-4fd4-8a43-e07c0021c35e\": \"3e104703-b069-4fd4-8a43-e07c0021c35e\", \"3d8a8a82-a766-415a-9cc9-6fdc66df36e5\": \"3d8a8a82-a766-415a-9cc9-6fdc66df36e5\", \"b95fbb53-1705-4496-a620-a793b30d3e50\": \"b95fbb53-1705-4496-a620-a793b30d3e50\", \"58caf546-e2d1-4fb2-8b21-e9d42089c5d4\": \"58caf546-e2d1-4fb2-8b21-e9d42089c5d4\", \"b5a026c9-169e-4ae5-ab2e-e48b8f23e241\": \"b5a026c9-169e-4ae5-ab2e-e48b8f23e241\", \"b980aba6-8b7c-489f-ba35-8dff2ec1de80\": \"b980aba6-8b7c-489f-ba35-8dff2ec1de80\", \"a1c0f322-b4b8-45b5-93ca-0407dac2bacb\": \"a1c0f322-b4b8-45b5-93ca-0407dac2bacb\", \"ad52604a-f9ca-42d2-8ca6-67a3f38ae197\": \"ad52604a-f9ca-42d2-8ca6-67a3f38ae197\", \"3f39d949-a855-486b-92e3-5834b3fa7adf\": \"3f39d949-a855-486b-92e3-5834b3fa7adf\", \"c9ce64c8-5fa5-4aaf-9bf4-fe5e6b08f304\": \"c9ce64c8-5fa5-4aaf-9bf4-fe5e6b08f304\", \"e45f3570-386a-499f-8d45-d56fd052a620\": \"e45f3570-386a-499f-8d45-d56fd052a620\", \"fb0183aa-3998-4fa0-8a02-c52a53dae07d\": \"fb0183aa-3998-4fa0-8a02-c52a53dae07d\", \"e859231e-3f9d-42f1-ae7d-0bacb4ffd650\": \"e859231e-3f9d-42f1-ae7d-0bacb4ffd650\", \"a5fc4fb6-70e9-4fec-9325-17df15f8034a\": \"a5fc4fb6-70e9-4fec-9325-17df15f8034a\", \"246def6e-fa1c-4cba-be79-7e93c25c0a20\": \"246def6e-fa1c-4cba-be79-7e93c25c0a20\", \"9b23dd70-8515-47b6-b7ed-b1f7a9bbcded\": \"9b23dd70-8515-47b6-b7ed-b1f7a9bbcded\", \"f823cd9e-1c54-48fe-91ba-fe1dd37e4d83\": \"f823cd9e-1c54-48fe-91ba-fe1dd37e4d83\", \"af6b527a-7010-4270-ac2f-d1345c0c9a0c\": \"af6b527a-7010-4270-ac2f-d1345c0c9a0c\", \"3f80278a-1aa2-4f66-ae1c-15f9107d2888\": \"3f80278a-1aa2-4f66-ae1c-15f9107d2888\", \"ed56d1ec-d5d8-43d9-bfa2-ec0df8b4637d\": \"ed56d1ec-d5d8-43d9-bfa2-ec0df8b4637d\", \"2e5a8439-2c6e-467a-8a4f-6052a7569921\": \"2e5a8439-2c6e-467a-8a4f-6052a7569921\", \"b6697a3e-b92f-4852-b044-d42338f56b76\": \"b6697a3e-b92f-4852-b044-d42338f56b76\", \"2f383320-3aac-4dbc-b397-5e7106c9ce5c\": \"2f383320-3aac-4dbc-b397-5e7106c9ce5c\", \"7870944b-22da-4277-8099-f1f4b2e93ea8\": \"7870944b-22da-4277-8099-f1f4b2e93ea8\", \"62826853-fb8b-42a6-ab1a-d017ee83ab0d\": \"62826853-fb8b-42a6-ab1a-d017ee83ab0d\", \"2e278148-bb67-479e-9cbc-71fce6bf47e8\": \"2e278148-bb67-479e-9cbc-71fce6bf47e8\", \"980113ee-65cf-4cfd-8ff3-16e3f2f74f0e\": \"980113ee-65cf-4cfd-8ff3-16e3f2f74f0e\", \"0d6bb14b-f870-4613-8417-a99a2f4bacf7\": \"0d6bb14b-f870-4613-8417-a99a2f4bacf7\", \"ada4c3c5-f37a-45e7-a770-4b24fe6d1bee\": \"ada4c3c5-f37a-45e7-a770-4b24fe6d1bee\", \"836cd09b-ca0e-45c8-bb7c-11f10a6d9422\": \"836cd09b-ca0e-45c8-bb7c-11f10a6d9422\", \"57d27f22-b8d9-4209-a957-abcb7cf6f806\": \"57d27f22-b8d9-4209-a957-abcb7cf6f806\", \"a6e2834f-9b7c-4230-8acb-6df6de10015c\": \"a6e2834f-9b7c-4230-8acb-6df6de10015c\", \"e4e97020-e167-4bc7-8ffe-d0fa5c9f8276\": \"e4e97020-e167-4bc7-8ffe-d0fa5c9f8276\", \"63ca57b0-336e-42e3-aece-babab67d445d\": \"63ca57b0-336e-42e3-aece-babab67d445d\", \"c61da399-36ed-4a7d-a6b8-b67f4e3f0d96\": \"c61da399-36ed-4a7d-a6b8-b67f4e3f0d96\", \"9e24b4fa-9c8c-46ad-9553-2ef142e49468\": \"9e24b4fa-9c8c-46ad-9553-2ef142e49468\", \"bd146991-a71d-423b-9eeb-a87c7fe84f95\": \"bd146991-a71d-423b-9eeb-a87c7fe84f95\", \"0a35b51f-a5f1-4622-a3ab-ccede72da8c9\": \"0a35b51f-a5f1-4622-a3ab-ccede72da8c9\", \"ca2ecc26-73ae-49b3-bbff-1fe8cba0e4d7\": \"ca2ecc26-73ae-49b3-bbff-1fe8cba0e4d7\", \"c85507e5-1d40-4313-9aac-13e9b15a2257\": \"c85507e5-1d40-4313-9aac-13e9b15a2257\", \"38432c8c-94ef-4084-ba86-26b6684a0b0c\": \"38432c8c-94ef-4084-ba86-26b6684a0b0c\", \"6cfe4d41-a073-4fcc-ba03-5a6edbd9478f\": \"6cfe4d41-a073-4fcc-ba03-5a6edbd9478f\", \"581b8ad6-ae2d-4ccd-b773-00d6cc903976\": \"581b8ad6-ae2d-4ccd-b773-00d6cc903976\", \"310f68de-09ca-4cc1-a2b5-29325b98def8\": \"310f68de-09ca-4cc1-a2b5-29325b98def8\", \"21a8230a-56ec-40cb-9e78-f138c1410209\": \"21a8230a-56ec-40cb-9e78-f138c1410209\", \"57303b22-4e61-4db0-b74f-6205f04aadaa\": \"57303b22-4e61-4db0-b74f-6205f04aadaa\", \"50136847-ac81-48b5-bd31-5a5ce26e2012\": \"50136847-ac81-48b5-bd31-5a5ce26e2012\", \"15527974-c566-48fc-94f8-9d71a3ec666c\": \"15527974-c566-48fc-94f8-9d71a3ec666c\", \"ccfd6fef-e831-49ac-bcf4-f5cac9b72f1e\": \"ccfd6fef-e831-49ac-bcf4-f5cac9b72f1e\", \"f9457a7b-b436-4c64-88c6-3d57c24ba78d\": \"f9457a7b-b436-4c64-88c6-3d57c24ba78d\", \"37da3683-76f6-48b2-b6cb-d2fa080f8261\": \"37da3683-76f6-48b2-b6cb-d2fa080f8261\", \"6e77cb0e-50b8-4e91-9793-f45ad3e9a6c0\": \"6e77cb0e-50b8-4e91-9793-f45ad3e9a6c0\", \"20995b25-cd48-435c-aa02-5f29e874448e\": \"20995b25-cd48-435c-aa02-5f29e874448e\", \"5bd46081-f627-497b-ac4a-bbdaad90e21a\": \"5bd46081-f627-497b-ac4a-bbdaad90e21a\", \"b9f3efbf-130c-40ed-88d7-4cc77c1edb37\": \"b9f3efbf-130c-40ed-88d7-4cc77c1edb37\", \"c38bdc1d-de1c-46d4-99dc-ea8d12de0b43\": \"c38bdc1d-de1c-46d4-99dc-ea8d12de0b43\", \"43731fdd-a6bc-4899-8eb1-ed35b1d59e5e\": \"43731fdd-a6bc-4899-8eb1-ed35b1d59e5e\", \"0e84608b-5ec3-423a-b395-a04d4dbff0b2\": \"0e84608b-5ec3-423a-b395-a04d4dbff0b2\", \"a69ebb50-52c1-41ed-9cbf-0477d63ffe68\": \"a69ebb50-52c1-41ed-9cbf-0477d63ffe68\", \"d05528f3-2733-450b-aa64-0ccbd09e838e\": \"d05528f3-2733-450b-aa64-0ccbd09e838e\", \"7f88c850-dc42-4ada-9c74-95aa4ed98ee9\": \"7f88c850-dc42-4ada-9c74-95aa4ed98ee9\", \"426dcb17-db27-4cd2-b12d-02cc27c84431\": \"426dcb17-db27-4cd2-b12d-02cc27c84431\", \"c4496084-a51c-4bf0-94f5-160b20d678ce\": \"c4496084-a51c-4bf0-94f5-160b20d678ce\", \"6d8b8f1a-89c2-487a-8844-482183c63038\": \"6d8b8f1a-89c2-487a-8844-482183c63038\", \"564a5c1d-5c36-47ca-bd7f-0d113924e2a2\": \"564a5c1d-5c36-47ca-bd7f-0d113924e2a2\", \"ad19c32c-4cf8-453b-a7d2-9a9af5a7805c\": \"ad19c32c-4cf8-453b-a7d2-9a9af5a7805c\", \"644e2c55-59fa-48ed-b030-8e492a702a3d\": \"644e2c55-59fa-48ed-b030-8e492a702a3d\", \"cd5b393c-a302-4dc4-8a97-4ad891c0cfdf\": \"cd5b393c-a302-4dc4-8a97-4ad891c0cfdf\", \"c090e675-5759-4659-b375-6b0c78932caa\": \"c090e675-5759-4659-b375-6b0c78932caa\", \"59ce0f1e-9992-4ac2-a75b-bddeb68cda09\": \"59ce0f1e-9992-4ac2-a75b-bddeb68cda09\", \"c8fbb361-aa80-4e3f-ae38-c711aad928e2\": \"c8fbb361-aa80-4e3f-ae38-c711aad928e2\", \"22ab8bb9-b297-4e3f-ac1a-4cae1d3fe104\": \"22ab8bb9-b297-4e3f-ac1a-4cae1d3fe104\", \"d1037cf9-fb72-432f-81fd-4f2ea05c704b\": \"d1037cf9-fb72-432f-81fd-4f2ea05c704b\", \"39b95165-ec7f-444f-9eec-b3ebf5e16dbf\": \"39b95165-ec7f-444f-9eec-b3ebf5e16dbf\", \"dbe3093a-3688-4d74-9c68-ca309c2730bd\": \"dbe3093a-3688-4d74-9c68-ca309c2730bd\", \"63de9613-8762-474f-8d19-8fe297475cf3\": \"63de9613-8762-474f-8d19-8fe297475cf3\", \"d8e7b605-9ffc-4261-bf15-c018fd3673cb\": \"d8e7b605-9ffc-4261-bf15-c018fd3673cb\", \"9a7d07c5-5f9d-4e05-8ecc-647f4556b9d2\": \"9a7d07c5-5f9d-4e05-8ecc-647f4556b9d2\", \"5da80d7c-55ce-4536-9c8e-a92b000b5c8e\": \"5da80d7c-55ce-4536-9c8e-a92b000b5c8e\", \"4b4bc158-914b-4da4-bdc0-00219d32ae9f\": \"4b4bc158-914b-4da4-bdc0-00219d32ae9f\", \"9380c4aa-e943-4d63-b18c-d896eca0c1ab\": \"9380c4aa-e943-4d63-b18c-d896eca0c1ab\", \"3468fbbe-a2d1-4913-a963-82bda3856436\": \"3468fbbe-a2d1-4913-a963-82bda3856436\", \"c2bd44e5-51a7-4757-8b88-110fe86b93ed\": \"c2bd44e5-51a7-4757-8b88-110fe86b93ed\", \"6600635e-64e6-4fe1-8644-897239fd12cc\": \"6600635e-64e6-4fe1-8644-897239fd12cc\", \"bf45216c-c9a3-4a51-af1f-a1486826ae26\": \"bf45216c-c9a3-4a51-af1f-a1486826ae26\", \"db99bf9b-6170-44a2-a907-50d48b0743b0\": \"db99bf9b-6170-44a2-a907-50d48b0743b0\", \"4d1cee72-3275-43bc-b952-ee579c9ddffd\": \"4d1cee72-3275-43bc-b952-ee579c9ddffd\", \"611a0fdb-c8c7-4847-aa26-9ab6a93bbd05\": \"611a0fdb-c8c7-4847-aa26-9ab6a93bbd05\", \"3ff4aa82-b5a2-4c96-9a99-ae31bb63e4c1\": \"3ff4aa82-b5a2-4c96-9a99-ae31bb63e4c1\", \"33409c64-3d1b-4af6-b8fc-b68c88878e73\": \"33409c64-3d1b-4af6-b8fc-b68c88878e73\", \"40a3d989-dc4d-442c-b94f-826626cba435\": \"40a3d989-dc4d-442c-b94f-826626cba435\", \"ffde7908-b9ab-4b0f-9572-de5c8c877c3c\": \"ffde7908-b9ab-4b0f-9572-de5c8c877c3c\", \"33e58917-883e-4e30-b40b-83a6a33ff4ee\": \"33e58917-883e-4e30-b40b-83a6a33ff4ee\", \"83f28e1d-e14a-45f9-b01b-73de3e9f80d2\": \"83f28e1d-e14a-45f9-b01b-73de3e9f80d2\", \"20faecbb-7942-4341-95a3-4808986ccd3f\": \"20faecbb-7942-4341-95a3-4808986ccd3f\", \"2a3bbed4-db61-4a45-8c75-14491f8b4aa6\": \"2a3bbed4-db61-4a45-8c75-14491f8b4aa6\"}, \"doc_id_dict\": {}, \"embeddings_dict\": {}}"}}}
1 change: 1 addition & 0 deletions motleycrew/common/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Defaults:
"crewai": "pip install crewai",
"llama_index": "pip install llama-index",
"autogen": "pip install autogen",
"lunary": "pip install lunary"
}
DEFAULT_NUM_THREADS = 4
DEFAULT_EVENT_LOOP_SLEEP = 1
8 changes: 6 additions & 2 deletions motleycrew/tracking/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
CBEventType = None
ChatMessage = None

from lunary import track_event
from lunary import event_queue_ctx
try:
from lunary import track_event, event_queue_ctx
except ImportError:
track_event = None
event_queue_ctx = None

from motleycrew.common.enums import LunaryRunType, LunaryEventName
from motleycrew.common.utils import ensure_module_is_installed
Expand Down Expand Up @@ -109,6 +112,7 @@ def __init__(
event_ends_to_ignore (List[CBEventType]): List of events for which event completion processing is ignored
"""
ensure_module_is_installed("llama_index")
ensure_module_is_installed("lunary")
super(LlamaIndexLunaryCallbackHandler, self).__init__(
event_starts_to_ignore=event_starts_to_ignore or [],
event_ends_to_ignore=event_ends_to_ignore or [],
Expand Down
12 changes: 9 additions & 3 deletions motleycrew/tracking/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import os
from typing import List, Optional

from lunary import LunaryCallbackHandler
try:
from lunary import LunaryCallbackHandler
except ImportError:
LunaryCallbackHandler = None

from langchain_core.callbacks import BaseCallbackHandler, BaseCallbackManager
from langchain_core.runnables import RunnableConfig, ensure_config

from .callbacks import LlamaIndexLunaryCallbackHandler
from motleycrew.common import LLMFramework
from motleycrew.common import logger
from motleycrew.common import LLMFramework, logger
from motleycrew.common.utils import ensure_module_is_installed


def get_lunary_public_key():
Expand All @@ -36,6 +40,7 @@ def create_lunary_callback() -> LunaryCallbackHandler:
"""
lunary_public_key = get_lunary_public_key()
if lunary_public_key is not None:
ensure_module_is_installed("lunary")
return LunaryCallbackHandler(app_id=lunary_public_key)


Expand All @@ -50,6 +55,7 @@ def get_llamaindex_default_callbacks():
# init lunary callback
lunary_public_key = get_lunary_public_key()
if lunary_public_key is not None:
ensure_module_is_installed("lunary")
_default_callbacks.append(LlamaIndexLunaryCallbackHandler(lunary_public_key))

return _default_callbacks
Expand Down
Loading
Loading