swarmauri 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarmauri-0.1.6/PKG-INFO +88 -0
- swarmauri-0.1.6/README.md +29 -0
- swarmauri-0.1.6/setup.cfg +4 -0
- swarmauri-0.1.6/setup.py +74 -0
- swarmauri-0.1.6/swarmauri/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/community/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/community/document_stores/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/community/document_stores/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/community/document_stores/concrete/RedisDocumentStore.py +73 -0
- swarmauri-0.1.6/swarmauri/community/document_stores/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/community/retrievers/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/community/retrievers/base/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/community/retrievers/concrete/RedisDocumentRetriever.py +53 -0
- swarmauri-0.1.6/swarmauri/community/retrievers/concrete/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/community/tools/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/community/tools/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/DownloadPdfTool.py +64 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/EntityRecognitionTool.py +31 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/GmailReadTool.py +117 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/GmailSendTool.py +105 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/PaCMAP.py +66 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/SentimentAnalysisTool.py +26 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/WebScrapingTool.py +51 -0
- swarmauri-0.1.6/swarmauri/community/tools/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/agent_apis/IAgentCommands.py +83 -0
- swarmauri-0.1.6/swarmauri/core/agent_apis/IAgentRouterCRUD.py +56 -0
- swarmauri-0.1.6/swarmauri/core/agent_apis/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/agents/ISwarmAgent.py +55 -0
- swarmauri-0.1.6/swarmauri/core/agents/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/chains/ICallableChain.py +15 -0
- swarmauri-0.1.6/swarmauri/core/chains/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/core/chunkers/IChunker.py +32 -0
- swarmauri-0.1.6/swarmauri/core/chunkers/__init__.py +7 -0
- swarmauri-0.1.6/swarmauri/core/conversations/IConversation.py +44 -0
- swarmauri-0.1.6/swarmauri/core/conversations/IMaxSize.py +17 -0
- swarmauri-0.1.6/swarmauri/core/conversations/ISystemContext.py +24 -0
- swarmauri-0.1.6/swarmauri/core/conversations/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/document_stores/IDocumentStore.py +75 -0
- swarmauri-0.1.6/swarmauri/core/document_stores/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/documents/IDocument.py +72 -0
- swarmauri-0.1.6/swarmauri/core/documents/IEmbed.py +24 -0
- swarmauri-0.1.6/swarmauri/core/documents/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/messages/IMessage.py +26 -0
- swarmauri-0.1.6/swarmauri/core/messages/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/core/models/IFit.py +13 -0
- swarmauri-0.1.6/swarmauri/core/models/IModel.py +22 -0
- swarmauri-0.1.6/swarmauri/core/models/IPredict.py +13 -0
- swarmauri-0.1.6/swarmauri/core/models/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/parsers/IParser.py +20 -0
- swarmauri-0.1.6/swarmauri/core/parsers/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/prompts/IPrompt.py +21 -0
- swarmauri-0.1.6/swarmauri/core/prompts/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/retrievers/IRetriever.py +25 -0
- swarmauri-0.1.6/swarmauri/core/retrievers/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/swarm_apis/IAgentRegistration.py +72 -0
- swarmauri-0.1.6/swarmauri/core/swarm_apis/ISwarmAPI.py +40 -0
- swarmauri-0.1.6/swarmauri/core/swarm_apis/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/swarms/ISwarm.py +0 -0
- swarmauri-0.1.6/swarmauri/core/swarms/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/toolkits/IToolkit.py +52 -0
- swarmauri-0.1.6/swarmauri/core/toolkits/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/tools/IParameter.py +87 -0
- swarmauri-0.1.6/swarmauri/core/tools/ITool.py +35 -0
- swarmauri-0.1.6/swarmauri/core/tools/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/tracing/IChainTracer.py +25 -0
- swarmauri-0.1.6/swarmauri/core/tracing/ITraceContext.py +29 -0
- swarmauri-0.1.6/swarmauri/core/tracing/ITracer.py +45 -0
- swarmauri-0.1.6/swarmauri/core/tracing/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/utils/ITransactional.py +24 -0
- swarmauri-0.1.6/swarmauri/core/utils/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IAngleBetweenVectors.py +23 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IDecompose.py +24 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IDistanceSimilarity.py +49 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IDivergence.py +21 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IGradient.py +22 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IOrthogonalProject.py +21 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IProject.py +22 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IReflect.py +21 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/ISimilarity.py +26 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/ISimiliarityQuery.py +19 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorArithmetic.py +31 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorBasisCheck.py +20 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorLinearCombination.py +21 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorNorm.py +49 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorProduct.py +66 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorRotate.py +24 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorSpan.py +21 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/IVectorStore.py +56 -0
- swarmauri-0.1.6/swarmauri/core/vector_stores/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/core/vectorizers/IVectorize.py +21 -0
- swarmauri-0.1.6/swarmauri/core/vectorizers/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/core/vectors/IVector.py +18 -0
- swarmauri-0.1.6/swarmauri/core/vectors/IVectorMeta.py +28 -0
- swarmauri-0.1.6/swarmauri/core/vectors/IVectorTransform.py +49 -0
- swarmauri-0.1.6/swarmauri/core/vectors/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/experimental/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/experimental/conversations/ConsensusBuildingConversation.py +90 -0
- swarmauri-0.1.6/swarmauri/experimental/conversations/SemanticConversation.py +55 -0
- swarmauri-0.1.6/swarmauri/experimental/conversations/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/experimental/models/HierarchicalAttentionModel.py +66 -0
- swarmauri-0.1.6/swarmauri/experimental/models/SageMaker.py +42 -0
- swarmauri-0.1.6/swarmauri/experimental/models/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/experimental/parsers/PDFToTextParser.py +42 -0
- swarmauri-0.1.6/swarmauri/experimental/parsers/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/CypherQueryTool.py +43 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/FileDownloaderTool.py +36 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/LinkedInArticleTool.py +79 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/OutlookSendMailTool.py +82 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/SQLite3QueryTool.py +42 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/TwitterPostTool.py +41 -0
- swarmauri-0.1.6/swarmauri/experimental/tools/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/experimental/utils/ISerializable.py +21 -0
- swarmauri-0.1.6/swarmauri/experimental/utils/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/experimental/utils/get_last_frame.py +20 -0
- swarmauri-0.1.6/swarmauri/experimental/utils/save_schema.py +71 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/CanberraDistance.py +67 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/ChebyshevDistance.py +47 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/HaversineDistance.py +50 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/ManhattanDistance.py +49 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/MinkowskiDistance.py +68 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/SSASimilarity.py +51 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/SSIVSimilarity.py +51 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/ScannVectorStore.py +149 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/SorensenDiceDistance.py +51 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/SquaredEuclideanDistance.py +46 -0
- swarmauri-0.1.6/swarmauri/experimental/vector_stores/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/agents/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/agents/base/SwarmAgentBase.py +95 -0
- swarmauri-0.1.6/swarmauri/standard/agents/base/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/ChatSwarmAgent.py +48 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/MultiPartyChatSwarmAgent.py +54 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/MultiPartyToolAgent.py +97 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/SimpleSwarmAgent.py +34 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/SingleCommandAgent.py +27 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/ToolAgent.py +91 -0
- swarmauri-0.1.6/swarmauri/standard/agents/concrete/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/apis/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/apis/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/apis/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/chains/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/chains/base/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/chains/concrete/CallableChain.py +21 -0
- swarmauri-0.1.6/swarmauri/standard/chains/concrete/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/concrete/DelimiterBasedChunker.py +40 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/concrete/FixedLengthChunker.py +39 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/concrete/SimpleSentenceChunker.py +29 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/concrete/SlidingWindowChunker.py +39 -0
- swarmauri-0.1.6/swarmauri/standard/chunkers/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/base/ConversationBase.py +37 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/base/SystemContextBase.py +32 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/concrete/LimitedSizeConversation.py +39 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/concrete/LimitedSystemContextConversation.py +87 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/concrete/SharedConversation.py +115 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/concrete/SimpleConversation.py +11 -0
- swarmauri-0.1.6/swarmauri/standard/conversations/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/base/DocumentStoreBase.py +76 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/concrete/Doc2VecDocumentStore.py +57 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/concrete/TFIDFDocumentStore.py +56 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/concrete/Word2VecDocumentStore.py +78 -0
- swarmauri-0.1.6/swarmauri/standard/document_stores/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/documents/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/documents/base/DocumentBase.py +64 -0
- swarmauri-0.1.6/swarmauri/standard/documents/base/EmbeddedBase.py +22 -0
- swarmauri-0.1.6/swarmauri/standard/documents/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/documents/concrete/Document.py +6 -0
- swarmauri-0.1.6/swarmauri/standard/documents/concrete/EmbeddedDocument.py +9 -0
- swarmauri-0.1.6/swarmauri/standard/documents/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/messages/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/messages/base/MessageBase.py +55 -0
- swarmauri-0.1.6/swarmauri/standard/messages/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/messages/concrete/AgentMessage.py +9 -0
- swarmauri-0.1.6/swarmauri/standard/messages/concrete/FunctionMessage.py +25 -0
- swarmauri-0.1.6/swarmauri/standard/messages/concrete/HumanMessage.py +21 -0
- swarmauri-0.1.6/swarmauri/standard/messages/concrete/SystemMessage.py +16 -0
- swarmauri-0.1.6/swarmauri/standard/messages/concrete/__init__.py +4 -0
- swarmauri-0.1.6/swarmauri/standard/models/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/models/base/ModelBase.py +28 -0
- swarmauri-0.1.6/swarmauri/standard/models/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/models/concrete/AzureGPT.py +69 -0
- swarmauri-0.1.6/swarmauri/standard/models/concrete/OpenAIImageGenerator.py +43 -0
- swarmauri-0.1.6/swarmauri/standard/models/concrete/OpenAIModel.py +63 -0
- swarmauri-0.1.6/swarmauri/standard/models/concrete/OpenAIToolModel.py +21 -0
- swarmauri-0.1.6/swarmauri/standard/models/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/BERTEmbeddingParser.py +58 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/CSVParser.py +45 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/EntityRecognitionParser.py +41 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/HtmlTagStripParser.py +37 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/KeywordExtractorParser.py +44 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/MarkdownParser.py +40 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/OpenAPISpecParser.py +45 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/PhoneNumberExtractorParser.py +40 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/PythonParser.py +53 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/RegExParser.py +43 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/TextBlobNounParser.py +41 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/TextBlobSentenceParser.py +39 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/TfidfParser.py +17 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/URLExtractorParser.py +45 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/XMLParser.py +47 -0
- swarmauri-0.1.6/swarmauri/standard/parsers/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/prompts/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/prompts/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/prompts/concrete/Prompt.py +40 -0
- swarmauri-0.1.6/swarmauri/standard/prompts/concrete/PromptTemplate.py +58 -0
- swarmauri-0.1.6/swarmauri/standard/prompts/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/retrievers/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/retrievers/base/DocumentRetrieverBase.py +39 -0
- swarmauri-0.1.6/swarmauri/standard/retrievers/base/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/retrievers/concrete/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/states/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/states/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/states/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/swarms/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/swarms/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/swarms/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/toolkits/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/toolkits/base/ToolkitBase.py +76 -0
- swarmauri-0.1.6/swarmauri/standard/toolkits/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/toolkits/concrete/Toolkit.py +17 -0
- swarmauri-0.1.6/swarmauri/standard/toolkits/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/tools/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/tools/base/ToolBase.py +80 -0
- swarmauri-0.1.6/swarmauri/standard/tools/base/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/tools/concrete/AdditionTool.py +36 -0
- swarmauri-0.1.6/swarmauri/standard/tools/concrete/Parameter.py +102 -0
- swarmauri-0.1.6/swarmauri/standard/tools/concrete/TestTool.py +26 -0
- swarmauri-0.1.6/swarmauri/standard/tools/concrete/WeatherTool.py +29 -0
- swarmauri-0.1.6/swarmauri/standard/tools/concrete/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/base/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/CallableTracer.py +32 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/ChainTracer.py +51 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/SimpleTraceContext.py +21 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/SimpleTracer.py +40 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/TracedVariable.py +28 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/VariableTracer.py +23 -0
- swarmauri-0.1.6/swarmauri/standard/tracing/concrete/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/utils/__init__.py +0 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/base/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/ChiSquaredDistance.py +36 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/CosineDistance.py +63 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/EuclideanDistance.py +50 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/FaissVectorStore.py +78 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/JaccardIndexDistance.py +71 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/LevenshteinDistance.py +73 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/VectorProduct.py +33 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/WeaviateVectorStore.py +36 -0
- swarmauri-0.1.6/swarmauri/standard/vector_stores/concrete/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/vectorizers/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/vectorizers/base/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/vectorizers/concrete/BERTEmbeddingVectorizer.py +59 -0
- swarmauri-0.1.6/swarmauri/standard/vectorizers/concrete/TFIDFVectorizer.py +56 -0
- swarmauri-0.1.6/swarmauri/standard/vectorizers/concrete/__init__.py +1 -0
- swarmauri-0.1.6/swarmauri/standard/vectors/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/vectors/base/VectorBase.py +30 -0
- swarmauri-0.1.6/swarmauri/standard/vectors/base/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri/standard/vectors/concrete/SimpleVector.py +7 -0
- swarmauri-0.1.6/swarmauri/standard/vectors/concrete/__init__.py +2 -0
- swarmauri-0.1.6/swarmauri.egg-info/PKG-INFO +88 -0
- swarmauri-0.1.6/swarmauri.egg-info/SOURCES.txt +271 -0
- swarmauri-0.1.6/swarmauri.egg-info/dependency_links.txt +1 -0
- swarmauri-0.1.6/swarmauri.egg-info/requires.txt +50 -0
- swarmauri-0.1.6/swarmauri.egg-info/top_level.txt +1 -0
swarmauri-0.1.6/PKG-INFO
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: swarmauri
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: A short description of your package
|
|
5
|
+
Home-page: http://github.com/yourusername/your_package_name
|
|
6
|
+
Author: Jacob Stewart
|
|
7
|
+
Author-email: your_email@example.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: requests
|
|
15
|
+
Provides-Extra: standard
|
|
16
|
+
Requires-Dist: openai; extra == "standard"
|
|
17
|
+
Requires-Dist: transformers; extra == "standard"
|
|
18
|
+
Requires-Dist: tensorflow; extra == "standard"
|
|
19
|
+
Requires-Dist: scipy; extra == "standard"
|
|
20
|
+
Requires-Dist: typing_extensions; extra == "standard"
|
|
21
|
+
Requires-Dist: scikit-learn; extra == "standard"
|
|
22
|
+
Requires-Dist: gensim; extra == "standard"
|
|
23
|
+
Provides-Extra: community
|
|
24
|
+
Requires-Dist: openai; extra == "community"
|
|
25
|
+
Requires-Dist: transformers; extra == "community"
|
|
26
|
+
Requires-Dist: tensorflow; extra == "community"
|
|
27
|
+
Requires-Dist: scipy; extra == "community"
|
|
28
|
+
Requires-Dist: typing_extensions; extra == "community"
|
|
29
|
+
Requires-Dist: redisearch; extra == "community"
|
|
30
|
+
Requires-Dist: google-api-python-client; extra == "community"
|
|
31
|
+
Requires-Dist: google-auth-httplib2; extra == "community"
|
|
32
|
+
Requires-Dist: google-auth-oauthlib; extra == "community"
|
|
33
|
+
Requires-Dist: boto3; extra == "community"
|
|
34
|
+
Provides-Extra: experimental
|
|
35
|
+
Requires-Dist: openai; extra == "experimental"
|
|
36
|
+
Requires-Dist: transformers; extra == "experimental"
|
|
37
|
+
Requires-Dist: tensorflow; extra == "experimental"
|
|
38
|
+
Requires-Dist: scipy; extra == "experimental"
|
|
39
|
+
Requires-Dist: typing_extensions; extra == "experimental"
|
|
40
|
+
Requires-Dist: google-api-python-client; extra == "experimental"
|
|
41
|
+
Requires-Dist: google-auth-httplib2; extra == "experimental"
|
|
42
|
+
Requires-Dist: google-auth-oauthlib; extra == "experimental"
|
|
43
|
+
Requires-Dist: boto3; extra == "experimental"
|
|
44
|
+
Provides-Extra: full
|
|
45
|
+
Requires-Dist: openai; extra == "full"
|
|
46
|
+
Requires-Dist: transformers; extra == "full"
|
|
47
|
+
Requires-Dist: tensorflow; extra == "full"
|
|
48
|
+
Requires-Dist: scipy; extra == "full"
|
|
49
|
+
Requires-Dist: typing_extensions; extra == "full"
|
|
50
|
+
Requires-Dist: redisearch; extra == "full"
|
|
51
|
+
Requires-Dist: google-api-python-client; extra == "full"
|
|
52
|
+
Requires-Dist: google-auth-httplib2; extra == "full"
|
|
53
|
+
Requires-Dist: google-auth-oauthlib; extra == "full"
|
|
54
|
+
Requires-Dist: boto3; extra == "full"
|
|
55
|
+
Requires-Dist: yake; extra == "full"
|
|
56
|
+
Requires-Dist: torch; extra == "full"
|
|
57
|
+
Requires-Dist: scikit-learn; extra == "full"
|
|
58
|
+
Requires-Dist: gensim; extra == "full"
|
|
59
|
+
|
|
60
|
+
# SwarmaURI SDK
|
|
61
|
+
This repository includes core interfaces, standard ABCs, and standard concrete references of the SwarmaURI Framework.
|
|
62
|
+
|
|
63
|
+
## Steps to compile python package from source
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/cobycloud/swarmauri
|
|
66
|
+
cd swarmauri
|
|
67
|
+
python -m build
|
|
68
|
+
pip install ./dist/swarmauri-0.1.tar.gz --force-reinstall
|
|
69
|
+
```
|
|
70
|
+
## ./combined
|
|
71
|
+
This includes convenience outputs to enable conversations with GPTs.
|
|
72
|
+
|
|
73
|
+
## ./dist
|
|
74
|
+
This includes SwarmaURI python package builds. This will eventually be excluded from this directory in favor of pypi.
|
|
75
|
+
|
|
76
|
+
## ./scripts
|
|
77
|
+
This includes convenience scripts that are nother included with the SwarmaURI SDK.
|
|
78
|
+
#### /scripts/combine_files.py
|
|
79
|
+
```bash
|
|
80
|
+
#This script generates the convenience outputs found in ./combined
|
|
81
|
+
python ./combine_files.py
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## ./swamauri
|
|
85
|
+
This includes the libaries for the SwarmaURI python package.
|
|
86
|
+
|
|
87
|
+
## ./tests
|
|
88
|
+
This includes test cases for the SwarmaURI python package.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# SwarmaURI SDK
|
|
2
|
+
This repository includes core interfaces, standard ABCs, and standard concrete references of the SwarmaURI Framework.
|
|
3
|
+
|
|
4
|
+
## Steps to compile python package from source
|
|
5
|
+
```bash
|
|
6
|
+
git clone https://github.com/cobycloud/swarmauri
|
|
7
|
+
cd swarmauri
|
|
8
|
+
python -m build
|
|
9
|
+
pip install ./dist/swarmauri-0.1.tar.gz --force-reinstall
|
|
10
|
+
```
|
|
11
|
+
## ./combined
|
|
12
|
+
This includes convenience outputs to enable conversations with GPTs.
|
|
13
|
+
|
|
14
|
+
## ./dist
|
|
15
|
+
This includes SwarmaURI python package builds. This will eventually be excluded from this directory in favor of pypi.
|
|
16
|
+
|
|
17
|
+
## ./scripts
|
|
18
|
+
This includes convenience scripts that are nother included with the SwarmaURI SDK.
|
|
19
|
+
#### /scripts/combine_files.py
|
|
20
|
+
```bash
|
|
21
|
+
#This script generates the convenience outputs found in ./combined
|
|
22
|
+
python ./combine_files.py
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## ./swamauri
|
|
26
|
+
This includes the libaries for the SwarmaURI python package.
|
|
27
|
+
|
|
28
|
+
## ./tests
|
|
29
|
+
This includes test cases for the SwarmaURI python package.
|
swarmauri-0.1.6/setup.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
import swarmauri
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name='swarmauri',
|
|
6
|
+
version=swarmauri.__version__,
|
|
7
|
+
author='Jacob Stewart',
|
|
8
|
+
author_email='your_email@example.com',
|
|
9
|
+
description='A short description of your package',
|
|
10
|
+
long_description=open('README.md').read(),
|
|
11
|
+
long_description_content_type='text/markdown',
|
|
12
|
+
url='http://github.com/yourusername/your_package_name',
|
|
13
|
+
license='MIT',
|
|
14
|
+
packages=find_packages(include=['swarmauri*']), # Include packages in your_package and libs directories
|
|
15
|
+
install_requires=[
|
|
16
|
+
'numpy', # Common dependencies for all distributions
|
|
17
|
+
'requests'
|
|
18
|
+
],
|
|
19
|
+
extras_require={
|
|
20
|
+
'standard': [
|
|
21
|
+
'openai',
|
|
22
|
+
'transformers',
|
|
23
|
+
'tensorflow',
|
|
24
|
+
'scipy',
|
|
25
|
+
'typing_extensions',
|
|
26
|
+
'scikit-learn',
|
|
27
|
+
'gensim'
|
|
28
|
+
],
|
|
29
|
+
'community': [
|
|
30
|
+
'openai',
|
|
31
|
+
'transformers',
|
|
32
|
+
'tensorflow',
|
|
33
|
+
'scipy',
|
|
34
|
+
'typing_extensions',
|
|
35
|
+
'redisearch',
|
|
36
|
+
'google-api-python-client',
|
|
37
|
+
'google-auth-httplib2',
|
|
38
|
+
'google-auth-oauthlib',
|
|
39
|
+
'boto3'
|
|
40
|
+
],
|
|
41
|
+
'experimental': [
|
|
42
|
+
'openai',
|
|
43
|
+
'transformers',
|
|
44
|
+
'tensorflow',
|
|
45
|
+
'scipy',
|
|
46
|
+
'typing_extensions',
|
|
47
|
+
'google-api-python-client',
|
|
48
|
+
'google-auth-httplib2',
|
|
49
|
+
'google-auth-oauthlib',
|
|
50
|
+
'boto3'
|
|
51
|
+
],
|
|
52
|
+
'full': [
|
|
53
|
+
'openai',
|
|
54
|
+
'transformers',
|
|
55
|
+
'tensorflow',
|
|
56
|
+
'scipy',
|
|
57
|
+
'typing_extensions',
|
|
58
|
+
'redisearch',
|
|
59
|
+
'google-api-python-client',
|
|
60
|
+
'google-auth-httplib2',
|
|
61
|
+
'google-auth-oauthlib',
|
|
62
|
+
'boto3',
|
|
63
|
+
'yake',
|
|
64
|
+
'torch',
|
|
65
|
+
'scikit-learn',
|
|
66
|
+
'gensim'
|
|
67
|
+
]},
|
|
68
|
+
classifiers=[
|
|
69
|
+
'License :: OSI Approved :: MIT License',
|
|
70
|
+
'Programming Language :: Python :: 3.10',
|
|
71
|
+
],
|
|
72
|
+
python_requires='>=3.10',
|
|
73
|
+
setup_requires=["wheel"]
|
|
74
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.6"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
from ....standard.document_stores.base.DocumentStoreBase import DocumentStoreBase
|
|
3
|
+
from ....core.documents.IDocument import IDocument
|
|
4
|
+
import redis
|
|
5
|
+
import json
|
|
6
|
+
from redis.commands.search.field import TextField, NumericField, TagField
|
|
7
|
+
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RedisDocumentStore(DocumentStoreBase):
|
|
11
|
+
def __init__(self, host, password, port, db):
|
|
12
|
+
"""Store connection details without initializing the Redis client."""
|
|
13
|
+
self._host = host
|
|
14
|
+
self._password = password
|
|
15
|
+
self._port = port
|
|
16
|
+
self._db = db
|
|
17
|
+
self._redis_client = None # Delayed initialization
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def redis_client(self):
|
|
21
|
+
"""Lazily initialize and return the Redis client using a factory method."""
|
|
22
|
+
if self._redis_client is None:
|
|
23
|
+
print('here')
|
|
24
|
+
self._redis_client = redis.Redis(host=self._host,
|
|
25
|
+
password=self._password,
|
|
26
|
+
port=self._port,
|
|
27
|
+
db=self._db)
|
|
28
|
+
print('there')
|
|
29
|
+
return self._redis_client
|
|
30
|
+
|
|
31
|
+
def add_document(self, document: IDocument) -> None:
|
|
32
|
+
|
|
33
|
+
data = document.as_dict()
|
|
34
|
+
doc_id = data['id']
|
|
35
|
+
del data['id']
|
|
36
|
+
self.redis_client.json().set(doc_id, '$', json.dumps(data))
|
|
37
|
+
|
|
38
|
+
def add_documents(self, documents: List[IDocument]) -> None:
|
|
39
|
+
with self.redis_client.pipeline() as pipe:
|
|
40
|
+
for document in documents:
|
|
41
|
+
pipe.set(document.doc_id, document)
|
|
42
|
+
pipe.execute()
|
|
43
|
+
|
|
44
|
+
def get_document(self, doc_id: str) -> Optional[IDocument]:
|
|
45
|
+
result = self.redis_client.json().get(doc_id)
|
|
46
|
+
if result:
|
|
47
|
+
return json.loads(result)
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
def get_all_documents(self) -> List[IDocument]:
|
|
51
|
+
keys = self.redis_client.keys('*')
|
|
52
|
+
documents = []
|
|
53
|
+
for key in keys:
|
|
54
|
+
document_data = self.redis_client.get(key)
|
|
55
|
+
if document_data:
|
|
56
|
+
documents.append(json.loads(document_data))
|
|
57
|
+
return documents
|
|
58
|
+
|
|
59
|
+
def update_document(self, doc_id: str, updated_document: IDocument) -> None:
|
|
60
|
+
self.add_document(updated_document)
|
|
61
|
+
|
|
62
|
+
def delete_document(self, doc_id: str) -> None:
|
|
63
|
+
self.redis_client.delete(doc_id)
|
|
64
|
+
|
|
65
|
+
def __getstate__(self):
|
|
66
|
+
"""Return the object state for serialization, excluding the Redis client."""
|
|
67
|
+
state = self.__dict__.copy()
|
|
68
|
+
state['_redis_client'] = None # Exclude Redis client from serialization
|
|
69
|
+
return state
|
|
70
|
+
|
|
71
|
+
def __setstate__(self, state):
|
|
72
|
+
"""Restore the object state after serialization, reinitializing the Redis client."""
|
|
73
|
+
self.__dict__.update(state)
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
from redisearch import Client, Query
|
|
3
|
+
from ....core.documents.IDocument import IDocument
|
|
4
|
+
from ....standard.document_stores.concrete.ConcreteDocument import ConcreteDocument
|
|
5
|
+
from ....standard.retrievers.base.DocumentRetrieverBase import DocumentRetrieverBase
|
|
6
|
+
|
|
7
|
+
class RedisDocumentRetriever(DocumentRetrieverBase):
|
|
8
|
+
"""
|
|
9
|
+
A document retriever that fetches documents from a Redis store.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, redis_idx_name, redis_host, redis_port):
|
|
13
|
+
"""
|
|
14
|
+
Initializes a new instance of RedisDocumentRetriever.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
redis_client (Redis): An instance of the Redis client.
|
|
18
|
+
"""
|
|
19
|
+
self._redis_client = None
|
|
20
|
+
self._redis_idx_name = redis_idx_name
|
|
21
|
+
self._redis_host = redis_host
|
|
22
|
+
self._redis_port = redis_port
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def redis_client(self):
|
|
26
|
+
"""Lazily initialize and return the Redis client using a factory method."""
|
|
27
|
+
if self._redis_client is None:
|
|
28
|
+
self._redis_client = Client(self.redis_idx_name, host=self.redis_host, port=self.redis_port)
|
|
29
|
+
return self._redis_client
|
|
30
|
+
|
|
31
|
+
def retrieve(self, query: str, top_k: int = 5) -> List[IDocument]:
|
|
32
|
+
"""
|
|
33
|
+
Retrieve the most relevant documents based on the given query.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
query (str): The query string used for document retrieval.
|
|
37
|
+
top_k (int, optional): The number of top relevant documents to retrieve. Defaults to 5.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
List[IDocument]: A list of the top_k most relevant documents.
|
|
41
|
+
"""
|
|
42
|
+
query_result = self.redis_client.search(Query(query).paging(0, top_k))
|
|
43
|
+
|
|
44
|
+
documents = [
|
|
45
|
+
ConcreteDocument(
|
|
46
|
+
doc_id=doc.id,
|
|
47
|
+
content=doc.text, # Note: Adjust 'text' based on actual Redis document schema
|
|
48
|
+
metadata=doc.__dict__ # Including full document fields and values in metadata
|
|
49
|
+
)
|
|
50
|
+
for doc in query_result.docs
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
return documents
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Dict
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from ...standard.tools.base.ToolBase import ToolBase
|
|
5
|
+
from ...standard.tools.concrete.Parameter import Parameter
|
|
6
|
+
|
|
7
|
+
class DownloadPDFTool(ToolBase):
|
|
8
|
+
def __init__(self):
|
|
9
|
+
parameters = [
|
|
10
|
+
Parameter(
|
|
11
|
+
name="url",
|
|
12
|
+
type="string",
|
|
13
|
+
description="The URL of the PDF file to download",
|
|
14
|
+
required=True
|
|
15
|
+
),
|
|
16
|
+
Parameter(
|
|
17
|
+
name="destination",
|
|
18
|
+
type="string",
|
|
19
|
+
description="The path where the PDF file will be saved",
|
|
20
|
+
required=True
|
|
21
|
+
)
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
super().__init__(name="DownloadPDFTool",
|
|
25
|
+
description="Downloads a PDF from a specified URL and saves it to a specified path.",
|
|
26
|
+
parameters=parameters)
|
|
27
|
+
|
|
28
|
+
def __call__(self, url: str, destination: str) -> Dict[str, str]:
|
|
29
|
+
"""
|
|
30
|
+
Download the PDF from the specified URL and saves it to the given destination path.
|
|
31
|
+
|
|
32
|
+
Parameters:
|
|
33
|
+
- url (str): The URL from where to download the PDF.
|
|
34
|
+
- destination (str): The local file path where the PDF should be saved.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
- Dict[str, str]: A dictionary containing the result message and the destination path.
|
|
38
|
+
"""
|
|
39
|
+
try:
|
|
40
|
+
# Send a GET request to the specified URL
|
|
41
|
+
response = requests.get(url, stream=True)
|
|
42
|
+
|
|
43
|
+
# Raise an HTTPError if the status code is not 200 (OK)
|
|
44
|
+
response.raise_for_status()
|
|
45
|
+
|
|
46
|
+
# Ensure destination directory exists
|
|
47
|
+
Path(destination).parent.mkdir(parents=True, exist_ok=True)
|
|
48
|
+
|
|
49
|
+
# Open a file at the specified destination path and write the content of the response to it
|
|
50
|
+
with open(Path(destination), 'wb') as file:
|
|
51
|
+
for chunk in response.iter_content(chunk_size=8192):
|
|
52
|
+
file.write(chunk)
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
"message": "PDF downloaded successfully.",
|
|
56
|
+
"destination": destination
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
except requests.exceptions.RequestException as e:
|
|
60
|
+
# Handle requests-related errors
|
|
61
|
+
return {"error": f"Failed to download PDF: {e}"}
|
|
62
|
+
except IOError as e:
|
|
63
|
+
# Handle file I/O errors
|
|
64
|
+
return {"error": f"Failed to save PDF: {e}"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from transformers import pipeline, logging as hf_logging
|
|
3
|
+
from ....standard.tools.base.ToolBase import ToolBase
|
|
4
|
+
from ....standard.tools.concrete.Parameter import Parameter
|
|
5
|
+
|
|
6
|
+
hf_logging.set_verbosity_error()
|
|
7
|
+
|
|
8
|
+
class EntityRecognitionTool(ToolBase):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
parameters = [
|
|
11
|
+
Parameter("text","string","The text for entity recognition",True)
|
|
12
|
+
]
|
|
13
|
+
super().__init__(name="EntityRecognitionTool",
|
|
14
|
+
description="Extracts named entities from text",
|
|
15
|
+
parameters=parameters)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def __call__(self, text: str) -> dict:
|
|
19
|
+
try:
|
|
20
|
+
self.nlp = pipeline("ner")
|
|
21
|
+
entities = self.nlp(text)
|
|
22
|
+
organized_entities = {}
|
|
23
|
+
for entity in entities:
|
|
24
|
+
if entity['entity'] not in organized_entities:
|
|
25
|
+
organized_entities[entity['entity']] = []
|
|
26
|
+
organized_entities[entity['entity']].append(entity['word'])
|
|
27
|
+
return json.dumps(organized_entities)
|
|
28
|
+
except Exception as e:
|
|
29
|
+
raise e
|
|
30
|
+
finally:
|
|
31
|
+
del self.nlp
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import base64
|
|
3
|
+
import json
|
|
4
|
+
from googleapiclient import discovery
|
|
5
|
+
from google.oauth2 import service_account
|
|
6
|
+
from googleapiclient.discovery import build
|
|
7
|
+
from ....standard.tools.base.ToolBase import ToolBase
|
|
8
|
+
from ....standard.tools.concrete.Parameter import Parameter
|
|
9
|
+
|
|
10
|
+
class GmailReadTool(ToolBase):
|
|
11
|
+
SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
|
|
12
|
+
|
|
13
|
+
def __init__(self, credentials_path: str, sender_email: str):
|
|
14
|
+
"""
|
|
15
|
+
Initializes the GmailReadTool with a path to the credentials JSON file.
|
|
16
|
+
|
|
17
|
+
Parameters:
|
|
18
|
+
credentials_path (str): The path to the Gmail service JSON file.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
parameters = [
|
|
22
|
+
Parameter(
|
|
23
|
+
name="query",
|
|
24
|
+
type="string",
|
|
25
|
+
description='''The query to filter emails. For example, "is:unread" or "from:example@gmail.com" or "from:sender@company.com"''',
|
|
26
|
+
required=True
|
|
27
|
+
),
|
|
28
|
+
Parameter(
|
|
29
|
+
name="max_results",
|
|
30
|
+
type="integer",
|
|
31
|
+
description='''The number of emails to return. Defaults to 10.'''
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
super().__init__(name="GmailReadTool",
|
|
37
|
+
description="Read emails from a Gmail account.",
|
|
38
|
+
parameters = parameters)
|
|
39
|
+
self.credentials_path = credentials_path
|
|
40
|
+
self.sender_email = sender_email
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def authenticate(self):
|
|
44
|
+
"""
|
|
45
|
+
Authenticates the user and creates a Gmail API service.
|
|
46
|
+
"""
|
|
47
|
+
credentials = service_account.Credentials.from_service_account_file(
|
|
48
|
+
self.credentials_path, scopes=self.SCOPES)
|
|
49
|
+
|
|
50
|
+
delegated_credentials = credentials.with_subject(self.sender_email)
|
|
51
|
+
self.service = discovery.build('gmail', 'v1', credentials=delegated_credentials)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def __call__(self, query='', max_results=10):
|
|
56
|
+
"""
|
|
57
|
+
Fetches emails from the authenticated Gmail account based on the given query.
|
|
58
|
+
|
|
59
|
+
Parameters:
|
|
60
|
+
query (str): The query to filter emails. For example, "is:unread".
|
|
61
|
+
max_results (int): The maximum number of email messages to fetch.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
list: A list of email messages.
|
|
65
|
+
"""
|
|
66
|
+
self.authenticate()
|
|
67
|
+
try:
|
|
68
|
+
# Call the Gmail API
|
|
69
|
+
|
|
70
|
+
gmail_messages = self.service.users().messages()
|
|
71
|
+
results = gmail_messages.list(userId='me', q=query, maxResults=max_results).execute()
|
|
72
|
+
messages = results.get('messages', [])
|
|
73
|
+
message_data = ""
|
|
74
|
+
for message in messages:
|
|
75
|
+
|
|
76
|
+
msg = gmail_messages.get(userId='me', id=message['threadId'], format="full").execute()
|
|
77
|
+
headers = msg['payload']['headers']
|
|
78
|
+
|
|
79
|
+
sender = next(header['value'] for header in headers if header['name'] == 'From')
|
|
80
|
+
subject = next(header['value'] for header in headers if header['name'] == 'Subject')
|
|
81
|
+
reply_to = next((header['value'] for header in headers if header['name'] == 'Reply-To'), subject)
|
|
82
|
+
date_time = next(header['value'] for header in headers if header['name'] == 'Date')
|
|
83
|
+
|
|
84
|
+
#part = msg['payload']['parts'][0]
|
|
85
|
+
#data = part['body']['data']
|
|
86
|
+
#decoded_data = base64.urlsafe_b64decode(data.encode('ASCII'))
|
|
87
|
+
|
|
88
|
+
formatted_msg = f"\nsender:{sender} reply-to:{reply_to} subject: {subject} date_time:{date_time}"
|
|
89
|
+
|
|
90
|
+
message_data += formatted_msg
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
return message_data
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
except Exception as e:
|
|
98
|
+
print(f"An error occurred: {e}")
|
|
99
|
+
return []
|
|
100
|
+
|
|
101
|
+
finally:
|
|
102
|
+
del self.service
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import json
|
|
3
|
+
from email.mime.multipart import MIMEMultipart
|
|
4
|
+
from email.mime.text import MIMEText
|
|
5
|
+
from googleapiclient import discovery
|
|
6
|
+
from google.oauth2 import service_account
|
|
7
|
+
from googleapiclient.discovery import build
|
|
8
|
+
from swarmauri.standard.tools.base.ToolBase import ToolBase
|
|
9
|
+
from swarmauri.standard.tools.concrete.Parameter import Parameter
|
|
10
|
+
|
|
11
|
+
class GmailSendTool(ToolBase):
|
|
12
|
+
SCOPES = ['https://www.googleapis.com/auth/gmail.send']
|
|
13
|
+
|
|
14
|
+
def __init__(self, credentials_path: str, sender_email: str):
|
|
15
|
+
"""
|
|
16
|
+
Initializes the GmailSendTool with a path to the credentials JSON file and the sender email.
|
|
17
|
+
|
|
18
|
+
Parameters:
|
|
19
|
+
credentials_path (str): The path to the Gmail service JSON file.
|
|
20
|
+
sender_email (str): The email address being used to send emails.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
parameters = [
|
|
24
|
+
Parameter(
|
|
25
|
+
name="recipients",
|
|
26
|
+
type="string",
|
|
27
|
+
description="The email addresses of the recipients, separated by commas",
|
|
28
|
+
required=True
|
|
29
|
+
),
|
|
30
|
+
Parameter(
|
|
31
|
+
name="subject",
|
|
32
|
+
type="string",
|
|
33
|
+
description="The subject of the email",
|
|
34
|
+
required=True
|
|
35
|
+
),
|
|
36
|
+
Parameter(
|
|
37
|
+
name="htmlMsg",
|
|
38
|
+
type="string",
|
|
39
|
+
description="The HTML message to be sent as the email body",
|
|
40
|
+
required=True
|
|
41
|
+
)
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
super().__init__(name="GmailSendTool",
|
|
45
|
+
description="Sends an email using the Gmail API.",
|
|
46
|
+
parameters=parameters)
|
|
47
|
+
self.credentials_path = credentials_path
|
|
48
|
+
self.sender_email = sender_email
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def authenticate(self):
|
|
52
|
+
"""
|
|
53
|
+
Authenticates the user and creates a Gmail API service for sending emails.
|
|
54
|
+
"""
|
|
55
|
+
credentials = service_account.Credentials.from_service_account_file(
|
|
56
|
+
self.credentials_path, scopes=self.SCOPES)
|
|
57
|
+
|
|
58
|
+
delegated_credentials = credentials.with_subject(self.sender_email)
|
|
59
|
+
self.service = build('gmail', 'v1', credentials=delegated_credentials)
|
|
60
|
+
|
|
61
|
+
def create_message(self, to: str, subject: str, message_text: str):
|
|
62
|
+
"""
|
|
63
|
+
Create a MIMEText message for sending an email.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
sender (str): The email address of the sender.
|
|
67
|
+
to (str): The email address of the recipient.
|
|
68
|
+
subject (str): The subject of the email.
|
|
69
|
+
message_text (str): The HTML body of the email.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
The created MIMEText message.
|
|
73
|
+
"""
|
|
74
|
+
message = MIMEMultipart('alternative')
|
|
75
|
+
message['from'] = self.sender_email
|
|
76
|
+
message['to'] = to
|
|
77
|
+
message['subject'] = subject
|
|
78
|
+
mime_text = MIMEText(message_text, 'html')
|
|
79
|
+
message.attach(mime_text)
|
|
80
|
+
raw_message = base64.urlsafe_b64encode(message.as_string().encode('utf-8'))
|
|
81
|
+
return {'raw': raw_message.decode('utf-8')}
|
|
82
|
+
|
|
83
|
+
def __call__(self, recipients, subject, htmlMsg):
|
|
84
|
+
"""
|
|
85
|
+
Sends an email to the specified recipients with the given subject and HTML message.
|
|
86
|
+
|
|
87
|
+
Parameters:
|
|
88
|
+
sender (str): The email address of the sender.
|
|
89
|
+
recipients (str): The email address of the recipients, separated by commas.
|
|
90
|
+
subject (str): The subject of the email.
|
|
91
|
+
htmlMsg (str): The HTML content of the email body.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
The result of sending the email or an error message if the operation fails.
|
|
95
|
+
"""
|
|
96
|
+
self.authenticate()
|
|
97
|
+
try:
|
|
98
|
+
message = self.create_message(recipients, subject, htmlMsg)
|
|
99
|
+
sent_message = (self.service.users().messages().send(userId='me', body=message).execute())
|
|
100
|
+
return f"Email sent successfully to {recipients}"
|
|
101
|
+
|
|
102
|
+
except Exception as e:
|
|
103
|
+
return f"An error occurred in sending the email: {e}"
|
|
104
|
+
finally:
|
|
105
|
+
del self.service
|