You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
🏠
Learn something new everyday!
David
Cdaprod
🏠
Learn something new everyday!
As a highly motivated autodidact, a single father of triplet boys, I’ve got an amazing story to tell.
Example of how you might update objects in Weaviate with tokenized data (note: this is a conceptual example and assumes you have a function tokenize_text and a Weaviate client client set up)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bash script that automates setting up a Python environment, optionally downloads WLED, and flashes firmware to multiple ESP32 devices.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pseudocode outlines the creation of a state machine similar to LangGraph using Pydantic for data validation. The Node class represents tasks or agents with their specific functions. The StateGraph manages nodes and transitions based on conditions. This abstract implementation can be extended with more sophisticated logic for conditions, nod…
To create an abstracted LangGraph-like state machine using Pydantic, we will design a system that allows for the creation of nodes (agents) and edges (transitions) in a graph that represents a workflow. The agents will have specific roles or functions, and the transitions between these agents will be dictated by the outcomes of their actions. Pydantic will be used for data validation and settings management, ensuring that the components of our state machine are well-defined and interact correctly.
Step 1: Define the Base Models with Pydantic
First, we need to define our base models for Nodes (Agents) and Edges (Transitions). Pydantic models will ensure that each component of our graph adheres to a specific structure and type, facilitating error handling and data consistency.
Step 2: Implement the Graph Structure
We will create a class for the graph itself, which holds the nodes and edges and manages the workflow's execution. This includes methods for adding nodes, adding edges, and determining the
This approach allows you to build flexible and dynamic ETL pipelines where the flow can adapt based on the data it processes. Each node in the pipeline can perform specific ETL tasks, and the decision on where the data flows next can be made dynamically, enabling complex data processing scenarios tailored to the needs of each dataset.
To create dynamic ETL (Extract, Transform, Load) pipes with dynamic edges and nodes using Pydantic for data validation, we will expand upon the previously discussed abstracted LangGraph-like state machine. This ETL pipeline will dynamically adjust its flow based on the data passed through each node, allowing for flexible data processing scenarios.
Step 1: Define the Data Model and Node Functionality
First, define Pydantic models for the data that will flow through the ETL pipeline. These models ensure that each stage of the ETL process receives and produces data in the expected format.
This guide and script provide a foundational approach to integrating iOS Shortcuts with web services for security analysis, enhancing your ability to quickly assess the safety of URLs on the fly.
Creating an iOS Shortcuts workflow that integrates with the VirusTotal API to test URLs directly from the Share Sheet involves a series of steps. This workflow will capture URLs shared via the Share Sheet, submit them to the VirusTotal API for safety analysis, and then display the analysis results to you. Below is a guide on setting up this workflow, including the necessary scripts to publish this as a gist or integrate it into your iOS device's Shortcuts app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The MinIoAgent handles user queries by parsing statements and constructing the appropriate sequence of calls to the available tools. Each tool is invoked depending on the specified objective, whether it's listing, uploading, downloading, or removing objects. Intermediate steps are captured and presented in the final response. Users can modify th…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To remove newline characters (\n) or punctuation from strings within your Pydantic models, you can enhance your validators to include these additional checks and transformations. Python's str methods and the string module can be very helpful for such tasks.
Here's an example of how you might adjust a Pydantic model validator to remove newline characters and punctuation from each item in a list attribute:
Extending the Pydantic Model with Custom Validation