Skip to content

Commit

Permalink
Handle empty system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianLucas committed Aug 21, 2024
1 parent 30df78f commit a3f11e6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions interpreter/core/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
litellm.REPEATED_STREAMING_CHUNK_LIMIT = 99999999

import json
import logging
import subprocess
import time
import uuid
Expand All @@ -25,10 +26,9 @@
from .run_tool_calling_llm import run_tool_calling_llm
from .utils.convert_to_openai_messages import convert_to_openai_messages

import logging

# Create or get the logger
logger = logging.getLogger('LiteLLM')
logger = logging.getLogger("LiteLLM")


class SuppressDebugFilter(logging.Filter):
def filter(self, record):
Expand All @@ -37,6 +37,7 @@ def filter(self, record):
return False # Suppress this log message
return True # Allow all other messages


class Llm:
"""
A stateless LMC-style LLM with some helpful properties.
Expand Down Expand Up @@ -265,6 +266,12 @@ def run(self, messages):

pass

# If there should be a system message, there should be a system message!
# Empty system messages appear to be deleted :(
if system_message == "":
if messages[0]["role"] != "system":
messages = [{"role": "system", "content": system_message}] + messages

## Start forming the request

params = {
Expand Down

0 comments on commit a3f11e6

Please sign in to comment.