The RIGHT WAY To Build AI Agents with CrewAI (BONUS: 100% Local)

Matthew Berman
15 Apr 202419:46

Summary

TLDR在这个视频中,演讲者展示了如何使用Lightning AI来构建一个高效的Crew AI团队。Lightning AI不仅提供了一个基于云的代码编辑器,允许团队成员在云端协作编写代码,还可以利用开源模型来增强功能。视频中,演讲者首先创建了一个新的Lightning Studio,并在其中建立了一个名为“financial analyst crew”的代码框架。通过YAML文件定义了两个任务——“research company task”和“analyze company task”,以及两个相应的代理——“company researcher”和“company analyst”。接着,演讲者展示了如何使用LangChain和Gro模型来执行这些任务,并最终通过Lightning AI的GPU加速来提高处理速度。此外,还介绍了如何使用Lightning AI的Studio模板来快速启动一个项目,并利用API Builder插件将模型作为API服务暴露出来,从而实现与Crew AI的无缝集成。视频最后,演讲者鼓励观众如果喜欢这个视频就点赞和订阅。

Takeaways

  • 🚀 介绍了如何使用Lightning AI搭建一个基于云的协作代码编辑器和开源模型的Crew AI团队。
  • 📂 创建一个新的Studio和代码工作室,以便在云端进行项目管理和环境管理。
  • 🔧 采用模块化的方式构建Crew AI代码框架,使用yaml定义代理和任务。
  • 🛠️ 定义任务和代理,通过在配置文件中编写代码来明确它们的角色和目标。
  • 🔄 通过迭代和复制任务定义,快速创建多个任务,每个任务对应一个代理。
  • 📈 展示了如何为金融分析团队创建任务,例如研究特定公司和分析公司财务状况。
  • 🤖 为每个任务创建代理,如金融研究员和金融分析师,并为它们设置详细的背景故事和目标。
  • 📋 编写主文件main.py,将代理和任务组合在一起,创建Crew AI的运行流程。
  • 🔗 介绍了如何使用Lang chain和Grock来连接和驱动Crew AI中的代理。
  • 🛠️ 演示了如何使用Poetry来打包和管理项目依赖,为项目创建一个虚拟环境。
  • 🔧 通过Lightning AI的API Builder插件,将Crew AI与OpenAI兼容的API端点连接。
  • 🎉 强调了使用Lightning AI的GPU资源来加速大型模型的推理过程,并展示了实际操作过程。

Q & A

  • 视频介绍了使用什么工具来搭建Crew AI团队?

    -视频介绍了使用Lightning AI,这是一个云端代码编辑器,可以与他人协作编辑代码,并能够为开源模型提供动力。

  • Crew AI的代码库在未来将会是什么样子?

    -Crew AI的代码库在未来将会是非常模块化的,拥有独立的工具区域,使用YAML定义代理和任务,并且所有内容都会汇集到一个简短的main.py文件中。

  • 为什么要使用Lightning AI来管理Python环境?

    -使用Lightning AI可以避免Python环境管理带来的头痛问题,因为它本质上是一个每次启动都是全新环境的云端代码编辑器。

  • 在Crew AI中,如何定义任务和代理?

    -在Crew AI中,任务和代理通过在config文件夹中创建相应的.yaml文件来定义,其中包括角色、目标、背景故事等信息。

  • 视频提到了哪些金融分析中的重要指标?

    -视频提到了盈利能力比率、流动性比率、偿债能力比率等金融分析中的重要指标。

  • 如何使用Lightning AI的GPU来为开源模型提供动力?

    -通过在Lightning AI的云端环境中配置模型,设置相应的GPU参数,并将模型通过API与Crew AI团队集成,从而使用Lightning AI的GPU为开源模型提供动力。

  • 视频最后提到了哪些步骤来运行和测试Crew AI团队?

    -视频最后提到了使用Poetry来整合项目、安装依赖、运行项目以及测试使用不同的模型(如Gro和Mixol)来驱动Crew AI团队的步骤。

  • 如何将Crew AI团队的API端点暴露出来?

    -通过使用Lightning AI的API Builder插件,设置端口和启用认证,然后获取基础URL,最后在Crew AI代码中使用这个URL来替换原来的模型配置。

  • 视频提到了哪些工具来帮助分析公司的财务表现?

    -视频提到了使用SEC工具来帮助分析公司的财务表现,这是一个已经存在于Crew AI示例库中的工具。

  • 在视频中,为什么要在不同的任务中使用不同的模型?

    -在不同的任务中使用不同的模型可以根据任务的具体需求选择最合适的模型,例如,某些任务可能需要更专业的财务分析模型,而其他任务可能只需要基本的信息检索功能。

  • 视频提到了哪些步骤来确保Crew AI团队的结构正确?

    -视频提到了创建源文件夹、定义任务和代理、创建主文件以及使用Poetry进行项目整合等步骤来确保Crew AI团队的结构正确。

