Noizu.Github (Noizu Labs: Github API v0.1.0)
Noizu.Github is a library providing a simple wrapper around Github's API calls. It handles various API features such as completions, chat, edit, image generation, image editing, image variation, embeddings, audio transcription, audio translation, file management, and content moderation.
configuration
Configuration
To configure the library, you need to set the Github API key and optionally, the Github organization in your application's configuration:
config :noizu_github,
github_api_key: "your_api_key_here",
Link to this section Summary
Functions
A helper function to make API calls to the Github API. This function handles both non-stream and stream API calls.
Link to this section Types
error_tuple()
@type error_tuple() :: {:error, details :: term()}
stream_option()
@type stream_option() :: boolean()
stream_options()
Link to this section Functions
api_call(type, url, body, model, options \\ nil)
A helper function to make API calls to the Github API. This function handles both non-stream and stream API calls.
parameters
Parameters
- type: The HTTP request method (e.g., :get, :post, :put, :patch, :delete)
- url: The full URL for the API endpoint
- body: The request body in map format
- model: The model to be used for the response processing
- options
- stream: A boolean value to indicate whether the request should be processed as a stream or not (default: false)
- raw: return raw response
- response_log_callback: function(finch) callback for request log.
- response_log_callback: function(finch, start_ms) callback for response log.
returns
Returns
Returns a tuple {:ok, response} on successful API call, where response is the decoded JSON response in map format. Returns {:error, term} on failure, where term contains error details.
example
Example
url = "https://api.github.com/v1/completions"
body = %{
prompt: "Once upon a time",
model: "text-davinci-003",
max_tokens: 50,
temperature: 0.7
}
{:ok, response} = Noizu.Github.api_call(:post, url, body, Noizu.Github.Completion, stream: false)