Search
squint
@borkdude
Run squint in val.town!
Script
console.log(theString);
theString = theString.replace(`'squint-cljs/core.js'`, `'npm:squint-cljs/core.js'`);
const AsyncFunction = Object.getPrototypeOf(async function() {}).constructor;
await (new AsyncFunction(theString)());
webgen
@thesephist
Made on Val Town livestream. This project is a kind of a mini tribute to Websim . To-dos: Spruce up styles a bit Write this README ~Add a cache!~ ~Try moving style tag to the bottom by prompting so content appears immediately and then becomes styled~ didn't work b/c CSS parsing isn't progressive Need more prompting to get the model not to generate placeholder-y content Better root URL page / index page with links to some good sample generations
HTTP
import { blob } from "https://esm.town/v/std/blob?v=12";
import OpenAI from "npm:openai";
const openai = new OpenAI();
const getCacheKey = (url: string): string => {
let pageResult = "";
// // 2. Do one OpenAI inference to expand that URL to a longer page description
const pageDescriptionStream = await openai.chat.completions.create({
model: "gpt-4o",
// 3. Generate the page
const stream = await openai.chat.completions.create({
model: "gpt-4o",
val_4Etu5C04ol
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_4Etu5C04ol(req) {
try {
const body = await req.text();
// Create a function from the provided code and execute it
const userFunction = async () => {
const findPrimes = (n) => {
// Execute and capture the result
const result = await userFunction();
// Handle different types of results
gptMemoryManager
@xkonti
A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: xkonti.tech Demonstration First conversation: What GPT sent do the API: {
"name": "Life Essence and Biological Processes",
"description": "Explore the role of life essence in enabling biological processes, with a focus on how dimensional interference, particularly from the Incorporeal dimension, facilitates the existence of these processes. This exploration should delve into the complex interplay between the Physical and Incorporeal dimensions, examining how life essence acts as a crucial element in the emergence and sustenance of life in the Physical dimension.",
"summary": "Expanding on the role of life essence in biological processes, emphasizing the interaction between the Physical and Incorporeal dimensions.",
"reason": "To deepen the understanding of how life essence, influenced by dimensional interference, is essential for biological processes in the novel's universe."
} Separate conversation somewhere in the future: Setup There are several steps to set up the API: deploy and configure the API create the API key for your GPT add an action for the API in you GPT add prompt section to your GPT so that it can use it properly Deploying the API on Val Town Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample In the code configure the appropriate values: apiName the name of your API - used in the Privacy Policy (eg. Memory API ) contactEmail - the email to provide for contact in the Privacy Policy (eg. some@email.com ) lastPolicyUpdate - the date the Privacy Policy was last updated (eg. 2023-11-28 ) blobKeyPrefix - the prefix for the blob storage keys used by your API - more info below (eg. gpt:memories: ) apiKeyPrefix - the prefix for you API Keys secrets - more info below (eg. GPTMEMORYAPI_KEY_ ) Create API keys The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique name and API key . The name is used for identifying the specific GPT and appended to both: blobKeyPrefix - to maintain separate memory storage from other GPTs apiKeyPrefix - to maintain separate API key for each GPT Please pick a unique alphanumeric name for your GPT. For example personaltrainer . Generate some alphanumeric API key for your GPT. For example Wrangle-Chapped-Monkhood4-Domain-Suspend Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by apiKeyPrefix . Using the default it would be GPTMEMORYAPI_KEY_personaltrainer . The value of the secret should be the API key itself. The memories of the GPT will be stored in the blob storage under the key blobKeyPrefix + name , for example: gpt:memories:personaltrainer . Adding GPT action Add a new action in your GPT. Get the OpenAPI spefication by calling the /openapi endpoint of your API Change all <APIURL> instances within the specification to the url of your deployed API. For example https://xkonti-memoryapiexample.web.val.run Set the authentication method to basic and provide a base64 encoded version of the <name>:<apiKey> . For example: personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend -> cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ= Add the link to the privacy policy, which is the /privacy endpoint of your API. For example: https://xkonti-memoryapiexample.web.val.run/privacy Adding the prompt section To make your GPT understand the usage of your new action you should include usage instruction in your prompt. Here's an example of such instructions section: # Long-term memory
At some point the user might ask you to do something with "memory". Things like "remember", "save to memory", "forget", "update memory", etc. Please use corresponding actions to achieve those tasks. User might also ask you to perform some task with the context of your "memory" - in that case fetch all memories before proceeding with the task. The memories should be formed in a clear and purely informative language, void of unnecessary adjectives or decorative language forms. An exception to that rule might be a case when the language itself is the integral part of information (snippet of writing to remember for later, examples of some specific language forms, quotes, etc.).
Structure of a memory:
- name - a simple name of the memory to give it context at a glance
- description - a detailed description of the thing that should be remembered. There is no length limit.
- summary - a short summary of the memory. This should be formed in a way that will allow for ease of understanding which memories to retrieve in full detail just by reading the list of summaries. If there are some simple facts that have to be remembered and are the main point of the memory they should be included in the summary. The summary should also be written in a compressed way with all unnecessary words skipped if possible (more like a set of keywords or a Google Search input).
- reason - the reason for the remembering - this should give extra information about the situation in which the memory was requested to be saved.
The memory accessed through those actions is a long-term memory persistent between various conversations with the user. You can assume that there already are many memories available for retrieval.
In some situations you might want to save some information to your memory for future recall. Do it in situations where you expect that some important details of the conversation might be lost and should be preserved.
Analogously you can retrieve memories at any point if the task at hand suggests the need or there isn't much information about the subject in your knowledge base.
Script
1. Add a new action in your GPT.
2. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
3. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
aqi
@raei
An interactive, runnable TypeScript val by raei
Script
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=3";
export async function aqi(location = "Berlin") {
const data = await easyAQI({ location });
if (data.severity.includes("Unhealthy")) {
val_sCJrhQtEiy
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_sCJrhQtEiy(req) {
try {
// Execute the code directly and capture its result
getCNNNews
@fab1an
An interactive, runnable TypeScript val by fab1an
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function getCNNNews() {
const response = await fetch(
"https://saurav.tech/NewsAPI/everything/cnn.json"
val_nXuOLJjN1O
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_nXuOLJjN1O(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Test 1: Check for patterns in random number generation
function testRandomness() {
const samples = 1000;
const numbers = [];
connect4_random_agent
@saolsen
An interactive, runnable TypeScript val by saolsen
HTTP
import * as connect4 from "https://esm.town/v/saolsen/connect4";
import { connect4_agent } from "https://esm.town/v/saolsen/connect4_agent";
function rand_action(state: connect4.State): connect4.Action {
let player = state.next_player;
while (true) {
myApi
@lazydefi1
An interactive, runnable TypeScript val by lazydefi1
Script
export function myApi(name) {
return "hi " + name;
questionPractice
@pomcute
Recieve an email with a question each day from https://www.are.na/lisa-marie/asking-the-right-questions-sbkcnb9eank
Cron
import { arenaChannelContents } from "https://esm.town/v/pomcute/arenaChannelContents";
import { email } from "https://esm.town/v/std/email";
export default async function questionPractice(interval: Interval) {
const contents = await arenaChannelContents({ channelId: "asking-the-right-questions-sbkcnb9eank" });
const textContents = contents.filter(item => item.class === "Text");
aHandler
@taufiq
An interactive, runnable TypeScript val by taufiq
HTTP
import { reactExample } from "https://esm.town/v/stevekrouse/reactExample?v=0";
import { aFunction } from "https://esm.town/v/taufiq/aFunction";
export async function aHandler(request: Request): Promise<Response> {
return reactExample();
myApi
@ankit411
An interactive, runnable TypeScript val by ankit411
Script
export function myApi(name) {
return "hi " + name;
val_QNCsjRvGfn
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_QNCsjRvGfn(req) {
try {
const body = await req.text();
// Create a function from the provided code and execute it
const userFunction = async () => {
function findPrimes(limit) { const primes = []; for (let num = 2; num < limit; num++) { let isPrime = true; for (let i = 2; i <= Math.sqrt(num); i++) { if (num % i === 0) { isPrime = false; break; } } if (isPrime) { primes.push(num); } } return primes; } findPrimes(10);
// Execute and capture the result
const result = await userFunction();
// Handle different types of results