Outlines

00:00

🚀 构建最优的Crew AI团队

本段介绍了如何使用Lightning AI这一云端代码编辑器来构建一个Crew AI团队。Lightning AI不仅支持代码协作,还能为开源模型提供动力。视频作者展示了如何创建一个新的工作室,并构建一个模块化的Crew AI代码框架。通过定义任务和代理,使用yaml文件来组织结构,并利用Lightning AI的自动环境管理功能,简化了Python环境配置的复杂性。

05:01

📋 定义任务和代理

在这一段中,视频作者详细阐述了如何定义任务和代理。通过创建不同的文件夹和文件,如config文件夹和agents.yaml、tasks.yaml文件,来明确任务和代理的结构。作者还解释了如何为每个任务和代理编写具体的描述和期望输出,以及如何为每个代理设置角色和背景故事。

10:02

🔧 编写主要的代码文件

视频作者在这一部分开始编写主要的代码文件,包括导入必要的库和创建crew AI项目的基础结构。通过定义agent和task的类,并将它们与之前定义的配置文件关联起来,作者展示了如何将任务和代理整合到一起。此外,还介绍了如何设置任务的处理顺序和详细输出。

15:02

🌟 运行Crew AI团队并测试

在最后一段中,作者运行了构建的Crew AI团队,并进行了测试。首先,使用Gro模型快速有效地完成了任务。然后,作者展示了如何使用Lightning AI的Studio模板来运行更大规模的开源模型,并将其API端点集成到Crew AI中。通过这些步骤,作者成功地展示了Crew AI的强大功能和灵活性。

Mindmap

Keywords

💡crew AI

crew AI是指一种人工智能团队,它能够根据任务需求自动分配和协调不同的AI代理。在视频中,crew AI的创始人展示了如何构建一个crew AI代码库,并使用Lightning AI这个云基础的代码编辑器和开源模型驱动平台来实现。

💡Lightning AI

Lightning AI是一个云基础的代码编辑器,它允许多人在线协作编辑代码,并且可以驱动开源模型。在视频中,Lightning AI被用来构建和运行crew AI团队,提供了一个方便的环境来管理Python环境和依赖。

💡代码框架

代码框架是指在软件开发中提前定义好的代码结构和布局,它为开发提供了一个清晰的指导和模板。在视频中,金融分析团队的代码框架包括了源代码文件夹、配置文件夹以及主程序文件等。

💡任务

任务是指在crew AI中定义的一系列操作或目标,代理需要根据任务描述来执行相应的动作并输出预期结果。在视频中,任务包括研究公司和分析公司两个部分。

💡代理

代理是指在crew AI中执行任务的AI实体,每个代理都有特定的角色和目标。在视频中,代理被定义为金融研究员和金融分析师,它们根据任务需求执行不同的职责。

💡配置文件

配置文件是用来存储软件或系统中设置和参数的文件,它通常包含了系统运行所需的各种配置信息。在视频中,配置文件用于定义crew AI中的代理和任务。

💡主程序文件

