xref: /plugin/aichat/_test/ModelOllamaTest.php (revision acf2d4e085b8eb23a2b5038da937926c79e0773f)
1f8753427SAndreas Gohr (aider)<?php
2f8753427SAndreas Gohr (aider)
3f8753427SAndreas Gohr (aider)namespace dokuwiki\plugin\aichat\test;
4f8753427SAndreas Gohr (aider)
5*acf2d4e0SAndreas Gohruse dokuwiki\HTTP\DokuHTTPClient;
6*acf2d4e0SAndreas Gohr
7f8753427SAndreas Gohr (aider)/**
8f8753427SAndreas Gohr (aider) * Ollama Model Test
9f8753427SAndreas Gohr (aider) *
10f8753427SAndreas Gohr (aider) * @group plugin_aichat
11f8753427SAndreas Gohr (aider) * @group plugins
12f8753427SAndreas Gohr (aider) * @group internet
13f8753427SAndreas Gohr (aider) */
14f8753427SAndreas Gohr (aider)class ModelOllamaTest extends AbstractModelTest
15f8753427SAndreas Gohr (aider){
16f8753427SAndreas Gohr (aider)    protected string $provider = 'Ollama';
17d72a84c5SAndreas Gohr    protected string $api_key_env = '';
18f8753427SAndreas Gohr (aider)    protected string $chat_model = 'llama3.2';
19f8753427SAndreas Gohr (aider)    protected string $embedding_model = 'nomic-embed-text';
20*acf2d4e0SAndreas Gohr
21*acf2d4e0SAndreas Gohr    public function setUp(): void
22*acf2d4e0SAndreas Gohr    {
23*acf2d4e0SAndreas Gohr        global $conf;
24*acf2d4e0SAndreas Gohr        parent::setUp();
25*acf2d4e0SAndreas Gohr
26*acf2d4e0SAndreas Gohr        $conf['plugin']['aichat']['ollama_apiurl'] = 'http://localhost:11434/api';
27*acf2d4e0SAndreas Gohr        $url = $conf['plugin']['aichat']['ollama_apiurl'] . '/version';
28*acf2d4e0SAndreas Gohr
29*acf2d4e0SAndreas Gohr        $http = new DokuHTTPClient();
30*acf2d4e0SAndreas Gohr        $http->timeout = 4;
31*acf2d4e0SAndreas Gohr        $result = $http->get($url);
32*acf2d4e0SAndreas Gohr
33*acf2d4e0SAndreas Gohr        if (!$result) $this->markTestSkipped('Local Ollama server seems not to be available.');
34*acf2d4e0SAndreas Gohr    }
35f8753427SAndreas Gohr (aider)}
36