Back to packages list

Vals using openai

Description from the NPM package:
The official TypeScript library for the OpenAI API
janpaul123 avatar
semanticSearchNeon
@janpaul123
Script
Forked from janpaul123/semanticSearchBlobs
janpaul123 avatar
indexValsNeon
@janpaul123
Cron
Forked from janpaul123/indexValsBlobs
janpaul123 avatar
indexValsBlobs
@janpaul123
Script
Forked from janpaul123/indexValsTurso
pattysi avatar
OpenAI
@pattysi
Script
Forked from std/openai
kirineko avatar
chat
@kirineko
Script
Forked from webup/chat
yawnxyz avatar
openAiHelloWorld
@yawnxyz
Script
// Create a secret named OPENAI_API_KEY at https://www.val.town/settings/environment-variables
pomdtr avatar
OpenAI
@pomdtr
Script
Forked from std/openai
std avatar
openai
@std
Script
OpenAI - Docs ↗ Use OpenAI's chat completion API with std/openai . This integration enables access to OpenAI's language models without needing to acquire API keys. For free Val Town users, all calls are sent to gpt-4o-mini . Usage import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" }, ], model: "gpt-4", max_tokens: 30, }); console.log(completion.choices[0].message.content); Limits While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind: Usage Quota : We limit each user to 10 requests per minute. Features : Chat completions is the only endpoint available. If these limits are too low, let us know! You can also get around the limitation by using your own keys: Create your own API key on OpenAI's website Create an environment variable named OPENAI_API_KEY Use the OpenAI client from npm:openai : import { OpenAI } from "npm:openai"; const openai = new OpenAI(); 📝 Edit docs
dantaeyoung avatar
weatherGPT
@dantaeyoung
Cron
Forked from stevekrouse/weatherGPT
liaolile avatar
weatherGPT
@liaolile
Cron
Forked from stevekrouse/weatherGPT
kyutarou avatar
gpt4Example
@kyutarou
Script
Forked from stevekrouse/gpt4Example
cosmo avatar
chat_openai
@cosmo
Script
An interactive, runnable TypeScript val by cosmo
nbbaier avatar
draftReadme
@nbbaier
Script
Forked from nbbaier/readmeGPT
nbbaier avatar
WriterOptions
@nbbaier
Script
An interactive, runnable TypeScript val by nbbaier
nbbaier avatar
readmeGPT
@nbbaier
Script
Forked from nbbaier/sqliteWriter
nbbaier avatar
sqliteWriter
@nbbaier
Script
SQLite QueryWriter The 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. This val is inspired by prisma-gpt . PRs welcome! See Todos below for some ideas I have. Usage Import the QueryWriter class into your script: import { QueryWriter } from "https://esm.town/v/nbbaier/sqliteWriter"; Create an instance of QueryWriter, providing the desired table and an optional model: const writer = new QueryWriter({ table: "my_table", model: "gpt-4-1106-preview" }); Call the writeQuery() method to generate an SQL query based on a user input string: const userInput = "Show me all the customers with more than $1000 in purchases."; const query = await writer.writeQuery(userInput); Alternatively, use the gptQuery() method to both generate and execute the SQL query: const userInput = "Show me all the customers with more than $1000 in purchases."; const result = await writer.gptQuery(userInput); Handle the generated query or query result according to your application's needs. API new QueryWriter(args: { table: string; model?: string }): QueryWriter Creates a new instance of the QueryWriter class. table : The name of the database table to operate on. model (optional): The model to use for generating SQL queries. Defaults to "gpt-3.5-turbo". apiKey (optional): An OpenAI API key. Defaults to Deno.env.get("OPENAI_API_KEY") . writeQuery(str: string): Promise<string> Generates an SQL query based on the provided user input string. str : The user input string describing the desired query. Returns a Promise that resolves to the generated SQL query. gptQuery(str: string): Promise<any> Generates and executes an SQL query based on the provided user input string. str : The user input string describing the desired query. Returns a Promise that resolves to the result of executing the generated SQL query. Todos [ ] Handle multiple tables for more complex use cases [ ] Edit prompt to allow for more than just SELECT queries [ ] Allow a user to add to the system prompt maybe? [ ] Expand usage beyond just Turso SQLite to integrate with other databases