主程序文件是软件或项目中的核心文件,它通常包含了程序运行的主要逻辑和流程控制。在视频中,主程序文件是用来将代理和任务整合起来,形成完整的crew AI团队。

💡云环境

云环境是指基于云计算技术提供的虚拟化环境,它允许用户通过网络访问和使用存储、计算等资源。在视频中,Lightning AI提供的云环境使得用户无需管理本地Python环境,可以直接在云端编写和运行代码。

💡环境管理

环境管理是指在软件开发中对开发环境进行配置、维护和更新的过程,包括管理依赖库、软件版本等。在视频中,由于使用了Lightning AI的云环境,避免了本地Python环境管理的繁琐。

💡开源模型

开源模型是指公开发布且允许他人自由使用和修改的预训练AI模型。这类模型通常由社区共同维护,可以被集成到不同的平台和应用中。在视频中,作者提到了使用Lightning AI的GPU资源来驱动开源模型。

💡API

API(应用程序编程接口)是软件之间进行交互的一种约定,它定义了软件组件之间如何通信。在视频中,作者展示了如何通过API Builder将Olama模型的API端点暴露出来,并将其与crew AI团队集成。

Highlights

介绍如何使用Lightning AI云编辑器建立一个Crew AI团队

Lightning AI不仅支持代码云端协作,还能为开源模型提供动力

创建一个新的Studio,简化Python环境管理

使用YAML定义代理和任务,模块化构建Crew AI代码框架

定义任务:研究特定公司的股票信息

定义任务:分析公司的财务状况

创建代理:公司研究员和公司分析师

编写main.py文件,将代理和任务整合在一起

使用Grock开源模型,通过Lightning AI GPU加速

展示如何使用Lightning AI的API构建器公开模型

使用Mistol和Lightning AI GPU运行Crew AI团队

演示了如何结构化Crew AI,使用Lightning AI和开源模型

通过Lightning Studio快速启动和运行项目

展示了如何将Crew AI与不同的模型和工具结合使用

使用Poetry管理项目依赖和运行Crew AI团队

通过Lightning AI的云环境避免了本地环境配置的麻烦

提供了一个完整的示例,从设置到运行Crew AI团队

Transcripts

play00:00

in this video I'm going to show you the

play00:02

optimal way to set up your crew AI team

play00:05

this comes straight from the crew AI

play00:08

founder and he has shown me the future

play00:10

of what a crew AI codebase looks like

play00:13

and we're going to be building all of

play00:14

this using lightning AI which is not

play00:17

only a cloud-based code editor which

play00:19

allows you to collaborate with anybody

play00:21

on your code in the cloud but you can

play00:23

also power your open- Source models with

play00:26

it which I'll also be showing you how to

play00:28

do so we're going to build a Crea I team

play00:30

and then we're going to swap out gp4 and

play00:33

we're going to power it using mixol or

play00:35

mistol we'll see and I want to thank

play00:37

lightning. AI for sponsoring this video

play00:39

I'm super excited to build this team on

play00:41

lightning and I'm going to publish this

play00:43

lightning studio in the description

play00:45

below so you can get access to it you

play00:47

can clone it and you can play around

play00:48

with it yourself the first thing we're

play00:50

going to be doing is building our crew

play00:52

AI code framework and so the first thing

play00:55

we need to do is create a new studio so

play00:57

if you don't already have a lightning

play00:59

account go ahead head and sign up

play01:01

they'll give you some free credits to

play01:02

get started click new studio right there

play01:04

and we're going to create a code Studio

play01:07

then we click Start and this entire

play01:09

environment is in the cloud so it really

play01:11

saves you a lot of headaches with python

play01:14

environment management because it's

play01:15

essentially a fresh environment every

play01:17

single time and if you've been watching

play01:19

my videos you know how frustrating

play01:21

python environment management is all

play01:23

right so the high level of how we're

play01:25

going to structure our crew is now very

play01:28

modular we're going to have a separate

play01:29

area area for tools we're going to be

play01:31

using yaml to Define our agents and

play01:34

tasks and everything is going to pipe

play01:36

