Fix issue with model defaults and bump version

This commit is contained in:
LUIS NOVO 2024-10-30 18:28:29 -03:00
parent 68cd7d7dda
commit 2f2cdabd2d
8 changed files with 83 additions and 49 deletions

View file

@ -51,3 +51,7 @@ docker-update-latest: docker-buildx-prepare
# Release with latest
docker-release-all: docker-release docker-update-latest
dev:
docker compose -f docker-compose.dev.yml up --build

View file

@ -29,7 +29,7 @@ services:
open_notebook:
image: lfnovo/open_notebook:latest
ports:
- "8502:8502"
- "8080:8502"
env_file:
- ./docker.env
depends_on:
@ -52,16 +52,29 @@ Go to the [Usage](docs/USAGE.md) page to learn how to use all features.
- **Multi-Notebook Support**: Organize your research across multiple notebooks effortlessly.
- **Broad Content Integration**: Works with links, PDFs, TXT files, PowerPoint presentations, YouTube videos, and pasted text (audio/video support coming soon).
- **Multi-model support**: Open AI, Anthropic, Gemini, Vertex AI, Open Router, Ollama.
- **Podcast Generator**: Automatically convert your notes into a podcast format.
- **Broad Content Integration**: Works with links, PDFs, EPUB, Office, TXT, Markdown files, YouTube videos, Audio files, Video files and pasted text.
- **AI-Powered Notes**: Write notes yourself or let the AI assist you in generating insights.
- **Recursive Summarization**: Tackle large content by recursively summarizing it.
- **Integrated Search Engines**: Built-in full-text and vector search for faster information retrieval.
- **Fine-Grained Context Management**: Choose exactly what to share with the AI to maintain control.
- **Podcast Generator**: Automatically convert your notes into a podcast format.
- **Multi-model support**: Open AI, Anthropic, Gemini, Vertex AI, Open Router, Ollama.
## 🚀 New Features
### v0.0.7 - Model Management 🗂️
- Manage your AI models and providers in a single interface
- Define default models for several tasks such as chat, transformation, embedding, etc
- Enabled support for Embedding models from Gemini, Vertex and Ollama
### v0.0.6 - ePub and Office files support 📄
You can now process ePub and Office files (Word, Excel, PowerPoint), extracting text and insights from them. Perfect for books, reports, presentations, and more.
### v0.0.5 - Audio and Video support 📽️
You can now process audio and video files, extracting transcripts and insights from them. Perfect for podcasts, interviews, lectures, and more.
### v0.0.4 - Podcasts 🎙️
You can now build amazing custom podcasts based on your own data. Customize your speakers, episode structure, cadence, voices, etc.

View file

@ -1,9 +1,13 @@
import streamlit as st
from open_notebook.config import DEFAULT_MODELS
from open_notebook.database.migrate import MigrationManager
# from open_notebook.config import DEFAULT_MODELS
from open_notebook.domain.models import DefaultModels
from stream_app.utils import version_sidebar
default_models = DefaultModels.load()
version_sidebar()
mm = MigrationManager()
if mm.needs_migration:
@ -13,27 +17,25 @@ if mm.needs_migration:
st.success("Migration successful")
st.rerun()
elif (
not DEFAULT_MODELS.default_chat_model
or not DEFAULT_MODELS.default_transformation_model
not default_models.default_chat_model
or not default_models.default_transformation_model
):
st.warning(
"You don't have default chat and transformation models selected. Please, select them on the settings page."
)
st.stop()
elif not DEFAULT_MODELS.default_embedding_model:
elif not default_models.default_embedding_model:
st.warning(
"You don't have a default embedding model selected. Vector search will not be possible and your assistant will be less able to answer your queries. Please, select one on the settings page."
)
st.stop()
elif not DEFAULT_MODELS.default_speech_to_text_model:
elif not default_models.default_speech_to_text_model:
st.warning(
"You don't have a default speech to text model selected. Your assistant will not be able to transcribe audio. Please, select one on the settings page."
)
elif not DEFAULT_MODELS.default_text_to_speech_model:
elif not default_models.default_text_to_speech_model:
st.warning(
"You don't have a default text to speech model selected. Your assistant will not be able to generate audio and podcasts. Please, select one on the settings page."
)
elif not DEFAULT_MODELS.large_context_model:
elif not default_models.large_context_model:
st.warning(
"You don't have a large context model selected. Your assistant will not be able to process large documents. Please, select one on the settings page."
)

View file

