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

[FEAT] Add support for OllamaEmbeddings in Chonkie #139

Open
chenzf11 opened this issue Jan 7, 2025 · 1 comment
Open

[FEAT] Add support for OllamaEmbeddings in Chonkie #139

chenzf11 opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@chenzf11
Copy link

chenzf11 commented Jan 7, 2025

I need to call the local ollama model, and that's how I'm using chonkie now

from chonkie import SemanticChunker
from chonkie import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
    url="http://x.x.x.x:11434/v1",
    model="bge-m3:latest",
    api_key="ollama",
)

# Basic initialization with default parameters
chunker = SemanticChunker(
    embedding_model=embeddings,                     # Default model
    threshold=0.5,                               # Similarity threshold (0-1) or (1-100) or "auto"
    chunk_size=500,                              # Maximum tokens per chunk
    min_sentences=1                              # Initial sentences per chunk
)

and in thechonkie/src/chonkie/embeddings/openai.py, add url parameter to use

self.client = OpenAI(
            base_url=url,
            api_key=api_key or os.getenv("OPENAI_API_KEY"),
            organization=organization,
            timeout=timeout,
            max_retries=max_retries,
        )
@chenzf11 chenzf11 added the enhancement New feature or request label Jan 7, 2025
@bhavnicksm bhavnicksm changed the title [FEAT] chonkie adds support for the ollama model [FEAT] Add support for OllamaEmbeddings in Chonkie Jan 7, 2025
@bhavnicksm
Copy link
Collaborator

Hey @chenzf11! 😄

Thanks for opening a feature request! We have actually thought about this before and added it to our ROADMAP (#123).

Happy to accept PRs for this if you're working on it! Though we would probably try to support it as it's own independent Embeddings implementation inheriting from the BaseEmbeddings class.

Thanks! 😊

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

No branches or pull requests

2 participants