into a very short main.py file so I just

play01:40

spun up a new lightning studio and

play01:43

that's really all we have to do we can

play01:45

already get started so the first thing

play01:46

we're going to do is create a source

play01:48

folder so go ahead rightclick click new

play01:51

folder and then type source and

play01:54

everything should feel very familiar and

play01:56

lightning because it is essentially vs

play01:59

code in the class and the cool thing is

play02:01

you don't actually need to set up your

play02:03

environment you don't need to struggle

play02:05

with your python environments with

play02:07

dealing with all of these dependencies

play02:09

it just works so we created our source

play02:12

folder and then within the source folder

play02:14

we're going to name our new crew so

play02:17

we're going to actually create another

play02:18

folder within that and I want to make a

play02:20

financial analyst crew and so just like

play02:22

that I name it financial analyst crew

play02:24

hit enter then that creates another

play02:26

folder all right then within that folder

play02:28

we're going to create a another folder

play02:30

config and all of this is just to

play02:33

structure what we need to put everything

play02:36

together so from here we're going to

play02:37

write click we're going to create a new

play02:38

folder we're going to call it config and

play02:40

this is where we're going to put our

play02:42

definitions of our tasks and our agents

play02:45

and as I mentioned they're both going to

play02:46

be Emo files so let's do that now right

play02:48

click we're going to say new file and

play02:50

we're going to call it

play02:52

agents. for the first one and then we're

play02:54

going to right click new file and we're

play02:56

going to call it task. for the second

play02:59

one and now this is where we're going to

play03:01

Define our agents and tasks and the nice

play03:04

thing about doing it this way so if you

play03:06

start getting into the habit of

play03:07

structuring your cruise just like this I

play03:10

believe pretty soon crew AI is going to

play03:12

give you the ability to actually expose

play03:14

an endpoint to control your cruise based

play03:17

on this structure so it'll automatically

play03:19

be able to create you an API so that's

play03:21

why it's good to follow the golden path

play03:23

here so let's start writing our tasks

play03:25

the first task is going to be

play03:27

researching a specific company that I

play03:29

want analyze so I'm going to call it

play03:31

research company task and then we put a

play03:33

colon after it and then we need two

play03:35

parameters within that description and

play03:39

expected output So within the

play03:41

description this is where we're going to

play03:43

describe the task at hand so what we're

play03:45

going to say is use a Search tool and

play03:48

we'll come back to this we'll actually

play03:50

build the Search tool to look up this

play03:52

Company's stock information and then I

play03:54

put company name and the fact that I

play03:56

have curly braces around the company

play03:58

name now makes it a variable which we're

play04:00

going to pass in later and this makes it

play04:02

so that we can basically pass in any

play04:04

company name the goal is to prepare

play04:07

enough information to make an informed

play04:08

analysis of the company's stock

play04:10

performance the next thing we need is

play04:12

the expected output and for the expected

play04:14

output I say all of the relevant

play04:16

Financial wh I spelled Financial wrong

play04:19

financial information about the

play04:20

company's stock performance okay so

play04:22

that's the first task it's as simple as

play04:24

that now I'm going to make a second task

play04:26

so I'm just going to copy that first

play04:28

task paste it again

play04:30

and the second task is going to be

play04:33

analyze company task so I'll delete the

play04:36

descriptions from before and I'll delete

play04:38

the expected output from before as well

play04:41

and we'll put new ones in place so I

play04:43

switched over to Claude 3 which by the

play04:46

way is my new go-to model I no longer

play04:49

prefer GPT 4 Cloud 3 has just been so

play04:52

good and I asked what metrics should

play04:55

someone include in a financial analysis

play04:57

and it gave me a bunch of different

play04:59

metrics and so I'm simply going to copy

play05:01

paste these into the description of the

play05:03

task I want so I say take company names

play05:06

and again I pass in the variable

play05:08

financial information analyze it and

play05:09

provide a financial analysis including

play05:12

profitability ratio liquidity ratio

play05:14

solvency ratios and so on and for the

play05:16

