hectorperez

hectorperez

Package config in Livebook notebook

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.

Marked As Solved

LostKobrakai

LostKobrakai

Mix — Mix v1.13.4 see the second example

Also Liked

hectorperez

hectorperez

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: "...",
    ]
  ]
)
Anko

Anko

To answer my own question :stuck_out_tongue:

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: %{}}})

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement