Git Product home page Git Product logo

icebaker / ruby-nano-bots Goto Github PK

View Code? Open in Web Editor NEW
89.0 6.0 11.0 429 KB

Ruby Implementation of Nano Bots: small, AI-powered bots that can be easily shared as a single file, designed to support multiple providers such as Anthropic Claude, Cohere Command, Google Gemini, Maritaca AI, Mistral AI, Ollama, OpenAI ChatGPT, and others, with support for calling tools (functions).

Home Page: https://rubygems.org/gems/nano-bots

License: MIT License

Ruby 33.86% Lua 66.14%
chatgpt gpt gpt-4 llama openai openai-api nano-bots llm gemini gemini-pro

ruby-nano-bots's People

Contributors

icebaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ruby-nano-bots's Issues

Feature request - option to have different input and output contexts

It would be useful to have the option to branch to a new context e.g.
nb model inputcontext -o newcontext eval do the thing

Along the same lines, being able to read multiple inputcontexts and write to a new one would be useful.

Agents could then summarise existing conversations, or draw related ones together.

LMQL support

Hi,

Have you considered LMQL (https://lmql.ai) as a provider? It allows for a more structured outputs, as well as tool use, and it supports both remote providers as well as local models via llama.cpp.

I currently interact with it from Ruby with a slightly modified version of their websocket streaming example, which I can supply if it's useful to you.

PS. Love to see more LLM projects in Ruby, and this is an interesting project

the server responded with status 400 (Faraday::BadRequestError) with Gemini API key

Hi, I'm trying to use nanobots with Gemini API key and keep failing repeatedly. after some debugging, I can see that gemini-ai and curl work great with my API key, while nb fails to work.

For convenience the code is all here: https://github.com/palladius/ragazzi

# .env file has this 
export GOOGLE_API_KEY='blah blah blah'
# gemini-api-cartridge.yaml
---
meta:
  symbol: ๐Ÿค–
  name: Nano Bot Name
  author: Your Name
  version: 1.0.0
  license: CC0-1.0
  description: A helpful assistant.

behaviors:
  interaction:
    directive: You are a helpful assistant.

provider:
  id: google
  credentials:
    service: generative-language-api
    api-key: ENV/GOOGLE_API_KEY
  options:
    model: gemini-pro
$ nb gemini-api-cartridge.yaml - eval "Hello" 
/usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/response/raise_error.rb:16:in `on_complete': the server responded with status 400 (Faraday::BadRequestError)
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/middleware.rb:18:in `block in call'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/response.rb:42:in `on_complete'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/middleware.rb:17:in `call'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/rack_builder.rb:152:in `build_response'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/connection.rb:444:in `run_request'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/faraday-2.9.1/lib/faraday/connection.rb:280:in `post'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/gemini-ai-4.0.0/controllers/client.rb:150:in `request'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/gemini-ai-4.0.0/controllers/client.rb:101:in `stream_generate_content'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/components/providers/google.rb:152:in `evaluate'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/controllers/session.rb:131:in `process_interaction'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/controllers/session.rb:107:in `process'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/controllers/session.rb:93:in `evaluate_and_print'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/controllers/interfaces/eval.rb:15:in `evaluate'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/controllers/instance.rb:52:in `eval'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/controllers/interfaces/cli.rb:80:in `handle!'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/ports/dsl/nano-bots.rb:32:in `cli'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/ports/dsl/nano-bots/cli.rb:5:in `<top (required)>'
        from <internal:/usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from <internal:/usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/nano-bots-3.1.0/bin/nb:4:in `<top (required)>'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/bin/nb:25:in `load'
        from /usr/local/google/home/ricc/.rbenv/versions/3.2.1/bin/nb:25:in `<main>'

I thought I might have a bad key, but then I tried this with same key and that worked:

require 'gemini-ai'

client = Gemini.new(
  credentials: {
    service: 'generative-language-api',
    api_key: ENV['GOOGLE_API_KEY'],
    version: 'v1beta'
  },
  options: {
    model: 'gemini-pro',
    server_sent_events: true }
)

client.stream_generate_content(
  { contents: {
    role: 'user',
    parts: { text: 'hi!' } } }
) do |event, parsed, raw|
  puts event
end

==>

{"candidates"=>[{"content"=>{"parts"=>[{"text"=>"Hello! How can I assist you today?"}], "role"=>"model"}, "finishReason"=>"STOP", "index"=>0, "safetyRatings"=>[{"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT", "probability"=>"NEGLIGIBLE"}, {"category"=>"HARM_CATEGORY_HATE_SPEECH", "probability"=>"NEGLIGIBLE"}, {"category"=>"HARM_CATEGORY_HARASSMENT", "probability"=>"NEGLIGIBLE"}, {"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT", "probability"=>"NEGLIGIBLE"}]}], "usageMetadata"=>{"promptTokenCount"=>3, "candidatesTokenCount"=>9, "totalTokenCount"=>12}}

Please help

$ ruby -v
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]

$ cat Gemfile
source "https://rubygems.org"

gem 'nano-bots', '~> 3.1.0'
gem 'gemini-ai', '~> 4.0.0'

Is there a way to delete states by identifier?

The state names in the storage folder are encrypted, as well as the contents. I wonder if it is possible to delete a given state by providing the state string? Something like nb delete state123

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.