8 个开源工具助您构建下一个 AI SaaS 应用🔥🚀

2025-05-25

8 个开源工具助您构建下一个 AI SaaS 应用🔥🚀

我和很多公司合作过,相信我,他们对人工智能解决方案的需求非常巨大。从谷歌到Meta,所有科技巨头都在大力投资人工智能模型。

现在是构建人工智能应用程序以满足不断增长的需求的最佳时机,但找到合适的工具可能具有挑战性。

我整理了八个开源工具,帮助您轻松开发基于 AI 的 SaaS 应用程序。

恶搞之家彼得跳舞


1. Composio 👑:适用于 AI 代理的一体化工具解决方案

我已经构建了自己的 AI 驱动的 SaaS 应用程序,请相信我:添加与 AI 代理的多个集成以自动化工作流程比听起来要困难得多。

Composio 是该领域唯一的解决方案。它拥有超过 90 种工具和集成,涵盖 CRM、HRM、社交媒体、开发和生产力等各个行业。

您可以将这些工具与 AI 模型连接起来,让它们自动化工作流程,例如审查 PR 和处理 Discord 上的客户查询。

Composio 工具目录

它代表您的用户处理复杂的用户身份验证和授权,例如 OAuth、JWT 和 API Key,以便您可以将时间花在其他重要的事情上。

您可以通过使用 安装来快速开始使用 Composio  pip

pip install composio-core
Enter fullscreen mode Exit fullscreen mode

添加 GitHub 集成。

composio add github
Enter fullscreen mode Exit fullscreen mode

Composio 代表您处理用户身份验证和授权。

以下是如何使用 GitHub 集成来启动存储库。

from openai import OpenAI
from composio_openai import ComposioToolSet, App

openai_client = OpenAI(api_key="******OPENAIKEY******")

# Initialise the Composio Tool Set
composio_toolset = ComposioToolSet(api_key="**\\*\\***COMPOSIO_API_KEY**\\*\\***")

## Step 4
# Get GitHub tools that are pre-configured
actions = composio_toolset.get_actions(actions=[Action.GITHUB_ACTIVITY_STAR_REPO_FOR_AUTHENTICATED_USER])

## Step 5
my_task = "Star a repo ComposioHQ/composio on GitHub"

# Create a chat completion request to decide on the action
response = openai_client.chat.completions.create(
model="gpt-4-turbo",
tools=actions, # Passing actions we fetched earlier.
messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": my_task}
  ]
)
Enter fullscreen mode Exit fullscreen mode

运行此 Python 脚本以使用代理执行给定的指令。

有关 Composio 的更多信息,请访问其文档

作曲 GIF

为 Composio 代码库加星标 ⭐


2. Vercel AI SDK:快速构建AI应用程序的工具包

如果您是一名 Typescript 开发人员,正在寻找构建 AI 应用程序的统一解决方案,那么这就是适合您的解决方案。

Vercel AI SDK 是一个统一的 Typescript 工具包,旨在帮助开发人员使用 React、Vue、Svelte、NextJS 和 Node JS 构建 AI 驱动的解决方案。

它主要有两个组成部分,

  • AI SDK Core:使用 LLM 生成结构化对象、文本和工具调用的统一 API。
  • AI SDK UI:一组与框架无关的钩子,用于快速构建聊天和生成用户界面。

首先,安装该库。

npm install ai
Enter fullscreen mode Exit fullscreen mode

安装您选择的模型提供程序。

npm install @ai-sdk/openai
Enter fullscreen mode Exit fullscreen mode

调用 OpenAI API。

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai'; // Ensure OPENAI_API_KEY environment variable is set

async function main() {
  const { text } = await generateText({
    model: openai('gpt-4-turbo'),
    system: 'You are a friendly assistant!',
    prompt: 'Why is the sky blue?',
  });

  console.log(text);
}

main();
Enter fullscreen mode Exit fullscreen mode

调用 Anthropic API

import { generateText } from "ai"
import { anthropic } from "@ai-sdk/anthropic"
const { text } = await generateText({
model: anthropic("claude-3-opus-20240229"),
prompt: "What is love?"
})
Enter fullscreen mode Exit fullscreen mode

查看文档以了解更多信息。

Vefcel AI SDK GIF

为 AI SDK 存储库加星标⭐


3. Julep:AI 应用的托管后端

如果处理不当,开发 AI 应用很快就会变得错综复杂。Julep 为开发者提供全面的解决方案,帮助他们构建具有长期记忆的 AI 代理并管理多步骤流程。

Julep 支持创建多步骤任务,包括决策、循环、并行处理以及与众多外部工具和 API 的集成。

虽然许多人工智能应用程序仅限于简单、线性的提示链和 API 调用,并且分支最少,但 Julep 可以处理更复杂的场景。

Julep 有 Python 和 Javascript 版本。

快速开始使用 Julep。

npm install @julep/sdk
Enter fullscreen mode Exit fullscreen mode

