Skip to content

Commit

Permalink
fix Groq.configure docs, add install generator
Browse files Browse the repository at this point in the history
  • Loading branch information
fitttdev committed Apr 26, 2024
1 parent a0fd39e commit 981b305
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ If bundler is not being used to manage dependencies, install the gem by executin
- Place in env var `GROQ_API_KEY`, or explicitly pass into configuration below.
- Use the `Groq::Client` to interact with Groq and your favourite model.

```shell
rails g groq:install
```
to generate inializer file

```ruby
client = Groq::Client.new # uses ENV["GROQ_API_KEY"] and "llama3-8b-8192"
client = Groq::Client.new(api_key: "...", model_id: "llama3-8b-8192")

Groq.configuration do |config|
Groq.configure do |config|
config.api_key = "..."
config.model_id = "llama3-70b-8192"
end
Expand Down Expand Up @@ -160,7 +165,7 @@ As above, you can specify the default model to use for all `chat()` calls:
```ruby
client = Groq::Client.new(model_id: "llama3-70b-8192")
# or
Groq.configuration do |config|
Groq.configure do |config|
config.model_id = "llama3-70b-8192"
end
```
Expand Down Expand Up @@ -318,10 +323,10 @@ The defaults are:
=> 1
```

You can override them in the `Groq.configuration` block, or with each `chat()` call:
You can override them in the `Groq.configure` block, or with each `chat()` call:

```ruby
Groq.configuration do |config|
Groq.configure do |config|
config.max_tokens = 512
config.temperature = 0.5
end
Expand Down
20 changes: 20 additions & 0 deletions lib/generators/groq/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'rails/generators/base'

module Groq
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)

def create_groq_init_file
create_file "config/initializers/groq.rb", <<~RUBY
# frozen_string_literal: true
Groq.configure do |config|
config.api_key = ENV["GROQ_API_KEY"]
config.model_id = "llama3-70b-8192"
end
RUBY
end
end
end
end

0 comments on commit 981b305

Please sign in to comment.