Skip to content

Commit

Permalink
remove callback from OpenAiImage
Browse files Browse the repository at this point in the history
- was only partially implemented
- not needed
  • Loading branch information
brainlid committed Jun 16, 2024
1 parent 13f5d08 commit a6af118
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/images/open_ai_image.ex
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,14 @@ defmodule LangChain.Images.OpenAIImage do
`LangChain.Images.GeneratedImage` structs.
"""
@spec call(t()) :: {:ok, [GeneratedImage.t()]} | {:error, String.t()}
def call(openai, callback_fn \\ nil)
def call(openai)

def call(%OpenAIImage{} = openai, callback_fn) do
def call(%OpenAIImage{} = openai) do
if override_api_return?() do
Logger.warning("Found override API response. Will not make live API call.")

case get_api_override() do
{:ok, {:ok, data} = response} ->

Check warning on line 191 in lib/images/open_ai_image.ex

View workflow job for this annotation

GitHub Actions / Build and test

variable "data" is unused (if the variable is not meant to be used, prefix it with an underscore)
# fire callback for fake responses too
Utils.fire_callback(openai, data, callback_fn)
response

# fake error response
Expand All @@ -204,7 +202,7 @@ defmodule LangChain.Images.OpenAIImage do
else
try do
# make base api request and perform high-level success/failure checks
case do_api_request(openai, callback_fn) do
case do_api_request(openai) do
{:error, reason} ->
{:error, reason}

Expand All @@ -226,11 +224,8 @@ defmodule LangChain.Images.OpenAIImage do
# - `{:error, reason}` - Where reason is a string explanation of what went
# wrong.
#
# If a callback_fn is provided, it will fire with each

# Executes the callback function passing the response parsed to the data
# structures. Retries the request up to 3 times on transient errors with a
# brief delay
# Retries the request up to 3 times on transient errors with a brief delay
@doc false
@spec do_api_request(t(), retry_count :: integer()) :: {:ok, list()} | {:error, String.t()}
def do_api_request(openai, retry_count \\ 3)
Expand Down

0 comments on commit a6af118

Please sign in to comment.