charmaineValSearchcomponents.tsx2 matches
1227<a href="?q=function" className="example-link">function</a>
1228<a href="?q=discord" className="example-link">discord</a>
1229<a href="?q=openai" className="example-link">openai</a>
1230<a href="?q=react" className="example-link">react</a>
1231</div>
1381<a href="?q=function" className="example-link">function</a>
1382<a href="?q=discord" className="example-link">discord</a>
1383<a href="?q=openai" className="example-link">openai</a>
1384<a href="?q=react" className="example-link">react</a>
1385</div>
stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
tourguideitinerary.ts3 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import {
4saveItinerary,
1213const app = new Hono();
14const openai = new OpenAI();
1516function generateId(): string {
82Provide realistic coordinates within the actual site boundaries.`;
8384const completion = await openai.chat.completions.create({
85messages: [{ role: "user", content: prompt }],
86model: "gpt-4o-mini",
blogget-old-posts.ts5 matches
198},
199{
200"title": "An Introduction to OpenAI fine-tuning",
201"slug": "an-introduction-to-openai-fine-tuning",
202"link": "/blog/an-introduction-to-openai-fine-tuning",
203"description": "How to customize OpenAI to your liking",
204"pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205"author": "Steve Krouse",
417"slug": "val-town-newsletter-16",
418"link": "/blog/val-town-newsletter-16",
419"description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420"pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421"author": "Steve Krouse",
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
1// MEES Assistant API Endpoint
2// Remember to add your environment variables in Val settings:
3// - OPENAI_API_KEY
4// - PINECONE_API_KEY
5// - ASSISTANT_ID
67import { OpenAI } from "https://deno.land/x/openai@v4.20.1/mod.ts";
8import { Pinecone } from "https://esm.sh/@pinecone-database/pinecone@1.1.2";
910const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
11const pinecone = new Pinecone({ apiKey: Deno.env.get("PINECONE_API_KEY") });
12const ASSISTANT_ID = Deno.env.get("ASSISTANT_ID");
3435// Get embedding for query
36const embeddingResponse = await openai.embeddings.create({
37model: "text-embedding-3-small",
38input: query,
123let thread;
124if (threadId) {
125thread = await openai.beta.threads.retrieve(threadId);
126} else {
127thread = await openai.beta.threads.create();
128}
129130// Add message to thread
131await openai.beta.threads.messages.create(thread.id, {
132role: "user",
133content: message,
135136// Run the assistant
137const run = await openai.beta.threads.runs.create(thread.id, {
138assistant_id: ASSISTANT_ID,
139});
214215// Poll for completion
216let runStatus = await openai.beta.threads.runs.retrieve(thread.id, run.id);
217let allMediaDisplays = [];
218219while (runStatus.status !== "completed" && runStatus.status !== "failed") {
220await new Promise(resolve => setTimeout(resolve, 1000));
221runStatus = await openai.beta.threads.runs.retrieve(thread.id, run.id);
222223if (runStatus.status === "requires_action") {
226allMediaDisplays = [...allMediaDisplays, ...mediaDisplays];
227228await openai.beta.threads.runs.submitToolOutputs(thread.id, run.id, {
229tool_outputs: toolOutputs,
230});
237238// Get the assistant's response
239const messages = await openai.beta.threads.messages.list(thread.id);
240const lastMessage = messages.data[0];
241const response = lastMessage.content[0].type === "text"
githubactivitysummarizermain.tsx6 matches
1// This approach fetches GitHub activity for two users specified in the URL,
2// sends it to OpenAI for analysis, and returns collaboration suggestions.
3// It uses the GitHub API (which doesn't require authentication for public data)
4// and the OpenAI API (which does require an API key).
5// Tradeoff: We're using an inline API key for simplicity, which isn't ideal for security.
6// Note: This might hit rate limits for the GitHub API due to fetching a year of data.
78import { OpenAI } from "https://esm.town/v/std/openai";
910const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API key
1112export default async function main(req: Request): Promise<Response> {
51const user1Summary = summarizeActivity(user1Data);
5253const openai = new OpenAI(OPENAI_API_KEY);
54const completion = await openai.chat.completions.create({
55model: "gpt-4o-mini",
56messages: [
stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
Towniesystem_prompt.txt4 matches
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
8990### OpenAI
9192```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96messages: [
97{ role: "user", content: "Say hello in a creative way" },
Townie.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },