avatarLaxfed Paulacy

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2703

Abstract

play the actual video.</li><li><b>Rendering the Video:</b> Using Remotion lambda to render the video and storing the file in an S3 bucket.</li></ol><h2 id="8e6b">Code Snippets</h2><h2 id="9049">Fetching Stats</h2><div id="b770"><pre><span class="hljs-keyword">interface</span> <span class="hljs-symbol">Stats</span> { username: <span class="hljs-built_in">string</span> year: number email: <span class="hljs-built_in">string</span> <span class="hljs-comment">// ... other stats</span> }</pre></div><h2 id="2fd1">Generating the Manifest</h2><div id="2709"><pre><span class="hljs-comment">// Prompt to format the AI's response</span> <span class="hljs-keyword">const</span> prompt = <span class="hljs-title class_">ChatPromptTemplate</span>.<span class="hljs-title function_">fromMessages</span>([ [<span class="hljs-string">'system'</span>, <span class="hljs-string">You are Github Video Maker...</span>], [<span class="hljs-string">'human'</span>, <span class="hljs-string">The GitHub stats are as follows: <span class="hljs-subst">${stats}</span></span>] ]);</pre></div><h2 id="242a">Video Manifest Schema</h2><div id="8c66"><pre><span class="hljs-keyword">import</span> z <span class="hljs-keyword">from</span> <span class="hljs-string">'zod'</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> videoSchema = z.<span class="hljs-title function_">object</span>({ <span class="hljs-attr">scenes</span>: z.<span class="hljs-title function_">array</span>( z.<span class="hljs-title function_">object</span>({ <span class="hljs-attr">text</span>: z.<span class="hljs-title function_">string</span>().<span class="hljs-title function_">describe</span>(<span class="hljs-string">'Displays on screen'</span>), <span class="hljs-attr">animation</span>: z.<span class="hljs-title function_">discriminatedUnion</span>(<span class="hljs-string">'type'</span>, [ <span class="hljs-comment">// ... animation types</span> ]) }).<span class="hljs-title function_">describe</span>(<span class="hljs-string">'Scenes in the video'</span>) ) })

<span class="hljs-keyword">export</span> <span class="hljs-keyword">type</span> <span class="hljs-title class_">Manifest</span> = z.<span class="hljs-property">infer</span><<span class="hljs-keyword">typeof</span> videoSchema></pre></div><h2 id="44c5">Playing the Video</h2><div id="f059"><pre><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> <span class="hljs-title function_">Video</span> = (<span class="hljs-params">{ video }</span>) => { <span class="hljs-keyword">const</span> { fps } = <span class="hljs-title function_">useVideoConfi

Options

g</span>()

<span class="hljs-keyword">return</span> video.<span class="hljs-property">scenes</span>.<span class="hljs-title function_">map</span>(<span class="hljs-function">(<span class="hljs-params">{ text, animation }, i</span>) =></span> { <span class="hljs-keyword">switch</span> (animation?.<span class="hljs-property">type</span>) { <span class="hljs-keyword">case</span> <span class="hljs-string">'languages'</span>: <span class="hljs-keyword">return</span> ( <span class="language-xml"><span class="hljs-tag"><<span class="hljs-name">Languages</span> <span class="hljs-attr">from</span>=<span class="hljs-string">{i</span> * <span class="hljs-attr">fps</span> * <span class="hljs-attr">5</span>} <span class="hljs-attr">languages</span>=<span class="hljs-string">{animation.languages}</span> /></span></span> ) <span class="hljs-comment">// ... other cases</span> <span class="hljs-attr">default</span>: <span class="hljs-keyword">return</span> ( <span class="language-xml"><span class="hljs-tag"><<span class="hljs-name">Conclusion</span> <span class="hljs-attr">from</span>=<span class="hljs-string">{i</span> * <span class="hljs-attr">fps</span> * <span class="hljs-attr">5</span>} <span class="hljs-attr">text</span>=<span class="hljs-string">{text}</span> /></span></span> ) } }) }</pre></div><h2 id="c660">Conclusion</h2><p id="39d3">This project showcases the integration of various cutting-edge technologies to create personalized videos at scale. By following this tutorial, you can understand how to leverage LangChain, LLMs, and other tools to build similar projects in 2024.</p><div id="af90" class="link-block"> <a href="https://readmedium.com/langchain-what-is-the-new-langchain-architecture-and-community-path-to-langchain-v0-1-910473985f35"> <div> <div> <h2>LANGCHAIN — What Is the New Langchain Architecture and Community Path to Langchain v0.1?</h2> <div><h3>Technology’s future is in the hands of the dreamers, not the regulators. — Robin Chase</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*nu7ZXSdSXeo6aCLEJYoZpg.jpeg)"></div> </div> </div> </a> </div><p id="6710">Ready for takeoff? Give Year in code a try. Translate your keystrokes into stardust. Find solace in your retrospection, let others join you in your journey, and connect with starfarers alike.</p><p id="40fd">Your chronicle awaits.</p></article></body>

LANGCHAIN — Can Graphite Labs Create Personalized Videos at Scale?

Real artists ship. — Steve Jobs.

Creating personalized videos at scale is a complex task that involves integrating various technologies and platforms. In this tutorial, we’ll explore how Rubric Labs and Graphite leveraged LangChain and other technologies to create personalized videos for GitHub users at scale.

Tech Stack

Before we delve into the details, let’s take a look at the technologies used in this project:

  • GitHub GraphQL API: Used to fetch GitHub stats for the users.
  • LangChain.js & OpenAI GPT-4-turbo: Utilized to generate the video_manifest (the script) based on user data.
  • Remotion: Employed to create and play the video.
  • AWS Lambda & AWS S3: Used to render and store the video.
  • Three.js: Utilized for 3D objects.
  • Supabase: Employed for database and authentication.
  • Next.js 13: Used for frontend.
  • Vercel: Employed for hosting.
  • Tailwind: Utilized for styling.
  • Zod: Used for schema validation.

Overview of the Architecture

The architecture involves several key steps:

  1. Authentication and Data Fetching: Authenticating a GitHub user using Supabase auth, fetching user-specific data from the GitHub GraphQL API, and storing it in a PostgreSQL database hosted on Supabase.
  2. Generating the Manifest: Passing user stats to OpenAI’s gpt-4-turbo model via LangChain, along with a prompt on how to format its response to generate the video_manifest.
  3. Playing the Video: Mapping scenes to React components using Remotion to play the actual video.
  4. Rendering the Video: Using Remotion lambda to render the video and storing the file in an S3 bucket.

Code Snippets

Fetching Stats

interface Stats {
  username: string
  year: number
  email: string
  // ... other stats
}

Generating the Manifest

// Prompt to format the AI's response
const prompt = ChatPromptTemplate.fromMessages([
  ['system', `You are Github Video Maker...`],
  ['human', `The GitHub stats are as follows: ${stats}`]
]);

Video Manifest Schema

import z from 'zod'

export const videoSchema = z.object({
  scenes: z.array(
    z.object({
      text: z.string().describe('Displays on screen'),
      animation: z.discriminatedUnion('type', [
        // ... animation types
      ])
    }).describe('Scenes in the video')
  )
})

export type Manifest = z.infer<typeof videoSchema>

Playing the Video

export const Video = ({ video }) => {
  const { fps } = useVideoConfig()

  return video.scenes.map(({ text, animation }, i) => {
    switch (animation?.type) {
      case 'languages':
        return (
          <Languages from={i * fps * 5} languages={animation.languages} />
        )
      // ... other cases
      default:
        return (
          <Conclusion from={i * fps * 5} text={text} />
        )
    }
  })
}

Conclusion

This project showcases the integration of various cutting-edge technologies to create personalized videos at scale. By following this tutorial, you can understand how to leverage LangChain, LLMs, and other tools to build similar projects in 2024.

Ready for takeoff? Give Year in code a try. Translate your keystrokes into stardust. Find solace in your retrospection, let others join you in your journey, and connect with starfarers alike.

Your chronicle awaits.

Langchain
Videos
Personalized
ChatGPT
Create
Recommended from ReadMedium