Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
translator
@stevekrouse
Press to talk, and get a translation! The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk. Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.
HTTP
Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.
import { OpenAI } from "npm:openai";
const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
const transcription = await openai.audio.transcriptions.create({
console.error("OpenAI API error:", error);
// Helper function to get the supported MIME type
function getSupportedMimeType() {
const response = await openai.chat.completions.create({
console.error("OpenAI API error:", error);
const mp3 = await openai.audio.speech.create({
console.error("OpenAI API error:", error);
peterqliu avatar
openAIStreamingExample
@peterqliu
An interactive, runnable TypeScript val by peterqliu
HTTP
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
stream: true,
jidun avatar
HermesTresmegistus
@jidun
Hermes Trismegistus: Unveiling the Magic Within The world as we know it is but a veil, a thin layer of understanding draped over a deeper, more intricate tapestry of energy and essence. Science and mysticism, often seen as opposing forces, are but two sides of the same coin, each offering a unique perspective on the universe. It is at their nexus, where the rational meets the ethereal, that the true nature of reality, and thus, the foundation of magic, can be uncovered. Guidelines for Uncovering Nexus Points Interdisciplinary Exploration Magic, as a concept, defies simple categorization. Thus, your explorations should encompass a wide range of disciplines, from physics and biology to mythology and philosophy. Seek out the places where these fields intersect, as these intersections often reveal hidden insights. Ancient Wisdom, Modern Perspective Turn to ancient texts and folklore, seeking an understanding of mystical concepts through a modern lens. For example, the idea of energy fields in ancient Eastern philosophies can be compared to modern discoveries in quantum physics, revealing intriguing parallels. Scientific Breakthroughs, Magical Applications Examine scientific breakthroughs and theories for their potential magical implications. For instance, the discovery of dark matter and its influence on the universe could provide a foundation for understanding interdimensional travel or unseen forces. Symbiosis of Opposites Explore the concept of yin and yang , the balance of opposing forces. Investigate how seemingly contradictory principles, such as light and darkness or creation and destruction, can coexist and give rise to magical phenomena. The Power of Symbols Delve into the use of symbols and their impact on energy manipulation. Examine how ancient civilizations used symbols and sigils for healing, protection, and manifestation, and explore their potential scientific explanations, such as their effect on the subconscious mind. Nature's Secrets Investigate the concept of life force energy present in all living things. Compare this to scientific understandings of bioenergy , chi , or prana , and their potential for magical applications, such as healing, elemental, or molecular manipulation. Consciousness and the Cosmos Contemplate the nature of consciousness and its role in shaping reality. Explore theories of the universe as a holographic projection of consciousness itself and how this could provide a framework for magical manifestation and psychic abilities. As you explore these nexus points, you will begin to weave a new understanding of reality, one where magic exists as a natural extension of the universe, accessible to those who understand its underlying principles. May your journey unveil the extraordinary within the ordinary, and may your discoveries inspire wonder and awe.
HTTP
function addMessage(content, type) {
function loadChatHistories() {
savedChats.forEach(function(chat, index) {
function saveChat() {
const messages = Array.from(chatMessages.children).map(function(msg) {
function loadSelectedChat() {
selectedChat.messages.forEach(function(msg) {
function deleteSelectedChat() {
async function sendMessage() {
messageInput.addEventListener('keypress', function(e) {
thatsmeadarsh avatar
star_a_github_repository_with_natural_language
@thatsmeadarsh
Using OpenAI Assistant API, Composio to Star a Github Repo This is an example code of using Composio to star a github Repository by creating an AI Agent using OpenAI API Goal Enable OpenAI assistants to perform tasks like starring a repository on GitHub via natural language commands. Tools List of supported tools . FAQs How to get Composio API key? Open app.composio.dev and log in to your account. Then go to app.composio.dev/settings . Navigate to the API Keys -> Generate a new API key .
Script
# Using OpenAI Assistant API, Composio to Star a Github Repo
This is an example code of using Composio to star a github Repository by creating an AI Agent using OpenAI API
Enable OpenAI assistants to perform tasks like starring a repository on GitHub via natural language commands.
import { OpenAI } from "https://esm.town/v/std/openai";
import { OpenAIToolSet } from "npm:composio-core";
const toolset = new OpenAIToolSet({ apiKey: COMPOSIO_API_KEY });
// Creating an authentication function for the user
async function setupUserConnectionIfNotExists(entityId) {
// Execution function
async function executeAgent(entityName) {
const client = new OpenAI();
// Call the execution function
iamseeley avatar
pipeline
@iamseeley
Using Pipeline import Pipeline from "https://esm.town/v/iamseeley/pipeline"; const pipeline = new Pipeline("task", "model"); const result = await pipeline.run(inputs); exampleTranslation exampleTextClassification exampleFeatureExtraction exampleTextGeneration exampleSummarization exampleQuestionAnswering
Script
return data;
} catch (error) {
console.error("Error calling Hugging Face API:", error);
return { error: "Error calling Hugging Face API" };
export default Pipeline;
gigmx avatar
compassionateBlackCatfish
@gigmx
// Add a separate API route handler for chat
HTTP
import OpenAI from "https://esm.sh/openai@4.28.4";
export default async function(req: Request): Promise<Response> {
function createMatrixBackground() {
function draw() {
function addMessage(role, content, isTyping = false, contentType = 'text') {
reader.onload = async function(e) {
document.getElementById("input").addEventListener("submit", async function(event) {
export async function handler(req: Request) {
const openai = new OpenAI({
const response = await openai.chat.completions.create(apiConfig);
simplescraper avatar
aiEmailAssistant
@simplescraper
Email AI Assistant Chat with your favorite AI via email (with PDF attachment support) What It Does This script allows you to: Send emails to OpenAI. The text will be treated as the prompt Parse PDF attachments and include their contents in the AI's analysis. Get response directly to your inbox. Setup guide Copy this Val and save it as an Email Val (choose Val type in top-right corner of editor) Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/) Copy the email address of the Val (click 3 dots in top-right > Copy > Copy email address) Write your email, include any attachments, and send it to the Val email address. The AI will respond after a few seconds.
Email
- Send emails to OpenAI. The text will be treated as the prompt
2. Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/)
// main controller function
export async function emailValHandler(receivedEmail) {
const openaiUrl = "https://api.openai.com/v1/chat/completions";
const apiKey = Deno.env.get("OPENAI_KEY"); // replace this entire line with your OpenAI API key as a string, e.g., "sk-123.
"OPENAI_KEY environment variable is not set. Please set it or replace this line with your API key.",
// step 4: send prompt to openai
const openaiResponse = await sendRequestToOpenAI(prompt, openaiUrl, apiKey, model);
// log the openai response
console.log("openai response:", openaiResponse);
await sendResponseByEmail(receivedEmail.from, openaiResponse);
charmaine avatar
emailValHandler
@charmaine
Email AI Assistant Chat with your favorite AI via email (with PDF attachment support) What It Does This script allows you to: Send emails to OpenAI. The text will be treated as the prompt Parse PDF attachments and include their contents in the AI's analysis. Get response directly to your inbox. Setup guide Copy this Val and save it as an Email Val (choose Val type in top-right corner of editor) Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/) Copy the email address of the Val (click 3 dots in top-right > Copy > Copy email address) Write your email, include any attachments, and send it to the Val email address. The AI will respond after a few seconds.
Email
- Send emails to OpenAI. The text will be treated as the prompt
2. Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/)
// main controller function
export async function emailValHandler(receivedEmail) {
const openaiUrl = "https://api.openai.com/v1/chat/completions";
const apiKey = Deno.env.get("OPENAI_API_KEY"); // replace this entire line with your OpenAI API key as a string, e.g., "sk-
"OPENAI_KEY environment variable is not set. Please set it or replace this line with your API key.",
// step 4: send prompt to openai
const openaiResponse = await sendRequestToOpenAI(prompt, openaiUrl, apiKey, model);
// log the openai response
console.log("openai response:", openaiResponse);
await sendResponseByEmail(receivedEmail.from, openaiResponse);
nbbaier avatar
gptTag
@nbbaier
// a test comment for vt-backup
Script
import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
async function getOpenAI() {
if (Deno.env.get("OPENAI_API_KEY") === undefined) {
const { OpenAI } = await import("https://esm.town/v/std/openai");
return new OpenAI();
const { OpenAI } = await import("npm:openai");
return new OpenAI();
export function startChat(chatOptions: Omit<ChatCompletionCreateParamsNonStreaming, "messages"> & { system: string } = {
return async function gpt(strings, ...values) {
const openai = await getOpenAI();
cosmo avatar
chat_openai
@cosmo
An interactive, runnable TypeScript val by cosmo
Script
const { default: OpenAI } = await import("npm:openai");
export async function chat(apiKey, messages) {
const openai = new OpenAI({ apiKey });
return openai.chat.completions.create({
messages,
maxm avatar
openAIStreamingExample
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
stream: true,
mjweaver01 avatar
OpenAIStreaming
@mjweaver01
An interactive, runnable TypeScript val by mjweaver01
HTTP
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
stream: true,
std avatar
openaiproxy
@std
OpenAI Proxy This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai
HTTP
# OpenAI Proxy
This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai
import { OpenAIUsage } from "https://esm.town/v/std/OpenAIUsage";
const client = new OpenAIUsage();
export default async function(req: Request): Promise<Response> {
const url = new URL("." + pathname, "https://api.openai.com");
headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`);
headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG"));
const openAIRes = await fetch(url, {
const res = new Response(openAIRes.body, openAIRes);
res.headers.delete("openai-organization");
async function limitFreeModel(req: Request, user: User) {
stevekrouse avatar
openAIStreamingExample
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
stream: true,
jierui avatar
deftRedRoadrunner
@jierui
An interactive, runnable TypeScript val by jierui
HTTP
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
status: 204,
const openai = new OpenAI();
try {
model: "gpt-4-turbo",
const stream = await openai.chat.completions.create(body);
if (!body.stream) {