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/$%7Burl%7D?q=function&page=105&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 29291 results for "function"(4230ms)

nelsongptindex.html1 match

@zee1205โ€ขUpdated 4 days ago
77 }
78
79 /* Hide scrollbar but keep functionality */
80 .hide-scrollbar {
81 -ms-overflow-style: none;

nelsongptmistral.ts4 matches

@zee1205โ€ขUpdated 4 days ago
9const MISTRAL_API_URL = 'https://api.mistral.ai/v1/chat/completions';
10
11export async function generateMistralResponse(
12 userMessage: string,
13 context: VectorSearchResult[] = [],
57}
58
59function createSystemPrompt(context: VectorSearchResult[]): string {
60 const basePrompt = `You are Nelson-GPT, a specialized medical AI assistant powered by the Nelson Textbook of Pediatrics. You provide evidence-based answers to healthcare professionals and medical students focusing on pediatric medicine.
61
89}
90
91export async function* streamMistralResponse(response: Response): AsyncGenerator<string, void, unknown> {
92 const reader = response.body?.getReader();
93 if (!reader) {
132}
133
134export async function generateNonStreamingResponse(
135 userMessage: string,
136 context: VectorSearchResult[] = []

nelsongptembeddings.ts5 matches

@zee1205โ€ขUpdated 4 days ago
4const EMBEDDING_MODEL = 'sentence-transformers/all-MiniLM-L6-v2';
5
6export async function generateEmbedding(text: string): Promise<number[]> {
7 try {
8 const response = await fetch(
44}
45
46export async function generateEmbeddings(texts: string[]): Promise<number[][]> {
47 try {
48 const embeddings = await Promise.all(
56}
57
58// Utility function to normalize embeddings (optional, for better similarity search)
59export function normalizeEmbedding(embedding: number[]): number[] {
60 const magnitude = Math.sqrt(embedding.reduce((sum, val) => sum + val * val, 0));
61 return embedding.map(val => val / magnitude);
63
64// Calculate cosine similarity between two embeddings
65export function cosineSimilarity(a: number[], b: number[]): number {
66 if (a.length !== b.length) {
67 throw new Error('Embeddings must have the same length');

nelsongptsupabase.ts9 matches

@zee1205โ€ขUpdated 4 days ago
7export const supabase = createClient(supabaseUrl, supabaseServiceKey);
8
9export async function searchSimilarContent(
10 embedding: number[],
11 limit: number = 5,
35}
36
37export async function insertNelsonContent(
38 content: string,
39 embedding: number[],
64}
65
66export async function createNelsonContentTable(): Promise<void> {
67 try {
68 // Create the table if it doesn't exist
74 }
75
76 // Create the vector similarity search function
77 const { error: functionError } = await supabase.rpc('create_match_function');
78
79 if (functionError && !functionError.message.includes('already exists')) {
80 console.error('Error creating function:', functionError);
81 throw new Error(`Failed to create function: ${functionError.message}`);
82 }
83 } catch (error) {
88
89// Initialize database schema
90export async function initializeDatabase(): Promise<void> {
91 try {
92 // Check if the table exists

nelsongptREADME.md2 matches

@zee1205โ€ขUpdated 4 days ago
6
7- ๐Ÿฅ Medical AI assistant with evidence-based responses
8- ๐Ÿ“ฑ Progressive Web App (PWA) with offline functionality
9- ๐Ÿ’ฌ ChatGPT-like interface with real-time streaming responses
10- ๐Ÿ” RAG (Retrieval-Augmented Generation) workflow
46โ”‚ โ”‚ โ””โ”€โ”€ MessageBubble.tsx
47โ”‚ โ”œโ”€โ”€ hooks/
48โ”‚ โ”‚ โ””โ”€โ”€ useChat.ts # Chat functionality hook
49โ”‚ โ”œโ”€โ”€ services/
50โ”‚ โ”‚ โ”œโ”€โ”€ api.ts # API client

TownieValTownLogo.tsx1 match

@shecthrivesโ€ขUpdated 4 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function ValTownLogo () {
4 return (
5 <svg

TownieuseUser.tsx1 match

@shecthrivesโ€ขUpdated 4 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

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

TownieuseScrollToBottom.tsx3 matches

@shecthrivesโ€ขUpdated 4 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

@shecthrivesโ€ขUpdated 4 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(`
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 1 day ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserโ€ขUpdated 1 month ago
A helper function to build a file's email
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.