Skip to content

Commit

Permalink
add dependabot/kcl lib (#1)
Browse files Browse the repository at this point in the history
* add dependabot

Signed-off-by: Jess Frazelle <[email protected]>

* add stuffs

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* add sentry

Signed-off-by: Jess Frazelle <[email protected]>

* Revert "add sentry"

This reverts commit 7ccb5dc.

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

---------

Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz authored Oct 18, 2023
1 parent 8f32a15 commit eb4875c
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 72 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'daily'
- package-ecosystem: 'github-actions' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'daily'
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
types-lint-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/[email protected]
with:
node-version: '18'
cache: 'yarn'

- run: yarn install

- run: yarn check

- run: yarn lint

- run: yarn build
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ You can preview the production build with `yarn preview`.
## Before submitting a PR

Please run the following commands to ensure that your code is as ready for review as it can be:

```bash
yarn fmt --fix && yarn test
```
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"vite": "^4.4.2",
"vitest": "^0.32.2"
},
"type": "module"
"type": "module",
"dependencies": {
"@kittycad/lib": "^0.0.44"
}
}
40 changes: 14 additions & 26 deletions src/lib/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
export type CADFormat = 'fbx' | 'glb' | 'gltf' | 'obj' | 'ply' | 'step' | 'stl'
import { Models } from '@kittycad/lib'

export type CADFormat = Models['FileExportFormat_type']

interface ListParams {
limit?: number,
page_token?: string,
sort_by?: 'created_at_ascending' | 'created_at_descending',
limit?: number
page_token?: string
sort_by?: Models['CreatedAtSortMode_type']
}

export const endpoints = {
prompt: (output_format: CADFormat = 'step') => `${import.meta.env.VITE_API_BASE_URL}/ai/text-to-cad/${output_format}`,
list: ({ limit, page_token, sort_by = 'created_at_descending' }: ListParams) =>
`${import.meta.env.VITE_API_BASE_URL}/user/text-to-cad?limit=${limit}${page_token ? `&page_token=${page_token}` : ''}&sort_by=${sort_by}`,
prompt: (output_format: CADFormat = 'step') =>
`${import.meta.env.VITE_API_BASE_URL}/ai/text-to-cad/${output_format}`,
list: ({ limit, page_token, sort_by = 'created_at_descending' }: ListParams) =>
`${import.meta.env.VITE_API_BASE_URL}/user/text-to-cad?limit=${limit}${
page_token ? `&page_token=${page_token}` : ''
}&sort_by=${sort_by}`,
feedback: (id: string) => `${import.meta.env.VITE_API_BASE_URL}/user/text-to-cad/${id}`
}

export type PromptResponse = {
completed_at: string,
created_at?: string,
error?: string,
feedback?: "thumbs_up" | 'thumbs_down',
id?: string,
model_version?: string,
output_format?: CADFormat,
outputs?: Record<CADFormat, string>,
prompt?: string,
started_at?: string,
status?: 'queued' | 'uploaded' | 'in_progress' | 'completed' | 'failed',
updated_at?: string,
user_id?: string
}
export type PromptResponse = Models['TextToCad_type']

export type ListResponse = {
items: PromptResponse[],
next_page?: string,
}
export type ListResponse = Models['TextToCadResultsPage_type']
14 changes: 7 additions & 7 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type SubmissionResponse = {
export const load = async () => {
const response = await fetch(endpoints.list({ limit: 10 }), {
headers: {
'Authorization': `Bearer ${import.meta.env.VITE_AUTH_TOKEN}`,
},
Authorization: `Bearer ${import.meta.env.VITE_AUTH_TOKEN}`
}
})

const body = await response.json()
Expand All @@ -25,7 +25,7 @@ export const load = async () => {

return {
status: response.status,
body,
body
} satisfies LoadResponse
}

Expand All @@ -38,11 +38,11 @@ export const actions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${import.meta.env.VITE_AUTH_TOKEN}`,
Authorization: `Bearer ${import.meta.env.VITE_AUTH_TOKEN}`
},
body: JSON.stringify({
prompt: formData.get('prompt'),
}),
prompt: formData.get('prompt')
})
})

const body = await response.json()
Expand All @@ -52,7 +52,7 @@ export const actions = {

return {
status: response.status,
body,
body
} satisfies SubmissionResponse
}
} satisfies Actions
74 changes: 40 additions & 34 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
<script lang="ts">
import type { PageData } from './$types.js'
export let data: PageData
export let form
export let data: PageData
export let form
</script>

<section class="mx-auto max-w-3xl">
<h1 class="text-4xl mb-2">
Text to <span class="text-stroke text-stroke-chalkboard-100 dark:text-stroke-chalkboard-20">CAD</span>
</h1>
<form method="POST" class="flex w-full">
<label class="flex-1">
<span class="sr-only">Enter a text-to-CAD prompt:</span>
<input
autocapitalize="false"
name="prompt"
placeholder="Enter a text-to-CAD prompt:"
required
spellcheck="false"
type="text"
class="w-full px-4 py-1 border"
/>
</label>
<button type="submit" class="submit">Submit</button>
</form>
<h1 class="text-4xl mb-2">
Text to <span class="text-stroke text-stroke-chalkboard-100 dark:text-stroke-chalkboard-20"
>CAD</span
>
</h1>
<form method="POST" class="flex w-full">
<label class="flex-1">
<span class="sr-only">Enter a text-to-CAD prompt:</span>
<input
autocapitalize="false"
name="prompt"
placeholder="Enter a text-to-CAD prompt:"
required
spellcheck="false"
type="text"
class="w-full px-4 py-1 border"
/>
</label>
<button type="submit" class="submit">Submit</button>
</form>
</section>

{#if form}
<p>Submission response:</p>
<p>Submission response:</p>
{/if}

{#if data.body?.items?.length}
<section class="my-24">
<h2>Your generations</h2>
{#each data.body.items as item}
<pre class="border p-4 my-12 first-of-type:mt-0 overflow-auto">{JSON.stringify(item, null, 2)}</pre>
{/each}
</section>
<section class="my-24">
<h2>Your generations</h2>
{#each data.body.items as item}
<pre class="border p-4 my-12 first-of-type:mt-0 overflow-auto">{JSON.stringify(
item,
null,
2
)}</pre>
{/each}
</section>
{/if}

<style lang="postcss">
.submit {
@apply px-4 py-1 border border-l-0;
@apply border-chalkboard-100 dark:border-chalkboard-20;
@apply bg-energy-10 text-energy-100;
@apply dark:bg-energy-90 dark:text-energy-10
}
</style>
.submit {
@apply px-4 py-1 border border-l-0;
@apply border-chalkboard-100 dark:border-chalkboard-20;
@apply bg-energy-10 text-energy-100;
@apply dark:bg-energy-90 dark:text-energy-10;
}
</style>
2 changes: 1 addition & 1 deletion src/routes/view/[modelId]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>The prompt should load here!</h1>
<h1>The prompt should load here!</h1>
Loading

0 comments on commit eb4875c

Please sign in to comment.