<?php

/**
 * This class has been generated by dagger-php-sdk. DO NOT EDIT.
 */

declare(strict_types=1);

namespace Dagger;

class LLM extends Client\AbstractObject implements Client\IdAble
{
    /**
     * create a branch in the LLM's history
     */
    public function attempt(int $number): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('attempt');
        $innerQueryBuilder->setArgument('number', $number);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * returns the type of the current state
     */
    public function bindResult(string $name): Binding
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('bindResult');
        $innerQueryBuilder->setArgument('name', $name);
        return new \Dagger\Binding($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * return the LLM's current environment
     */
    public function env(): Env
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('env');
        return new \Dagger\Env($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Indicates whether there are any queued prompts or tool results to send to the model
     */
    public function hasPrompt(): bool
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('hasPrompt');
        return (bool)$this->queryLeaf($leafQueryBuilder, 'hasPrompt');
    }

    /**
     * return the llm message history
     */
    public function history(): array
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('history');
        return (array)$this->queryLeaf($leafQueryBuilder, 'history');
    }

    /**
     * return the raw llm message history as json
     */
    public function historyJSON(): Json
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('historyJSON');
        return new \Dagger\Json((string)$this->queryLeaf($leafQueryBuilder, 'historyJSON'));
    }

    /**
     * A unique identifier for this LLM.
     */
    public function id(): LLMId
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('id');
        return new \Dagger\LLMId((string)$this->queryLeaf($leafQueryBuilder, 'id'));
    }

    /**
     * return the last llm reply from the history
     */
    public function lastReply(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('lastReply');
        return (string)$this->queryLeaf($leafQueryBuilder, 'lastReply');
    }

    /**
     * Submit the queued prompt, evaluate any tool calls, queue their results, and keep going until the model ends its turn
     */
    public function loop(): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('loop');
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * return the model used by the llm
     */
    public function model(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('model');
        return (string)$this->queryLeaf($leafQueryBuilder, 'model');
    }

    /**
     * return the provider used by the llm
     */
    public function provider(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('provider');
        return (string)$this->queryLeaf($leafQueryBuilder, 'provider');
    }

    /**
     * Submit the queued prompt or tool call results, evaluate any tool calls, and queue their results
     */
    public function step(): LLMId
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('step');
        return new \Dagger\LLMId((string)$this->queryLeaf($leafQueryBuilder, 'step'));
    }

    /**
     * synchronize LLM state
     */
    public function sync(): LLMId
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('sync');
        return new \Dagger\LLMId((string)$this->queryLeaf($leafQueryBuilder, 'sync'));
    }

    /**
     * returns the token usage of the current state
     */
    public function tokenUsage(): LLMTokenUsage
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('tokenUsage');
        return new \Dagger\LLMTokenUsage($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * print documentation for available tools
     */
    public function tools(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('tools');
        return (string)$this->queryLeaf($leafQueryBuilder, 'tools');
    }

    /**
     * Return a new LLM with the specified function no longer exposed as a tool
     */
    public function withBlockedFunction(string $typeName, string $function): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withBlockedFunction');
        $innerQueryBuilder->setArgument('typeName', $typeName);
        $innerQueryBuilder->setArgument('function', $function);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * allow the LLM to interact with an environment via MCP
     */
    public function withEnv(EnvId|Env $env): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withEnv');
        $innerQueryBuilder->setArgument('env', $env);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Add an external MCP server to the LLM
     */
    public function withMCPServer(string $name, ServiceId|Service $service): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withMCPServer');
        $innerQueryBuilder->setArgument('name', $name);
        $innerQueryBuilder->setArgument('service', $service);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * swap out the llm model
     */
    public function withModel(string $model): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withModel');
        $innerQueryBuilder->setArgument('model', $model);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * append a prompt to the llm context
     */
    public function withPrompt(string $prompt): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withPrompt');
        $innerQueryBuilder->setArgument('prompt', $prompt);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * append the contents of a file to the llm context
     */
    public function withPromptFile(FileId|File $file): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withPromptFile');
        $innerQueryBuilder->setArgument('file', $file);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Use a static set of tools for method calls, e.g. for MCP clients that do not support dynamic tool registration
     */
    public function withStaticTools(): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withStaticTools');
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Add a system prompt to the LLM's environment
     */
    public function withSystemPrompt(string $prompt): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withSystemPrompt');
        $innerQueryBuilder->setArgument('prompt', $prompt);
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Disable the default system prompt
     */
    public function withoutDefaultSystemPrompt(): LLM
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withoutDefaultSystemPrompt');
        return new \Dagger\LLM($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }
}
