You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/image-url.jpg?q=openai&page=3&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=openai
Returns an array of strings in format "username" or "username/projectName"
Found 1576 results for "openai"(1805ms)
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import OpenAI from "https://esm.sh/openai@4.28.4";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
423if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
424try {
425const openai = new OpenAI({
426apiKey:
427"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",
432console.log("Received messages:", JSON.stringify(messages, null, 2));
433434// Prepare messages for OpenAI API
435const formattedMessages = [
436{ role: "system", content: CHARACTER_DESCRIPTION },
443console.log("Formatted messages:", JSON.stringify(formattedMessages, null, 2));
444445const completion = await openai.chat.completions.create({
446messages: formattedMessages,
447model: "gpt-3.5-turbo",
453});
454455console.log("OpenAI Response:", JSON.stringify(completion.choices[0].message, null, 2));
456457return Response.json({
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(req: Request): Promise<Response> {
11});
12}
13const openai = new OpenAI();
1415try {
28}
2930const stream = await openai.chat.completions.create(body);
3132if (!body.stream) {