Search

Results include substring matches and semantically similar vals. Learn more
sharanbabu avatar
legitimateTanTiger
@sharanbabu
* This code creates a search engine prototype with autocomplete functionality using the Cerebras LLM API. * It uses React for the frontend and the Cerebras API for generating autocomplete suggestions. * The suggestions are cached in the browser to reduce API calls. * It implements a two-step LLM process: first to get initial suggestions, then to filter them for sensibility and ethics. * If the second LLM call fails, it displays "Failed to fetch" instead of showing results.
HTTP
* This code creates a search engine prototype with autocomplete functionality using the Cerebras LLM API.
* It uses React for the frontend and the Cerebras API for generating autocomplete suggestions.
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [query, setQuery] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
async function server(request: Request): Promise<Response> {
if (request.method === "POST" && new URL(request.url).pathname === "/suggestions") {
} catch (error) {
console.error("Error calling Cerebras API:", error);
return new Response(JSON.stringify({ error: "Failed to fetch" }), {
bis avatar
honoExample
@bis
Hono Here's an example using the Hono server library with the Web API . It works great!
HTTP
const name = c.req.param("name");
return c.text(`Hi ${capitalize(name)}`);
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
export default app.fetch;
stnkvcs avatar
getAirtableDataAPI
@stnkvcs
// Initialize Airtable configuration
HTTP
const baseId = Deno.env.get("AIRTABLE_BASE_ID");
const tableName = Deno.env.get("AIRTABLE_TABLE_NAME");
async function fetchAirtableData(uid: string) {
if (!airtableApiKey || !baseId || !tableName) {
throw new Error("Missing Airtable environment variables");
const data = await response.json();
return data.records[0]; // Return only the first (and should be only) matching record
export default async function server(req: Request): Promise<Response> {
// Handle OPTIONS request for CORS preflight
if (req.method === "OPTIONS") {
cameronpak avatar
homeless
@cameronpak
Homeless Services by OurTechnology At OurTechnology , we create technology solutions to empower and equip those who serve the homeless. We have a large data set of available resources in the US to aid in helping those experiencing homelessness find local resources, community, and support. This private ( but public to read ) API is used in our ChatGPT Assistant, Homeless Services . Why a ChatGPT Assistant ? OpenAI announced on May 13, 2024 that free users will soon be able to "discover and use GPTs and the GPT Store ( OpenAI )" There's a larger number of people experiencing homelessness who own a phone than what I imagined. ChatGPT allows for a simple interface, even with voice chat (a more natural way to navigate the tool), to find resources to help those experiencing homelessness. And, it's fast! Technical details The data set has been compiled together over the years and will continue to be updated as new techniques and partnerships make that possible. We use Typesense , a search as a service tool, to provide lightning fast search results for homeless resources near you. This endpoint is created with Hono and is an incredibly easy way to create an API. Contact OurTechnology Visit our website Email us! Find us on LinkedIn While this is on Cameron Pak's ValTown, this code is owned and operated by OurTechnology.
HTTP
## Why a [ChatGPT Assistant](https://chatg.pt/homeless-help)?
- OpenAI announced on May 13, 2024 that free users will soon be able to "discover and use GPTs and the GPT Store ([OpenAI](ht
- There's a larger number of people experiencing homelessness who own a phone than what I imagined.
* @return {number} the distance in miles
function convertMetersToMiles(meters: number): number {
return 0.000621371 * meters;
// Round a number to the nearest quarter.
function roundToQuarter(number: number) {
let remainder = number % 1;
* @return {SearchParams | SearchParamsWithPreset} The constructed search parameters.
function constructTypesenseParams({
query,
* @return {Promise<any>} A Promise that resolves to an array of resources matching the search criteria.
export async function getResources({
lat,
hancock avatar
myApi
@hancock
An interactive, runnable TypeScript val by hancock
Script
export function myApi(name: string) {
return `Hello ${name}!`;
git avatar
viem_auto_load_abi
@git
// Seaport 1.1 contract address
Script
abi,
address,
functionName: "information",
console.info(result);
git avatar
faucets
@git
An interactive, runnable TypeScript val by git
HTTP
export default async function(req: Request): Promise<Response> {
return new Response(
JSON.stringify(
markm247 avatar
myApi
@markm247
An interactive, runnable TypeScript val by markm247
Script
export function myApi() {
return "hi ";
temptemp avatar
elegantJadeParrotfish
@temptemp
@jsxImportSource npm:hono@3/jsx
HTTP
const app = new Hono();
import { load } from "npm:cheerio";
async function archive(url: string) {
const response = await fetch(url);
const body = await response.text();
benlenarts avatar
SongTagger
@benlenarts
Spotify Playback A val to setting up some endpoints for Spotify play state.
HTTP
} catch (e) {
return c.json({ error: "Failed callback" + e });
async function getToken(c) {
const state = c.req.query("state") as string;
const authData = await db.select().from(table).where(eq(table.id, state)).limit(1);
mattq avatar
dream_interpreter
@mattq
interpret your dream
Cron
export default async function(interval) {
// Sample phrases and words that are likely to appear in dream descriptions
const introPhrases = [
devn avatar
myApi
@devn
An interactive, runnable TypeScript val by devn
Script
export function myApi(name) {
return "hi " + name;
mtemple avatar
myApi
@mtemple
An interactive, runnable TypeScript val by mtemple
Script
export function myApi(name) {
return "hi " + name;
karkowg avatar
theOneSky
@karkowg
theonesky bsky firehose as The Matrix source code
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function createTypewriterMachine() {
const messages = ["The bsky has you...", "Follow the blue butterfly", "made with val.town"];
return state;
function MatrixBlueskyStream() {
const [posts, setPosts] = useState([]);
const [machineState, setMachineState] = useState(typewriterMachine.current.initialState);
// Wrapper function to update state
const updateMachineState = useCallback((event) => {
const agent = new BskyAgent({ service: "https://bsky.social" });
async function streamPosts() {
try {
lastRenderTime: Date.now(),
function draw() {
try {
const animationFrame = setInterval(draw, 33);
// Cleanup function
return () => {
</div>
function App() {
return <MatrixBlueskyStream />;
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
naomizhang avatar
jokeGeneratorVal
@naomizhang
// Fetches a random joke.
Cron
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",