-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
192 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
/examples/**/*.db | ||
|
||
# rspec failure tracking | ||
.rspec_status | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Roseflow | ||
module Text | ||
class Completion | ||
def initialize(input) | ||
@input = input | ||
end | ||
|
||
# Creates a new completion for the given input. | ||
def call(model:, prompt:, **options) | ||
provider.completions(model: model, prompt: @input, **options).choices | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ | |
|
||
module Types | ||
include Dry.Types() | ||
|
||
Number = Types::Float | Types::Integer | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require "active_model/type" | ||
|
||
module Roseflow | ||
module VectorStores | ||
module Type | ||
class Vector < ActiveModel::Type::Value | ||
def initialize(dimensions:, model:, attribute_name:) | ||
super() | ||
@dimensions = dimensions | ||
@model = model | ||
@attribute_name = attribute_name | ||
end | ||
|
||
def self.cast(value, dimensions:) | ||
value = value.to_a.map(&:to_f) | ||
|
||
raise Error, "Values must be finite" unless value.all?(&:finite?) | ||
|
||
value | ||
end | ||
|
||
def cast(value) | ||
self.class.cast(value, dimensions: @dimensions) unless value.nil? | ||
end | ||
|
||
def serialize(value) | ||
raise NotImplementedError | ||
end | ||
|
||
def deserialize(value) | ||
raise NotImplementedError | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.