يقوم Bosquet بمهمة جعل بناء تطبيقات الذكاء الاصطناعي أمرًا بسيطًا. تحتاج جميع تطبيقات الذكاء الاصطناعي غير التافهة إلى العمل مع قوالب سريعة تنمو بسرعة في التعقيد، وتتطلب نوافذ سياق LLM المحدودة إدارة الذاكرة، وهناك حاجة إلى وكلاء لتطبيقات الذكاء الاصطناعي للتفاعل مع العالم الخارجي.
يوفر Bosquet أدوات للعمل مع مفاهيم تطبيقات الذكاء الاصطناعي:
وثائق المشروع الكاملة (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
التي تحتوي على البيانات التي تم إنشاؤها فقط