// GLM 4.7 chat via Cerebras — non-streaming example.
//
// Run with:
//   tetherscript run \
//     --grant-provider https://api.cerebras.ai \
//     --grant-provider-key $CEREBRAS_API_KEY \
//     examples/glm_chat.tether
//
// Requires a Cerebras API key: https://cloud.cerebras.ai/

fn main() {
    // Check what we're connected to
    let info = provider.describe().unwrap()
    println("Provider endpoint: " + info.endpoint)
    println("Provider scheme: " + info.scheme)
    println("Provider path: " + info.path)

    // Build messages
    let messages = []
    let sys = map()
    sys.role = "system"
    sys.content = "You are a helpful assistant. Reply in one short sentence."
    messages.push(sys)

    let user = map()
    user.role = "user"
    user.content = "What are the advantages of GLM 4.7?"
    messages.push(user)

    // GLM 4.7 options
    let opts = map()
    opts.model = "zai-glm-4.7"
    opts.max_completion_tokens = 4000
    opts.temperature = 1
    opts.top_p = 0.95
    opts.reasoning_effort = "none"
    opts.clear_thinking = false

    println("")
    println("Sending GLM 4.7 chat request...")
    let result = provider.chat(messages, opts)
    if result.is_ok() {
        println("Response: " + result.unwrap())
    } else {
        println("Error: " + str(result))
    }
}