tembo-io / pg_vectorize

The simplest way to build AI workloads on Postgres
https://tembo.io/pg_vectorize/
715 stars 29 forks source link

increase embedding provider support #152

Open ChuckHend opened 6 days ago

ChuckHend commented 6 days ago

add support for embeddings from:

Embedding providers are added by implementing the required traits. For example see the implementation for Cohere

tavallaie commented 4 days ago

not only embedding but also other things beside OLLAMA like calling api can help a lot, for example I can not use it with persian embedding and some other models.

ChuckHend commented 4 days ago

We do have support for Ollama (thanks to @destrex271) - but we are pretty light on documentation on using it is.

https://github.com/tembo-io/pg_vectorize/blob/main/core/src/transformers/providers/ollama.rs

tavallaie commented 4 days ago

can we change this

We do have support for Ollama (thanks to @destrex271) - but we are pretty light on documentation on using it is.

https://github.com/tembo-io/pg_vectorize/blob/main/core/src/transformers/providers/ollama.rs

can you change this pub const OLLAMA_BASE_URL: &str = "http://localhost:3001"; to env variables and optional apikey ? so we can support other online ollama like compatible webservices

ChuckHend commented 4 days ago

Yes it can be changed. It is a configuration is Postgres:

When you run this with docker-compose it gets set to the docker service name by default.

postgres=# show vectorize.ollama_service_url ;
   vectorize.ollama_service_url   
----------------------------------
 http://ollama-serve:3001/v1/chat
(1 row)

but it can be set to whatever value you want, e.g. ALTER SYSTEM SET vectorize.ollama_service_url to 'https://www.myservice.ai/embeddings'. The assumption here is that whatever service running at vectorize.ollama_service_url has an API (request and response) schema exactly like Ollama's.

Similarly, you can change the OpenAI url so long as the server running has the same API schema as OpenAI

postgres=# show vectorize.openai_service_url ;
 vectorize.openai_service_url 
------------------------------
 https://api.openai.com/v1
(1 row)

All the Postgres settings that can be changed are defined here: https://github.com/tembo-io/pg_vectorize/blob/main/extension/src/guc.rs

tavallaie commented 4 days ago

Let me try it

ChuckHend commented 3 days ago

Let me know if you run into any issues. Can ping me here, or in the Tembo community slack.

algora-pbc[bot] commented 1 day ago

💎 $150 bounty • Tembo

Steps to solve:

  1. Start working: Comment /attempt #152 with your implementation plan
  2. Submit work: Create a pull request including /claim #152 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to tembo-io/pg_vectorize!

Add a bounty • Share on socials