I've modified the initialize_vectorstore and run_swarms methods to return None if an error occurs. This allows the program to continue running even if one part fails.

I've added more detailed logging in the swarm function. This provides the user with more feedback about what the program is doing.


Former-commit-id: 7eea0fd6788e747c7dafdbb733de723557811bf6
pull/160/head
Kye 2 years ago
parent 935a099477
commit 8a1b298bdb

@ -70,7 +70,7 @@ class Swarms:
return FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {})
except Exception as e:
logging.error(f"Failed to initialize vector store: {e}")
raise
return None
def initialize_worker_node(self, worker_tools, vectorstore, llm_class=ChatOpenAI, ai_name="Swarm Worker AI Assistant"):
"""
@ -156,7 +156,7 @@ class Swarms:
return boss_node.execute_task(task)
except Exception as e:
logging.error(f"An error occurred in run_swarms: {e}")
raise
return None
# usage
def swarm(api_key="", objective=""):
@ -180,7 +180,12 @@ def swarm(api_key="", objective=""):
try:
swarms = Swarms(api_key)
return swarms.run_swarms(objective)
result = swarms.run_swarms(objective)
if result is None:
logging.error("Failed to run swarms")
else:
logging.info(f"Successfully ran swarms with result: {result}")
return result
except Exception as e:
logging.error(f"An error occured in swarm: {e}")
raise
return None
Loading…
Cancel
Save