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. · GitHub

Marked As Solved

LostKobrakai

LostKobrakai

Mix — Mix v1.20.2 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: %{}}})

Last Post!

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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement