bosquet
2024.02.22
Bosquet은 AI 애플리케이션 구축을 단순화하는 임무를 수행하고 있습니다. 모든 중요한 AI 애플리케이션은 복잡성이 빠르게 증가하는 프롬프트 템플릿으로 작업해야 하며 제한된 LLM 컨텍스트 창에는 메모리 관리가 필요하며 AI 애플리케이션이 외부 세계와 상호 작용하려면 에이전트가 필요합니다.
Bosquet은 다음과 같은 AI 애플리케이션 개념을 사용할 수 있는 도구를 제공합니다.
전체 프로젝트 문서(WIP)
키와 같은 비밀은 secrets.edn
파일에 저장되고 로컬 매개변수는 config.edn
에 보관됩니다. config.edn.sample
및 config.edn.sample
파일의 복사본을 만듭니다. 필요에 따라 변경하세요.
명령줄 인터페이스 데모
CLI 옵션을 얻으려면 다음 명령을 실행하십시오.
clojure -M -m bosquet.cli
다음을 사용하여 기본 모델을 설정합니다.
clojure -M -m bosquet.cli llms set --service openai --temperature 0 --model gpt-4
서비스에 대한 API KEY를 설정하는 것을 잊지 마세요(필요한 경우 'openai'를 다른 이름으로 변경)
clojure -M -m bosquet.cli keys set openai
해당 세트를 사용하면 세대를 실행할 수 있습니다.
clojure -M -m bosquet.cli "2+{{x}}="
아니면 파일을 이용해서
clojure -M -m bosquet.cli -p demo/play-writer-prompt.edn -d demo/play-writer-data.edn
간단한 프롬프트 완료는 다음과 같이 수행할 수 있습니다.
(require '[bosquet.llm.generator :refer [generate llm]])
(generate "When I was 6 my sister was half my age. Now I’m 70 how old is my sister?")
=>
"When you were 6, your sister was half your age, which means she was 6 / 2 = 3 years old.nSince then, there is a constant age difference of 3 years between you and your sister.nNow that you are 70, your sister would be 70 - 6 = 64 years old."}
( require '[bosquet.llm :as llm])
( require '[bosquet.llm.generator :refer [generate llm]])
( generate
llm/default-services
{ :question-answer " Question: {{question}} Answer: {{answer}} "
:answer ( llm :openai )
:self-eval [ " Question: {{question}} "
" Answer: {{answer}} "
" "
" Is this a correct answer? "
" {{test}} " ]
:test ( llm :openai )}
{ :question " What is the distance from Moon to Io? " })
=>
{ :question-answer
" Question: What is the distance from Moon to Io? Answer: " ,
:answer
" The distance from the Moon to Io varies, as both are orbiting different bodies. On average, the distance between the Moon and Io is approximately 760,000 kilometers (470,000 miles). However, this distance can change due to the elliptical nature of their orbits. " ,
:self-eval
" Question: What is the distance from Moon to Io? n Answer: The distance from the Moon to Io varies, as both are orbiting different bodies. On average, the distance between the Moon and Io is approximately 760,000 kilometers (470,000 miles). However, this distance can change due to the elliptical nature of their orbits. nn Is this a correct answer? " ,
:test
" No, the answer provided is incorrect. The Moon is Earth's natural satellite, while Io is one of Jupiter's moons. Therefore, the distance between the Moon and Io can vary significantly depending on their relative positions in their respective orbits around Earth and Jupiter. " }
( require '[bosquet.llm.wkk :as wkk])
( generate
[[ :system " You are an amazing writer. " ]
[ :user [ " Write a synopsis for the play: "
" Title: {{title}} "
" Genre: {{genre}} "
" Synopsis: " ]]
[ :assistant ( llm wkk/openai
wkk/model-params { :temperature 0.8 :max-tokens 120 }
wkk/var-name :synopsis )]
[ :user " Now write a critique of the above synopsis: " ]
[ :assistant ( llm wkk/openai
wkk/model-params { :temperature 0.2 :max-tokens 120 }
wkk/var-name :critique )]]
{ :title " Mr. X "
:genre " Sci-Fi " })
=>
#:bosquet{ :conversation
[[ :system " You are an amazing writer. " ]
[ :user
" Write a synopsis for the play: n Title: Mr. X n Genre: Sci-Fi n Synopsis: " ]
[ :assistant " In a futuristic world where technology ... " ]
[ :user " Now write a critique of the above synopsis: " ]
[ :assistant
" The synopsis for the play " Mr. X " presents an intriguing premise ... " ]],
:completions
{ :synopsis
" In a futuristic world where technology has ... " ,
:critique
" The synopsis for the play " Mr. X " presents an intriguing premise set ... " }}
생성 반환 :bosquet/conversation
목록 생성된 부분이 채워진 전체 채팅 및 생성된 데이터만 포함하는 :bosquet/completions