Skip to content

Commit

Permalink
FQN changes (#86)
Browse files Browse the repository at this point in the history
* image -> images

* file -> files. remove warnings

* embedding -> embeddings

* match module names

* completion -> completions

* model -> models

* moderation - > moderations

* fix fine tuning naming

* fqn assistants

* fix beta fqn

* add on

* test userguide
  • Loading branch information
restlessronin authored Apr 26, 2024
1 parent 91092d8 commit 4664508
Show file tree
Hide file tree
Showing 22 changed files with 137 additions and 136 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Assistant do
defmodule OpenaiEx.Beta.Assistants do
@moduledoc """
This module provides an implementation of the OpenAI assistants API. The API reference can be found at https://platform.openai.com/docs/api-reference/assistants.
Expand Down Expand Up @@ -43,7 +43,7 @@ defmodule OpenaiEx.Beta.Assistant do
Example usage:
iex> _request = OpenaiEx.Beta.Assistant.new(model: "gpt-4-turbo")
iex> _request = OpenaiEx.Beta.Assistants.new(model: "gpt-4-turbo")
%{model: "gpt-4-turbo"}
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Assistant.File do
defmodule OpenaiEx.Beta.Assistants.File do
@moduledoc """
This module provides an implementation of the OpenAI assistants files API. The API reference can be found at https://platform.openai.com/docs/api-reference/assistants.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Thread do
defmodule OpenaiEx.Beta.Threads do
@moduledoc """
This module provides an implementation of the OpenAI threads API. The API reference can be found at https://platform.openai.com/docs/api-reference/threads.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Thread.Message do
defmodule OpenaiEx.Beta.Threads.Messages do
@moduledoc """
This module provides an implementation of the OpenAI messages API. The API
reference can be found at https://platform.openai.com/docs/api-reference/messages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Thread.Message.File do
defmodule OpenaiEx.Beta.Threads.Messages.File do
@moduledoc """
This module provides an implementation of the OpenAI messages files API. The API reference can be found at https://platform.openai.com/docs/api-reference/messages.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Thread.Run do
defmodule OpenaiEx.Beta.Threads.Runs do
@moduledoc """
This module provides an implementation of the OpenAI run API. The API
reference can be found at https://platform.openai.com/docs/api-reference/runs.
Expand Down Expand Up @@ -42,7 +42,7 @@ defmodule OpenaiEx.Beta.Thread.Run do
Example usage:
iex> _request = OpenaiEx.Beta.Thread.Run.new(thread_id: "thread_foo", assistant_id: "assistant_bar")
iex> _request = OpenaiEx.Beta.Threads.Runs.new(thread_id: "thread_foo", assistant_id: "assistant_bar")
%{assistant_id: "assistant_bar", thread_id: "thread_foo"}
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Beta.Run.Step do
defmodule OpenaiEx.Beta.Threads.Runs.Steps do
@moduledoc false
defp ep_url(thread_id, run_id, step_id \\ nil) do
"/threads/#{thread_id}/runs/#{run_id}/steps" <>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.ChatCompletion do
defmodule OpenaiEx.Chat.Completions do
@moduledoc """
This module provides an implementation of the OpenAI chat completions API. The API reference can be found at https://platform.openai.com/docs/api-reference/chat/completions.
Expand Down Expand Up @@ -55,10 +55,10 @@ defmodule OpenaiEx.ChatCompletion do
Example usage:
iex> _request = OpenaiEx.ChatCompletion.new(model: "davinci", messages: [OpenaiEx.ChatMessage.user("Hello, world!")])
iex> _request = OpenaiEx.Chat.Completions.new(model: "davinci", messages: [OpenaiEx.ChatMessage.user("Hello, world!")])
%{messages: [%{content: "Hello, world!", role: "user"}], model: "davinci"}
iex> _request = OpenaiEx.ChatCompletion.new(%{model: "davinci", messages: [OpenaiEx.ChatMessage.user("Hello, world!")]})
iex> _request = OpenaiEx.Chat.Completions.new(%{model: "davinci", messages: [OpenaiEx.ChatMessage.user("Hello, world!")]})
%{messages: [%{content: "Hello, world!", role: "user"}], model: "davinci"}
"""

Expand Down
6 changes: 3 additions & 3 deletions lib/openai_ex/embedding.ex → lib/openai_ex/embeddings.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Embedding do
defmodule OpenaiEx.Embeddings do
@moduledoc """
This module provides an implementation of the OpenAI embeddings API. The API reference can be found at https://platform.openai.com/docs/api-reference/embeddings.
Expand Down Expand Up @@ -35,10 +35,10 @@ defmodule OpenaiEx.Embedding do
Example usage:
iex> _request = OpenaiEx.Embedding.new(model: "davinci", input: "This is a test")
iex> _request = OpenaiEx.Embeddings.new(model: "davinci", input: "This is a test")
%{input: "This is a test", model: "davinci"}
iex> _request = OpenaiEx.Embedding.new(%{model: "davinci", input: "This is a test"})
iex> _request = OpenaiEx.Embeddings.new(%{model: "davinci", input: "This is a test"})
%{input: "This is a test", model: "davinci"}
"""

Expand Down
2 changes: 1 addition & 1 deletion lib/openai_ex/file.ex → lib/openai_ex/files.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.File do
defmodule OpenaiEx.Files do
@moduledoc """
This module provides an implementation of the OpenAI files API. The API reference can be found at https://platform.openai.com/docs/api-reference/files.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.FineTuning.Job do
defmodule OpenaiEx.FineTuning.Jobs do
@moduledoc """
This module provides an implementation of the OpenAI fine-tuning job API. The API reference can be found at https://platform.openai.com/docs/api-reference/fine-tuning.
Expand Down
8 changes: 4 additions & 4 deletions lib/openai_ex/image.ex → lib/openai_ex/images.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule OpenaiEx.Image do
defmodule OpenaiEx.Images do
@moduledoc """
This module provides an implementation of the OpenAI images API. The API reference can be found at https://platform.openai.com/docs/api-reference/images.
"""
alias OpenaiEx.Image
alias OpenaiEx.Images

@doc """
Calls the image generation endpoint.
Expand Down Expand Up @@ -39,7 +39,7 @@ defmodule OpenaiEx.Image do
def edit(openai = %OpenaiEx{}, image_edit = %{}) do
openai
|> OpenaiEx.Http.post("/images/edits",
multipart: image_edit |> OpenaiEx.Http.to_multi_part_form_data(Image.Edit.file_fields())
multipart: image_edit |> OpenaiEx.Http.to_multi_part_form_data(Images.Edit.file_fields())
)
end

Expand All @@ -61,7 +61,7 @@ defmodule OpenaiEx.Image do
openai
|> OpenaiEx.Http.post("/images/variations",
multipart:
image_variation |> OpenaiEx.Http.to_multi_part_form_data(Image.Variation.file_fields())
image_variation |> OpenaiEx.Http.to_multi_part_form_data(Images.Variation.file_fields())
)
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Image.Edit do
defmodule OpenaiEx.Images.Edit do
@moduledoc """
This module provides constructors for OpenAI Image Edit API request structure. The API reference can be found at https://platform.openai.com/docs/api-reference/images/create-edit.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Image.Generate do
defmodule OpenaiEx.Images.Generate do
@moduledoc """
This module provides constructors for the OpenAI image generation API. The API
reference can be found at https://platform.openai.com/docs/api-reference/images/create.
Expand Down Expand Up @@ -42,10 +42,10 @@ defmodule OpenaiEx.Image.Generate do
Example usage:
iex> _request = OpenaiEx.Image.Generate.new(prompt: "This is a test")
iex> _request = OpenaiEx.Images.Generate.new(prompt: "This is a test")
%{prompt: "This is a test"}
iex> _request = OpenaiEx.Image.Generate.new(%{prompt: "This is a test"})
iex> _request = OpenaiEx.Images.Generate.new(%{prompt: "This is a test"})
%{prompt: "This is a test"}
"""
def new(args = [_ | _]) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Image.Variation do
defmodule OpenaiEx.Images.Variation do
@moduledoc """
This module provides constructors for OpenAI Image Variation API request structure. The API reference can be found at https://platform.openai.com/docs/api-reference/images/create-variation.
Expand Down
2 changes: 1 addition & 1 deletion lib/openai_ex/model.ex → lib/openai_ex/models.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Model do
defmodule OpenaiEx.Models do
@moduledoc """
This module provides an implementation of the OpenAI Models API. Information about these models can be found at https://platform.openai.com/docs/models.
"""
Expand Down
6 changes: 3 additions & 3 deletions lib/openai_ex/moderation.ex → lib/openai_ex/moderations.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule OpenaiEx.Moderation do
defmodule OpenaiEx.Moderations do
@moduledoc """
This module provides an implementation of the OpenAI moderation API. The API reference can be found at https://platform.openai.com/docs/api-reference/moderations.
Expand Down Expand Up @@ -29,12 +29,12 @@ defmodule OpenaiEx.Moderation do
Example usage:
iex> OpenaiEx.Moderation.new(input: "This is a test")
iex> OpenaiEx.Moderations.new(input: "This is a test")
%{
input: "This is a test"
}
iex> OpenaiEx.Moderation.new(%{input: "This is a test"})
iex> OpenaiEx.Moderations.new(%{input: "This is a test"})
%{
input: "This is a test"
}
Expand Down
4 changes: 2 additions & 2 deletions notebooks/dlai_orderbot.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Mix.install([
])

alias OpenaiEx
alias OpenaiEx.ChatCompletion
alias OpenaiEx.Chat.Completions
alias OpenaiEx.ChatMessage
```

Expand Down Expand Up @@ -35,7 +35,7 @@ openai =
```elixir
defmodule OpenaiEx.Notebooks.DlaiOrderbot do
alias OpenaiEx
alias OpenaiEx.ChatCompletion
alias OpenaiEx.Chat.Completions

def create_chat_req(args = [_ | _]) do
args
Expand Down
2 changes: 1 addition & 1 deletion notebooks/images.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Mix.install([
])

alias OpenaiEx
alias OpenaiEx.Image
alias OpenaiEx.Images
```

## Simple Kino UI
Expand Down
4 changes: 2 additions & 2 deletions notebooks/streaming_orderbot.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Mix.install([
])

alias OpenaiEx
alias OpenaiEx.ChatCompletion
alias OpenaiEx.Chat.Completions
alias OpenaiEx.ChatMessage
```

Expand All @@ -27,7 +27,7 @@ openai = System.fetch_env!("LB_OPENAI_API_KEY") |> OpenaiEx.new()
```elixir
defmodule OpenaiEx.Notebooks.StreamingOrderbot do
alias OpenaiEx
alias OpenaiEx.ChatCompletion
alias OpenaiEx.Chat.Completions
require Logger

def set_task_pid(task_pid) do
Expand Down
Loading

0 comments on commit 4664508

Please sign in to comment.