使用 Julep 创建代理。

import { Julep } from "@julep/sdk";
import yaml from "js-yaml";

const client = new Julep({ apiKey: "your_julep_api_key",environment:dev });

async function createAgent() {
  const agent = await client.agents.create({
    name: "Storytelling Agent",
    model: "gpt-4",
    about:
      "You are a creative storytelling agent that can craft engaging stories and generate comic panels based on ideas.",
  });

  // 🛠️ Add an image generation tool (DALL·E) to the agent
  await client.agents.tools.create(agent.id, {
    name: "image_generator",
    description: "Use this tool to generate images based on descriptions.",
    integration: {
      provider: "dalle",
      method: "generate_image",
      setup: {
        api_key: "your_openai_api_key",
      },
    },
  });

  return agent;
}
Enter fullscreen mode Exit fullscreen mode

查看他们的文档以获取有关创建任务、执行任务和与代理聊天的更多信息。

人工智能

为 Julep 仓库加星标 ⭐


4. CopilotKit:为任何 Web 应用添加 AI 副驾驶

如果您想要一个可以方便地添加 AI 功能、文本生成和代理自动化的解决方案,那么您的搜索就到此结束。

它提供多个组件,例如应用内 AI 聊天机器人、Copilot 文本区域和生成 UI。

通过安装来开始使用 CopilotKit npm

npm install @copilotkit/react-core @copilotkit/react-ui @copilotkit/runtime
npm install openai
Enter fullscreen mode Exit fullscreen mode

设置 OpenAI 密钥。

OPENAI_API_KEY=your_api_key_here
Enter fullscreen mode Exit fullscreen mode

通过创建新路由来设置端点以处理/api/copilotkit端点。

#route.ts

import {
  CopilotRuntime,
  OpenAIAdapter,
  copilotRuntimeNextJSAppRouterEndpoint,
} from '@copilotkit/runtime';
import OpenAI from 'openai';
import { NextRequest } from 'next/server';

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const serviceAdapter = new OpenAIAdapter({ openai });
const runtime = new CopilotRuntime();

export const POST = async (req: NextRequest) => {
  const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
    runtime,
    serviceAdapter,
    endpoint: '/api/copilotkit',
  });

  return handleRequest(req);
};
Enter fullscreen mode Exit fullscreen mode

配置 Copilot 提供程序

#layout.tsx

import { CopilotKit } from "@copilotkit/react-core"; 

export default function RootLayout({children}) {
  return (
    {/* Make sure to use the URL you configured in the previous step */}
    <CopilotKit runtimeUrl="/api/copilotkit">
      {children}
    </CopilotKit> 
  );
}
Enter fullscreen mode Exit fullscreen mode

连接 Copilot UI。

#layout.tsx

import "@copilotkit/react-ui/styles.css";
import { CopilotPopup } from "@copilotkit/react-ui";

export function YourApp() {
  return (
    <>
      <YourMainContent />
      <CopilotPopup
        instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
        labels={{
          title: "Popup Assistant",
          initial: "Need any help?",
        }}
      />
    </>
  );
}
Enter fullscreen mode Exit fullscreen mode

这样,您就已成功在 Web 应用程序中添加了弹出窗口。

更多信息请参阅官方文档。

办理美国大学文凭【微信8522222】GIF

为 CopilotKit 代码库加星标⭐


5. E2b:运行 AI 生成代码的运行时

如果您正在构建需要 AI 生成代码执行的应用程序(例如 AI 分析师、软件开发人员或生成 UI),那么 E2B 就是首选平台。

它在底层使用一个独立的虚拟机来沙盒化代码执行。你可以在应用中为每个 LLM、用户或 AI 代理会话运行一个单独的沙盒。例如,如果你正在构建一个 AI 数据分析聊天机器人,你需要为每个用户会话启动一个沙盒。

安装 E2B SDK。

npm i @e2b/code-interpreter dotenv
Enter fullscreen mode Exit fullscreen mode

编写启动沙盒的代码。

import 'dotenv/config'
import { Sandbox } from '@e2b/code-interpreter'

const sbx = await Sandbox.create() // By default the sandbox is alive for 5 minutes
const execution = await sbx.runCode('print("hello world")') // Execute Python inside the sandbox
console.log(execution.logs)

const files = await sbx.files.list('/')
console.log(files)
Enter fullscreen mode Exit fullscreen mode

启动沙盒。

npx tsx ./index.ts
Enter fullscreen mode Exit fullscreen mode

查看文档以了解更多信息。

E2B Gif

为 E2B 代码库加星标 ⭐


6. Haystack:可用于生产的 AI 框架

Haystack 是一个完整的平台,可满足您构建可用于生产的 RAG 管道、最先进的 AI 搜索系统和 LLM 驱动的应用程序的所有需求。

Haystack 提供了一种模块化方法来构建管道,使开发人员可以更轻松地根据需要添加向量存储、重新排序器和嵌入模型等组件。

