Jhonnyr97 / cheshire_cat_api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CheshireCatApi

Welcome to CheshireCatApi

The Cheshire Cat AI Framework Client gem is a fundamental innovation for developers interested in exploring and leveraging the capabilities of Large Language Models (LLM) through the Cheshire Cat AI framework. This tool provides simplified access to a wide range of advanced functions, including plugin installation, customization of Large Language Models, the use of Embeddings, and effective management of chat history. With the ability to connect via WebSocket, it facilitates the development of dynamic and interactive dialogues with LLMs, expanding the creative and technical possibilities for developers.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add cheshire_cat_api

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install cheshire_cat_api

Usage

WebSocket

ws = ClientWs.new(url: "localhost:1865", user: nil)
ws.callback = lambda do |m|
  puts m.data
end
ws.connect 
ws.send_message("hello")
# => {"type":"chat_token","content":"Hello"}
# ...
# => {"type":"chat" ... }
ws = CheshireCatApi::ClientWs.new(url: "localhost:1865", user: nil, callback: Proc.new { |m| puts m.data } )
ws.connect(message: "hello")
# => {"type":"chat_token","content":"Hello"}
# ...
# => {"type":"chat" ... }

Settings, LLM, Plugin, Embedding, Rabbit Hole

cat = CheshireCatApi::Client.new("localhost:1865", "")

All Cheshire Cat AI settings

cat.settings.index

Set Cheshire Cat AI settings

cat.settings.create({
      name: "string",
      value: {},
      category: "string",
      setting_id: "483323c4-6bc1-4a53-81a9-b164dcd7da28",
      updated_at: 1_703_001_577
    })

Update Cheshire Cat AI settings

cat.settings.update({
      name: "string",
      value: {},
      category: "string",
      setting_id: "483323c4-6bc1-4a53-81a9-b164dcd7da28",
      updated_at: 1_703_001_577
    })

Plugin

All Cheshire Cat AI plugins

cat.plugins.index

Upload Cheshire Cat AI plugin

cat.plugins.upload(File.open("path/to/plugin"))

Update from url Cheshire Cat AI plugin

cat.plugins.update_from_url("https://github.com/example/example")

Delete Cheshire Cat AI plugin

cat.plugins.delete("example")

Toggle Cheshire Cat AI plugin

cat.plugins.toggle("example")

Show Cheshire Cat AI plugin

cat.plugins.show("example")

Settings Cheshire Cat AI plugin

cat.plugins.settings

Update settings Cheshire Cat AI plugin

cat.plugins.update_settings("example", { DataSource: "sqlite" })

Index llm settings

cat.llm.settings

Get llm setting

cat.llm.setting("example")

Update llm setting

cat.llm.update_setting("example", { url: "https://www.example.com" })

Embedding

Recall memory

cat.memory.recall("example", k: 100)

All collections

cat.memory.collections

Delete all collections

cat.memory.delete_collections

Delete collection

cat.memory.delete_collection("example")

Delete point

cat.memory.delete_point("collection", "example")

Delete all points

cat.memory.delete_points("collection")

All conversations

cat.memory.conversations

Delete all conversations

cat.memory.delete_conversations

Settings embedding

cat.embedder.settings

Setting embedding

cat.embedder.setting("example")

Update setting embedding

cat.embedder.update_setting("example", { size: 156 })

RABBIT HOLE

Update file for embedding

cat.rabbit_hole.update(File.open("path/to/file"))

Update url for embedding

cat.rabbit_hole.url("https://www.example.com")

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test-unit to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Jhonnyr97/cheshire_cat_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the CheshireCatApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

License:MIT License


Languages

Language:Ruby 99.6%Language:Shell 0.4%