expected output I am going to say a

play05:18

nicely formatted analysis including all

play05:20

of the financial metrics necessary for a

play05:22

thorough financial analysis of a company

play05:25

and so let's stop there obviously I can

play05:27

get much more sophisticated than this

play05:29

but that's not the point I just want to

play05:31

get something up and working and then I

play05:32

want to show you powering it using an

play05:35

open- Source model and powering that by

play05:37

lightning AI gpus okay so we have two

play05:40

tasks so research and then analyze and

play05:43

then we need agents now so let's click

play05:45

over to the agents. yl file so here is

play05:48

the structure of an agent definition and

play05:51

the name is going to be company

play05:52

researcher the role I'm going to name it

play05:54

Financial researcher the goal very

play05:57

similar to the task now one quick thing

play05:59

that I just added is I explicitly said

play06:02

using search tools I don't know if I

play06:04

actually have to do that but I like

play06:06

explicitly saying it CU it doesn't hurt

play06:07

and it makes me feel like okay it's

play06:09

actually going to know to use those

play06:10

tools okay backstory an expert Financial

play06:13

researcher who spends all day and night

play06:15

thinking about financial performance of

play06:17

different companies now we're going to

play06:18

set allow delegation to false because we

play06:21

don't want this agent delegating this

play06:23

task to anybody else and we're going to

play06:25

set verose to true because I want to

play06:27

actually see everything that this agent

play06:29

is thinking so I'm going to copy that

play06:31

and I'm going to paste it down here to

play06:32

create our second agent now typically

play06:34

what I do is I match every agent to an

play06:37

individual task so if there are two

play06:40

tasks there'll be two agents so let's

play06:42

start changing this now so instead of

play06:44

company researcher we're going to call

play06:46

this the company analyst and instead of

play06:50

financial researcher we'll call it

play06:51

financial analyst and then we're going

play06:53

to replace the goal so for the goal I'm

play06:55

going to say take provided company

play06:57

financial information and create a

play06:58

thorough financial report about a given

play07:00

company the backstory an expert

play07:02

financial analyst who prides themselves

play07:04

on creating clear and easily readable

play07:06

Financial reports of different companies

play07:08

again allow delegation false there's no

play07:10

need for that and verbose true so now we

play07:13

are done with agents now uh one quick

play07:16

thing I want to mention is you don't

play07:18

actually have to save any of the files

play07:20

while you're working with lightning AI

play07:22

it just saves it automatically as you're

play07:24

going which is really nice I've

play07:25

obviously gotten into the habit of

play07:26

hitting command save all the time so it

play07:29

doesn't hurt but you don't really have

play07:30

to do that and you can shut this off you

play07:33

can shut down the environment and come

play07:35

back to it later and it's all just going

play07:37

to be there working ready to go just

play07:39

like you left it okay next we're going

play07:41

to create our main file that puts all

play07:44

the agents in task together so

play07:46

rightclick on financial analyst crew and

play07:49

we're going to create a new file and

play07:51

let's call that crew. Pi so the first

play07:55

thing we need to do is import all the

play07:57

relevant libraries so we're going to say

play07:59

from crew AI import agent crew process

play08:03

and task and those are the four main

play08:05

pillars of a crew AI project then we're

play08:08

going to import crew base agent crew and

play08:11

task from the crew ai. project and also

play08:14

because grock is awesome we're going to

play08:17

be using grock to power all of this and

play08:19

we could do so through Lang chain so

play08:21

make sure you have all of these

play08:23

installed and we can pip install them if

play08:25

we need to later but right now we just

play08:27

need Lang chain grock import check Rock

play08:30

now let's actually create the crew base

play08:32

so enter enter and we'll say at crew

play08:35

base and then we're going to create a

play08:36

class financial analyst crew open PRS

play08:39

close pars colon we're going to describe

play08:42

what it is and then we're going to load

play08:44

up the agents and tasks that we just

play08:46

created then we need to set the grock

play08:49

information so we're going to do def

play08:51

init self none and then self. grock llm

