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

Ollama Support #41

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
- Yes, you _can_ have _both_ streaming and easy database storage.

- ↔️ **Provider/model agnostic and interoperable!**
- Native support for [OpenAI](https://platform.openai.com/docs/models), [Anthropic](https://docs.anthropic.com/en/docs/welcome), [NVIDIA NIM/NGC](https://build.nvidia.com/explore/reasoning) (+ more to come).
- Core support for [OpenAI](https://platform.openai.com/docs/models) and [Anthropic](https://docs.anthropic.com/en/docs/welcome).
- Experimental support for [Ollama](https://ollama.com/search) and [NVIDIA NIM/NGC](https://build.nvidia.com/explore/reasoning).
- Message representations are canonized. 😇
- Supports vision!
- Easily build committees!
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_structured_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from dotenv import load_dotenv; load_dotenv()


MODEL_BINDER = known_models.BIND_OPENAI_gpt_4o_mini()
MODEL_BINDER = known_models.BIND_OLLAMA_mistral_small()


PROMPT = """
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ classifiers = [
dependencies = [
"svs",
"aiohttp[speedups]",
"httpx",
"python-dotenv",
"colorama",
"pydantic >= 2.7, < 3",
Expand Down
2 changes: 1 addition & 1 deletion src/lasagna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
'build_static_output_agent',
]

__version__ = "0.10.4"
__version__ = "0.11.0"
24 changes: 24 additions & 0 deletions src/lasagna/known_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@
BIND_ANTHROPIC_claude_3_haiku = partial_bind_model('anthropic', 'claude-3-haiku-20240307')


OLLAMA_KNOWN_MODELS: List[ModelRecord] = [
# We'll only list models here that (1) support tool-calling because
# that's kind of the whole point of lasagna, and (2) we've tested
# ourselves and pass our "vibe" test. Users are of course more than
# welcome to use *other* Ollama models as they see fit.
{
'formal_name': 'llama3.2',
'display_name': 'Meta Llama 3.2',
},
{
'formal_name': 'mistral-small',
'display_name': 'Mistral Small',
},
{
'formal_name': 'mistral-large',
'display_name': 'Mistral Large',
},
]

BIND_OLLAMA_llama3_2 = partial_bind_model('ollama', 'llama3.2')
BIND_OLLAMA_mistral_small = partial_bind_model('ollama', 'mistral-small')
BIND_OLLAMA_mistral_large = partial_bind_model('ollama', 'mistral-large')


NVIDIA_KNOWN_MODELS: List[ModelRecord] = [
{
'formal_name': 'meta/llama3-70b-instruct',
Expand Down
11 changes: 11 additions & 0 deletions src/lasagna/known_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def attempt_load_all_known_providers() -> None:
providers_to_try_to_load = [
'openai',
'anthropic',
'ollama',
'nvidia',
]
for provider in providers_to_try_to_load:
Expand Down Expand Up @@ -63,6 +64,16 @@ def attempt_load_known_providers(provider: str) -> None:
models = ANTHROPIC_KNOWN_MODELS,
)

elif provider == 'ollama':
from .known_models import OLLAMA_KNOWN_MODELS
from .lasagna_ollama import LasagnaOllama
register_provider(
key = 'ollama',
name = 'Ollama',
factory = LasagnaOllama,
models = OLLAMA_KNOWN_MODELS,
)

elif provider == 'nvidia':
from .known_models import NVIDIA_KNOWN_MODELS
from .lasagna_nvidia import LasagnaNVIDIA
Expand Down
Loading