Building a production-ready AI application involves much more than just implementing machine learning models. It requires a robust architecture that can handle real-world demands, scale effectively, and maintain reliability. In this post, we'll dissect the essential components needed to run a production AI application and explore how the Mastra framework helps orchestrate these elements seamlessly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Workflow, Step } from '@mastra/core'; | |
import { z } from 'zod'; | |
async function main() { | |
// Step A: Increment the counter | |
const incrementStep = new Step({ | |
id: 'increment', | |
description: 'Increments the current value by 1', | |
outputSchema: z.object({ | |
newValue: z.number(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.2 | |
info: | |
title: ElevenLabs API Documentation | |
description: >- | |
This is the documentation for the ElevenLabs API. You can use this API to | |
use our service programmatically, this is done by using your xi-api-key. | |
<br/> You can view your xi-api-key using the 'Profile' tab on | |
https://beta.elevenlabs.io. Our API is experimental so all endpoints are | |
subject to change. | |
version: '1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"openapi": "3.0.0", | |
"info": { | |
"version": "2.26.0", | |
"title": "Netlify's API documentation", | |
"description": "Netlify is a hosting service for the programmable web. It understands your documents and provides an API to handle atomic deploys of websites, manage form submissions, inject JavaScript snippets, and much more. This is a REST-style API that uses JSON for serialization and OAuth 2 for authentication.\n\nThis document is an OpenAPI reference for the Netlify API that you can explore. For more detailed instructions for common uses, please visit the [online documentation](https://www.netlify.com/docs/api/). Visit our Community forum to join the conversation about [understanding and using Netlify’s API](https://community.netlify.com/t/common-issue-understanding-and-using-netlifys-api/160).\n\nAdditionally, we have two API clients for your convenience:\n- [Go Client](https://github.com/netlify/open-api#go-client)\n- [JS Client](https://github.com/netlify/build/tree/main/packages/js-client)", | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from "fs"; | |
import { OpenAI } from "langchain/llms/openai"; | |
import { loadSummarizationChain } from "langchain/chains"; | |
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter"; | |
import { PromptTemplate } from "langchain/prompts"; | |
const categories = [ | |
"News", | |
"Business", | |
"Technology", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": 1296269, | |
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", | |
"name": "Hello-World", | |
"full_name": "octocat/Hello-World", | |
"owner": { | |
"login": "octocat", | |
"id": 1, | |
"node_id": "MDQ6VXNlcjE=", | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { navigate } from "gatsby-link"; | |
import * as React from "react"; | |
import { useAuth } from "../hooks/useAuth"; | |
const wrapper = { | |
backgroundColor: `rgb(197,250,3)`, | |
display: `flex`, | |
alignItems: `center`, | |
justifyContent: `center`, | |
flexDirection: `column`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { useAuth } from "../hooks/useAuth"; | |
// .... other code .... // | |
export default function Login() { | |
const { login } = useAuth(); | |
return ( | |
<section style={wrapper}> | |
<div style={loginCard}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { navigate } from "gatsby-link"; | |
import { useMoralis } from "./useMoralis"; | |
export function useAuth() { | |
const { Moralis } = useMoralis(); | |
return { | |
login: async () => { | |
try { | |
const user = await Moralis?.Web3.authenticate(); | |
navigate("/"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function useMoralis() { | |
// Moralis Initialization | |
let Moralis; | |
if (typeof window !== `undefined`) { | |
Moralis = require("moralis"); | |
Moralis.initialize(process.env.GATSBY_MORALIS_APPLICATION_ID); | |
Moralis.serverURL = process.env.GATSBY_MORALIS_SERVER_ID; | |
} | |
return { Moralis }; | |
} |
NewerOlder