From 915456f998cc1df419c5641c16f2417530c68319 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:02:28 +0000 Subject: [PATCH 01/13] Create sweep.yaml --- sweep.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sweep.yaml diff --git a/sweep.yaml b/sweep.yaml new file mode 100644 index 0000000..89e1d02 --- /dev/null +++ b/sweep.yaml @@ -0,0 +1,27 @@ +# Sweep AI turns bugs & feature requests into code changes (https://sweep.dev) +# For details on our config file, check out our docs at https://docs.sweep.dev/usage/config + +# This setting contains a list of rules that Sweep will check for. If any of these rules are broken in a new commit, Sweep will create an pull request to fix the broken rule. +rules: + - "All new business logic should have corresponding unit tests." + - "Refactor large functions to be more modular." + - "Add docstrings to all functions and file headers." + +# This is the branch that Sweep will develop from and make pull requests to. Most people use 'main' or 'master' but some users also use 'dev' or 'staging'. +branch: 'main' + +# By default Sweep will read the logs and outputs from your existing Github Actions. To disable this, set this to false. +gha_enabled: True + +# This is the description of your project. It will be used by sweep when creating PRs. You can tell Sweep what's unique about your project, what frameworks you use, or anything else you want. +# +# Example: +# +# description: sweepai/sweep is a python project. The main api endpoints are in sweepai/api.py. Write code that adheres to PEP8. +description: '' + +# This sets whether to create pull requests as drafts. If this is set to True, then all pull requests will be created as drafts and GitHub Actions will not be triggered. +draft: False + +# This is a list of directories that Sweep will not be able to edit. +blocked_dirs: [] From abe0cdcfea6653ce208ab8638bf8cbb5d7109dbd Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:02:29 +0000 Subject: [PATCH 02/13] Create sweep template --- .github/ISSUE_TEMPLATE/sweep-template.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/sweep-template.yml diff --git a/.github/ISSUE_TEMPLATE/sweep-template.yml b/.github/ISSUE_TEMPLATE/sweep-template.yml new file mode 100644 index 0000000..9d687a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/sweep-template.yml @@ -0,0 +1,22 @@ +name: Sweep Issue +title: 'Sweep: ' +description: For small bugs, features, refactors, and tests to be handled by Sweep, an AI-powered junior developer. +labels: sweep +body: + - type: textarea + id: description + attributes: + label: Details + description: Tell Sweep where and what to edit and provide enough context for a new developer to the codebase + placeholder: | + Unit Tests: Write unit tests for . Test each function in the file. Make sure to test edge cases. + Bugs: The bug might be in . Here are the logs: ... + Features: the new endpoint should use the ... class from because it contains ... logic. + Refactors: We are migrating this function to ... version because ... + - type: input + id: branch + attributes: + label: Branch + description: The branch to work off of (optional) + placeholder: | + main \ No newline at end of file From 2993ab718648a15d6ac1f260809c8a25db33bbbc Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:22:33 +0000 Subject: [PATCH 03/13] feat: Add Dockerfile for application deployment --- Dockerfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bda7e6a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Node.js 14 image. +FROM node:14 + +# Set the working directory. +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies. +RUN npm install + +# Copy local code to the container image. +COPY . ./ + +# Build the application +RUN npm run build + +# Start the application +CMD [ "npm", "start" ] From 21522bbcd75d42c43e774455e8b90716681db802 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:22:58 +0000 Subject: [PATCH 04/13] feat: Add Kubernetes deployment configuration --- kubernetes/deployment.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 kubernetes/deployment.yaml diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yaml new file mode 100644 index 0000000..b8445ef --- /dev/null +++ b/kubernetes/deployment.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: haven-app + labels: + app: haven +spec: + replicas: 3 + selector: + matchLabels: + app: haven + template: + metadata: + labels: + app: haven + spec: + containers: + - name: haven-app + image: haven:latest + ports: + - containerPort: 8080 + resources: + requests: + cpu: "100m" + memory: "256Mi" + limits: + cpu: "500m" + memory: "512Mi" + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 1 From 0e425baa8f5a058f278175614ad16ef7b007a49f Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:23:15 +0000 Subject: [PATCH 05/13] feat: Add Kubernetes service configuration --- kubernetes/service.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 kubernetes/service.yaml diff --git a/kubernetes/service.yaml b/kubernetes/service.yaml new file mode 100644 index 0000000..d1d509a --- /dev/null +++ b/kubernetes/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: haven-service +spec: + selector: + app: haven + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + type: LoadBalancer From 79d3e0d03fa4eb3e19c2f8ead1ee0decedb5fe83 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:23:53 +0000 Subject: [PATCH 06/13] feat: Updated main/src/app/api/inference/route.ts --- main/src/app/api/inference/route.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/src/app/api/inference/route.ts b/main/src/app/api/inference/route.ts index 0761c0a..1b84001 100644 --- a/main/src/app/api/inference/route.ts +++ b/main/src/app/api/inference/route.ts @@ -26,7 +26,7 @@ async function getResponse(host: string, modelId: string | undefined, validatedB console.log("sending request", body, host); - return fetch(host, { + return fetch('haven-service', { method: "POST", headers: { "Content-Type": "application/json", @@ -84,7 +84,7 @@ export async function POST(request: Request) { const baseModel = model?.baseModel || defaultModelLoopup[validatedBody.modelId as keyof typeof defaultModelLoopup]; const baseModelValidated = y.string().oneOf(modelsToFinetune).required().validateSync(baseModel); - const host = inferenceEndpoints[baseModelValidated]; + return retryInference( async () => { From 7af0195ea812d06556810f8400cf3d612ac5caa6 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:12:18 +0000 Subject: [PATCH 07/13] feat: Add DatasetVisualization component for datas --- main/src/app/datasets/visualization.tsx | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 main/src/app/datasets/visualization.tsx diff --git a/main/src/app/datasets/visualization.tsx b/main/src/app/datasets/visualization.tsx new file mode 100644 index 0000000..e53b068 --- /dev/null +++ b/main/src/app/datasets/visualization.tsx @@ -0,0 +1,48 @@ +import React, { useState, useEffect } from 'react'; +import { Button } from '~/components/form/button'; +import { getDatasetDetails } from '~/server/controller/dataset'; + +const DatasetVisualization = ({ selectedDatasetId }) => { + const [datasetDetails, setDatasetDetails] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(''); + + useEffect(() => { + const fetchDatasetDetails = async () => { + setIsLoading(true); + setError(''); + try { + const details = await getDatasetDetails(selectedDatasetId); + setDatasetDetails(details); + } catch (err) { + setError('Failed to fetch dataset details'); + } finally { + setIsLoading(false); + } + }; + + if (selectedDatasetId) { + fetchDatasetDetails(); + } + }, [selectedDatasetId]); + + if (isLoading) return

