fix: 🐛 fixes to templating messages
This commit is contained in:
parent
ffc242ef2a
commit
c56e24d2a5
3 changed files with 13 additions and 6 deletions
|
|
@ -6,7 +6,7 @@ from pydantic import Field
|
|||
|
||||
from ...core.main import ChatMessage
|
||||
from ..llm import LLM, CompletionOptions
|
||||
from .prompts.chat import code_llama_template_messages
|
||||
from .prompts.chat import llama2_template_messages
|
||||
from .prompts.edit import simplified_edit_prompt
|
||||
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ class HuggingFaceTGI(LLM):
|
|||
"http://localhost:8080", description="URL of your TGI server"
|
||||
)
|
||||
|
||||
template_messages: Callable[[List[ChatMessage]], str] = code_llama_template_messages
|
||||
template_messages: Callable[[List[ChatMessage]], str] = llama2_template_messages
|
||||
|
||||
prompt_templates = {
|
||||
"edit": simplified_edit_prompt,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import json
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, Callable, Dict, List, Union
|
||||
|
||||
import websockets
|
||||
from pydantic import Field
|
||||
|
||||
from ...core.main import ChatMessage
|
||||
from . import LLM
|
||||
from .prompts.chat import llama2_template_messages
|
||||
from .prompts.edit import simplest_edit_prompt
|
||||
|
||||
|
||||
|
|
@ -40,6 +41,10 @@ class TextGenUI(LLM):
|
|||
"edit": simplest_edit_prompt,
|
||||
}
|
||||
|
||||
template_messages: Union[
|
||||
Callable[[List[Dict[str, str]]], str], None
|
||||
] = llama2_template_messages
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ already_saw_import_err = False
|
|||
|
||||
def encoding_for_model(model_name: str):
|
||||
global already_saw_import_err
|
||||
if already_saw_import_err:
|
||||
return None
|
||||
|
||||
try:
|
||||
import tiktoken
|
||||
from tiktoken_ext import openai_public # noqa: F401
|
||||
|
|
@ -32,9 +35,8 @@ def encoding_for_model(model_name: str):
|
|||
except Exception as _:
|
||||
return tiktoken.encoding_for_model("gpt-3.5-turbo")
|
||||
except Exception as e:
|
||||
if not already_saw_import_err:
|
||||
print("Error importing tiktoken", e)
|
||||
already_saw_import_err = True
|
||||
print("Error importing tiktoken", e)
|
||||
already_saw_import_err = True
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue