Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/image-url.jpg%20%22Optional%20title%22?q=function&page=89&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 20540 results for "function"(1128ms)

IdkdeepResearchAgent.ts7 matches

@ibrinzila•Updated 2 days ago
15 * 3. Compiling findings into a comprehensive report
16 */
17export default async function(req: Request): Promise<Response> {
18 console.log("Received request:", req.method, req.url);
19
101 }
102
103 // Only accept POST requests for API functionality
104 if (req.method !== "POST") {
105 return new Response(JSON.stringify({ error: "Method not allowed" }), {
169 * Conducts comprehensive research on a topic
170 */
171async function conductResearch(topic: string, depth: "light" | "medium" | "deep" = "medium"): Promise<ResearchReport> {
172 // Step 1: Break down the topic into subtopics
173 const subtopics = await generateSubtopics(topic, depth);
194 * Generates a list of subtopics for the main research topic
195 */
196async function generateSubtopics(topic: string, depth: string): Promise<string[]> {
197 const depthMap = {
198 "light": 3,
263 * Generates default subtopics if the AI-generated ones fail
264 */
265function generateDefaultSubtopics(topic: string, count: number): string[] {
266 const defaultSubtopics = [
267 `Overview of ${topic}`,
283 * Researches a specific subtopic in detail
284 */
285async function researchSubtopic(mainTopic: string, subtopic: string, depth: string): Promise<SubtopicResearch> {
286 const depthMap = {
287 "light": 300,
327 * Generates an executive summary based on all the research
328 */
329async function generateExecutiveSummary(topic: string, subtopicResearch: SubtopicResearch[]): Promise<string> {
330 try {
331 // Create a condensed version of the research to fit within token limits

IdksimpleTest.ts1 match

@ibrinzila•Updated 2 days ago
2 * Simple test to verify that HTTP endpoints are working
3 */
4export default function(req: Request): Response {
5 const html = `<!DOCTYPE html>
6<html lang="en">

IdktestAgent.ts1 match

@ibrinzila•Updated 2 days ago
3 * This will make a simple request to the agent and log the results
4 */
5export default async function(req: Request): Promise<Response> {
6 try {
7 // Get the URL of the current request to determine the agent URL

IdkREADME.md3 matches

@ibrinzila•Updated 2 days ago
1016. **Check Response Format**: If you're calling the API directly, ensure your request format is correct.
102
1037. **Run the Test Endpoint**: Use the test endpoint to verify basic functionality.
104
105## Customization
107You can modify the agent to suit your specific research needs:
108
109- Adjust the number of subtopics based on depth in the `generateSubtopics` function
110- Change the word count for each subtopic in the `researchSubtopic` function
111- Modify the system prompts to focus on specific aspects of research
112

IdkresearchInterface.ts2 matches

@ibrinzila•Updated 2 days ago
4 * A simple web interface to interact with the Deep Research Agent
5 */
6export default function(req: Request): Response {
7 // Get the current URL to determine the agent URL
8 const url = new URL(req.url);
113 <script>
114 // Simple markdown parser
115 function parseMarkdown(text) {
116 if (!text) return '';
117

New-Tweet-Alertmain.tsx3 matches

@amaan_eth•Updated 2 days ago
70}
71
72export default async function(req: Request): Promise<Response> {
73 if (req.method !== "POST") {
74 return new Response("This Val can only process POST requests from SocialData", {
104}
105
106async function sendEventToTelegram(event: NewTweetEvent): Promise<void> {
107 const tweet = event.data;
108 const user = tweet.user;
169}
170
171async function sendPhotoToTelegram(photoUrl: string): Promise<void> {
172 const telegramApiUrl = `https://api.telegram.org/bot${telegramBotApiToken}/sendPhoto`;
173

TownieuseUser.tsx1 match

@jasonkneen•Updated 2 days ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

TownieuseUsageStats.ts1 match

@jasonkneen•Updated 2 days ago
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;

TownieuseScrollToBottom.tsx3 matches

@jasonkneen•Updated 2 days ago
7 *
8 * @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9 * @returns {Object} An object containing containerRef and scrollToBottom function
10 */
11export function useScrollToBottomContainer(dependencies = []) {
12 const containerRef = useRef(null);
13
28
29// body scroll version
30export function useScrollToBottom(dependencies = []) {
31 const bottomRef = useRef(null);
32

Townieuser-summary.ts1 match

@jasonkneen•Updated 2 days ago
6 * This includes a fallback to inference calls data when usage data is missing
7 */
8export async function getUserSummary() {
9 // First, get the standard grouped data from the usage table
10 const groupedUsageData = await sqlite.execute(`

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 weeks ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.