경고
JS 에이전트는 아이디어를 테스트하는 초기 도서관이었으며 더 이상 적극적으로 개발되지 않았습니다. Modelfusion을 확인하십시오 - JS 에이전트의 학습을 통합 한 TypeScript 용보다 일반적인 AI 라이브러리입니다.
JS 에이전트는 JavaScript 및 TypeScript를 갖춘 AI 에이전트를 생성하기위한 종합 가능하고 확장 가능한 프레임 워크입니다.
에이전트 프로토 타입을 만드는 것은 쉽지만 신뢰성과 견고성을 높이는 것은 복잡하며 상당한 실험이 필요합니다. JS 에이전트는 강력한 빌딩 블록 및 툴링을 제공하여 록 고유 한 에이전트를 더 빠르게 개발할 수 있도록 도와줍니다.
지도 시간
Wikipedia 검색 엔진에 액세스하고 Wikipedia 기사를 읽을 수있는 에이전트. 이를 사용하여 Wikipedia 콘텐츠에 대한 질문에 답변 할 수 있습니다.
사용 된 기능 : gpt-3.5-turbo
, 사용자 정의 도구 (검색 Wikipedia, Wikipedia 기사 읽기), 다음 단계 루프 생성, Max Steps Run Controller 생성
Docker 컨테이너에서 작동하는 자동 개발자 에이전트. 파일을 읽고 파일을 작성하고 명령을 실행할 수 있습니다. 프로젝트에 맞게 조정하고이를 사용하여 코드를 문서화하고 테스트 작성, 테스트 및 기능 등을 업데이트 할 수 있습니다.
사용 된 기능 : gpt-4
, Docker 컨테이너의 공구 실행, 고정 설정 단계가있는 에이전트, 다중 에이전트 실행 속성, 다음 단계 루프 생성 (파일 읽기, 파일 쓰기, 실행, 명령, 사용자 요청), 에이전트 실행 후 비용 계산
Babyagi의 JS 에이전트 구현.
사용 된 기능 : HTTP 에이전트 서버, 텍스트 완성 모델 ( text-davinci-003
), 맞춤형 콘솔 출력, 업데이트 작업 계획 루프
PDF와 주제를 취하고 주제와 관련된 PDF의 모든 컨텐츠로 트위터 스레드를 만듭니다.
사용 된 특징 : 기능 구성 (없음), PDF 로딩, 분할 추출물-리피트
텍스트를 덩어리로 나누고 임베딩을 생성합니다.
사용 된 기능 : 직접 기능 호출 (에이전트 없음), 분할 텍스트 (GPT3-Tokenizer), 임베딩 생성
text-davinci-003
등)gpt-4
, gpt-3.5-turbo
)text-embedding-ada-002
)Step
및 AgentRun
)가있는 물체에만 사용됩니다.npm install js-agent
에이전트를 만드는 방법을 배우려면 예제와 문서를 참조하십시오.
import * as $ from "js-agent" ;
const openai = $ . provider . openai ;
export async function runWikipediaAgent ( {
wikipediaSearchKey ,
wikipediaSearchCx ,
openAiApiKey ,
task ,
} : {
openAiApiKey : string ;
wikipediaSearchKey : string ;
wikipediaSearchCx : string ;
task : string ;
} ) {
const searchWikipediaAction = $ . tool . programmableGoogleSearchEngineAction ( {
id : "search-wikipedia" ,
description :
"Search wikipedia using a search term. Returns a list of pages." ,
execute : $ . tool . executeProgrammableGoogleSearchEngineAction ( {
key : wikipediaSearchKey ,
cx : wikipediaSearchCx ,
} ) ,
} ) ;
const readWikipediaArticleAction = $ . tool . extractInformationFromWebpage ( {
id : "read-wikipedia-article" ,
description :
"Read a wikipedia article and summarize it considering the query." ,
inputExample : {
url : "https://en.wikipedia.org/wiki/Artificial_intelligence" ,
topic : "{query that you are answering}" ,
} ,
execute : $ . tool . executeExtractInformationFromWebpage ( {
extract : $ . text . extractRecursively . asExtractFunction ( {
split : $ . text . splitRecursivelyAtToken . asSplitFunction ( {
tokenizer : openai . tokenizer . forModel ( {
model : "gpt-3.5-turbo" ,
} ) ,
maxChunkSize : 2048 , // needs to fit into a gpt-3.5-turbo prompt and leave room for the answer
} ) ,
extract : $ . text . generateText . asFunction ( {
prompt : $ . prompt . extractChatPrompt ( ) ,
model : openai . chatModel ( {
apiKey : openAiApiKey ,
model : "gpt-3.5-turbo" ,
} ) ,
} ) ,
} ) ,
} ) ,
} ) ;
return $ . runAgent < { task : string } > ( {
properties : { task } ,
agent : $ . step . generateNextStepLoop ( {
actions : [ searchWikipediaAction , readWikipediaArticleAction ] ,
actionFormat : $ . action . format . flexibleJson ( ) ,
prompt : $ . prompt . concatChatPrompts (
async ( { runState : { task } } ) => [
{
role : "system" ,
content : `## ROLE
You are an knowledge worker that answers questions using Wikipedia content. You speak perfect JSON.
## CONSTRAINTS
All facts for your answer must be from Wikipedia articles that you have read.
## TASK
${ task } ` ,
} ,
] ,
$ . prompt . availableActionsChatPrompt ( ) ,
$ . prompt . recentStepsChatPrompt ( { maxSteps : 6 } )
) ,
model : openai . chatModel ( {
apiKey : openAiApiKey ,
model : "gpt-3.5-turbo" ,
} ) ,
} ) ,
controller : $ . agent . controller . maxSteps ( 20 ) ,
observer : $ . agent . observer . showRunInConsole ( { name : "Wikipedia Agent" } ) ,
} ) ;
}