Hi!
I was going to play with the package openai [1] in a livebook notebook.
In the setup I added:
Mix.install([
{:openai, "~> 0.1.1"}
])
However, I don’t know how/where to add the config (API key):
use Mix.Config
config :openai,
api_key: "your-api-key",
organization_key: "your-organization-key
Where should I place the package config (API key) so I can use it in a livebook notebook?
Thanks!
[1] GitHub - mgallo/openai.ex: community-maintained OpenAI API Wrapper written in Elixir.
3 Likes
Mix — Mix v1.13.4 see the second example
8 Likes
I missed that, thank you @LostKobrakai !
As a reference, I added this and it worked:
Mix.install(
[{:openai, "~> 0.1.1"}],
config: [
openai: [
api_key: "...",
organisation_key: "...",
]
]
)
8 Likes
Anko
March 2, 2024, 1:57am
5
Just wondering how I’d do it for something like Snap, GitHub - breakroom/snap: An Elasticsearch client for Elixir
It’s looking for a module to be created that you reference in the config, but if the config is in the Mix.install, then you can’t have a module defined before that
Anko
March 2, 2024, 2:18am
6
To answer my own question
Mix.install([
{:snap, "~> 0.9.0"},
{:kino, "~> 0.12.3"},
{:finch, "~> 0.18.0"}
])
defmodule Elastic do
use Snap.Cluster, otp_app: :snap
end
Kino.start_child!({Elastic, [url: "http://elastic.local:9200"]})
Snap.Search.search(Elastic, "products", %{query: %{match_all: %{}}})
1 Like