Skip to contents

artopenai 0.11.0

New Feature - Interactive Chat with Streaming

  • New openai_chat() function - Creates reusable chat objects for interactive, multi-turn conversations with streaming support. Built on {ellmer} for robust provider integration.

    # Create chat object
    chat <- openai_chat(sys_prompt = "You are an art expert.")
    
    # Multi-turn conversation
    chat$chat("What is Baroque art?")
    chat$chat("How does it differ from Renaissance?")
    
    # Streaming for real-time UI
    stream <- chat$stream("Tell me about Impressionism.")
    coro::loop(for (chunk in stream) cat(chunk))
    
    # Structured output
    schema <- ellmer::type_object(
      style = ellmer::type_string("Art style"),
      period = ellmer::type_string("Time period")
    )
    chat$chat_structured("Describe Cubism", type = schema)
  • ellmer Chat object methods:

    • $chat(...) - Send message(s), receive text response
    • $stream(...) - Stream response chunks for real-time display
    • $chat_structured(prompt, type) - Extract structured data with type validation
    • $register_tool(tool) - Add tools for function calling
  • Image and file input via ellmer content helpers:

    chat$chat(ellmer::content_image_file("artwork.png"), "Describe this.")
    chat$chat(ellmer::content_image_url("https://..."), "What style?")

Use Case Guidance

Use Case Function Why
Interactive chat openai_chat() Multi-turn, streaming, session state
Pipeline/structured openai_responses() Single-turn, JSON schemas, batch
Manual conversation openai_continue() Fine-grained control

Dependencies

  • Added to Imports: ellmer (>= 0.2.0) - Provides Chat object abstraction with streaming

Integration with artcurator

This release enables artcurator to provide unified chat interfaces across providers:

# artcurator can now offer:
curator_chat_new(artist_uuid, provider = "openai")
# Returns ellmer Chat with artist context as system prompt