Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjoyo committed Apr 29, 2024
1 parent 0e77fb9 commit 8b0220f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bpm_ai_inference/llm/llama_cpp/_constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

DEFAULT_MODEL = "QuantFactory/dolphin-2.9-llama3-8b-GGUF"
DEFAULT_MODEL = "QuantFactory/Meta-Llama-3-8B-Instruct-GGUF"
DEFAULT_QUANT_LARGE = "*Q8_0.gguf"
DEFAULT_QUANT_BALANCED = "*Q4_K_M.gguf"
DEFAULT_QUANT_SMALL = "*Q2_K.gguf"
Expand Down
1 change: 1 addition & 0 deletions bpm_ai_inference/llm/llama_cpp/llama_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(
verbose=False
)
else:
logger.info(f"Loading model file {filename} from {model}...")
self.llm = Llama.from_pretrained(
repo_id=model,
filename=filename,
Expand Down
15 changes: 15 additions & 0 deletions bpm_ai_inference/llm/llama_cpp/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging

from bpm_ai_core.llm.common.blob import Blob
from bpm_ai_core.llm.common.message import ChatMessage, AssistantMessage, ToolResultMessage

logger = logging.getLogger(__name__)
Expand All @@ -18,6 +19,20 @@ async def message_to_llama_dict(message: ChatMessage) -> dict:
elif isinstance(message, ToolResultMessage):
tool_response_content = f"{message.content}"
content = '<tool_response>\n{"name": "' + message.name + '", "content": ' + tool_response_content + '}\n</tool_response>'
elif isinstance(message.content, list):
content = ""
for e in message.content:
if isinstance(e, str):
content += e
elif isinstance(e, Blob) and (e.is_text()):
text = (await e.as_bytes()).decode("utf-8")
filename = (" name='" + e.path + "'") if e.path else ''
text = f"\n<file{filename}>\n{text}\n</file>\n"
content += text
else:
raise ValueError(
"Elements in ChatMessage.content must be str or Blob (text)"
)
else:
content = message.content

Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bpm-ai-inference"
version = "0.2.9"
version = "0.3.1"
description = "Inference and server for local AI implementations of bpm-ai-core abstractions."
authors = ["Bennet Krause <[email protected]>"]
repository = "https://github.com/holunda-io/bpm-ai-inference"
Expand All @@ -10,7 +10,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.11,<3.12"
bpm-ai-core = "^2.6.0"
bpm-ai-core = "^2.6.1"
langfuse = "^2.7.6"
faster-whisper = "^0.10.0"
lingua-language-detector = "^2.0.2"
Expand Down

0 comments on commit 8b0220f

Please sign in to comment.