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

Any plans for something like open_embedding() support? #16

Open
aaronsteers opened this issue Nov 15, 2024 · 2 comments
Open

Any plans for something like open_embedding() support? #16

aaronsteers opened this issue Nov 15, 2024 · 2 comments

Comments

@aaronsteers
Copy link

First of all: I love that this extension exists! I just stumbled on it today (shared by MotherDuck team member) and I'll definitely share with others who are interested in this capability.

Do you have any plans to add something like open_embedding() as companion/complement to open_prompt() or are you aware of anyone else looking at adding it?

Thanks for all your work!

@lmangani
Copy link
Collaborator

Hello @aaronsteers and thanks for the kind words. The code is just an HTTP wrapper so we can implement new functions pretty fast if you're willing to provide a curl example and a mockup of the function/parameters this would require.

@lmangani
Copy link
Collaborator

@aaronsteers another user of our http_client extension came up with this macro:

INSTALL http_client FROM community; LOAD http_client; 
CREATE OR REPLACE MACRO embedding(q) AS ( 
WITH  __input AS (
    SELECT
      http_post(
          'https://api.openai.com/v1/embeddings',
          headers => MAP {
            'Authorization': 'Bearer sk_your_openai_key',
            'Content-Type': 'application/json; charset=UTF-8'
          },
          params =>{
            'model': 'BAAI/bge-large-zh-v1.5',
            'input': q,
            'encoding_format':'float'
          }
      ) AS res
)
-- SELECT (table __input)
SELECT json_extract(((table __input)->>'body')::JSON ,'$.data[0].embedding') as  chat_response
);
select embedding('"DuckDB"') as embedding

If this is what you're after, we can implement it in the open_prompt() extension quite easily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants