Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Testing Setup #1

Open
ChakshuGautam opened this issue Apr 26, 2023 · 4 comments
Open

Automated Testing Setup #1

ChakshuGautam opened this issue Apr 26, 2023 · 4 comments
Assignees

Comments

@ChakshuGautam
Copy link
Contributor

  • Create a folder called /app/e2e/flow and add flows as flow-x where x is the actual test case name.
@Gautam-Rajeev
Copy link

{
"best_crop": {
"User": [
"What is the best crop to grow in Odisha?"
],
"AI": [
"Marigold is a suitable crop to grow in Odisha. Some of the marigold varieties that are suitable for Odisha include Giant Double African Yellow, Giant Double African Orange, Snow Bird, Golden Age, Sirakole, Spun Gold, Spun Yellow, Sweet 'n' Yellow, Sweet 'n' Gold, Bidhan Marigold-1, Bidhan Marigold-2, Pusa Basanti Gainda, Pusa Narangi Gainda, Red Pygmy, Happy Orange, Happy Yellow, Queen Sophia, Goldie, Star Dust, Rusty Red, Lemon Drop, Honey Comb, Golden Boy, Harmony, and Little Devil."
]
},

"Paddy_seeds_scheme_pesticide": {
"User": [
"When should I sow paddy in Kharif",
"Where can I buy their seeds from?",
"What are some pests that affect my crop ?",
"How to manage Green leaf hopper attack on this crop ?" ,
"How to manage Gundhi bug attack on this crop?",
"Where do I buy Abamectin from ? ",
"Can I leverage any scheme for the same? "
],
"AI": [
"The best time to sow paddy in Kharif season in Odisha is from mid-June to mid-July. However, the exact time for sowing may vary depending on the local weather conditions and soil type. It is always advisable to consult the local agricultural department or expert for the ideal sowing time and other farming practices for better yield.",
"You can purchase paddy seeds from registered dealers in Odisha who are registered with the e-Licensing system of the Department of Agriculture & Farmers' Empowerment. You can also purchase seeds through the pre-booking system in the GO-SUGAM portal. Additionally, you may be eligible for subsidy on purchase of seeds under the Seed DBT scheme by the state government. For more information, you can contact your closest extension worker. ",
"Pests that affect paddy crops include Neck Blast disease, Gundhi Bug, Swarming caterpillar, Panicle mite, Grasshopper, Thrips, Green leaf hopper, Stem borer, Bacterial leaf blight, Tungro disease, False smut disease, Foot rot, and Mealy bug. To manage these pests, farmers can use a variety of insecticides, organic solutions, and cultural control methods such as hoeing, weeding, and bund trimming. It is also important to choose the right variety of paddy for the local climate and to consult with a local agriculture officer for advice.",
"The best way to manage Green leaf hopper attack on paddy is to spray Dinotefuran or Flonicamid at the recommended dosage of 80 gm/acre and 60 gm/acre respectively. This should be done when the symptoms of yellowing of leaves from tip to downwards, retarded vigorous and stunted growth, and drying up of plant due to sucking up of the leaves are observed.",
"Based on the context provided, it is recommended to manage Gundhi bug attack on paddy by cleaning field bunds, avoiding staggered planting, using varieties with synchronisation of flowering in a large area, using flame torch at 8nos/ha of field bunds, and spraying/dusting Abamectin at 500ml/ha in a spiral manner from the field bund and ends at the centre.",
"The user can purchase Abamectin from registered dealers in the state of Odisha who are registered with the e-Licensing system of the Department of Agriculture & Farmers' Empowerment. These dealers are authorised to sell certified agri inputs by the state government. Farmers can also access the Need based plant protection DBT scheme to avail subsidy on purchase of pesticides.",
"No content yet"
]
},

"Paddy_seeds_variety_scheme": {
"User": [
"When should I sow paddy in Kharif",
"Where can I buy their seeds from?",
"What are some other best practices while growing paddy ?"
],
"AI": [
"The best time to sow paddy in Kharif season in Odisha is from mid-June to mid-July. However, the exact time for sowing may vary depending on the local weather conditions and soil type. It is always advisable to consult the local agricultural department or expert for the ideal sowing time and other farming practices for better yield.",
"You can purchase paddy seeds from registered dealers in Odisha who are registered with the e-Licensing system of the Department of Agriculture & Farmers' Empowerment. You can also purchase seeds through the pre-booking system in the GO-SUGAM portal. Additionally, you may be eligible for subsidy on purchase of seeds under the Seed DBT scheme by the state government. For more information, you can contact your closest extension worker. ",
"The best practices for growing paddy include choosing a variety that is adapted to the local climatic conditions, has a good yield potential, is tolerant to biotic and abiotic stresses, and has good grain quality. Additionally, it is important to consult with a local agriculture officer to know about the best performing rice varieties in the area."
]
}

}

