luo 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Dockerfile +34 -0
 - data/Gemfile.lock +1 -1
 - data/README.zh.md +5 -0
 - data/lib/luo/cli.rb +10 -0
 - data/lib/luo/version.rb +1 -1
 - metadata +2 -2
 - data/sample_/marqo.rb +0 -98
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 528a0e01226989292c4f0a2e3fba8d19ac4e2cbade3343c17edc08a313fd9705
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f6adb4ae59e2eeaa25ef4eb7813f387c3dda59fe91649f8dcca7d00f3fbabd42
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c4f92af574fae3ac6fef612dc6707bfb6bb1f95aeb62599071da2cd3064b65c2084162a2223bf0347d9e5500951c63ed7237dcd34f207f9c1a25357bc9a2b713
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 383f9c1769b14016f3ed696d5074524ff13bcb8ed4db223929323e4fa1a0e6a2befabb8ae3f5796ae147092bb8441fd3d42d4f605c9915e58338870be3ff5b63
         
     | 
    
        data/Dockerfile
    ADDED
    
    | 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            FROM ruby:3.2.2-alpine
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Install  docker/buildx-bin
         
     | 
| 
      
 4 
     | 
    
         
            +
            COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Set the working directory to /luo
         
     | 
| 
      
 7 
     | 
    
         
            +
            WORKDIR /luo
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # Copy the Gemfile, Gemfile.lock into the container
         
     | 
| 
      
 10 
     | 
    
         
            +
            COPY Gemfile Gemfile.lock luo.gemspec ./
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            # Required in luo.gemspec
         
     | 
| 
      
 13 
     | 
    
         
            +
            COPY lib/luo/version.rb /luo/lib/luo/version.rb
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            # Install system dependencies
         
     | 
| 
      
 16 
     | 
    
         
            +
            RUN apk add --no-cache --update build-base git docker openrc openssh-client-default \
         
     | 
| 
      
 17 
     | 
    
         
            +
                && rc-update add docker boot \
         
     | 
| 
      
 18 
     | 
    
         
            +
                && gem install bundler --version=2.4.3 \
         
     | 
| 
      
 19 
     | 
    
         
            +
                && bundle install
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            # Copy the rest of our application code into the container.
         
     | 
| 
      
 22 
     | 
    
         
            +
            # We do this after bundle install, to avoid having to run bundle
         
     | 
| 
      
 23 
     | 
    
         
            +
            # everytime we do small fixes in the source code.
         
     | 
| 
      
 24 
     | 
    
         
            +
            COPY . .
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            # Install the gem locally from the project folder
         
     | 
| 
      
 27 
     | 
    
         
            +
            RUN gem build luo.gemspec && \
         
     | 
| 
      
 28 
     | 
    
         
            +
                gem install ./luo-*.gem --no-document
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            RUN git config --global --add safe.directory /workdir
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            WORKDIR /workdir
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            ENTRYPOINT ["luo"]
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.zh.md
    CHANGED
    
    | 
         @@ -2,10 +2,15 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            是一款基于大模型的开发框架(面向产品经理),当前支持大模型提供商有: OpenAI、星火大模型。通过DSL能够快速创作并且测试大模型的效果。
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            ## 安装
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            ### 
         
     | 
| 
       5 
7 
     | 
    
         
             
            ```
         
     | 
| 
       6 
8 
     | 
    
         
             
            gem install luo
         
     | 
| 
       7 
9 
     | 
    
         
             
            ```
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            ###
         
     | 
| 
      
 12 
     | 
    
         
            +
            docker run --rm -it -v "$PWD:/workdir" luo_cli_cli -v
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       9 
14 
     | 
    
         
             
            ## 环境变量说明
         
     | 
| 
       10 
