Skip to content

[ModelProvider] error. Reason: Empty or invalid response in batch #213

@Hankpipi

Description

@Hankpipi

I encountered the same issue as #184. Below is the script I used:

import os
import duckdb

if __name__ == "__main__":
    print("DuckDB:", duckdb.__version__)

    con = duckdb.connect(database=":memory:")
    con.execute("INSTALL flock FROM community;")
    con.execute("LOAD flock;")

    print(
        con.execute("""
                        SELECT *
                        FROM duckdb_extensions() 
                        WHERE extension_name = 'flock';""").fetchall()
    )

    openai_api_key = os.getenv("OPENAI_API_KEY")
    con.execute("CREATE SECRET (TYPE OPENAI, API_KEY ?);", [openai_api_key])

    model_alias = "test"
    base_model  = "gpt-4o"

    con.execute(f"""
        CREATE MODEL(
            '{model_alias}',
            '{base_model}',
            'openai',
            {{
                "tuple_format": "json",
                "batch_size": 32,
                "model_parameters": {{"temperature": 0.7}}
            }}
        );
    """)

    result_df = con.execute(f"""
        SELECT llm_complete(
            {{'model_name': '{model_alias}'}},
            {{'prompt': 'Talk like a duck and write a poem about a database'}}
            );
    """).fetchdf()

    print(result_df)

The output is:

DuckDB: 1.4.0
[('flock', True, True, '/home/-/.duckdb/extensions/v1.4.0/linux_amd64/flock.duckdb_extension', '', [], '7f1c36a', 'REPOSITORY', 'community')]
Traceback (most recent call last):
  File "/home/-/flock/test.py", line 37, in <module>
    result_df = con.execute(f"""
_duckdb.Error: [ModelProvider] error. Reason: Empty or invalid response in batch

I am sure that the API key is valid, as the API key works with older versions of Flock (e.g., DuckDB 1.3.0 + Flockmtl 3de4a71). Could you please help me double-check this issue?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions