Skip to content

Commit

Permalink
OpenAI provider update. New types.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljuti committed Nov 21, 2023
1 parent 7d5a009 commit 67d5cf4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/roseflow/ai/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def models
@models ||= instance.models
end

def get_file_content(file_id)
@instance.get_file_content(file_id)
end

private

attr_reader :instance
Expand Down
4 changes: 4 additions & 0 deletions lib/roseflow/ai/providers/openai_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class OpenAIAdapter < BaseAdapter
def models
@provider.models
end

def get_file_content(file_id)
@provider.get_file_content(file_id)
end
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions lib/roseflow/chat/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,24 @@ class ModelMessage < Message

class UserMessage < Message
attribute :role, Types::String.constrained(included_in: %w(user))

def self.from(input)
new(
role: "user",
content: input
)
end
end

class SystemMessage < Message
attribute :role, Types::String.constrained(included_in: %w(system))

def self.from(input)
new(
role: "system",
content: input
)
end
end
end
end
10 changes: 10 additions & 0 deletions lib/roseflow/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,15 @@ module OpenAI
FunctionCallObject = Types::Hash
StringOrObject = Types::String | FunctionCallObject
StringOrArray = Types::String | Types::Array

VisionChatMessageContent = Types::Hash.schema(
text: Types::String,
type: Types::String.default("text"),
)

VisionImageMessageContent = Types::Hash.schema(
image_url: Types::Hash.schema(image_url: Types::String),
type: Types::String.default("image_url"),
)
end
end

0 comments on commit 67d5cf4

Please sign in to comment.