Back

Version 73

3d ago
import { openai } from "npm:@ai-sdk/openai";
import { generateText } from "npm:ai";
import ValTown from 'npm:@valtown/sdk';
// Interface definitions
interface RequestBody {
tool_implementation_description?: string;
}


interface ToolResponse {
description: string;
valUrl: string;
status: string;
message: string;
}

// Constants
const VALTOWN_URL = "https://api.val.town/v1";
const VALTOWN_API_KEY = Deno.env.get("VALTOWN_API_KEY");

const client = new ValTown({ bearerToken: VALTOWN_API_KEY });
// Main handler function
export default async function handler(req: Request): Promise<Response> {
console.debug("Received request with method:", req.method);

// Validate request method
if (req.method !== "POST") {
console.warn("Invalid request method detected:", req.method);
return new Response(
JSON.stringify({ message: "Only POST requests are allowed" }),
{ status: 405, headers: { "Content-Type": "application/json" } },
);
}

try {
console.debug("Parsing request body...");
ajax-create_a_tool.web.val.run
Updated: March 14, 2025