open-interpreter icon indicating copy to clipboard operation
open-interpreter copied to clipboard

interpreter.llm.completion = custom_language_model seems not working

Open sq2100 opened this issue 10 months ago • 3 comments

Describe the bug

I attempted to run the routine for the custom model, which is supposed to just echo back what the user said, but it was not successful.

def custom_language_model(openai_message):
    """
    OpenAI-compatible completions function (this one just echoes what the user said back).
    """
    users_content = openai_message[-1].get("content") # Get last message's content

    # To make it OpenAI-compatible, we yield this first:
    yield {"delta": {"role": "assistant"}}

    for character in users_content:
        yield {"delta": {"content": character}}

# Tell Open Interpreter to power the language model with this function

interpreter.llm.completion = custom_language_model

I attempted to make modifications to interpreter.llm.completions = custom_language_model But the parameters don't match up.

Reproduce

Run

def custom_language_model(openai_message):
    """
    OpenAI-compatible completions function (this one just echoes what the user said back).
    """
    users_content = openai_message[-1].get("content") # Get last message's content

    # To make it OpenAI-compatible, we yield this first:
    yield {"delta": {"role": "assistant"}}

    for character in users_content:
        yield {"delta": {"content": character}}

# Tell Open Interpreter to power the language model with this function

interpreter.llm.completion = custom_language_model

https://docs.openinterpreter.com/language-models/custom-models

Expected behavior

(this one just echoes what the user said back)

Screenshots

No response

Open Interpreter version

0.2.4

Python version

3.11

Operating System name and version

win 11

Additional context

No response

sq2100 avatar Apr 07 '24 09:04 sq2100