Coder Social home page Coder Social logo

bot_team's Introduction

Bot Team

A simple way to set up special purpose agents for use in ruby code

Talk to OpenAI

With 'OPENAI_API_KEY' set in your environment, you are ready to go.

ChatGptAgent.new.run("Make me a sandwich")
#=> "I'm happy to help with that! What kind of sandwich would you like?"

These, and other settings, can be set independantly by agent:

agent =
  ChatGptAgent.new(
    model: 'gpt-3.5-turbo',
    max_tokens: 200,
    system_directives: <<~PROMPT
      You are a friendly, helpful assistant, ready to answer questions,
      but every answer you give is in pig latin.
    PROMPT
  )
agent.run("What's the easiest way to clean your toenails?")
#=> "eThay easiestway ayway otay eanclay ouryay oenailstay isway otay useway a oodgay ailbruhbray ithway omesay aterway andway oapsay."

You can configure defaults for your project thusly:

BotTeam.configure do |config|
  config.model = 'gpt-4-turbo-preview'
  config.max_tokens = 4096
  config.tempurature = 1.7
  config.num_choices = 3
  config.api_key = `cat tmp/api_key.txt`.strip # but it's better to use ENV
end

Using tools is as simple as a ruby method (but be warned, all the arguments must be keyword arguments):

def alert(message:)
  puts "!!!!!!!! #{message} !!!!!!!!"
end

agent = ChatGptAgent.new
agent.add_function(method: method(:alert))
agent.run("Say something alarming")
# !!!!!!!! Warning: This is a test of the emergency alert system. This is only a test. !!!!!!!!
#=> [nil]

bot_team's People

Contributors

loneconspirator avatar majikthys avatar

Stargazers

Dwight van Tuyl avatar

Watchers

Dwight van Tuyl avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.