Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spin 3 interfaces and bump version number #291

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
uses: fermyon/actions/spin/setup@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: "v3.0.0-rc.1"

- name: Run Test
shell: bash
Expand Down
100 changes: 100 additions & 0 deletions bin/wit/deps/[email protected]/postgres.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package spin:[email protected];

interface postgres {
/// Errors related to interacting with a database.
variant error {
connection-failed(string),
bad-parameter(string),
query-failed(string),
value-conversion-failed(string),
other(string)
}

/// Data types for a database column
enum db-data-type {
boolean,
int8,
int16,
int32,
int64,
floating32,
floating64,
str,
binary,
date,
time,
datetime,
timestamp,
other,
}

/// Database values
variant db-value {
boolean(bool),
int8(s8),
int16(s16),
int32(s32),
int64(s64),
floating32(f32),
floating64(f64),
str(string),
binary(list<u8>),
date(tuple<s32, u8, u8>), // (year, month, day)
time(tuple<u8, u8, u8, u32>), // (hour, minute, second, nanosecond)
/// Date-time types are always treated as UTC (without timezone info).
/// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple.
datetime(tuple<s32, u8, u8, u8, u8, u8, u32>),
/// Unix timestamp (seconds since epoch)
timestamp(s64),
db-null,
unsupported,
}

/// Values used in parameterized queries
variant parameter-value {
boolean(bool),
int8(s8),
int16(s16),
int32(s32),
int64(s64),
floating32(f32),
floating64(f64),
str(string),
binary(list<u8>),
date(tuple<s32, u8, u8>), // (year, month, day)
time(tuple<u8, u8, u8, u32>), // (hour, minute, second, nanosecond)
/// Date-time types are always treated as UTC (without timezone info).
/// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple.
datetime(tuple<s32, u8, u8, u8, u8, u8, u32>),
/// Unix timestamp (seconds since epoch)
timestamp(s64),
db-null,
}

/// A database column
record column {
name: string,
data-type: db-data-type,
}

/// A database row
type row = list<db-value>;

/// A set of database rows
record row-set {
columns: list<column>,
rows: list<row>,
}

/// A connection to a postgres database.
resource connection {
/// Open a connection to the Postgres instance at `address`.
open: static func(address: string) -> result<connection, error>;

/// Query the database.
query: func(statement: string, params: list<parameter-value>) -> result<row-set, error>;

/// Execute command to the database.
execute: func(statement: string, params: list<parameter-value>) -> result<u64, error>;
}
}
File renamed without changes.
8 changes: 4 additions & 4 deletions bin/wit/llm.wit → bin/wit/deps/[email protected]/llm.wit
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ interface llm {
/// Note: the backing implementation may return less tokens.
max-tokens: u32,
/// The amount the model should avoid repeating tokens.
repeat-penalty: float32,
repeat-penalty: f32,
/// The number of tokens the model should apply the repeat penalty to.
repeat-penalty-last-n-token-count: u32,
/// The randomness with which the next token is selected.
temperature: float32,
temperature: f32,
/// The number of possible next tokens the model will choose from.
top-k: u32,
/// The probability total of next tokens the model will choose from.
top-p: float32
top-p: f32
}

