TowniecalculateCost.tsx1 match
5const CACHE_WRITE_RATE = 3.75; // $3.75 per M cache-write tokens
67export function calculateCost({
8input_tokens,
9output_tokens,
TownieBranchSelect.tsx1 match
7const NEW_BRANCH_VAL = "__NEW_BRANCH__";
89export function BranchSelect() {
10const { projectId, branchId } = useParams() as {
11projectId: string;
5* Returns null if authentication is successful, or a Response if it fails
6*/
7export async function basicAuthMiddleware(req: Request): Promise<Response | null> {
8const realm = "Usage Dashboard";
9const unauthorizedResponse = new Response("Unauthorized", {
17});
1819export function App() {
20const [audio, setAudio] = useLocalStorage("AUDIO", false);
21const user = useUser();
ipv4-counterindex.html4 matches
101.replace("ems.sh", "val.town");
102103// Function to format dates nicely
104function formatDate(dateString) {
105const date = new Date(dateString);
106return date.toLocaleString();
107}
108109// Function to update the UI with visit data
110function updateUI(data) {
111// Update total visits
112document.getElementById("total-visits").textContent =
cerebras_coderv2index.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_coderv2index.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 Qwen-3-32B 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_coderv2generate-code.ts3 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}
89function filterThinkingTokens(text: string): string {
10// Find the last occurrence of </think>
11const lastThinkEndIndex = text.lastIndexOf("</think>");
20}
2122export async function generateCode(prompt: string, currentCode: string) {
23const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
24if (starterPrompt) {
133}
134135// --- HTML Generation Function (With Dashboard Grid Background & New Input) ---
136// --- HTML Generation Function (With Luxe-inspired Dashboard Style) ---
137function generateHtmlShell(initialUrl, initialText, initialQuery, sourceUrl) {
138const escapedUrl = initialUrl.replace(/"/g, """);
139const escapedText = initialText.replace(/</g, "<").replace(/>/g, ">");
504// --- Client-side PDF text extraction (basic example, consider robust library like pdf.js for production)
505Â Â // This is a placeholder. Full PDF.js integration is more involved.
506Â Â async function extractTextFromPdfClientSide(file) {
507Â Â Â Â return new Promise((resolve, reject) => {
508Â Â Â Â Â Â const reader = new FileReader();
544Â Â const submitButtonText = submitButton.querySelector('span');
545546Â Â function escapeHtml(unsafe) {
547Â Â Â Â if (unsafe === null || typeof unsafe === 'undefined') return '';
548Â Â Â Â return String(unsafe)
554Â Â }
555556Â Â function addStatusMessage(message, type = 'info') { // types: info, error, progress
557const initialStatusP = statusContainer.querySelector('p');
558if (initialStatusP && initialStatusP.textContent === 'Awaiting input...') {
566Â Â }
567568Â Â function displayAnalysisResults(data) {
569Â Â Â Â structuredResultsContainer.innerHTML = '';
570811812// --- Main Request Handler (Server Code) ---
813export default async function(req: Request) {
814// --- Dynamic Imports (Inside Handler) ---
815const { OpenAI } = await import("https://esm.town/v/std/openai");
833834// --- Helper: Extract Text using pdf.js-extract (Server-side) ---
835async function extractPdfTextNative(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> {
836const agent = "PDF Extraction Agent (Val Server)";
837log.push({ agent, type: "step", message: `Processing PDF: ${fileName} using npm:pdf.js-extract` });
855}
856857// --- Helper Function: Call OpenAI API ---
858async function callOpenAI(
859openai: OpenAI,
860systemPrompt: string,
898899// --- Main Agent Flow Logic (Modified for single Legal AI Agent) ---
900async function runLegalAnalysisFlow(
901input: {
902legalTaskQuery: string;
133}
134135// --- HTML Generation Function (With Dashboard Grid Background & New Input) ---
136function generateHtmlShell(initialUrl, initialText, initialQuery, sourceUrl) {
137const escapedUrl = initialUrl.replace(/"/g, """);
138const escapedText = initialText.replace(/</g, "<").replace(/>/g, ">");
238// Client-side PDF text extraction (basic example, consider robust library like pdf.js for production)
239// This is a placeholder. Full PDF.js integration is more involved.
240async function extractTextFromPdfClientSide(file) {
241return new Promise((resolve, reject) => {
242const reader = new FileReader();
278const submitButtonText = submitButton.querySelector('span');
279280function escapeHtml(unsafe) {
281if (unsafe === null || typeof unsafe === 'undefined') return '';
282return String(unsafe)
288}
289290function addStatusMessage(message, type = 'info') { // types: info, error, progress
291const entry = document.createElement('div');
292entry.className = \`status-entry \${type}\`;
296}
297298function displayAnalysisResults(data) {
299structuredResultsContainer.innerHTML = ''; // Clear previous results
300504505// --- Main Request Handler (Server Code) ---
506export default async function(req: Request) {
507// --- Dynamic Imports (Inside Handler) ---
508const { OpenAI } = await import("https://esm.town/v/std/openai");
526527// --- Helper: Extract Text using pdf.js-extract (Server-side) ---
528async function extractPdfTextNative(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> {
529const agent = "PDF Extraction Agent (Val Server)";
530log.push({ agent, type: "step", message: `Processing PDF: ${fileName} using npm:pdf.js-extract` });
548}
549550// --- Helper Function: Call OpenAI API ---
551async function callOpenAI(
552openai: OpenAI,
553systemPrompt: string,
591592// --- Main Agent Flow Logic (Modified for single Legal AI Agent) ---
593async function runLegalAnalysisFlow(
594input: {
595legalTaskQuery: string;