Skip to content
Open
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
23 changes: 18 additions & 5 deletions lib/prompt-templates/create-local-circuit-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async function fetchFileContent(url: string): Promise<string> {
}
return await response.text()
} catch (error) {
console.error("Error fetching file content:", error)
throw error
console.warn(`Unable to fetch ${url}:`, error)
return ""
}
}

Expand All @@ -33,22 +33,35 @@ export const createLocalCircuitPrompt = async () => {
"",
)

const propsDoc =
(await fetchFileContent(
const [generatedAiDoc, propsDoc] = await Promise.all([
fetchFileContent("https://docs.tscircuit.com/ai.txt"),
fetchFileContent(
"https://raw.githubusercontent.com/tscircuit/props/main/generated/COMPONENT_TYPES.md",
)) || ""
),
])

const cleanedGeneratedAiDoc = generatedAiDoc
.replace(/\r/g, "")
.replace(/\n{3,}/g, "\n\n")
.trim()

const cleanedPropsDoc = propsDoc
.split("\n")
.filter((line) => !line.startsWith("#"))
.join("\n")
.replace(/\n\n+/g, "\n\n")

const generatedDocsSection = cleanedGeneratedAiDoc
? `## Auto-generated tscircuit docs\n\n${cleanedGeneratedAiDoc}\n`
: ""

return `
You are an expert in electronic circuit design and tscircuit, and your job is to create a circuit board in tscircuit with the user-provided description.

YOU MUST ABIDE BY THE RULES IN THE RULES SECTION

${generatedDocsSection}

## tscircuit API overview

Here's an overview of the tscircuit API:
Expand Down
Loading