play08:55

and this is where we pull in the grock

play08:58

chat information we're going to say

play08:59

temperature zero model name and we're

play09:01

going to be using mixol and we'll need

play09:03

to set the token but we'll do that in a

play09:06

minute now let's pull our agents and our

play09:08

task into this file so at agent okay so

play09:11

I wrote out the first agent definition

play09:13

so we have at agent def company

play09:15

researcher self and then we point it at

play09:17

agent and we're going to be returning a

play09:20

new agent object config and then we pull

play09:23

in the config from the agents. yl file

play09:27

and we pass in the grock L M as it's llm

play09:30

and remember as I've said a lot of times

play09:33

you can actually pass in a different

play09:34

model from different sources into each

play09:37

individual agent so if you want to use

play09:39

gp4 for one clad for another Mixel for

play09:42

another and then an open source model

play09:44

powered by lightning as another you

play09:46

could totally do that next let's copy

play09:48

this and we're going to create our

play09:49

second agent and this second agent is

play09:52

company analyst okay so it's going to do

play09:55

the same thing we're going to pass it as

play09:57

an agent return the agent op object and

play10:00

instead of company researcher we're

play10:01

going to call it company analyst and

play10:04

that's it th those are our definitions

play10:06

for the two agents now we need to create

play10:08

definitions for our tasks so just like

play10:11

agent we say at task at the top we'll

play10:13

say def company research task same as

play10:16

before just like agents except instead

play10:19

of agent we say task here new line then

play10:21

we'll return a task object with

play10:24

definitions config is equal to self.

play10:28

task config and then we'll pull in the

play10:30

relevant task and rather than passing in

play10:33

an llm which wouldn't make sense for a

play10:35

task we're going to pass in our agent

play10:37

that we want to do this task so we say

play10:39

self. compan researcher and that should

play10:43

be good now let's copy it and create the

play10:45

second task down here here we'll say def

play10:48

analyze company task we'll create the

play10:51

task return the task but we'll say

play10:53

analyze company task here and we

play10:55

actually want the company analyst as the

play10:58

agent and I think we're done I think

play11:01

this looks good ah no we need one more

play11:03

thing so we actually have to Define our

play11:05

crew which puts it all together all the

play11:07

agents and all the tasks so we say at

play11:09

crew def crew and we pass it itself make

play11:12

a new crew object so here we're going to

play11:15

return a crew and now we need to pass it

play11:17

all the information to actually create

play11:19

that crew so we'll do agents is equal to

play11:22

self. agents and the self. Agents is

play11:26

automatically created by these

play11:28

decorators right here just a heads up on

play11:31

that so that's all we got to do then for

play11:33

task we do the same thing self. task

play11:36

then we need to set a process so we're

play11:37

going to do process. sequential because

play11:39

we just want it happening one after

play11:41

another and then verbose is equal to two

play11:44

because we want it to Output everything

play11:46

now I think we're done all right now we

play11:48

need to actually create our main.py so

play11:50

we already have one right here so let's

play11:52

go ahead and move that into the

play11:53

financial analyst crew okay main.py and

play11:56

all it does is print hello lightning

play11:58

world so so we're going to import OS and

play12:01

we're going to import the rest of what

play12:03

we need to basically use a m file so

play12:06

Fromm import load. MV load. M then we're

play12:10

going to import our financial analyst

play12:13

crew so it's as simple as from

play12:16

financialist analy financialanalyst

play12:18

crew. crew import and then import the

play12:20

financial analyst crew so now we have

play12:22

everything we need all right and this is

play12:24

the entire main file so we're going to

play12:26

Define run we're going to pass in the

play12:28

inputs and the only input we have is

play12:30

company name Tesla and the nice thing is

play12:32

crew automatically interpolates all of

play12:34

that for us then we're going to say

play12:36

financial analyst crew. crew kickoff

play12:39

we'll pass in the inputs and then we put

play12:41

this kind of main portion down at the

play12:42

bottom now let's create our n file and

play12:46

we're almost done so on the very outside