15 
     | 
    
         
             
            ```Bash
         
     | 
| 
       11 
16 
     | 
    
         
             
            OPENAI_ACCESS_TOKEN= # OpenAI的访问令牌
         
     | 
    
        data/lib/luo/cli.rb
    CHANGED
    
    | 
         @@ -33,9 +33,19 @@ module Luo 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    end
         
     | 
| 
       34 
34 
     | 
    
         
             
                  end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
      
 36 
     | 
    
         
            +
                  class Run < Dry::CLI::Command
         
     | 
| 
      
 37 
     | 
    
         
            +
                    desc "Run Luo"
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    def call(*)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      exec "ruby application.rb"
         
     | 
| 
      
 41 
     | 
    
         
            +
                    end
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       36 
44 
     | 
    
         
             
                  register "version", Version, aliases: %w[v -v --version]
         
     | 
| 
       37 
45 
     | 
    
         
             
                  register "commit", Commit, aliases: ["c"]
         
     | 
| 
       38 
46 
     | 
    
         
             
                  register "init", Init, aliases: ["i"]
         
     | 
| 
      
 47 
     | 
    
         
            +
                  register "run", Run, aliases: ["r"]
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
       39 
49 
     | 
    
         
             
                end
         
     | 
| 
       40 
50 
     | 
    
         | 
| 
       41 
51 
     | 
    
         
             
              end
         
     | 
    
        data/lib/luo/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: luo
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.11
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - MJ
         
     | 
| 
         @@ -181,6 +181,7 @@ files: 
     | 
|
| 
       181 
181 
     | 
    
         
             
            - ".idea/modules.xml"
         
     | 
| 
       182 
182 
     | 
    
         
             
            - ".idea/vcs.xml"
         
     | 
| 
       183 
183 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
      
 184 
     | 
    
         
            +
            - Dockerfile
         
     | 
| 
       184 
185 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       185 
186 
     | 
    
         
             
            - Gemfile.lock
         
     | 
| 
       186 
187 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -222,7 +223,6 @@ files: 
     | 
|
| 
       222 
223 
     | 
    
         
             
            - lib/luo/xinghuo.rb
         
     | 
| 
       223 
224 
     | 
    
         
             
            - lib/luo/xinghuo_agent_runner.rb
         
     | 
| 
       224 
225 
     | 
    
         
             
            - luo.gemspec
         
     | 
| 
       225 
     | 
    
         
            -
            - sample_/marqo.rb
         
     | 
| 
       226 
226 
     | 
    
         
             
            - sig/luo.rbs
         
     | 
| 
       227 
227 
     | 
    
         
             
            - sig/luo/agent.rbs
         
     | 
| 
       228 
228 
     | 
    
         
             
            - sig/luo/agent_runner_base.rbs
         
     | 
    
        data/sample_/marqo.rb
    DELETED
    
    | 
         @@ -1,98 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'httparty'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class Marqo
         
     | 
| 
       4 
     | 
    
         
            -
              include HTTParty
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              base_uri ENV.fetch('MARQO_URL')
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              class SearchResult < RecursiveOpenStruct
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              # TODO: Add a way to pass in auth
         
     | 
| 
       12 
     | 
    
         
            -
              def initialize(auth = { username: 'admin', password: 'admin' })
         
     | 
| 
       13 
     | 
    
         
            -
                @auth = auth
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              def store(index:, doc:, id:, non_tensor_fields: [])
         
     | 
| 
       17 
     | 
    
         
            -
                return if ENV['MARQO_URL'].blank?
         
     | 
| 
       18 
     | 
    
         
            -
                puts
         
     | 
| 
       19 
     | 
    
         
            -
                puts "🧠🧠🧠 INDEX: #{index} 🧠🧠🧠"
         
     | 
| 
       20 
     | 
    
         
            -
                puts "🧠🧠🧠 DOC: #{doc} 🧠🧠🧠"
         
     | 
| 
       21 
     | 
    
         
            -
                puts "🧠🧠🧠 ID: #{id} 🧠🧠🧠"
         
     | 
| 
       22 
     | 
    
         
            -
                puts "🧠🧠🧠 NON TENSOR FIELDS: #{non_tensor_fields} 🧠🧠🧠"
         
     | 
| 
       23 
     | 
    
         
            -
                puts
         
     | 
| 
       24 
     | 
    
         
            -
                options = {
         
     | 
| 
       25 
     | 
    
         
            -
                  headers: { 'Content-Type' => 'application/json' },
         
     | 
| 
       26 
     | 
    
         
            -
                  body: [doc.merge({_id: id})].to_json
         
     | 
| 
       27 
     | 
    
         
            -
                }
         
     | 
| 
       28 
     | 
    
         
            -
                url = "/indexes/#{index.to_s.parameterize}/documents"
         
     | 
| 
       29 
     | 
    
         
            -
                if non_tensor_fields.any?
         
     | 
| 
       30 
     | 
    
         
            -
                  field_array = non_tensor_fields.map { |f| "non_tensor_fields=#{f}" }
         
     | 
| 
       31 
     | 
    
         
            -
                  url += "?#{field_array.join("&")}"
         
     | 
| 
       32 
     | 
    
         
            -
                end
         
     | 
| 
       33 
     | 
    
         
            -
                self.class.post(url, options).then do |response|
         
     | 
| 
       34 
     | 
    
         
            -
                  puts response
         
     | 
| 
       35 
     | 
    
         
            -
                  response.dig("items",0,"_id")
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
              def search(index_name, query, filter: nil, limit: 5)
         
     | 
| 
       40 
     | 
    
         
            -
                puts
         
     | 
| 
       41 
     | 
    
         
            -
                puts "🔍🔍🔍 #{index_name} 🔍🔍🔍"
         
     | 
| 
       42 
     | 
    
         
            -
                puts "🔍🔍🔍 #{query} 🔍🔍🔍"
         
     | 
| 
       43 
     | 
    
         
            -
                puts "🔍🔍🔍 #{filter} 🔍🔍🔍"
         
     | 
| 
       44 
     | 
    
         
            -
                puts
         
     | 
| 
       45 
     | 
    
         
            -
                options = {
         
     | 
| 
       46 
     | 
    
         
            -
                  basic_auth: @auth,
         
     | 
| 
       47 
     | 
    
         
            -
                  headers: { 'Content-Type' => 'application/json' },
         
     | 
| 
       48 
     | 
    
         
            -
                  body: {
         
     | 
| 
       49 
     | 
    
         
            -
                    q: query,
         
     | 
| 
       50 
     | 
    
         
            -
                    filter: filter,
         
     | 
| 
       51 
     | 
    
         
            -
                    searchMethod: "TENSOR",
         
     | 
| 
       52 
     | 
    
         
            -
                    limit: limit
         
     | 
| 
       53 
     | 
    
         
            -
                  }.to_json
         
     | 
| 
       54 
     | 
    
         
            -
                }
         
     | 
| 
       55 
     | 
    
         
            -
                response = self.class.post("/indexes/#{index_name.to_s.parameterize}/search", options)
         
     | 
| 
       56 
     | 
    
         
            -
                SearchResult.new(response, recurse_over_arrays: true)
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def lexsearch(index_name, attributes, query)
         
     | 
| 
       60 
     | 
    
         
            -
                options = {
         
     | 
| 
       61 
     | 
    
         
            -
                  basic_auth: @auth,
         
     | 
| 
       62 
     | 
    
         
            -
                  headers: { 'Content-Type' => 'application/json' },
         
     | 
| 
       63 
     | 
    
         
            -
                  body: {
         
     | 
| 
       64 
     | 
    
         
            -
                    q: query,
         
     | 
| 
       65 
     | 
    
         
            -
                    searchableAttributes: attributes,
         
     | 
| 
       66 
     | 
    
         
            -
                    searchMethod: "LEXICAL"
         
     | 
| 
       67 
     | 
    
         
            -
                  }.to_json
         
     | 
| 
       68 
     | 
    
         
            -
                }
         
     | 
| 
       69 
     | 
    
         
            -
                SearchResult.new(self.class.post("/indexes/#{index_name.to_s.parameterize}/search", options))
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
              def delete(index_name, id_or_ids)
         
     | 
| 
       73 
     | 
    
         
            -
                options = {
         
     | 
| 
       74 
     | 
    
         
            -
                  basic_auth: @auth,
         
     | 
| 
       75 
     | 
    
         
            -
                  headers: { 'Content-Type' => 'application/json' },
         
     | 
| 
       76 
     | 
    
         
            -
                  body: [id].flatten.to_json
         
     | 
| 
       77 
     | 
    
         
            -
                }
         
     | 
| 
       78 
     | 
    
         
            -
                self.class.post("/indexes/#{index_name.to_s.parameterize}/documents/delete-batch", options)
         
     | 
| 
       79 
     | 
    
         
            -
              end
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
              def remove(index_name)
         
     | 
| 
       82 
     | 
    
         
            -
                options = {
         
     | 
| 
       83 
     | 
    
         
            -
                  basic_auth: @auth,
         
     | 
| 
       84 
     | 
    
         
            -
                  headers: { 'Content-Type' => 'application/json' }
         
     | 
| 
       85 
     | 
    
         
            -
                }
         
     | 
| 
       86 
     | 
    
         
            -
                self.class.delete("/indexes/#{index_name.to_s.parameterize}", options)
         
     | 
| 
       87 
     | 
    
         
            -
              end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
              def self.client
         
     | 
| 
       90 
     | 
    
         
            -
                @client ||= new
         
     | 
| 
       91 
     | 
    
         
            -
              end
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
              private
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
              def wrap(result)
         
     | 
| 
       96 
     | 
    
         
            -
                RecursiveOpenStruct.new(hash, recurse_over_arrays: true)
         
     | 
| 
       97 
     | 
    
         
            -
              end
         
     | 
| 
       98 
     | 
    
         
            -
            end
         
     |