@ -104,7 +104,7 @@ or the shourcut
make run
```
## Setting up the providers
## Setting up the providers and models
Several new providers are supported now:
@ -120,30 +120,33 @@ All providers are installed out of the box. All you need to do is to setup the e
Please refer to the `.env.example` file for instructions on which ENV variables are necessary for each.
### Use provider-modelname convention
### Create models on the Settings page
You should prepend the provider name to the model_name when setting up your env variables, examples:
Go to the settings page and create your different models.
- openai/gpt-4o-mini
- anthropic/claude-3-5-sonnet-20240620
- ollama/gemma2
- openrouter/nvidia/llama-3.1-nemotron-70b-instruct
- vertexai/gemini-1.5-flash-001
- gemini/gemini-1.5-flash-001
| Model Type | Supported Providers |
|------------|-----------|
| Language | OpenAI, Anthropic, Open Router, LiteLLM, Vertex AI, Vertex AI, Anthropic, Gemini, Ollama |
| Embedding | OpenAI, Gemini, Vertex AI, Ollama |
| Speech to Text | OpenAI |
| Text to Speech | OpenAI, ElevenLabs |
__There will be a UI configuration for models in the coming days.__
## Setup 2 models for more flexibility
> 📝 **Notice:** For complete usage of all the features, you need to setup at least 4 models (one of each type).
There are 2 configurations for models at this point:
After setting up the models, head to the Model Defaults tab to define the default models. There are several defaults to setup.
```
DEFAULT_MODEL="openai/gpt-4o-mini"
SUMMARIZATION_MODEL="openrouter/nvidia/llama-3.1-nemotron-70b-instruct"
```
- **DEFAULT_MODEL** is used by the chat tool
- **SUMMARIZATION_MODEL (optional)** is used on the content summarization
| Model Default | Purpose |
|------------|-----------|
| Chat Model | Will be used on all chats |
| Transformation Model | Will be used for summaries, insights, etc |
| Large Context | For content higher then 110k tokens (use Gemini here) |
| Speech to Text | For transcribing text from your audio/video uploads |
| Text to Speech | For generating podcasts |
| Embedding | For creating vector representation of content |
All model types and defaults are required for now. If you are not sure which to pick, go with OpenAI, the only one that covers all possible model types.
The reason for opting for this route is because different LLMs, will behave better/worse depending on the type of request and type of tools offered. So it makes sense to build a more refined system to decide which model should process which task.

View file

@ -38,10 +38,16 @@ os.makedirs(PODCASTS_FOLDER, exist_ok=True)
DEFAULT_MODELS = DefaultModels.load()
EMBEDDING_MODEL = get_model(
DEFAULT_MODELS.default_embedding_model, model_type="embedding"
)
if DEFAULT_MODELS.default_embedding_model:
EMBEDDING_MODEL = get_model(
DEFAULT_MODELS.default_embedding_model, model_type="embedding"
)
else:
EMBEDDING_MODEL = None
SPEECH_TO_TEXT_MODEL = get_model(
DEFAULT_MODELS.default_speech_to_text_model, model_type="speech_to_text"
)
if DEFAULT_MODELS.default_speech_to_text_model:
SPEECH_TO_TEXT_MODEL = get_model(
DEFAULT_MODELS.default_speech_to_text_model, model_type="speech_to_text"
)
else:
SPEECH_TO_TEXT_MODEL = None

View file

@ -1,6 +1,5 @@
from typing import ClassVar, Optional
from loguru import logger
from pydantic import BaseModel
from open_notebook.database.repository import (
@ -37,8 +36,10 @@ class DefaultModels(BaseModel):
def load(self):
result = repo_query("SELECT * FROM open_notebook:default_models;")
if result:
logger.debug(result)
return DefaultModels(**result[0])
result = result[0]
dm = DefaultModels(**result)
return dm
return DefaultModels()
@classmethod
def update(self, data):

View file

@ -65,7 +65,6 @@ with model_tab:
st.caption(
f"Unavailable Providers: {', '.join(unavailable_providers)}. Please check docs page if you wish to enable them."
)
model_name = st.text_input("Model Name", "")
# Filter model types based on provider availability in MODEL_CLASS_MAP
available_model_types = []
@ -76,7 +75,14 @@ with model_tab:
if not available_model_types:
st.error(f"No compatible model types available for provider: {provider}")
else:
model_type = st.selectbox("Model Type", available_model_types)
model_type = st.selectbox(
"Model Type",
available_model_types,
help="Use language for text generation models, text_to_speech for TTS models for generating podcasts, etc.",
)
model_name = st.text_input(
"Model Name", "", help="gpt-4o-mini, claude, gemini, llama3, etc"
)
if st.button("Save"):
model = Model(name=model_name, provider=provider, type=model_type)
model.save()
@ -209,9 +215,8 @@ with model_defaults_tab:
"Caution: you cannot change the embedding model once there is embeddings or they will need to be regenerated"
)
# if st.button("Save Defaults", key="save_defaults"):
for k, v in defs.items():
defs[k] = v.id
if st.button("Save Defaults", key="save_defaults"):
DefaultModels.update(defs)
st.rerun()
if v:
defs[k] = v.id
DefaultModels.update(defs)

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "open-notebook"
version = "0.0.6"
version = "0.0.7"
description = "An open source implementation of a research assistant, inspired by Google Notebook LM"
authors = ["Luis Novo <lfnovo@gmail.com>"]
license = "MIT"