Skip to content

Commit

Permalink
homogenizing interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
fsndzomga committed Dec 24, 2023
1 parent ae2b7d4 commit f639002
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Here is a quick example to get you started:
require 'mistral_rb'
# Initialize the API with your API key
mistral = MistralAPI.new("your_api_key_here")
mistral = MistralAPI.new(api_key: "your_api_key_here")
# Create Chat Completion
response = mistral.create_chat_completion("mistral-tiny", [{role: "user", content: "Who is Macron?"}])
response = mistral.create_chat_completion(model: "mistral-tiny", messages: [{role: "user", content: "Who is Macron?"}])
puts response.choices.to_s
# Create Embeddings
embedding_response = mistral.create_embeddings("mistral-embed", ["Hello", "world"])
puts embedding_response.data.first.embedding
embedding_response = mistral.create_embeddings(model: "mistral-embed", input: ["Hello", "world"])
puts embedding_response.data.first.inspect
# List Available Models
model_list_response = mistral.list_available_models
Expand Down
4 changes: 2 additions & 2 deletions lib/mistral_rb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class MistralAPI
include HTTParty

def initialize(api_key, base_uri = "https://api.mistral.ai/v1")
def initialize(api_key:, base_uri: "https://api.mistral.ai/v1")
@headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
Expand Down Expand Up @@ -42,7 +42,7 @@ def create_chat_completion(model:, messages:, temperature: 0.7, top_p: 1, max_to
end
end

def create_embeddings(model, input, encoding_format = "float")
def create_embeddings(model:, input:, encoding_format: "float")
body = {
model: model,
input: input,
Expand Down

0 comments on commit f639002

Please sign in to comment.