from bulk_chain.api import iter_content
from bulk_chain.core.utils import dynamic_init


# Tested under: https://github.com/nicolay-r/nlp-thirdgate/blob/master/llm/openai_156.py
provider = dynamic_init(class_filepath="providers/openai_156.py")(
    base_url="https://api.novita.ai/openai",
    api_token="sk_qpuGSSuz4sF3PgWXg72wstp6-ojtYt1rX3pdXTVocPU",
    model_name="meta-llama/llama-3.3-70b-instruct")

content_it = iter_content(
    # 1. Your schema.              
    schema=[
      {"prompt": "extract topic: {text}", "out": "topic" },
      {"prompt": "extract subject: {text}", "out": "subject"},
    ],
    # 2. Your third-party model implementation.
    llm=provider,
    batch_size=10,
    # 3. Toggle streaming if needed
    stream=False,
    # 4. Toggle asynchronous mode if needed
    async_mode=True,
    # 5. Your iterator of dictionaries
    input_dicts_it=[
        { "text": "Rocks are hard" },
        { "text": "Water is wet" },
        { "text": "Fire is hot" }
    ],
)

for batch in content_it:
    for entry in batch:
        print(entry)