First pass at uniformed types, specs and docs
- spec public functions (skipping controllers, views, live views and components) - use types instead of explanations in docs - remove redundant docs - fix typos
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
defmodule OpenAI.API do
|
||||
require Logger
|
||||
|
||||
@spec gpt(OpenAI.Completion.t(), OpenAI.Config.t()) :: {:ok, map()} | {:error, term()}
|
||||
def gpt(completion, config) do
|
||||
resp =
|
||||
config
|
||||
@@ -26,6 +27,9 @@ defmodule OpenAI.API do
|
||||
end
|
||||
end
|
||||
|
||||
@spec chat_stream([map()], String.t(), String.t(), float(), OpenAI.Config.t(), (String.t() ->
|
||||
any())) ::
|
||||
:ok | {:error, String.t()}
|
||||
def chat_stream(messages, instructions, model, temperature, config, cb) do
|
||||
case config
|
||||
|> new_request()
|
||||
@@ -60,6 +64,7 @@ defmodule OpenAI.API do
|
||||
end
|
||||
end
|
||||
|
||||
@spec get_embeddings(String.t(), OpenAI.Config.t()) :: {:ok, [float()]} | {:error, term()}
|
||||
def get_embeddings(text, config) do
|
||||
resp =
|
||||
config
|
||||
|
||||
@@ -4,4 +4,11 @@ defmodule OpenAI.Completion do
|
||||
temperature: 0.2,
|
||||
role: "user",
|
||||
model: "gpt-4o-mini"
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
content: String.t(),
|
||||
temperature: float(),
|
||||
role: String.t(),
|
||||
model: String.t()
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user