Skip to content

Commit

Permalink
Merge pull request #4 from Backland-Labs/develop
Browse files Browse the repository at this point in the history
#3: Add Local Embeddings
  • Loading branch information
mkrueger12 authored Oct 2, 2024
2 parents 308c1ee + 5f66144 commit 1b24fb3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- uses: ko-build/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: ko build
- run: ko build
11 changes: 10 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@

SemCache is an open-source semantic cache microservice for LLM applications. SemCache is aimed at advanced LLM application developers looking for a secure, performant semantic cache for their applications.


## Why Use SemCache?
SemCache abstracts away the complexity of semantic cache by packing the configuration of the database and API routes into a simple endpoint.

### When to use SemCache
SemCache fills the need for lightweight tools that provide core functionality without the bloat of the existing libraries. SemCache is built with cloud native deployments in mind.
SemCache fills the need for lightweight tools that provide core functionality without the bloat of the existing libraries. SemCache is built with cloud native deployments in mind.

## Endpoints

`/check` - Checks if there is any data in the cache
`/write` - Upserts data in the cache
14 changes: 5 additions & 9 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type PutRequestBody struct {
}

type PutResponseBody struct {
Result string `json:"operation_result"`
Result string `json:"result"`
}

func HandleGetRequest(c *fiber.Ctx) error {
Expand Down Expand Up @@ -113,7 +113,6 @@ func HandleGetRequest(c *fiber.Ctx) error {

func HandlePutRequest(c *fiber.Ctx) error {
c.Accepts("text/plain", "application/json")
c.Accepts("json", "text")

// Parse the JSON body using Sonic
var reqBody PutRequestBody
Expand All @@ -126,7 +125,7 @@ func HandlePutRequest(c *fiber.Ctx) error {

log.Info().Msgf("Received request body: %v", reqBody)

// Execute a couple of steps (example operations)
// convert to lowercase
reqBody.Message = strings.ToLower(reqBody.Message)

log.Info().Msgf("Converted message to lowercase: %v", reqBody.Message)
Expand All @@ -139,22 +138,19 @@ func HandlePutRequest(c *fiber.Ctx) error {

log.Info().Msg("Created vectors for query")

// query qdrant for response
// initialize databases
// Acess Qdrant client
qdrantClient := database.GetQdrantClient()

log.Info().Msg("Initialized Qdrant client")

operationInfo := database.PutQdrant(qdrantClient, vectors, reqBody.Message, reqBody.ModelResponse)

log.Info().Msgf("Received operation info: %v", operationInfo)
log.Info().Msgf("received operation info: %v", operationInfo)

// Prepare the response
respBody := PutResponseBody{
Result: operationInfo.String(),
}

// Encode the response using Sonic
// Encode the response
jsonResp, err := c.App().Config().JSONEncoder(respBody)
if err != nil {
log.Error().Msg("Failed to encode response")
Expand Down

0 comments on commit 1b24fb3

Please sign in to comment.