1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
23async function getOpenAI() {
4// if you don't have a key, use our std library version
5if (Deno.env.get("OPENAI_API_KEY") === undefined) {
14/**
15* Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16* This function can handle both single string inputs and arrays of message objects.
17* It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18*
21* @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22*/
23export async function chat(
24input: string | Message[],
25options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
23async function getOpenAI() {
4// if you don't have a key, use our std library version
5if (Deno.env.get("OPENAI_API_KEY") === @std/openai) {
14/**
15* Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16* This function can handle both single string inputs and arrays of message objects.
17* It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18*
21* @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22*/
23export async function chat(
24input: string | Message[],
25options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,
1# OpenAI ChatGPT helper function
23This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.
jadeGophermain.tsx3 matches
1011const clientCode = () => {
12document.getElementById("input").addEventListener("submit", function(event) {
13event.preventDefault();
1434+ `&assistantId=${input.getAttribute("data-assistant-id")}`,
35);
36eventSource.onmessage = function(event) {
37console.log(event);
38responseDiv.innerText += JSON.parse(event.data);
39};
4041eventSource.onerror = function() {
42eventSource.close();
43};
linkInBioTemplatemain.tsx1 match
2import { renderToString } from "npm:react-dom/server";
34export default async function(req: Request) {
5return new Response(
6renderToString(
httpHandlerOKmain.tsx1 match
1export function handler(request: Request) {
2return Response.json({ ok: true });
3}
quickstartWebsitemain.tsx1 match
2import { renderToString } from "npm:react-dom/server";
34export default async function(req: Request) {
5return new Response(
6renderToString(
1import { parseFeed } from "jsr:@mikaelporttila/rss@*";
23export default async function(req: Request): Promise<Response> {
4return new Response(
5(await parseFeed(
gitReleaseNotesmain.tsx10 matches
16}
1718// Function to fetch package info from NPM registry
19async function fetchPackageInfo(packageName: string) {
20const url = `https://registry.npmjs.org/${packageName}`;
21const response = await fetch(url);
26}
2728// Function to extract GitHub repo URL from package info
29function extractGitHubRepoUrl(packageInfo: any): string | null {
30const repository = packageInfo.repository;
31if (repository && repository.url) {
38}
3940// Function to get the GitHub repository path (owner/repo) from the URL
41function getGithubRepoPath(repoUrl: string): string | null {
42const match = repoUrl.match(/github\.com\/([^\/]+\/[^\/]+)/);
43return match ? match[1] : null;
44}
4546async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48if (!response.ok) {
52}
5354function compareVersions(version1: string, version2: string): number {
55const v1 = version1.replace(/^v/, "").split(".").map(Number);
56const v2 = version2.replace(/^v/, "").split(".").map(Number);
63}
6465async function getReleaseNotesBetweenVersions(repo: string, currentVersion: string): Promise<GithubRelease[]> {
66const releases = await getGithubReleases(repo);
6774}
7576async function checkNpmUpdates(packageJsonUrl: string): Promise<string> {
77try {
78const response = await fetch(packageJsonUrl);
reacttldrawclientmain.tsx1 match
20} = await import(ret.url + "?bundle-deps");
2122export function App() {
23return (
24<>