semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

SQL DB Agent/Connector/Skills

Open samleegithub opened this issue 1 year ago • 2 comments

What is the best approach to using Semantic Kernel to access SQL databases?

This blog post by LangChain about LLMs and SQL has some interesting ideas: https://blog.langchain.dev/llms-and-sql/

It discusses:

  • Ways to a include a description of the database schema and data in the input prompts.
  • How to limit output size to fit in max token limits
  • How to handle errors.

Is the best approach a combination of a SQL DB connector + skills customized with DB schema + data?

What about the error handling? Is that another skill? Or is that some kind of agent or part of the planner's job?

samleegithub avatar Apr 07 '23 17:04 samleegithub

This is interesting. I think for precision, error handling and other related stuff, it might be more convenient to call a native skill that handles database read and write whenever necessary in a semantic skill

tynguyen avatar Apr 08 '23 10:04 tynguyen

Hi @samleegithub this is a really interesting article. I am on the same page as @tynguyen. I would consider creating a SQL DB connector, a set of native skills that interact with this connector, perform error handling, and process large batches of data. Then more targeted semantic skills can call these native skills.

We mostly follow this pattern for the Connectors.Sqlite SqliteMemoryStore (though here, the schema is mostly defined at the connector level).

awharrison-28 avatar Apr 12 '23 17:04 awharrison-28

I am investigating approaches to this issue

crickman avatar Jun 19 '23 20:06 crickman

Curious any update on this issue or any workaround/options if one wants to query the SQL DB as part of building the prompt?

Balak88 avatar Jul 10 '23 05:07 Balak88

@samleegithub not sure if have seen this blog post > https://devblogs.microsoft.com/semantic-kernel/use-natural-language-to-execute-sql-queries/ we discuss and share our approach. Hopefully this helps with your question. Closing this issue but if you have further questions feel free to post on here.

nacharya1 avatar Aug 17 '23 21:08 nacharya1

@nacharya1 Thanks for sharing this blog post. I hadn't seen it before.

Is there a way to leverage this to turn into a plugin?

samleegithub avatar Aug 18 '23 00:08 samleegithub

We are currently working on a big investment on memory and storage: https://github.com/microsoft/semantic-memory

Currently, the strategy is to incorporate SQL access as part of this. Active discussion are underway on how this intersects with plug-in architecture.

crickman avatar Aug 24 '23 16:08 crickman