1### Blob Array
23Create an array as a Database, instantly!
45Just create a new val for your array:
ValTupleStoragemain.tsx1 match
23import { jsonCodec } from "npm:lexicodec";
4import { KeyValuePair, ScanStorageArgs, Tuple, WriteOps } from "npm:tuple-database";
56export class ValTupleStorage {
1Migrated from folder: Database/ValTupleStorage_Example
ValTupleStorageREADME.md1 match
1Migrated from folder: Database/ValTupleStorage
sqliteWriterREADME.md3 matches
1# SQLite QueryWriter
23The QueryWriter class is a utility for generating and executing SQL queries using natural language and OpenAI. It provides a simplified interface for interacting with your Val Town SQLite database and generating SQL queries based on user inputs.
45This val is inspired by [prisma-gpt](https://github.com/aliyeysides/prisma-gpt). PRs welcome! See **Todos** below for some ideas I have.
42Creates a new instance of the QueryWriter class.
4344- `table`: The name of the database table to operate on.
45- `model` (optional): The model to use for generating SQL queries. Defaults to "gpt-3.5-turbo".
46- `apiKey` (optional): An OpenAI API key. Defaults to `Deno.env.get("OPENAI_API_KEY")`.
68- [ ] Edit prompt to allow for more than just `SELECT` queries
69- [ ] Allow a user to add to the system prompt maybe?
70- [ ] Expand usage beyond just Turso SQLite to integrate with other databases
7172Migrated from folder: projects/gptTools/sqliteWriter
add_to_notion_w_ai_webpagemain.tsx19 matches
41function createPrompt(title, description, properties) {
42let prompt =
43"You are processing content into a database. Based on the title of the database, its properties, their types and options, and any existing descriptions, infer appropriate values for the fields:\n";
44prompt += `Database Title: ${title}\n`;
4546if (description) {
47prompt += `Database Description: ${description}\n\n`;
48} else {
49prompt += "\n";
115}
116117async function get_and_save_notion_db_processed_properties(databaseId)
118{
119const response = await notion.databases.retrieve({ database_id: databaseId });
120const db_id = response.id.replaceAll("-", "");
121const processed_properties = processProperties(response);
126}
127128async function get_notion_db_info(databaseId) {
129databaseId = databaseId.replaceAll("-", "");
130let db_info = null;
131try {
132db_info = await blob.getJSON(databaseId);
133if (!db_info) {
134throw new Error("db_info is null or undefined");
135}
136} catch (error) {
137db_info = await get_and_save_notion_db_processed_properties(databaseId);
138}
139console.log(db_info);
142}
143144async function get_and_save_notion_db_info(databaseId) {
145databaseId = databaseId.replaceAll("-", "");
146let db_info = await get_and_save_notion_db_processed_properties(databaseId);
147db_info["zod_schema"] = createZodSchema(db_info["filteredProps"]);
148return db_info;
288}
289290async function addToNotion(databaseId, text) {
291databaseId = databaseId.replaceAll("-", "");
292const properties = await process_text(databaseId, text);
293console.log(properties);
294const response = await notion.pages.create({
295"parent": {
296"type": "database_id",
297"database_id": databaseId,
298},
299"properties": properties,
316<div id="answer">
317<div id="answer-content" hx-get="/clear" hx-trigger="load delay:2s" hx-target="#answer">
318Processed and added to Notion Database
319</div>
320</div>
329<html>
330<head>
331<title>Add To Money Database W/ AI</title>
332<style>
333{`
1Example usage of the [add_to_notion_w_ai val](https://www.val.town/v/nerdymomocat/add_to_notion_w_ai)
23Try with the [money database](https://nerdymomocat-shortened-url.vercel.app/ai-add-to-money-db).
45Read and watch the demo run [here](https://nerdymomocat.github.io/posts/use-notions-property-description-as-text-db-add-itor/)
add_to_notion_w_aimain.tsx17 matches
37function createPrompt(title, description, properties) {
38let prompt =
39"You are processing content into a database. Based on the title of the database, its properties, their types and options, and any existing descriptions, infer appropriate values for the fields:\n";
40prompt += `Database Title: ${title}\n`;
4142if (description) {
43prompt += `Database Description: ${description}\n\n`;
44} else {
45prompt += "\n";
111}
112113async function get_and_save_notion_db_processed_properties(databaseId)
114{
115const response = await notion.databases.retrieve({ database_id: databaseId });
116const db_id = response.id.replaceAll("-", "");
117const processed_properties = processProperties(response);
122}
123124async function get_notion_db_info(databaseId) {
125databaseId = databaseId.replaceAll("-", "");
126let db_info = null;
127try {
128db_info = await blob.getJSON(databaseId);
129if (!db_info) {
130throw new Error("db_info is null or undefined");
131}
132} catch (error) {
133db_info = await get_and_save_notion_db_processed_properties(databaseId);
134}
135db_info["zod_schema"] = createZodSchema(db_info["filteredProps"]);
137}
138139async function get_and_save_notion_db_info(databaseId) {
140databaseId = databaseId.replaceAll("-", "");
141let db_info = await get_and_save_notion_db_processed_properties(databaseId);
142db_info["zod_schema"] = createZodSchema(db_info["filteredProps"]);
143return db_info;
283}
284285async function addToNotion(databaseId, text) {
286databaseId = databaseId.replaceAll("-", "");
287const properties = await process_text(databaseId, text);
288console.log(properties);
289const response = await notion.pages.create({
290"parent": {
291"type": "database_id",
292"database_id": databaseId,
293},
294"properties": properties,
add_to_notion_w_aiREADME.md4 matches
1Uses instructor and open ai (with gpt-4-turbo) to process any content into a notion database entry.
23Use `addToNotion` with any database id and content.
45```
10```
1112Prompts are created based on your database name, database description, property name, property type, property description, and if applicable, property options (and their descriptions).
1314Supports: checkbox, date, multi_select, number, rich_text, select, status, title, url, email
1516- Uses `NOTION_API_KEY`, `OPENAI_API_KEY` stored in env variables and uses [Valtown blob storage](https://esm.town/v/std/blob) to store information about the database.
17- Use `get_notion_db_info` to use the stored blob if exists or create one, use `get_and_save_notion_db_info` to create a new blob (and replace an existing one if exists).
18
connect4_sitemain.tsx1 match
1058// There are concurrency issues with this, turns could get
1059// evaluated twice and overwrite each other, but future steve
1060// can handle that with a real database.
1061app.post("/matches/:match_id/agent_turn", async (c) => {
1062const parsed_id = MatchId.safeParse(c.req.param("match_id"));