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

Module Generation #4

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions prompt-templates/create-circuit-chip1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const createCircuitBoard1Template = ({
currentCode = "",
availableImports,
}: { currentCode?: string; availableImports?: Record<string, string> }) => `
Please create a react component export for a chip circuit board in tscircuit with
the user-provided description.
`
1 change: 1 addition & 0 deletions tests/board-samples/sample1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const boardSample1 = "an led with an 0402 footprint"
1 change: 1 addition & 0 deletions tests/board-samples/sample2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const boardSample2 = "a blinking led connected to a 555 timer"
2 changes: 2 additions & 0 deletions tests/board-samples/sample3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const boardSample3 =
"a push button that when pressed will turn on a light"
1 change: 1 addition & 0 deletions tests/board-samples/sample4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const boardSample4 = "a switch that when flipped spins a motor"
1 change: 1 addition & 0 deletions tests/module-samples/sample1-na555.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const moduleSample1 = "the NA555 timer"
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { expect, test } from "bun:test"
import { runInitialPrompt } from "lib/code-runner/run-prompt"
import { createCircuitBoard1Template } from "prompt-templates/create-circuit-board1"
import { sample1 } from "tests/samples/sample1"
import { boardSample1 } from "tests/board-samples/sample1"

test("create-circuit-board1-prompt1", async () => {
const systemPrompt = createCircuitBoard1Template({ currentCode: "" })

const { success, circuit } = await runInitialPrompt(
{ systemPrompt, userPrompt: sample1 },
{ systemPrompt, userPrompt: boardSample1 },
{
model: "claude-3-haiku-20240307",
outputType: "board",
}
},
)

expect(success).toBe(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect, test } from "bun:test"
import { runInitialPrompt } from "lib/code-runner/run-prompt"
import { createCircuitBoard1Template } from "prompt-templates/create-circuit-board1"
import { moduleSample1 } from "tests/module-samples/sample1-na555"

test("create-circuit-board1-prompt1", async () => {
const systemPrompt = createCircuitBoard1Template({ currentCode: "" })

const { success, circuit } = await runInitialPrompt(
{ systemPrompt, userPrompt: boardSample1 },
{
model: "claude-3-haiku-20240307",
outputType: "board",
},
)

expect(success).toBe(true)

const led = circuit?.selectOne("led")

expect(led).toBeDefined()
})
1 change: 0 additions & 1 deletion tests/samples/sample1.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/samples/sample2.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/samples/sample3.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/samples/sample4.ts

This file was deleted.

6 changes: 3 additions & 3 deletions tests/smoke/create-circuit-board1-sample1.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { expect, test } from "bun:test"
import { runInitialPrompt } from "lib/code-runner/run-prompt"
import { createCircuitBoard1Template } from "prompt-templates/create-circuit-board1"
import { sample1 } from "tests/samples/sample1"
import { boardSample1 } from "tests/board-samples/sample1"
import { askAboutOutput } from "tests/fixtures/ask-about-output"

test("create-circuit-board1-prompt1", async () => {
const systemPrompt = createCircuitBoard1Template({ currentCode: "" })

const { success, circuit, codefence } = await runInitialPrompt(
{ systemPrompt, userPrompt: sample1 },
{ systemPrompt, userPrompt: boardSample1 },
{
model: "claude-3-haiku-20240307",
outputType: "board",
}
},
)

expect(success).toBe(true)
Expand Down
4 changes: 2 additions & 2 deletions tests/smoke/create-circuit-board1-with-import.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from "bun:test"
import { runInitialPrompt } from "lib/code-runner/run-prompt"
import { createCircuitBoard1Template } from "prompt-templates/create-circuit-board1"
import { sample1 } from "tests/samples/sample1"
import { boardSample1 } from "tests/board-samples/sample1"
import { askAboutOutput } from "tests/fixtures/ask-about-output"

test("create-circuit-board1-prompt1", async () => {
Expand Down Expand Up @@ -49,7 +49,7 @@ import MicroUsb from "@tsci/seveibar.micro-usb"
preSuppliedImports: {
"@tsci/seveibar.micro-usb": MicroUsb,
},
}
},
)

expect(success).toBe(true)
Expand Down
Loading