play12:48

of this entire folder we're going to

play12:50

rightclick new file and we're going to

play12:52

call ITV and we're going to pass a grock

play12:55

API key right there so I grabbed a new

play12:57

grock API key and yes I am going to

play13:00

revoke this key before publishing the

play13:02

video so that's it grock API key and

play13:04

then pass it in just like that okay so I

play13:07

am going to create some tools now and

play13:09

we're not actually going to create them

play13:11

from scratch we're just going to use

play13:12

tools that are currently in the crew aai

play13:15

examples Library already for us so we

play13:18

have an SEC tools which is kind of

play13:20

exactly what we need so let's go ahead

play13:22

and we're just going to copy the whole

play13:23

file we'll switch back and then in the

play13:26

financial analyst crew we're going to

play13:27

right click and we're going to create a

play13:29

new folder and we're going to call it

play13:30

tools then we're going to create a new

play13:32

file in there and we're going to call it

play13:33

SEC tools. py and we're going to paste

play13:36

in all that code so all of this

play13:38

hopefully will just work out of the box

play13:40

all right now we're going to use poetry

play13:42

to put it all together and to actually

play13:44

run the project so to do that we're

play13:47

going to first do pip install poetry

play13:49

then we're going to create a new file

play13:51

and we're going to call it Pi project.

play13:55

TL and you don't really have to know how

play13:57

much of this works and to be honest I

play13:59

don't really know how much of this works

play14:01

uh I'm just not super familiar with

play14:03

poetry but this is the way crew is going

play14:05

to be done going forward so we're going

play14:06

to paste in all this stuff and it

play14:09

basically just sets up poetry for us and

play14:12

the only thing that we're going to need

play14:13

to customize is the financial analyst

play14:15

crew name right there next we're going

play14:17

to lock the dependencies so poetry lock

play14:20

all right should be done and there it is

play14:22

the poetry. loock file perfect then

play14:23

we're going to do poetry install Okay so

play14:26

this is installing all the dependencies

play14:28

now all right there it's done now we

play14:30

should be able to run it from here so

play14:32

poetry run financial analyst crew hit

play14:35

enter uh I missed one thing so I forgot

play14:37

to actually rename it to what we need so

play14:40

financial analyst crew right there now

play14:42

that it's there we should be able to run

play14:44

it properly so I'm going to do poetry

play14:46

install one more time just in case all

play14:48

right now we got no warning so now it

play14:49

should work poetry run financial analyst

play14:52

crew all right so I got another module

play14:54

not found issu so let's do pip install

play14:56

linkchain grock and I'm not sure why we

play14:58

have to do do that again but let's try

play15:00

it hopefully this works okay so let's

play15:02

run it again all right it looks like we

play15:04

got it working wonderful wow look how

play15:08

lightning fast that was okay so let's

play15:10

see what it did so here we go entering

play15:13

the chain Final Answer Tesla's ticker

play15:16

symbol current stock price market cap

play15:19

getting all this great information about

play15:21

Tesla and recent news as well then it

play15:25

passes it on to the financial analyst

play15:28

and it's doing a bunch of different

play15:30

calculations okay all perfect and then

play15:33

we have the ratios and the different

play15:35

metrics that we asked for and then the

play15:37

final output perfect look at this

play15:40

beautiful so it all worked and it was

play15:43

lightning fast so now we have our crew

play15:46

set up but it's using Gro which is

play15:49

fantastic but we want to try running it

play15:51

with an open- Source model powered by

play15:53

lightning AI so you can plug in any

play15:55

model that you want so leave this tab

play15:57

open all right then we're going to go to

play15:59

the studio templates page within

play16:02

lightning. so it's lightning. a/ Studios

play16:05

and this basically comes with a bunch of

play16:08

preconfigured Studios that are ready to

play16:10

go and they have a bunch of them a bunch

play16:13

of really cool ones from running olama

play16:16

fine-tuning you can build diffusion

play16:18

models they just have a bunch of them

play16:20

all right and it already has this run

play16:23

