Skip to content

Instantly share code, notes, and snippets.

Plan for Email Workflow System with LLM Integration in Frappe Framework

1. Conceptualization:

  • Objective: Build an automated email workflow system using the Frappe framework, incorporating LLM-based decision-making at each step.
  • Key Features: Drag-and-drop interface, LLM integration for content analysis and response, flexible email flow design.

2. System Design:

  • Workflow Builder Interface:
    • Drag-and-Drop Nodes: Users can design email workflows by dragging and dropping nodes representing different actions (e.g., send email, read email, analyze content).
  • Paths and Connections: Define the flow of actions based on the outputs of LLM analyses.
@esafwan
esafwan / Temp.md
Created July 4, 2024 07:49
Purchase Reciept PR

Logical Issues

  1. Redundant List Initialization: stock_and_asset_items is initialized twice.
  2. Confusing Conditional Logic: The logic to determine if the tax amount should be proportionally distributed or based on item-specific rates can be streamlined.
  3. Tax Calculation: The tax rate calculation logic might be unclear and could lead to errors if the item_tax_rate JSON structure or tax conditions are not consistent.

Code Improvement Suggestions

  1. Remove Redundant List Initialization: Only initialize stock_and_asset_items once.
  2. Simplify Conditional Logic: Streamline the conditions for tax amount calculation to improve readability and maintainability.
  3. Use Modern Python Constructs: Utilize list comprehensions and modern Python features for cleaner code.
  4. Improve Error Handling: Add clear error messages and handle potential edge cases, such as empty tax rates or missing item details.
@esafwan
esafwan / doctype.js
Last active June 19, 2024 10:33
Hide Childtable's row, disable checkbox
frappe.ui.form.on('Process File', {
onload: function(frm) {
frm.fields_dict['action'].grid.wrapper.find('.grid-row-check').hide();
frm.fields_dict['action'].grid.wrapper.find('.grid-header-row .grid-row-check').parent().hide();
// Disable row reordering
frm.fields_dict['action'].grid.cannot_be_reordered = true;
// Inject custom CSS to remove the entire checkbox column
$("<style>")
@esafwan
esafwan / all.md
Last active June 2, 2024 21:46
Frappe v15 List + Kanban Js Code

Frappe Kanban Implementation: basepath: frappe/frappe/public/js/frappe/views/kanban/

./kanban_view.js

import KanbanSettings from "./kanban_settings";

frappe.provide("frappe.views");

frappe.views.KanbanView = class KanbanView extends frappe.views.ListView {
@esafwan
esafwan / FrappeCallIntercept.js
Created April 28, 2024 20:31
Override frappe call to intercept the call and act on basis of it.
/**
* Extends the functionality of Frappe's assignment feature for Leads.
*
* Problem:
* When a document like a Lead is assigned to a user via the sidebar, the information about the assignment
* (who it was assigned to, who assigned it, and when) is not stored in a way that can be easily displayed
* on Kanban cards or list columns. It only results in a ToDo list item without these details on the Lead itself.
*
* Solution:

To connect to Frappe's WebSocket and receive real-time updates when a document of a particular DocType is saved, you can use the socket.io-client library in your React Native app. Here's an example of a single-component app that demonstrates how to connect to the WebSocket, authenticate with an API key, and receive updates for a specific DocType:

import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import io from 'socket.io-client';

const API_KEY = 'your_api_key'; // Replace with your actual API key
const SITE_NAME = 'your_site_name'; // Replace with your site name
const DOCTYPE = 'your_doctype'; // Replace with the DocType you want to monitor

For use in prompt for AI for code related to frappe realtime and websocket

Realtime (socket.io) Frappe ships with an API for realtime events based on socket.io. Since socket.io needs a Node server to run, we run a Node process in parallel to the main web server.

Client APIs (JavaScript) frappe.realtime.on

@esafwan
esafwan / img.typ
Last active April 19, 2024 21:06
Typst catlog
#let img(image_path, img_width: auto, img_height: auto, img_alt: none, img_fit: "cover") = [
#image(image_path, width: img_width, height: img_height, alt: img_alt, fit: img_fit)
]
#let fig(image_path, img_width: auto, img_height: auto, img_alt: none, img_fit: "cover", img_caption: none) = [
#figure(
image(image_path, width: img_width, height: img_height, alt: img_alt, fit: img_fit),
caption: [
img_caption
]
@esafwan
esafwan / Simple typst handbook.md
Created April 19, 2024 15:36
short & Simple Typst Guide (WIP)

Image in Typst:

image in typst(raster/vector.Support: PNG, JPEG, GIF & SVG. Params:

image(
str,
format: autostr,
width: autorelative,
height: autorelative,
alt: nonestr,
@esafwan
esafwan / Read Me.md
Created April 16, 2024 05:16
Output directory tree as text with python

Python code for displaying the directory structure of a specific directory. It allows users to view the contents of a directory up to two levels deep, organizing and listing all subdirectories and files neatly.

Example Use Case:

Imagine you have a project directory for a web application, and you want to quickly understand how the files and folders are organized within this directory without diving into each folder manually. You can use this script to print out a structured list of all the directories and files, up to two levels deep.

Directory Structure Example:

Suppose your project directory is structured as follows: