Giter Club home page Giter Club logo

Comments (3)

louis030195 avatar louis030195 commented on May 24, 2024 2

@vadi2 yes :)

You can use a local postgres for example

First, run Docker, then:

docker run -d --name pgvector -p 8080:8080 -p 5432:5432 \
    -e POSTGRES_DB=embedbase -e POSTGRES_PASSWORD=localdb \
    -v data:/var/lib/postgresql/data ankane/pgvector

This will start a Docker container with an image that can handle vector data type and semantic search queries

You can then use either OpenAI to create embeddings like so:

# main.py
import os
from embedbase import get_app
from embedbase.database.postgres_db import Postgres
from embedbase.embedding.openai import OpenAI
import uvicorn
 
# get api key here https://platform.openai.com/account/api-keys
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
 
app = (
    get_app()
    .use_embedder(OpenAI(OPENAI_API_KEY))
    .use_db(Postgres())
    .run()
)
 
if __name__ == "__main__":
    uvicorn.run("main:app", reload=True)

Make sure to install the dependencies pip install embedbase uvicorn, then you can start Embedbase:

python3 main.py

Make sure to replace references to "https://embedbase-hosted-usx5gpslaq-uc.a.run.app/v1/documentation" to "http://localhost:8000/v1/documentation" in your javascript/ts code.
We recommend using the SDK, although this tutorial does not use the SDK yet, we will update it ASAP.

You can also run a local Embedbase with a custom "embedder" such as sentence transformer as explained here if you want to keep everything local.

Please let me know if that solve your issue

from embedbase.

louis030195 avatar louis030195 commented on May 24, 2024

@vadi2
If you don't want to use Docker, you can also go with in memory database:

import uvicorn
from embedbase import get_app

from embedbase.database.memory_db import MemoryDatabase
from embedbase.embedding.openai import OpenAI
 
app = (
    get_app()
    .use_embedder(OpenAI("<your key>"))
    .use_db(MemoryDatabase())
).run()

if __name__ == "__main__":
    uvicorn.run("main:app")

from embedbase.

louis030195 avatar louis030195 commented on May 24, 2024

@vadi2 feel free to reopen the issue with if you have any other problems 😃

from embedbase.

Related Issues (20)

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.