cerebras_coderqueries.ts5 matches
2import { ITERATIONS_TABLE, KEY, PROJECTS_TABLE, SCHEMA_VERSION } from "./migrations.ts";
34export async function createProject(prompt: string) {
5const projectResult = await sqlite.execute(
6`INSERT INTO ${PROJECTS_TABLE} (initial_prompt) VALUES (?)`,
11}
1213export async function getNextVersionNumber(projectId: number) {
14const data = await sqlite.execute(
15`SELECT version_number FROM ${ITERATIONS_TABLE}
21}
2223export async function insertVersion(projectId: number, versionNumber: number, prompt: string, code: string) {
24await sqlite.execute(
25`INSERT INTO ${ITERATIONS_TABLE}
29}
3031export async function getCodeInner(table: string, project: string, version?: string) {
32let data;
33if (version === undefined) {
50}
5152export async function getCode(project: string, version?: string) {
53// try to get code in the new table partition first
54const code = await getCodeInner(ITERATIONS_TABLE, project, version);
cerebras_codermigrations.ts1 match
7export const ITERATIONS_TABLE = "cerebras_coder_iterations";
89export async function createTables() {
10await sqlite.execute(`
11CREATE TABLE IF NOT EXISTS ${PROJECTS_TABLE} (
cerebras_codermain.tsx1 match
6await createTables();
78export default async function cerebras_coder(req: Request): Promise<Response> {
9if (req.method === "POST") {
10let { prompt, currentCode, versionHistory, projectId } = await req.json();
cerebras_coderindex.ts7 matches
23);
2425function Hero({
26prompt,
27setPrompt,
4445<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46Turn your ideas into fully functional apps in{" "}
47<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48less than a second
115}
116117function App() {
118const previewRef = React.useRef<HTMLDivElement>(null);
119const [prompt, setPrompt] = useState("");
169});
170171function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172setLoading(true);
173setTimeout(() => handleSubmit(promptItem.prompt), 0);
174}
175176async function handleSubmit(e: React.FormEvent | string) {
177if (typeof e !== "string") {
178e.preventDefault();
225}
226227function handleVersionChange(direction: "back" | "forward") {
228const { currentVersionIndex, versions } = versionHistory;
229if (direction === "back" && currentVersionIndex > 0) {
973);
974975function client() {
976const path = window.location.pathname;
977const root = createRoot(document.getElementById("root")!);
cerebras_coderindex.html1 match
19<meta property="og:site_name" content="Cerebras Coder">
20<meta property="og:url" content="https://cerebrascoder.com"/>
21<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22<meta property="og:type" content="website">
23<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
cerebras_codergenerate-code.ts2 matches
2import STARTER_PROMPTS from "../public/starter-prompts.js";
34function extractCodeFromFence(text: string): string {
5const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6return htmlMatch ? htmlMatch[1].trim() : text;
7}
89export async function generateCode(prompt: string, currentCode: string) {
10const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11if (starterPrompt) {
steamforumscannerREADME.md1 match
10import scanSteamForums from "https://esm.town/v/dreww/steamforumscanner";
1112export default async function(interval: Interval) {
13const dota2Threads = await scanSteamForums({
14gameName: "Dota 2",
steamforumscannermain.tsx15 matches
29}
3031async function sendErrorEmail(gameName: string, error: Error, context: string) {
32const subject = `Error in Steam Forum Scanner for ${gameName}`;
33const text = `An error occurred while ${context} for ${gameName}:\n\n${error.message}\n\n${error.stack}`;
41}
4243function constructSteamUrl(steamId: string): string {
44return `https://steamcommunity.com/app/${steamId}/discussions/`;
45}
4647export default async function scanSteamForums({
48gameName,
49steamId,
98}
99100async function cleanupDebugHtmlBlobs(gameName: string) {
101try {
102const debugBlobs = await blob.list(`steam_html_debug_${gameName}_`);
115}
116117async function fetchSteamDiscussionsPage(url: string): Promise<string> {
118const response = await fetch(url, {
119headers: {
132}
133134async function saveDebugHtml(gameName: string, html: string) {
135const key = `steam_html_debug_${gameName}_${Date.now()}`;
136await blob.set(key, html);
138}
139140async function getStoredThreads(gameName: string): Promise<SteamThread[]> {
141const storageKey = `steam_threads_${gameName}`;
142return await blob.getJSON(storageKey) ?? [];
143}
144145function identifyThreadsToNotify(currentThreads: SteamThread[], storedThreads: SteamThread[]): SteamThread[] {
146return currentThreads.filter(currentThread => {
147const storedThread = storedThreads.find(st => st.id === currentThread.id);
150}
151152async function sendDiscordNotifications(
153gameName: string,
154threads: SteamThread[],
174}
175176async function updateStoredThreads(gameName: string, storedThreads: SteamThread[], currentThreads: SteamThread[]) {
177const currentThreadMap = new Map(currentThreads.map(thread => [thread.id, thread]));
178200}
201202function parseThreads(html: string): SteamThread[] {
203const $ = cheerio.load(html);
204251}
252253function cleanTitle(title: string): string {
254return title.replace(/\t/g, '').trim();
255}
256257function parseForumTopic($: cheerio.Root, el: cheerio.Element): SteamThread {
258const threadNameEl = $(el).find(".forum_topic_name");
259const link = $(el).find(".forum_topic_overlay");
275}
276277function parseForumTopicName($: cheerio.Root, el: cheerio.Element): SteamThread {
278const link = $(el).find("a");
279const url = link.attr("href") ?? "";
295}
296297async function sendDiscordWebhook(
298gameName: string,
299threads: SteamThread[],
synced_reducermain.tsx1 match
1export default async function(req: Request): Promise<Response> {
2const url = new URL(req.url);
3if (url.pathname === "/v1") {
templateTwitterAlertREADME.md2 matches
46- Key: `mentionsDiscord`
47- Value: Your Discord webhook URL.
48Notifications will be sent using this function:
4950```ts
6364- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.