Remarkably, Ben's Bytes is one of the best newsletters I receive about tech news
The best AI and tech newsletter I'm currently subscribed to
A collection of articles tagged with Artificial Intelligence on my blog!
The best AI and tech newsletter I'm currently subscribed to
The best Web Dev newsletter I'm currently subscribed to
MidJourney v5 is here and it’s pretty insane.
This video by Two Minute Papers titled “Midjourney AI: A League Above DALL-E 2!” really does a great explanation of how groundbreaking MidJourney is.
This tweet really put it on the map for me, with a crazy breakdown of how its new features stack up.
These systems don't train on customer inputshttps://t.co/rx2VcIjJmD
— Guillermo Rauch (@rauchg) March 13, 2023
From this GitHub snippet:
async function OpenAITextStream(search: string) {
const payload: OpenAITextPayload = {
model: 'text-davinci-003',
prompt: search,
temperature: 0,
max_tokens: 2048,
frequency_penalty: 0.0,
stream: true,
presence_penalty: 0.0,
n: 1
};
const encoder = new TextEncoder();
const decoder = new TextDecoder();
let counter = 0;
const res = await fetch('https://api.openai.com/v1/completions', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${key}`
},
method: 'POST',
body: JSON.stringify(payload)
});
const stream = new ReadableStream({
async start(controller) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function onParse(event: ParseEvent) {
if (event.type === 'event') {
const data = event.data;
// https://beta.openai.com/docs/api-reference/completions/create#completions/create-stream
if (data === '[DONE]') {
controller.close();
return;
}
try {
const json = JSON.parse(data);
const text = json.choices[0].text;
if (counter < 2 && (text.match(/\n/) || []).length) {
// this is a prefix character (i.e., "\n\n"), do nothing
return;
}
const queue = encoder.encode(text);
controller.enqueue(queue);
counter++;
} catch (e) {
controller.error(e);
}
}
}
// stream response (SSE) from OpenAI may be fragmented into multiple chunks
// this ensures we properly read chunks and invoke an event for each SSE event stream
const parser = createParser(onParse);
// https://web.dev/streams/#asynchronous-iteration
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for await (const chunk of res.body as any) {
parser.feed(decoder.decode(chunk));
}
}
});
return stream;
}
Amazing. A glimpse of how AI will revolutionize code migrations.https://t.co/PT5fyD7lza (h/t @thomasglopes) pic.twitter.com/mAPC5PgwiI
— Guillermo Rauch (@rauchg) March 12, 2023
Also, An example of OpenAI API and ReadableStream with GPT 3 in SvelteKit. And Guillermo later mentions that OpenAI does not train on customer inputs
The best AI and tech newsletter I'm currently subscribed to
The best Web Dev newsletter I'm currently subscribed to
MidJourney v5 is here and it’s pretty insane.
This video by Two Minute Papers titled “Midjourney AI: A League Above DALL-E 2!” really does a great explanation of how groundbreaking MidJourney is.
This tweet really put it on the map for me, with a crazy breakdown of how its new features stack up.
These systems don't train on customer inputshttps://t.co/rx2VcIjJmD
— Guillermo Rauch (@rauchg) March 13, 2023
From this GitHub snippet:
async function OpenAITextStream(search: string) {
const payload: OpenAITextPayload = {
model: 'text-davinci-003',
prompt: search,
temperature: 0,
max_tokens: 2048,
frequency_penalty: 0.0,
stream: true,
presence_penalty: 0.0,
n: 1
};
const encoder = new TextEncoder();
const decoder = new TextDecoder();
let counter = 0;
const res = await fetch('https://api.openai.com/v1/completions', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${key}`
},
method: 'POST',
body: JSON.stringify(payload)
});
const stream = new ReadableStream({
async start(controller) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function onParse(event: ParseEvent) {
if (event.type === 'event') {
const data = event.data;
// https://beta.openai.com/docs/api-reference/completions/create#completions/create-stream
if (data === '[DONE]') {
controller.close();
return;
}
try {
const json = JSON.parse(data);
const text = json.choices[0].text;
if (counter < 2 && (text.match(/\n/) || []).length) {
// this is a prefix character (i.e., "\n\n"), do nothing
return;
}
const queue = encoder.encode(text);
controller.enqueue(queue);
counter++;
} catch (e) {
controller.error(e);
}
}
}
// stream response (SSE) from OpenAI may be fragmented into multiple chunks
// this ensures we properly read chunks and invoke an event for each SSE event stream
const parser = createParser(onParse);
// https://web.dev/streams/#asynchronous-iteration
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for await (const chunk of res.body as any) {
parser.feed(decoder.decode(chunk));
}
}
});
return stream;
}
Amazing. A glimpse of how AI will revolutionize code migrations.https://t.co/PT5fyD7lza (h/t @thomasglopes) pic.twitter.com/mAPC5PgwiI
— Guillermo Rauch (@rauchg) March 12, 2023
Also, An example of OpenAI API and ReadableStream with GPT 3 in SvelteKit. And Guillermo later mentions that OpenAI does not train on customer inputs