Skip to content

Commit

Permalink
Add python fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
slundberg committed Dec 6, 2023
1 parent fb9d70c commit 444b025
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions guidance/models/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
import time
import numpy as np
import logging
from .. import cpp as cpp
logger = logging.getLogger(__name__)
try:
from .. import cpp
except ImportError:
logger.warn("Failed to load guidance.cpp, falling back to Python mirror implementations...")
from .. import _cpp as cpp
from .._utils import ByteTrie, log_softmax, softmax
from .._parser import EarleyCommitParser
from .._grammar import StatelessFunction, string, _call_pool, _tag_pattern, Null, replace_model_variables, unreplace_model_variables, select, Terminal

logger = logging.getLogger(__name__)

# define some constants we will reuse many times
_null_grammar = string('')
format_pattern = re.compile(r"<\|\|_.*?_\|\|>", flags=re.DOTALL)
Expand Down

0 comments on commit 444b025

Please sign in to comment.