Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Add Install generator and update README #6

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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