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:
Claudio Ortolina
2026-03-06 08:33:11 +00:00
parent 99e30d5fdf
commit 7cf9b4e7f8
81 changed files with 652 additions and 300 deletions
+10
View File
@@ -1,10 +1,19 @@
defmodule OpenAI do
alias OpenAI.API
@type chat_stream_opts :: [
model: String.t(),
temperature: float(),
instructions: String.t(),
on_chunk: (String.t() -> any())
]
@spec gpt(OpenAI.Completion.t()) :: {:ok, map()} | {:error, term()}
def gpt(completion) do
API.gpt(completion, config())
end
@spec chat_stream([map()], chat_stream_opts()) :: :ok | {:error, String.t()}
def chat_stream(messages, opts \\ []) when is_list(messages) do
model = Keyword.get(opts, :model, "gpt-4.1")
temperature = Keyword.get(opts, :temperature, 0.7)
@@ -17,6 +26,7 @@ defmodule OpenAI do
end
end
@spec embeddings(String.t()) :: {:ok, [float()]} | {:error, term()}
def embeddings(text) do
API.get_embeddings(text, config())
end