Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Mistral

livebooks/mistral.livemd

Mistral

Mix.install([
  :req,
  :kino,
  :jason,
  {:replicate, "~> 1.2.0"}
])

Application.put_env(:replicate, :replicate_api_token, System.fetch_env!("LB_REPLICATE_API_TOKEN"))

Set OpenHermes-2.5

name = "mistralai/mistral-7b-instruct-v0.1"
model = Replicate.Models.get!(name)
version = Replicate.Models.get_latest_version!(model)

Run OpenHermes-2.5

prompt = "Write me elixir program that reverse a string"

input =
  %{
    top_k: 50,
    top_p: 0.9,
    temperature: 0.5,
    max_new_tokens: 2048,
    prompt: prompt
  }

{:ok, prediction} = Replicate.Predictions.create(version, input)

Section

{:ok, result} = Replicate.Predictions.get(prediction.id)
result.output
|> Enum.join()