Search

3,362 results found for openai (3296ms)

Code
3,267

1. **Website Discovery**: If no website is provided, searches DuckDuckGo to find the company's o
2. **HTML Fetching**: Retrieves the raw HTML from the company's homepage
3. **AI Logo Extraction**: Uses OpenAI's GPT-4o-mini with enhanced logic to locate the company l
4. **Format Prioritization**: Prefers Inline SVG > SVG files > PNG > other image formats
5. **Inline SVG Conversion**: Converts inline SVG elements to base64 encoded data URLs
2. **Page Discovery**: Tries multiple pages including homepage, /about, /contact, /about-us, /co
3. **HTML Analysis**: Fetches HTML from each page until an address is found
4. **AI Address Extraction**: Uses OpenAI to locate and format the company's physical address
## Example Usage
## Rate Limits
This API uses OpenAI's services, so it's subject to OpenAI's rate limits. For production use, co
## Technical Details
- Built with Hono framework on Val Town
- Uses OpenAI GPT-4o-mini for logo and address extraction
- Supports both provided websites and automatic website discovery
- Handles relative and absolute URL conversion
import { Hono } from "https://esm.sh/hono@3.11.7";
import { OpenAI } from "https://esm.town/v/std/openai";
const app = new Hono();
}
// Helper function to extract logo URL using OpenAI
async function extractLogoUrl(html: string, websiteUrl: string): Promise<string | null> {
try {
// Use custom API key if provided, otherwise use Val Town's built-in integration
const apiKey = Deno.env.get('OPENAI_API_KEY');
const openai = apiKey ? new OpenAI({ apiKey }) : new OpenAI();
const prompt = `I will provide you with the HTML source code of a company's website. Please
${html.substring(0, 25000)}`; // Increased for better SVG detection
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: prompt }
return result;
} catch (error) {
console.error('Error extracting logo URL with OpenAI:', error);
return null;
}
}
// Helper function to extract company address using OpenAI
async function extractCompanyAddress(html: string, websiteUrl: string): Promise<string | null> {
try {
// Use custom API key if provided, otherwise use Val Town's built-in integration
const apiKey = Deno.env.get('OPENAI_API_KEY');
const openai = apiKey ? new OpenAI({ apiKey }) : new OpenAI();
const prompt = `I will provide you with the HTML source code of a company's website. Please
${html.substring(0, 15000)}`;
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: prompt }
return result;
} catch (error) {
console.error('Error extracting company address with OpenAI:', error);
return null;
}
console.log(`Extracting logo URL from HTML (${html.length} characters)...`);
// Extract logo URL using OpenAI
const logoUrl = await extractLogoUrl(html, websiteUrl);
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { Hono } from "npm:hono@4.4.12";
}
// --- BACKEND LOGIC: HONO ROUTER & OPENAI INTEGRATION ---
const app = new Hono();
app.post("/generate-config-ui", async (c) => {
try {
const openai = new OpenAI();
// The kernel matrices are too large to be useful in the prompt, so they are omitted.
.replace("<SVG_SOURCE>", SVG_SOURCE_CODE);
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { Hono } from "npm:hono@4.4.12";
try {
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o", // Using gpt-4o for better spatial reasoning and precise output
messages: [
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" },
FilesToolHandlers,
KVToolHandlers,
OpenAIToolHandlers,
AdminToolHandlers,
} from "../tools/handlers/index.ts";
private filesHandlers: FilesToolHandlers;
private codeHandlers: CodeToolHandlers;
private openaiHandlers: OpenAIToolHandlers;
private adminHandlers: AdminToolHandlers;
this.kvHandlers = new KVToolHandlers(docClient, DYNAMODB_TABLE);
this.filesHandlers = new FilesToolHandlers(s3Client, S3_BUCKET);
this.openaiHandlers = new OpenAIToolHandlers();
this.adminHandlers = new AdminToolHandlers(docClient, DYNAMODB_TABLE, this.filesHandlers, s3
},
{
name: "openai-chat-completion",
handler: (args: any, authContext: AuthContext) => this.openaiHandlers.handleChatCompletion(ar
},
{
return await toolErrorWrapper(this.codeHandlers.handleListSkills(args, authContext));
// OpenAI tools
case "openai-chat-completion":
return await toolErrorWrapper(this.openaiHandlers.handleChatCompletion(args, authContext
// Admin tools (only available in admin mode)
import { Bot, webhookCallback } from "https://deno.land/x/grammy@v1.35.0/mod.ts";
import { OpenAI } from "https://esm.town/v/std/openai";
// הטוקן הראשי עדיין נחוץ כדי שהבוט ידע מי הוא
const currentMode = userModes[chatId] || "tutor";
console.log(`ChatID ${chatId} in mode '${currentMode}' sent: ${text}`);
const response = await getOpenAIResponse(text, currentMode);
ctx.reply(response);
});
async function getOpenAIResponse(text: string, mode: string) {
const personality = botPersonalities[mode];
if (!personality) return "Error: Invalid mode selected.";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{ role: "system", content: personality.prompt },
// /api/story-options.ts – Edge runtime
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
// More robust version that handles edge cases
},
];
/* ───── OpenAI call ───── */
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages,
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" },