Giter Site home page Giter Site logo

marcominerva / openaiembeddingsample Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 0.0 9.77 MB

An example that shows how to use Semantic Kernel and Kernel Memory to work with embeddings in a .NET application using SQL Server as Vector Database.

License: MIT License

C# 100.00%
azure-openai c-sharp chatgpt dotnet embeddings openai sql-server vector-database visual-studio kernel-memory

openaiembeddingsample's Introduction

OpenAI Embeddings Sample

An example that shows how to use Semantic Kernel and Kernel Memory to work with embeddings in a .NET application using SQL Server as Vector Database.

The embeddings are stored in a SQL Server database and the Vector Search is efficiently performed thanks to COLUMNSTORE indexes.

To execute the application:

  • Create a database in SQL Server
  • Open the AppCostants.cs file and set the connection string to the database and the other required parameters. This example assumes you're using Azure OpenAI, but you can easily update it to use OpenAI or whatever LLM you want. Take a look to Kernel and KernelMemoryBuilder configurations in the Program.cs file
  • Import some documents into the memory (search for await kernelMemory.ImportDocumentAsync in the Program.cs file

Refer to Program.cs to see how document chunking is performed and how embeddings are calculated, stored and retrieved from the database using Kernel Memory.

If you want to see a manual (explicit) approach to embedding and Vector Search using SQL Server, refer to the manual-approach branch.

openaiembeddingsample's People

Contributors

dependabot[bot] avatar marcominerva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openaiembeddingsample's Issues

For me, no error, but both tables [SKMemories] and [SKMemoryCollections] are empty

Hello,

Thanks for your share. I tried to run the program as it is. I am not seeing any error while trying to uplaod a pdf file, but both tables [SKMemories] and [SKMemoryCollections] are empty and no memories generated.

Any suggestion please?

info: Microsoft.KernelMemory.Handlers.TextExtractionHandler[0]
Handler 'extract' ready
info: Microsoft.KernelMemory.Handlers.TextPartitioningHandler[0]
Handler 'partition' ready
info: Microsoft.KernelMemory.Handlers.SummarizationHandler[0]
Handler 'summarize' ready
info: Microsoft.KernelMemory.Handlers.GenerateEmbeddingsHandler[0]
Handler 'gen_embeddings' ready, 1 embedding generators
info: Microsoft.KernelMemory.Handlers.SaveRecordsHandler[0]
Handler save_records ready, 1 vector storages
info: Microsoft.KernelMemory.Handlers.DeleteDocumentHandler[0]
Handler 'private_delete_document' ready
info: Microsoft.KernelMemory.Handlers.DeleteIndexHandler[0]
Handler 'private_delete_index' ready
info: Microsoft.KernelMemory.Handlers.DeleteGeneratedFilesHandler[0]
Handler 'delete_generated_files' ready
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
Queueing upload of 1 files for further processing [request 2a4e1d6d2dd842f29957ccda4e9eeeff202401230325092344298]
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
File uploaded: LIC.pdf, 189007 bytes
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
Handler 'extract' processed pipeline 'default/2a4e1d6d2dd842f29957ccda4e9eeeff202401230325092344298' successfully
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
Handler 'partition' processed pipeline 'default/2a4e1d6d2dd842f29957ccda4e9eeeff202401230325092344298' successfully
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
Handler 'gen_embeddings' processed pipeline 'default/2a4e1d6d2dd842f29957ccda4e9eeeff202401230325092344298' successfully
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
Handler 'save_records' processed pipeline 'default/2a4e1d6d2dd842f29957ccda4e9eeeff202401230325092344298' successfully
info: Microsoft.KernelMemory.Pipeline.BaseOrchestrator[0]
Pipeline 'default/2a4e1d6d2dd842f29957ccda4e9eeeff202401230325092344298' complete

Question: how much payment I made
info: Microsoft.SemanticKernel.Connectors.OpenAI.AzureOpenAIChatCompletionService[0]
Prompt tokens: 93. Completion tokens: 11. Total tokens: 104.
warn: Microsoft.KernelMemory.Search.SearchClient[0]
No memories available
I'm sorry, I haven't found any relevant information about that can be used to answer your question

Question:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.