mirror of
https://github.com/SkalaraAI/skalara-mvp.git
synced 2025-04-03 20:10:21 -04:00
started dedpuing logic
This commit is contained in:
parent
ff35d2c537
commit
4d6920d56b
86
app/page.tsx
86
app/page.tsx
|
@ -33,6 +33,7 @@ import {
|
|||
} from "@/components/ui/table";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { set } from "date-fns";
|
||||
|
||||
const MIN_FEATURES_PER_PROJECT = 6;
|
||||
const MAX_FEATURES_PER_PROJECT = 12;
|
||||
|
@ -63,6 +64,14 @@ const openai = new OpenAIChatApi(
|
|||
}
|
||||
);
|
||||
|
||||
type Project = {
|
||||
name: string;
|
||||
description: string;
|
||||
stack: string[];
|
||||
features?: Feature[];
|
||||
tasks?: Task[];
|
||||
};
|
||||
|
||||
type Feature = {
|
||||
name: string;
|
||||
description: string;
|
||||
|
@ -95,6 +104,8 @@ export default function Home() {
|
|||
});
|
||||
|
||||
const [stackInput, setStackInput] = useState("");
|
||||
const [deps, setDeps] = useState<Dependency[]>([]);
|
||||
const [project, setProject] = useState<Project>();
|
||||
const [features, setFeatures] = useState<Feature[]>([]);
|
||||
const [tasks, setTasks] = useState<Task[]>([]);
|
||||
|
||||
|
@ -103,6 +114,7 @@ export default function Home() {
|
|||
async function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
setFeatures([]);
|
||||
setTasks([]);
|
||||
setProject(values);
|
||||
|
||||
try {
|
||||
const feature_gen_prompt = `You are an AI software project manager. You use agile methodology and the best software project management techniques to plan software projects for indie developers.
|
||||
|
@ -276,6 +288,18 @@ Instructions: For each feature, we need to figure out what other features need t
|
|||
});
|
||||
const tasks: Task[][] = await Promise.all(featurePromises);
|
||||
setTasks(tasks.flat());
|
||||
|
||||
let featuresWithTasks = [...features];
|
||||
featuresWithTasks.forEach((feature) => {
|
||||
feature.tasks = tasks
|
||||
.flat()
|
||||
.filter((task) => task.feature === feature.uid);
|
||||
});
|
||||
|
||||
setFeatures(featuresWithTasks);
|
||||
setDeps(_dependencies);
|
||||
|
||||
console.log("featuresWithTasks ", featuresWithTasks);
|
||||
}
|
||||
|
||||
async function generateTask(
|
||||
|
@ -360,6 +384,64 @@ Dependency-Based Order (numeric)
|
|||
}
|
||||
}
|
||||
|
||||
async function dedupeTasks() {
|
||||
try {
|
||||
features.forEach((feature) => {
|
||||
console.log("deduping feature ", feature.name);
|
||||
let _deps = deps
|
||||
.filter((dep) => dep.uid === feature.uid)
|
||||
.map((dep) => dep.depUid);
|
||||
if (_deps.length > 0) {
|
||||
feature.tasks!.forEach((task) => {
|
||||
console.log("deduping task ", task.name);
|
||||
let otherTasks: Task[] = [];
|
||||
_deps.forEach((dep) => {
|
||||
otherTasks = [
|
||||
...otherTasks,
|
||||
...tasks.filter((t) => t.feature === dep),
|
||||
];
|
||||
});
|
||||
dedupeTask(task, otherTasks);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
async function dedupeTask(targetTask: Task, otherTasks: Task[]) {
|
||||
try {
|
||||
const prompt = `You are an AI software project manager. You use agile methodology and the best software project management techniques to plan software projects for indie developers.
|
||||
|
||||
I am an indie developer creating a new software project. Here are the details:
|
||||
"""
|
||||
Project Name: ${project?.name}
|
||||
Project Description: ${project?.description}
|
||||
Tech Stack: ${project?.stack.join(", ")}
|
||||
"""
|
||||
We have generated a list of features which contain a list of tasks to build out those features. We need to dedupe the tasks so that we don't have any duplicate tasks. Check if this task is a duplicate of any other task in the project. If it is, then return the UID of the task that it is a duplicate of. If it is not a duplicate, then return null.
|
||||
|
||||
Task:
|
||||
"""
|
||||
Name: ${targetTask.name}
|
||||
Description: ${targetTask.description}
|
||||
"""
|
||||
|
||||
Other Tasks:
|
||||
"""
|
||||
${otherTasks.map((task) => {
|
||||
return `Name: ${task.name}, Description: ${task.description}, ID: ${task.uid}.\n`;
|
||||
})}
|
||||
"""
|
||||
`;
|
||||
|
||||
// logic to to actually complete and return a boolean
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
const keyHandler = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if ((e.key === "Enter" || e.key === "Tab") && stackInput !== "") {
|
||||
e.preventDefault();
|
||||
|
@ -455,6 +537,7 @@ Dependency-Based Order (numeric)
|
|||
<TabsList>
|
||||
<TabsTrigger value="features">Features</TabsTrigger>
|
||||
<TabsTrigger value="tasks">Tasks</TabsTrigger>
|
||||
<TabsTrigger value="duplicates">Duplicates</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="features">
|
||||
<Table>
|
||||
|
@ -505,6 +588,9 @@ Dependency-Based Order (numeric)
|
|||
);
|
||||
})}
|
||||
</TabsContent>
|
||||
<TabsContent value="duplicates">
|
||||
This is where deduping logic will be displayed.
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user