From c5d688a47c6a355bb4b1d473faed4941bd62e172 Mon Sep 17 00:00:00 2001 From: Alvise Susmel Date: Wed, 15 May 2024 22:27:08 +0200 Subject: [PATCH] Llamacpp.url/0 gets url from config :api_url --- lib/instructor/adapters/llamacpp.ex | 4 ++-- test/instructor_test.exs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/instructor/adapters/llamacpp.ex b/lib/instructor/adapters/llamacpp.ex index c0c9f91..92fa764 100644 --- a/lib/instructor/adapters/llamacpp.ex +++ b/lib/instructor/adapters/llamacpp.ex @@ -149,8 +149,8 @@ defmodule Instructor.Adapters.Llamacpp do "#{prompt}" end - defp url() do - Keyword.get(config(), :url, "http://localhost:8080/completion") + def url() do + Keyword.get(config(), :api_url, "http://localhost:8080/completion") end defp chat_template() do diff --git a/test/instructor_test.exs b/test/instructor_test.exs index 8b44060..64cab62 100644 --- a/test/instructor_test.exs +++ b/test/instructor_test.exs @@ -21,6 +21,9 @@ defmodule InstructorTest do :openai_mock -> Application.put_env(:instructor, :adapter, InstructorTest.MockOpenAI) + + nil -> + :ok end end @@ -419,4 +422,9 @@ defmodule InstructorTest do result |> Enum.to_list() end end + + test "Llamacpp adapter gets the url from :api_url in config" do + Application.put_env(:instructor, :llamacpp, api_url: "http://1.2.3.4:8080/completion") + assert "http://1.2.3.4:8080/completion" == Instructor.Adapters.Llamacpp.url() + end end