Skip to content

Commit

Permalink
Remove legacy host functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Oct 9, 2024
1 parent 21aac68 commit 9d228ef
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 598 deletions.
104 changes: 0 additions & 104 deletions runtime/hostfunctions/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@
package hostfunctions

import (
"context"
"fmt"

"github.com/hypermodeinc/modus/runtime/collections"
)

func init() {
registerCollectionsHostFunctions()
registerLegacyCollectionsHostFunctions()
}

func registerCollectionsHostFunctions() {
registerHostFunction("hypermode", "computeDistance_v2", collections.ComputeDistance,
withCancelledMessage("Cancelled computing distance."),
withErrorMessage("Error computing distance."),
Expand Down Expand Up @@ -108,102 +103,3 @@ func registerCollectionsHostFunctions() {
return fmt.Sprintf("Collection: %s, Namespace: %s, Keys: %v", collectionName, namespace, keys)
}))
}

func registerLegacyCollectionsHostFunctions() {

// Support functions from older SDK versions.
// Each of these function wrappers must maintain the original signature.
// We can remove these when we can be sure that nobody is using them.

registerHostFunction("hypermode", "computeDistance",
func(ctx context.Context, collectionName, searchMethod, id1, id2 string) (*collections.CollectionSearchResultObject, error) {
return collections.ComputeDistance(ctx, collectionName, "", searchMethod, id1, id2)
},
withCancelledMessage("Cancelled computing distance."),
withErrorMessage("Error computing distance."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "computeSimilarity",
func(ctx context.Context, collectionName, searchMethod, id1, id2 string) (*collections.CollectionSearchResultObject, error) {
return collections.ComputeDistance(ctx, collectionName, "", searchMethod, id1, id2)
},
withCancelledMessage("Cancelled computing similarity."),
withErrorMessage("Error computing similarity."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "deleteFromCollection",
func(ctx context.Context, collectionName, key string) (*collections.CollectionMutationResult, error) {
return collections.DeleteFromCollection(ctx, collectionName, "", key)
},
withCancelledMessage("Cancelled deleting from collection."),
withErrorMessage("Error deleting from collection."),
withMessageDetail(func(collectionName, key string) string {
return fmt.Sprintf("Collection: %s, Key: %s", collectionName, key)
}))

registerHostFunction("hypermode", "getTextFromCollection",
func(ctx context.Context, collectionName, key string) (string, error) {
return collections.GetTextFromCollection(ctx, collectionName, "", key)
},
withCancelledMessage("Cancelled getting text from collection."),
withErrorMessage("Error getting text from collection."),
withMessageDetail(func(collectionName, key string) string {
return fmt.Sprintf("Collection: %s, Key: %s", collectionName, key)
}))

registerHostFunction("hypermode", "getTextsFromCollection",
func(ctx context.Context, collectionName string) (map[string]string, error) {
return collections.GetTextsFromCollection(ctx, collectionName, "")
},
withCancelledMessage("Cancelled getting texts from collection."),
withErrorMessage("Error getting texts from collection."),
withMessageDetail(func(collectionName string) string {
return fmt.Sprintf("Collection: %s", collectionName)
}))

registerHostFunction("hypermode", "nnClassifyCollection",
func(ctx context.Context, collectionName, searchMethod, text string) (*collections.CollectionClassificationResult, error) {
return collections.NnClassify(ctx, collectionName, "", searchMethod, text)
},
withCancelledMessage("Cancelled classification."),
withErrorMessage("Error during classification."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "recomputeSearchMethod",
func(ctx context.Context, collectionName, searchMethod string) (*collections.SearchMethodMutationResult, error) {
return collections.RecomputeSearchMethod(ctx, collectionName, "", searchMethod)
},
withStartingMessage("Starting recomputing search method for collection."),
withCompletedMessage("Completed recomputing search method for collection."),
withCancelledMessage("Cancelled recomputing search method for collection."),
withErrorMessage("Error recomputing search method for collection."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "searchCollection",
func(ctx context.Context, collectionName, searchMethod, text string, limit int32, returnText bool) (*collections.CollectionSearchResult, error) {
return collections.SearchCollection(ctx, collectionName, nil, searchMethod, text, limit, returnText)
},
withCancelledMessage("Cancelled searching collection."),
withErrorMessage("Error searching collection."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "upsertToCollection",
func(ctx context.Context, collectionName string, keys, texts []string) (*collections.CollectionMutationResult, error) {
return collections.UpsertToCollection(ctx, collectionName, "", keys, texts, nil)
},
withCancelledMessage("Cancelled collection upsert."),
withErrorMessage("Error upserting to collection."),
withMessageDetail(func(collectionName string, keys []string) string {
return fmt.Sprintf("Collection: %s, Keys: %v", collectionName, keys)
}))
}
45 changes: 0 additions & 45 deletions runtime/hostfunctions/legacy.go

This file was deleted.

54 changes: 0 additions & 54 deletions runtime/models/legacymodels/classifier.go

This file was deleted.

57 changes: 0 additions & 57 deletions runtime/models/legacymodels/common.go

This file was deleted.

35 changes: 0 additions & 35 deletions runtime/models/legacymodels/embeddings.go

This file was deleted.

Loading

0 comments on commit 9d228ef

Please sign in to comment.