通过 安装 开始pip

pip install haystack-ai
Enter fullscreen mode Exit fullscreen mode

让我们创建一个简单的 RAG 管道。

import os
from haystack import Pipeline, Document
from haystack.utils import Secret
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders.answer_builder import AnswerBuilder
from haystack.components.builders.prompt_builder import PromptBuilder

# Write documents to InMemoryDocumentStore
document_store = InMemoryDocumentStore()
document_store.write_documents([
    Document(content="My name is Jean and I live in Paris."), 
    Document(content="My name is Mark and I live in Berlin."), 
    Document(content="My name is Giorgio and I live in Rome.")
])

# Build a RAG pipeline
prompt_template = """
Given these documents, answer the question.
Documents:
{% for doc in documents %}
    {{ doc.content }}
{% endfor %}
Question: {{question}}
Answer:
"""

retriever = InMemoryBM25Retriever(document_store=document_store)
prompt_builder = PromptBuilder(template=prompt_template)
llm = OpenAIGenerator(api_key=Secret.from_token(api_key))

rag_pipeline = Pipeline()
rag_pipeline.add_component("retriever", retriever)
rag_pipeline.add_component("prompt_builder", prompt_builder)
rag_pipeline.add_component("llm", llm)
rag_pipeline.connect("retriever", "prompt_builder.documents")
rag_pipeline.connect("prompt_builder", "llm")

# Ask a question
question = "Who lives in Paris?"
results = rag_pipeline.run(
    {
        "retriever": {"query": question},
        "prompt_builder": {"question": question},
    }
)

print(results["llm"]["replies"])
Enter fullscreen mode Exit fullscreen mode

RAG 管道有各种组件,如 Retriever、Prompt builder、LLM 等,

如果您想了解更多信息,请查看文档。

干草堆

为 Haystack 仓库加星标 ⭐


7. ChromaDB:人工智能应用数据库

如果你构建依赖语义检索的 AI 应用,向量数据库必不可少。ChromaDB 是最常用的向量数据库之一。它们支持文本和图像的索引。

如果您不想自行托管,他们也提供托管服务。Chroma 作为服务器运行,并提供第一方 Python 和 JavaScript/TypeScript 客户端 SDK。

  1. 安装 ChromaDB
yarn install chromadb chromadb-default-embed
Enter fullscreen mode Exit fullscreen mode

通过****安装Chromapypi以高效运行后端服务器。

运行 Chroma 后端:

chroma run --path ./getting-started
Enter fullscreen mode Exit fullscreen mode

然后,创建一个连接到它的客户端:

import { ChromaClient } from "chromadb";
const client = new ChromaClient();
Enter fullscreen mode Exit fullscreen mode

创建集合#

集合是存储嵌入、文档和任何其他元数据的地方。您可以创建一个集合,其名称如下:

const collection = await client.createCollection({
  name: "my_collection",
});
Enter fullscreen mode Exit fullscreen mode

将一些文本文档添加到集合中

Chroma 将存储您的文本并自动处理嵌入和索引。您还可以自定义嵌入模型。

await collection.add({
  documents: [
    "This is a document about pineapple",
    "This is a document about oranges",
  ],
  ids: ["id1", "id2"],
});
Enter fullscreen mode Exit fullscreen mode

查询集合

您可以使用查询文本列表来查询该集合,Chroma 将返回 n 最相似的结果。就是这么简单!

const results = await collection.query({
  queryTexts: "This is a query document about hawaii", // Chroma will embed this for you
  nResults: 2, // how many results to return
});
console.log(results);
Enter fullscreen mode Exit fullscreen mode

阅读文档以了解更多信息。

ChromaDB 数据库

为 ChromaDB 存储库加星标⭐


8. Postiz:人工智能社交媒体工具

构建 SaaS 应用程序需要大量的时间、精力和金钱,如果没有用户,使用花哨的技术也没有意义。

Postiz 解决了这个问题;它是一个人工智能工具,可以帮助您接触潜在用户和客户、产生潜在客户并帮助您完成 SaaS 之旅。

主要功能包括

  • 同时在多个社交媒体上发布内容。
  • 安排您的内容(计时),以便在人们在线时发布它。
  • 获得 AI 的帮助来生成内容,以便您可以更快地创建内容。
  • 如果您很懒,请添加您的社交媒体渠道并让其他人管理它们。

邮政信箱 GIF

为 Postiz 存储库加星标⭐


感谢您阅读本文。

在下面的评论中,让我知道其他很酷的 AI 工具或框架是否帮助您构建了应用程序。

PS 欢迎随时 在 X 上关注我;我会分享有价值的东西 - 保证!

文章来源:https://dev.to/nevodavid/8-open-source-tools-to-build-your-next-ai-saas-app-11ip
PREV
9 个必须了解的开源工具,让你比 99% 的开发人员更优秀
NEXT
40 个开源精华助您成为终极开发者🔥 🚀 1. Postiz 👑 👑