mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

bug: `sqlite3.OperationalError: no such tokenizer: trigram`

Open ArnavK-09 opened this issue 2 years ago • 6 comments

🐛 Describe the bug

Error using OpenApp(), discord bot example.

import os

import discord
from discord.ext import commands
from dotenv import load_dotenv
from embedchain import OpenSourceApp
from embedchain import App

load_dotenv()
intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="/ec ", intents=intents)
root_folder = os.getcwd()


def initialize_chat_bot():
    global chat_bot
    chat_bot = OpenSourceApp()


@bot.event
async def on_ready():
    print(f"Logged in as {bot.user.name}")
    initialize_chat_bot()


@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        await send_response(ctx, "Invalid command. Please refer to the documentation for correct syntax.")
    else:
        print("Error occurred during command execution:", error)


@bot.command()
async def add(ctx, data_type: str, *, url_or_text: str):
    print(f"User: {ctx.author.name}, Data Type: {data_type}, URL/Text: {url_or_text}")
    try:
        chat_bot.add(data_type, url_or_text)
        await send_response(ctx, f"Added {data_type} : {url_or_text}")
    except Exception as e:
        await send_response(ctx, f"Failed to add {data_type} : {url_or_text}")
        print("Error occurred during 'add' command:", e)


@bot.command()
async def query(ctx, *, question: str):
    print(f"User: {ctx.author.name}, Query: {question}")
    try:
        response = chat_bot.chat(question)
        await send_response(ctx, response)
    except Exception as e:
        await send_response(ctx, "An error occurred. Please try again!")
        print("Error occurred during 'query' command:", e)


async def send_response(ctx, message):
    if ctx.guild is None:
        await ctx.send(message)
    else:
        await ctx.reply(message)


bot.run("<token>")
2023-09-02 18:16:17 INFO     discord.client logging in using static token
2023-09-02 18:16:18 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 4e937e35e579a5c4aa0b50e02eaa0f68).
Logged in as Alpha Botty
2023-09-02 18:16:43 ERROR    discord.client Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/client.py", line 441, in _run_event
    await coro(*args, **kwargs)
  File "/workspaces/test/emebdchaintest.py", line 38, in on_ready
    initialize_chat_bot()
  File "/workspaces/test/emebdchaintest.py", line 32, in initialize_chat_bot
    chat_bot = OpenSourceApp()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/apps/OpenSourceApp.py", line 28, in __init__
    config = OpenSourceAppConfig()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/config/apps/OpenSourceAppConfig.py", line 36, in __init__
    super().__init__(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/config/apps/BaseAppConfig.py", line 43, in __init__
    self.db = BaseAppConfig.get_db(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/config/apps/BaseAppConfig.py", line 87, in get_db
    return ChromaDB(embedding_fn=embedding_fn, host=host, port=port)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/vectordb/chroma_db.py", line 37, in __init__
    self.client = chromadb.PersistentClient(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/__init__.py", line 47, in PersistentClient
    return Client(settings)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/__init__.py", line 86, in Client
    system.start()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/config.py", line 205, in start
    component.start()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/impl/sqlite.py", line 92, in start
    self.initialize_migrations()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/migrations.py", line 128, in initialize_migrations
    self.apply_migrations()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/migrations.py", line 156, in apply_migrations
    self.apply_migration(cur, migration)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/impl/sqlite.py", line 209, in apply_migration
    cur.executescript(migration["sql"])
sqlite3.OperationalError: no such tokenizer: trigram
ERROR:discord.client:Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/client.py", line 441, in _run_event
    await coro(*args, **kwargs)
  File "/workspaces/test/emebdchaintest.py", line 38, in on_ready
    initialize_chat_bot()
  File "/workspaces/test/emebdchaintest.py", line 32, in initialize_chat_bot
    chat_bot = OpenSourceApp()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/apps/OpenSourceApp.py", line 28, in __init__
    config = OpenSourceAppConfig()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/config/apps/OpenSourceAppConfig.py", line 36, in __init__
    super().__init__(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/config/apps/BaseAppConfig.py", line 43, in __init__
    self.db = BaseAppConfig.get_db(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/config/apps/BaseAppConfig.py", line 87, in get_db
    return ChromaDB(embedding_fn=embedding_fn, host=host, port=port)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/embedchain/vectordb/chroma_db.py", line 37, in __init__
    self.client = chromadb.PersistentClient(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/__init__.py", line 47, in PersistentClient
    return Client(settings)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/__init__.py", line 86, in Client
    system.start()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/config.py", line 205, in start
    component.start()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/impl/sqlite.py", line 92, in start
    self.initialize_migrations()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/migrations.py", line 128, in initialize_migrations
    self.apply_migrations()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/migrations.py", line 156, in apply_migrations
    self.apply_migration(cur, migration)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/chromadb/db/impl/sqlite.py", line 209, in apply_migration
    cur.executescript(migration["sql"])
sqlite3.OperationalError: no such tokenizer: trigram

ArnavK-09 avatar Sep 02 '23 18:09 ArnavK-09

Please run

import sqlite3
print(sqlite3.sqlite_version_info)

and tell us what it says.

cachho avatar Sep 02 '23 18:09 cachho

Please run

import sqlite3
print(sqlite3.sqlite_version_info)

and tell us what it says.

(3, 31, 1)

ArnavK-09 avatar Sep 02 '23 18:09 ArnavK-09

@cachho

ArnavK-09 avatar Sep 02 '23 18:09 ArnavK-09

(3, 31, 1)

You need at least 3.35.0.

Are you on Mac? We have a function that automatically swaps in the latest pysqlite3-binary on linux, but Chroma told me we should only use it on linux.

cachho avatar Sep 03 '23 09:09 cachho

(3, 31, 1)

You need at least 3.35.0.

Are you on Mac? We have a function that automatically swaps in the latest pysqlite3-binary on linux, but Chroma told me we should only use it on linux.

@cachho

Umm I'm on linuix, GitHub codeapacea

ArnavK-09 avatar Sep 03 '23 09:09 ArnavK-09

assigning it to @sidmohanty11

taranjeet avatar Dec 14 '23 08:12 taranjeet