mistal mixture of experts and all we

play16:25

need to do is Click open template right

play16:28

there so we select select what team

play16:29

space then click open and this takes a

play16:32

little while to load up because it's

play16:33

doing a lot in the background but it

play16:36

sets up everything for us and then I'm

play16:37

going to show you how to then expose the

play16:40

API from oama and then we're going to

play16:42

take that API endpoint and then power

play16:45

our model with it all right so it's done

play16:47

now if we look up in the top right and

play16:49

we hover over this button we can

play16:51

actually see that we're using a GPU an

play16:53

a1g and if we click on it then click

play16:55

into the gpus we can see we have a bunch

play16:58

available all the way through A1 100s

play17:00

h100s and yeah they do cost a lot of

play17:03

money to run but you don't need these

play17:05

beefy gpus for all the models but we

play17:07

will likely need something very powerful

play17:10

for mixol and now they have L4 support

play17:14

so you can just get another beastly GPU

play17:18

running your models but I'll just show

play17:20

you that we get it working I'm not

play17:22

actually going to let it do all the

play17:23

inference because that's not the point

play17:25

let's continue so once we have that

play17:28

we're going to come down here and we're

play17:29

going to click this plus button for the

play17:30

plugins we're going to go down to

play17:32

serving and then we're going to do API

play17:34

Builder and click install once that's

play17:36

done we exit out of here on the right

play17:38

side we now have this tab API Builder go

play17:41

ahead and click that now this is one

play17:43

that's just by default and you can

play17:45

actually just go ahead and right click

play17:46

on it and delete this like that and

play17:49

we're going to do a new API okay so

play17:52

we'll keep the name the same and for the

play17:54

port it's 11434 and that is just o

play17:57

llama's Port we don't need any

play17:59

authentication although if we're going

play18:00

to make this into a production

play18:01

environment yes you definitely want

play18:03

authentication then let's enable it then

play18:05

we're going to click on the name and

play18:08

we're going to grab this base URL right

play18:10

there so now this is the endpoint that

play18:12

is exposed with our open AI compatible

play18:15

API so now I switch back to our code so

play18:19

now to do it I'll leave the old code in

play18:21

there but what we need to do is right

play18:23

here from Lang chain. llms we're going

play18:25

to import oama and then we're going to

play18:28

on a new line create a new llm olama

play18:31

mixol then we're going to call olama

play18:33

we're going to pass in the model mixol

play18:35

and then for this base URL we're going

play18:37

to enter the URL that we copied earlier

play18:39

so just like that so then we'll copy

play18:42

this we're going to comment out this

play18:44

line and we'll do self. I'll call it

play18:46

grock llm just to save some time but

play18:49

we'll call it olama mixol just like that

play18:51

and it should all work now I believe

play18:54

there might be one more thing we have to

play18:55

do but let's give it a try and so poetry

play18:57

run financial analyst all right and

play18:59

there it goes so it's probably going to

play19:02

be pretty slow because it is a very big

play19:04

model Mixr and we're not using a super

play19:07

beefy GPU but I just want to show you

play19:09

getting it working and if we switch back

play19:10

to the oama studio we can actually see

play19:12

the GPU going bur right there so you can

play19:15

see it's it's working right now and

play19:17

there it goes look at that all right so

play19:20

if I stop it has a bunch of good

play19:21

information right there go back look at

play19:23

the GPU and now it goes down to zero

play19:26

again so we've confirmed it actually

play19:28

works so now you know how to structure a

play19:31

crew and do so in the most modern way

play19:32

you know how to spin up an open- Source

play19:34

model with lightning Ai and power it

play19:36

with their gpus and you know how to

play19:38

expose the endpoint and plug it into

play19:40

your crew if you liked this video please

play19:43

consider giving a like And subscribe and

play19:45

I'll see you in the next one

Rate This

5.0 / 5 (0 votes)

Related Tags
AI团队构建云端代码编辑Lightning AI金融分析团队协作代码管理开源模型自动化流程GPU加速API集成
Do you need a summary in English?