parent
							
								
									aee3a79c01
								
							
						
					
					
						commit
						b097e6016d
					
				| @ -0,0 +1,5 @@ | ||||
| """ | ||||
| This tutorial shows you how to integrate swarms with Langchain | ||||
| 
 | ||||
| """ | ||||
| 
 | ||||
| @ -0,0 +1,25 @@ | ||||
| from swarms.structs.agent import Agent | ||||
| 
 | ||||
| def agent_wrapper(ClassToWrap): | ||||
|     """ | ||||
|     This function takes a class 'ClassToWrap' and returns a new class that | ||||
|     inherits from both 'ClassToWrap' and 'Agent'. The new class overrides | ||||
|     the '__init__' method of 'Agent' to call the '__init__' method of 'ClassToWrap'. | ||||
|      | ||||
|     Args: | ||||
|         ClassToWrap (type): The class to be wrapped and made to inherit from 'Agent'. | ||||
|          | ||||
|     Returns: | ||||
|         type: The new class that inherits from both 'ClassToWrap' and 'Agent'. | ||||
|     """ | ||||
|      | ||||
|     class WrappedClass(ClassToWrap, Agent): | ||||
|         def __init__(self, *args, **kwargs): | ||||
|             try: | ||||
|                 Agent.__init__(self, *args, **kwargs) | ||||
|                 ClassToWrap.__init__(self, *args, **kwargs) | ||||
|             except Exception as e: | ||||
|                 print(f"Error initializing WrappedClass: {e}") | ||||
|                 raise e | ||||
|      | ||||
|     return WrappedClass | ||||
					Loading…
					
					
				
		Reference in new issue