Back
Version 16
4d ago
import { openai } from "npm:@ai-sdk/openai";
import { generateObject, generateText } from "npm:ai";
// Interface definitions
interface RequestBody {
tool_implementation_description?: string;
}
interface ToolResponse {
implementation: string;
description: string;
valUrl: string;
status: string;
message: string;
}
// Constants
const VALTOWN_URL = "https://api.val.town/v1";
const VALTOWN_API_KEY = "vtwn_3tQgC7vhnCNXLLowtinq4ipFygzg";
// 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...");
const body: RequestBody = await req.json();
ajax-create_a_tool.web.val.run
Updated: March 14, 2025