@ChakshuGautam
Copy link
Contributor Author

PR Raised here

@ChakshuGautam
Copy link
Contributor Author

QA tests it => if regression found add it to the test cases PR.

@ChakshuGautam ChakshuGautam changed the title Format test cases for QA Automated Testing Setup May 17, 2023
@ChakshuGautam
Copy link
Contributor Author

ChakshuGautam commented May 18, 2023

Hey @Amruth-Vamshi sharing a gist here.

  • Create the drawio tree in mermaid. @GautamR-Samagra
  • Generate random % for all paths. (Replace arrow with --40-->)
  • Walk over it to create different test cases dynamically. Stop at the flow on the nodes that are defined as Stop.
  • Fix the socket connection issue
  • Publish the results of a test case
    • Path taken - Q and A
    • Time taken - average, total, each response
    • +/- Responses - Embedding search of 0.97
type Node = string;
type WeightedEdge = [Node, Node, number];

interface Graph {
    [key: string]: { [key: string]: number };
}

class Parser {
    private diagram: string;

    constructor(diagram: string) {
        this.diagram = diagram;
    }

    private parse(): WeightedEdge[] {
        const edges = this.diagram.split("\n").filter(line => line.includes('--'));
        return edges.map(edge => {
            const [from, toWithWeight] = edge.split('--');
            const [to, weight] = toWithWeight.split('%-->');

            return [from.trim(), to.trim(), Number(weight) / 100];
        });
    }

    public toGraph(): Graph {
        const graph: Graph = {};
        const edges = this.parse();
        for (const [from, to, weight] of edges) {
            if (!(from in graph)) {
                graph[from] = {};
            }

            graph[from][to] = weight;
        }

        return graph;
    }
}

class Walker {
    private graph: Graph;

    constructor(graph: Graph) {
        this.graph = graph;
    }

    public walk(start: Node): void {
        let currentNode = start;
        while (true) {
            console.log(currentNode);
            const neighbors = this.graph[currentNode];
            if (!neighbors) {
                break;
            }

            const neighborsArr = Object.keys(neighbors);
            const weights = neighborsArr.map(neighbor => neighbors[neighbor]);

            let choice = this.weightedRandom(neighborsArr, weights);
            currentNode = choice;
        }
    }

    private weightedRandom(options: string[], weights: number[]): string {
        let i, pickedIndex,
            totalWeight = weights.reduce((prev, curr) => prev + curr, 0);
            
        let randomNum = Math.random() * totalWeight;
        
        for (i = 0; i < options.length; i++) {
            randomNum -= weights[i];

            if (randomNum < 0) {
                pickedIndex = i;
                break;
            }
        }

        return options[pickedIndex];
    }
}

// Create a new parser and parse the mermaid diagram
const diagram = `
    graph TD;
    A[Define Problem]--100%-->B[Collect Human Feedback];
    B--100%-->C[Preprocess Human Feedback];
    C--100%-->D[Train Initial RL Agent];
    D--100%-->E[Fine-tune with RL];
    E--100%-->A[Evaluate and Iterate];
`;

const parser = new Parser(diagram);
const graph = parser.toGraph();

// Create a new walker and walk through the graph
const walker = new Walker(graph);
walker.walk("A[Define Problem]");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

4 participants