/// The set of errors which may be raised by functions in this interface
Expand Down Expand Up @@ -57,7 +57,7 @@ interface llm {
/// Result of generating embeddings
record embeddings-result {
/// The embeddings generated by the request
embeddings: list<list<float32>>,
embeddings: list<list<f32>>,
/// Usage related to the embeddings generation request
usage: embeddings-usage
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ interface rdbms-types {
uint16(u16),
uint32(u32),
uint64(u64),
floating32(float32),
floating64(float64),
floating32(f32),
floating64(f64),
str(string),
binary(list<u8>),
db-null,
Expand All @@ -56,8 +56,8 @@ interface rdbms-types {
uint16(u16),
uint32(u32),
uint64(u64),
floating32(float32),
floating64(float64),
floating32(f32),
floating64(f64),
str(string),
binary(list<u8>),
db-null,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface sqlite {
/// A single column's result from a database query
variant value {
integer(s64),
real(float64),
real(f64),
text(string),
blob(list<u8>),
null
Expand Down
File renamed without changes.
46 changes: 46 additions & 0 deletions bin/wit/deps/wasi-keyvalue-2024-10-17/atomic.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// A keyvalue interface that provides atomic operations.
///
/// Atomic operations are single, indivisible operations. When a fault causes an atomic operation to
/// fail, it will appear to the invoker of the atomic operation that the action either completed
/// successfully or did nothing at all.
///
/// Please note that this interface is bare functions that take a reference to a bucket. This is to
/// get around the current lack of a way to "extend" a resource with additional methods inside of
/// wit. Future version of the interface will instead extend these methods on the base `bucket`
/// resource.
interface atomics {
use store.{bucket, error};

/// The error returned by a CAS operation
variant cas-error {
/// A store error occurred when performing the operation
store-error(error),
/// The CAS operation failed because the value was too old. This returns a new CAS handle
/// for easy retries. Implementors MUST return a CAS handle that has been updated to the
/// latest version or transaction.
cas-failed(cas),
}

/// A handle to a CAS (compare-and-swap) operation.
resource cas {
/// Construct a new CAS operation. Implementors can map the underlying functionality
/// (transactions, versions, etc) as desired.
new: static func(bucket: borrow<bucket>, key: string) -> result<cas, error>;
/// Get the current value of the key (if it exists). This allows for avoiding reads if all
/// that is needed to ensure the atomicity of the operation
current: func() -> result<option<list<u8>>, error>;
}

/// Atomically increment the value associated with the key in the store by the given delta. It
/// returns the new value.
///
/// If the key does not exist in the store, it creates a new key-value pair with the value set
/// to the given delta.
///
/// If any other error occurs, it returns an `Err(error)`.
increment: func(bucket: borrow<bucket>, key: string, delta: s64) -> result<s64, error>;

/// Perform the swap on a CAS operation. This consumes the CAS handle and returns an error if
/// the CAS operation failed.
swap: func(cas: cas, value: list<u8>) -> result<_, cas-error>;
}
63 changes: 63 additions & 0 deletions bin/wit/deps/wasi-keyvalue-2024-10-17/batch.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/// A keyvalue interface that provides batch operations.
///
/// A batch operation is an operation that operates on multiple keys at once.
///
/// Batch operations are useful for reducing network round-trip time. For example, if you want to
/// get the values associated with 100 keys, you can either do 100 get operations or you can do 1
/// batch get operation. The batch operation is faster because it only needs to make 1 network call
/// instead of 100.
///
/// A batch operation does not guarantee atomicity, meaning that if the batch operation fails, some
/// of the keys may have been modified and some may not.
///
/// This interface does has the same consistency guarantees as the `store` interface, meaning that
/// you should be able to "read your writes."
///
/// Please note that this interface is bare functions that take a reference to a bucket. This is to
/// get around the current lack of a way to "extend" a resource with additional methods inside of
/// wit. Future version of the interface will instead extend these methods on the base `bucket`
/// resource.
interface batch {
use store.{bucket, error};

/// Get the key-value pairs associated with the keys in the store. It returns a list of
/// key-value pairs.
///
/// If any of the keys do not exist in the store, it returns a `none` value for that pair in the
/// list.
///
/// MAY show an out-of-date value if there are concurrent writes to the store.
///
/// If any other error occurs, it returns an `Err(error)`.
get-many: func(bucket: borrow<bucket>, keys: list<string>) -> result<list<tuple<string, option<list<u8>>>>, error>;

/// Set the values associated with the keys in the store. If the key already exists in the
/// store, it overwrites the value.
///
/// Note that the key-value pairs are not guaranteed to be set in the order they are provided.
///
/// If any of the keys do not exist in the store, it creates a new key-value pair.
///
/// If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not
/// rollback the key-value pairs that were already set. Thus, this batch operation does not
/// guarantee atomicity, implying that some key-value pairs could be set while others might
/// fail.
///
/// Other concurrent operations may also be able to see the partial results.
set-many: func(bucket: borrow<bucket>, key-values: list<tuple<string, list<u8>>>) -> result<_, error>;

/// Delete the key-value pairs associated with the keys in the store.
///
/// Note that the key-value pairs are not guaranteed to be deleted in the order they are
/// provided.
///
/// If any of the keys do not exist in the store, it skips the key.
///
/// If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not
/// rollback the key-value pairs that were already deleted. Thus, this batch operation does not
/// guarantee atomicity, implying that some key-value pairs could be deleted while others might
/// fail.
///
/// Other concurrent operations may also be able to see the partial results.
delete-many: func(bucket: borrow<bucket>, keys: list<string>) -> result<_, error>;
}
Loading
Loading