Skip to content

Commit

Permalink
update with embedding api
Browse files Browse the repository at this point in the history
  • Loading branch information
leeduckgo committed Dec 21, 2023
1 parent 6460c60 commit 0f3e798
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/components/smart_prompter_interactor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ defmodule Components.SmartPrompterInteractor do
templates:
%{
create: "api/prompt_templates"
},
embedding:
%{
get: "api/embedding"
}
}
def register(username, password) do
Expand Down Expand Up @@ -96,7 +100,7 @@ defmodule Components.SmartPrompterInteractor do
|> Process.whereis()
|> Agent.get(fn token -> token end)
end

# +--------+
# | Topics |
# +--------+
Expand Down Expand Up @@ -183,4 +187,14 @@ defmodule Components.SmartPrompterInteractor do
String.replace(acc, "{#{key}}", value)
end)
end

# +-----------+
# | embedding |
# +-----------+

def get_embedding(endpoint, content) do
token = get_session(endpoint)
path = "#{endpoint}/#{@paths.embedding.get}"
ExHttp.http_post(path, %{text: content}, token, 3)
end
end

0 comments on commit 0f3e798

Please sign in to comment.