Loading...

; + if (error) return

Error: {error}

; + if (!datasetDetails) return

No dataset selected

; + + return ( +
+

{datasetDetails.name}

+

Rows: {datasetDetails.rows}

+

Created: {datasetDetails.created}

+ + +
+ ); +}; + +export default DatasetVisualization; From 0dd6d152e81d007708c09dcfe862e485249578aa Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:30:57 +0000 Subject: [PATCH 08/13] feat: Add HuggingFace API interaction for dataset --- main/src/server/controller/huggingface.ts | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 main/src/server/controller/huggingface.ts diff --git a/main/src/server/controller/huggingface.ts b/main/src/server/controller/huggingface.ts new file mode 100644 index 0000000..11dd65a --- /dev/null +++ b/main/src/server/controller/huggingface.ts @@ -0,0 +1,45 @@ +import axios from 'axios'; +import { createDataset } from '../database/dataset'; +import { downloadFile } from '../utils/modal'; + +const HUGGINGFACE_API_BASE_URL = 'https://huggingface.co/api'; + +export async function searchDatasets(query: string) { + const response = await axios.get(`${HUGGINGFACE_API_BASE_URL}/datasets/search`, { + params: { search: query }, + }); + return response.data; +} + +export async function downloadDataset(datasetId: string, userId: string) { + const datasetResponse = await axios.get(`${HUGGINGFACE_API_BASE_URL}/datasets/${datasetId}/download`, { + responseType: 'blob', + }); + + const datasetContent = datasetResponse.data; + const fileName = `${datasetId}.zip`; + + const downloadUrl = await downloadFile(datasetContent, fileName); + + // Assuming the function to extract metadata from the dataset file exists + const { name, rows } = extractMetadataFromDataset(datasetContent); + + await createDataset(userId, name, downloadUrl, rows); +} + +import JSZip from 'jszip'; + +function extractMetadataFromDataset(datasetContent: Blob): Promise<{ name: string; rows: number }> { + return new Promise((resolve, reject) => { + const zip = new JSZip(); + zip.loadAsync(datasetContent) + .then(zip => { + // Assuming the dataset is in a file named 'data.csv' inside the zip + zip.file('data.csv').async('string').then(content => { + const rows = content.split('\n').length - 1; // Subtract 1 for the header row + const name = 'Extracted Dataset Name'; // Placeholder for actual logic to extract name + resolve({ name, rows }); + }).catch(reject); + }).catch(reject); + }); +} From a61c0fb85bde8ef90654bddef3c3f4e9282779e9 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:33:04 +0000 Subject: [PATCH 09/13] feat: Updated main/src/app/datasets/page.tsx --- main/src/app/datasets/page.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/src/app/datasets/page.tsx b/main/src/app/datasets/page.tsx index 929f7f0..dd5a453 100644 --- a/main/src/app/datasets/page.tsx +++ b/main/src/app/datasets/page.tsx @@ -6,6 +6,7 @@ import DatasetTable from "./table"; import {getDatasets} from "~/server/database/dataset"; import type {Dataset} from "@prisma/client"; +import DatasetVisualization from './visualization'; function updatedAtToPrettyString(updatedAt: Date) { const now = new Date(); @@ -69,6 +70,7 @@ export default async function Page() {
+{/* TODO: Modify DatasetTable or its usage to include buttons for dataset visualization and download. Implement event handlers for these actions. */} ); } From 48e860722a253469676859343d163331a38420cc Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:35:48 +0000 Subject: [PATCH 10/13] feat: Updated main/src/app/datasets/table.tsx --- main/src/app/datasets/table.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main/src/app/datasets/table.tsx b/main/src/app/datasets/table.tsx index dece84e..70641f8 100644 --- a/main/src/app/datasets/table.tsx +++ b/main/src/app/datasets/table.tsx @@ -50,6 +50,9 @@ export default function DatasetTable({datasets}: {datasets: DatasetTableProps}) Created + + Actions + @@ -61,6 +64,10 @@ export default function DatasetTable({datasets}: {datasets: DatasetTableProps}) {/*{dataset.description}*/} {dataset.rows} {dataset.created} + + + + {/* From 20de25b49f048d28b8cee08b3d543794eda87038 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:37:55 +0000 Subject: [PATCH 11/13] feat: Updated main/src/server/database/dataset.ts --- main/src/server/database/dataset.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/src/server/database/dataset.ts b/main/src/server/database/dataset.ts index 5c72e35..f4041e4 100644 --- a/main/src/server/database/dataset.ts +++ b/main/src/server/database/dataset.ts @@ -1,15 +1,18 @@ import {db} from "."; -export async function createDataset(userId: string, name: string, fileName: string, rows: number) { +export async function createDataset(userId: string, name: string, fileName: string, rows: number, huggingFaceUrl: string, huggingFaceId: string) { return db.dataset.create({ data: { userId, name, fileName, rows, + huggingFaceUrl, + huggingFaceId, }, }); } +// Note: The database schema needs to be updated to include 'huggingFaceUrl' and 'huggingFaceId' fields. These fields should be of type string. export async function getDatasets(userId: string) { return db.dataset.findMany({ From faa30962ddae238bab03ce26459e1a7a66c07e08 Mon Sep 17 00:00:00 2001 From: Unity AI <157737648+uniAIDevs@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:45:20 -0400 Subject: [PATCH 12/13] Delete .github/ISSUE_TEMPLATE/sweep-template.yml --- .github/ISSUE_TEMPLATE/sweep-template.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/sweep-template.yml diff --git a/.github/ISSUE_TEMPLATE/sweep-template.yml b/.github/ISSUE_TEMPLATE/sweep-template.yml deleted file mode 100644 index 9d687a3..0000000 --- a/.github/ISSUE_TEMPLATE/sweep-template.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Sweep Issue -title: 'Sweep: ' -description: For small bugs, features, refactors, and tests to be handled by Sweep, an AI-powered junior developer. -labels: sweep -body: - - type: textarea - id: description - attributes: - label: Details - description: Tell Sweep where and what to edit and provide enough context for a new developer to the codebase - placeholder: | - Unit Tests: Write unit tests for . Test each function in the file. Make sure to test edge cases. - Bugs: The bug might be in . Here are the logs: ... - Features: the new endpoint should use the ... class from because it contains ... logic. - Refactors: We are migrating this function to ... version because ... - - type: input - id: branch - attributes: - label: Branch - description: The branch to work off of (optional) - placeholder: | - main \ No newline at end of file From 4d639dfc352ced7ecde7118b7a44efe7fdd092fa Mon Sep 17 00:00:00 2001 From: Unity AI <157737648+uniAIDevs@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:52:54 -0400 Subject: [PATCH 13/13] Delete sweep.yaml --- sweep.yaml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 sweep.yaml diff --git a/sweep.yaml b/sweep.yaml deleted file mode 100644 index 89e1d02..0000000 --- a/sweep.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Sweep AI turns bugs & feature requests into code changes (https://sweep.dev) -# For details on our config file, check out our docs at https://docs.sweep.dev/usage/config - -# This setting contains a list of rules that Sweep will check for. If any of these rules are broken in a new commit, Sweep will create an pull request to fix the broken rule. -rules: - - "All new business logic should have corresponding unit tests." - - "Refactor large functions to be more modular." - - "Add docstrings to all functions and file headers." - -# This is the branch that Sweep will develop from and make pull requests to. Most people use 'main' or 'master' but some users also use 'dev' or 'staging'. -branch: 'main' - -# By default Sweep will read the logs and outputs from your existing Github Actions. To disable this, set this to false. -gha_enabled: True - -# This is the description of your project. It will be used by sweep when creating PRs. You can tell Sweep what's unique about your project, what frameworks you use, or anything else you want. -# -# Example: -# -# description: sweepai/sweep is a python project. The main api endpoints are in sweepai/api.py. Write code that adheres to PEP8. -description: '' - -# This sets whether to create pull requests as drafts. If this is set to True, then all pull requests will be created as drafts and GitHub Actions will not be triggered. -draft: False - -# This is a list of directories that Sweep will not be able to edit. -blocked_dirs: []