BoxCars는 LLM (OpenAi, Anthropic, GPT4ALL), 검색, SQL (속편 및 활성 레코드 지원), Rails Active Record, Vector Search 등과 같은 다양한 개념을 사용하여 AI Composability를 갖춘 새로운 시스템을 만들 수있는 보석입니다. 이것은 개념 (개념 포함)과 함께 확장 될 수도 있습니다.
이 보석은 인기있는 Python Library Langchain에서 영감을 받았습니다. 그러나 우리는 루비 스핀을주고 초보자가 시작할 수 있도록보다 사용자 친화적으로 만들고 싶었습니다.
이 모든 개념은 BoxCars라는 모듈에 있습니다.
Boxcars.engine 사용됩니다.Boxcars::train 사용할 수 있습니다.Boxcar.configuration.default_engine ). 우리는 Boxcars::Anthropic 이라는 Anthropic의 Claude API를위한 엔진과 Boxcars::Gpt4allEng 이라는 GPT의 다른 엔진을 보유하고 있습니다.현재 우리의 시스템은 이미 프로젝트에 대한 행정 특권을 보유한 개인을 위해 설계되었습니다. 악의적 인 행동을 수행하기 위해 시스템의 프롬프트를 조작 할 수 있지만, 이미 관리에 액세스 할 수있는 경우 처음에 박스 카를 필요로하지 않고도 그러한 작업을 수행 할 수 있습니다.
참고 : 우리는 사악한 시도가 발생하는 것을 식별하고 방지하는 시스템의 능력을 향상시키는 방법을 적극적으로 찾고 있습니다. 제안이나 권장 사항이 있으시면 기존 문제를 찾거나 새 문제를 만들고 귀하의 의견을 제공하여 공유하십시오.
이 라인을 응용 프로그램의 보석에 추가하십시오.
gem 'boxcars'그런 다음 실행 :
$ bundle install
또는 직접 설치하십시오.
$ gem install boxcars
우리는 곧 더 많은 예를 추가 할 것입니다. 그러나 여기에 당신을 시작할 수있는 부부가 있습니다. 먼저 OpenAI, Anthropic 및 Google SERP (OpenAi_Access_token, Anthropic_api_key, serpapi_api_key) 등과 같은 서비스에 대한 환경 변수를 설정해야합니다. 환경에서 이러한 변수를 설정하지 않으려면 API로 직접 전달할 수 있습니다.
아래의 예에서, 우리는 첫 번째 줄에 환경을로드하기 위해 하나의 루비 보석을 추가했지만 원하는 것에 따라 필요하지 않을 수도 있습니다.
require "dotenv/load"
require "boxcars"참고 : 아래 예제를 시도하려면이 명령을 실행 한 다음 관심있는 코드 세그먼트에 붙여 넣습니다.
irb -r dotenv/load -r boxcars
# or if you prefer local repository
irb -r dotenv/load -r ./lib/boxcars # run the calculator
engine = Boxcars :: Openai . new ( max_tokens : 256 )
calc = Boxcars :: Calculator . new ( engine : engine )
puts calc . run "what is pi to the fourth power divided by 22.1?"생산 :
> Entering Calculator#run
what is pi to the fourth power divided by 22.1?
RubyREPL: puts (Math::PI**4)/22.1
Answer: 4.407651178009159
{"status":"ok","answer":"4.407651178009159","explanation":"Answer: 4.407651178009159","code":"puts (Math::PI**4)/22.1"}
< Exiting Calculator#run
4.407651178009159
OpenAI는 현재 가장 많이 사용되는 엔진이므로 엔진을 통과하지 않으면 예상대로 기본값이됩니다. 따라서 이것은 위의 스크립트와 동등한 짧은 버전입니다.
# run the calculator
calc = Boxcars :: Calculator . new # just use the default Engine
puts calc . run "what is pi to the fourth power divided by 22.1?" Boxcars::configuration.default_engine = NewDefaultEngine 으로 default_engine을 변경할 수 있습니다
우리가 지금까지 가지고있는 것이 있지만 새로운 아이디어와 함께 PR을 올리십시오.
# run a Train for a calculator, and search using default Engine
boxcars = [ Boxcars :: Calculator . new , Boxcars :: GoogleSearch . new ]
train = Boxcars . train . new ( boxcars : boxcars )
train . run "What is pi times the square root of the average temperature in Austin TX in January?"생산 :
> Entering Zero Shot#run
What is pi times the square root of the average temperature in Austin TX in January?
Thought: We need to find the average temperature in Austin TX in January and then multiply it by pi and the square root of the average temperature. We can use a search engine to find the average temperature in Austin TX in January and a calculator to perform the multiplication.
Question: Average temperature in Austin TX in January
Answer: January Weather in Austin Texas, United States. Daily high temperatures increase by 2°F, from 62°F to 64°F, rarely falling below 45°F or exceeding 76° ...
Observation: January Weather in Austin Texas, United States. Daily high temperatures increase by 2°F, from 62°F to 64°F, rarely falling below 45°F or exceeding 76° ...
Thought: We have found the average temperature in Austin TX in January, which is 64°F. Now we can use a calculator to perform the multiplication.
> Entering Calculator#run
pi * sqrt(64)
RubyREPL: puts(Math::PI * Math.sqrt(64))
Answer: 25.132741228718345
{"status":"ok","answer":"25.132741228718345","explanation":"Answer: 25.132741228718345","code":"puts(Math::PI * Math.sqrt(64))"}
< Exiting Calculator#run
Observation: 25.132741228718345
We have the final answer.
Final Answer: 25.132741228718345
Next Actions:
1. What is the average temperature in Austin TX in July?
2. What is the value of pi to 10 decimal places?
3. What is the square root of the average temperature in Miami FL in January?
< Exiting Zero Shot#run
더 많은 예는이 Jupyter 노트북을 참조하십시오.
Swagger Boxcar의 경우이 Jupyter 노트북을 참조하십시오.
간단한 벡터 저장 및 검색은이 Jupyter 노트북을 참조하십시오.
우리가 말한 일부 사람들은 당신이 루비 주피터 노트북을 운영 할 수 있다는 것을 몰랐습니다. 당신은 할 수 있습니다.
Rails 응용 프로그램에서 사용하거나 Boxcars.configuration.logger = your_logger 구성하면 로깅이 로그 파일로 이동합니다.
또한이 플래그를 설정하면 Boxcars.configuration.log_prompts = true 연결된 엔진에 건네주는 실제 프롬프트가 기록됩니다. 이것은 매우 말이 많지 않기 때문에 기본적으로 꺼지지 만 프롬프트를 디버깅하는 경우 편리합니다.
그렇지 않으면 표준으로 인쇄합니다.
레포를 확인한 후 bin/setup 실행하여 종속성을 설치하십시오. 그런 다음 rake spec 실행하여 테스트를 실행하십시오. 실험 할 수있는 대화식 프롬프트를 위해 bin/console 실행할 수도 있습니다.
이 보석을 로컬 컴퓨터에 설치하려면 bundle exec rake install 실행하십시오. 새 버전을 해제하려면 version.rb 에서 버전 번호를 업데이트 한 다음 bundle exec rake release 에 대한 GIT 태그를 생성하고 Git Commits 및 생성 된 태그를 푸시하고 .gem 파일을 rubygems.org로 누릅니다.
https://github.com/boxcarsai/boxcars에서 버그 보고서 및 풀 요청은 환영합니다. 이 프로젝트는 협업을위한 안전하고 환영하는 공간이되기위한 것이며, 기고자들은 행동 강령을 준수 할 것으로 예상됩니다.
보석은 MIT 라이센스의 조건에 따라 오픈 소스로 제공됩니다.
BoxCars Project의 코드베이스, 문제 추적기, 대화방 및 메일 링리스트에서 상호 작용하는 모든 사람은 행동 강령을 따라야합니다.