2import { getImageTotals } from "./getImageTotals";
3import { getTextTotals } from "./getTextTotals";
4import { DayTotal, UsageDB } from "./openAiUsageTypes";
5
6const createDayTotal = async (data, whisper_api_data, dalle_api_data) => {
10});
11
12interface OpenAiPricing {
13 textPricing: {
14 [key: string]: {
29}
30
31export const openAiPricing: OpenAiPricing = {
32 textPricing: {
33 "gpt-3.5-turbo-16k-0613": createPricing(3000, 4000),
1import { createDayTotal } from "./createDayTotal";
2import { cronEvalLogger as logger } from "https://esm.town/v/nbbaier/cronLogger";
3import { fetchOpenAiUsageData } from "./fetchOpenAiUsageData";
4import { updateBlobUsageDB } from "./updateBlobUsageDB";
5import { blob } from "https://esm.town/v/std/blob?v=11";
7import { DateTime } from "npm:luxon";
8
9const fetchAndStoreOpenAiUsage = async (interval: Interval) => {
10 const timeZone = "America/Chicago";
11 const date = DateTime.now();
15
16 try {
17 const { data, whisper_api_data, dalle_api_data } = await fetchOpenAiUsageData(today);
18
19 const day_total = await createDayTotal(data, whisper_api_data, dalle_api_data);
27};
28
29export default logger(fetchAndStoreOpenAiUsage);
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function anthropicCompletion(
4 prompt: string,
5) {
6 const openai = new OpenAI();
7
8 try {
9 const completion = await openai.chat.completions.create({
10 messages: [
11 { role: "user", content: prompt },
3
4import { email } from "https://esm.town/v/std/email";
5import { OpenAI } from "https://esm.town/v/std/OpenAI";
6
7// ------------------------------ Email Address ------------------------------
19 console.log(e);
20
21 // Use OpenAI provided by Val Town to reply to the email
22 const openai = new OpenAI();
23 let chatCompletion = await openai.chat.completions.create({
24 messages: [{
25 role: "user",
5// ---------------- Val Town Standard Library ----------------
6// Val Town provides limited free hosted services, including
7// functions for sending emails and using OpenAI
8import { email } from "https://esm.town/v/std/email";
9import { OpenAI } from "https://esm.town/v/std/OpenAI";
10
11// --------------------- Get weather data --------------------
22
23export default async function() {
24 // Use OpenAI provided by Val Town to get weather reccomendation
25 // Experiment with changing the prompt
26 const openai = new OpenAI();
27 let chatCompletion = await openai.chat.completions.create({
28 messages: [{
29 role: "user",
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },