Search

3,374 results found for openai (1753ms)

Code
3,279

import { OpenAI } from "https://esm.town/v/std/openai";
import { Video, ClipSuggestion, KeyframeInfo, TranscriptSegment } from '../../shared/types.ts';
// Initialize OpenAI client
const openai = new OpenAI();
/**
// In a real implementation, we would analyze the actual video content
// For this demo, we'll simulate video analysis using OpenAI
// First, check if we have transcript data
async function simulateTranscriptGeneration(video: Video): Promise<TranscriptSegment[]> {
// In a real implementation, we would use a speech-to-text service
// For this demo, we'll generate a fake transcript using OpenAI
const prompt = `Generate a realistic transcript for a ${video.duration || 300} second video ti
Format the response as a JSON array of objects with 'start', 'end', and 'text' properties.`;
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
): Promise<KeyframeInfo[]> {
// In a real implementation, we would analyze video frames and audio
// For this demo, we'll use OpenAI to identify potential key moments from the transcript
const transcriptText = transcript.map(segment => segment.text).join(" ");
Format the response as a JSON array of objects with 'time', 'confidence', and 'description' prop
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
): Promise<string> {
// In a real implementation, we would use more sophisticated NLP
// For this demo, we'll use OpenAI to generate a title
const transcriptText = relevantTranscript.map(segment => segment.text).join(" ");
The title should be attention-grabbing and optimized for social media engagement.`;
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
): Promise<string> {
// In a real implementation, we would use more sophisticated NLP
// For this demo, we'll use OpenAI to generate a description
const transcriptText = relevantTranscript.map(segment => segment.text).join(" ");
Include relevant hashtags if appropriate.`;
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
- **Backend**: Hono (API framework)
- **Database**: SQLite
- **AI Services**: OpenAI for content analysis, external video processing APIs
- **Authentication**: JWT-based auth system
- **Storage**: Val Town blob storage for metadata, external storage for video files
import { OpenAI } from "https://esm.town/v/std/openai";
import { Resume, JobRequirement, ResumeScore } from "../shared/types.ts";
// Initialize OpenAI client
const openai = new OpenAI();
/**
`;
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
/**
* Calculate similarity score between two texts using OpenAI embeddings
*/
export async function calculateSimilarity(text1: string, text2: string): Promise<number> {
const response = await openai.embeddings.create({
model: "text-embedding-3-small",
input: [text1, text2],
- **Frontend**: HTML, CSS (Tailwind), and TypeScript with React
- **Database**: SQLite for storing resumes and job requirements
- **NLP/ML**: OpenAI embeddings for semantic matching
## Project Structure
# Small subset of OpenAI API
>![WARNING]
```bash
curl 'https://www.val.town/v/YOUR_USER_NAME/openai_api' \
-H 'Content-Type: application/json' \
-X POST \
```js
const response = await fetch('https://www.val.town/v/YOUR_USER_NAME/openai_api', {
method: 'POST',
headers: {
import Ajv from "https://esm.sh/ajv@8.13.0";
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const sharedHeaders = {
"Access-Control-Allow-Origin": "*",
</head>
<body>
<h1>Small subset of OpenAI API</h1>
<blockquote>
<pre><code>curl 'https://www.val.town/v/YOUR_USER_NAME/openai_api'
-H 'Content-Type: application/json'
-X POST
<p>or in JS</p>
onse = await fetch('https://www.val.town/v/YOUR_USER_NAME/openai_api', {
method: 'POST',
headers: {
}
const completion = await openai.chat.completions.create({
...body,
model: "gpt-3.5-turbo",
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
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" },
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
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" },
- `NEWSLETTER_RECIPIENT_EMAIL`: The email address where the newsletter will be sent
- `OPENAI_API_KEY`: For generating content (automatically provided by Val Town)
- `GITHUB_TOKEN` (optional): A GitHub personal access token to avoid rate limiting when fetching
The newsletter uses:
- OpenAI to generate unique React/JS/TS knowledge tips
- React's blog API to fetch the latest React news (with OpenAI as a fallback)
- GitHub's API to find trending repositories related to React/JS/TS
- Val Town's email functionality to send the formatted newsletter
You can customize the newsletter by modifying the `daily-react-newsletter.ts` file:
- Adjust the OpenAI prompts to get different types of content
- Change the email template design
- Modify the GitHub search query to find different types of repositories
1. Check the logs in Val Town to see any error messages
2. Verify that all environment variables are set correctly
3. Ensure your OpenAI API key has sufficient quota
4. If GitHub API requests are failing, consider adding a GitHub token
import { OpenAI } from "https://esm.town/v/std/openai";
import { email } from "https://esm.town/v/std/email";
// Function to generate React/JS/TS knowledge using OpenAI
async function generateReactKnowledge(): Promise<string> {
const openai = new OpenAI();
const prompt = "Share one useful but lesser-known fact or technique about React, JavaScript, o
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",
console.error("Error fetching React news:", error);
// Fallback to OpenAI for React news if the API fails
const openai = new OpenAI();
const prompt = "What's a recent development or news in the React ecosystem? Provide a brief
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",
console.error("Error fetching trending repos:", error);
// Fallback to OpenAI for trending repos if the API fails
const openai = new OpenAI();
const prompt = "What's a trending GitHub repository related to React, JavaScript, or TypeScr
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",