Skip to content

Commit

Permalink
change openaipikey field to apikey
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Jun 17, 2024
1 parent 6157806 commit e5eda69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/ai/ai.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ai {
*
* @var string
*/
private string $openaiapikey;
private string $apikey;

/**
* LLM Model e.g. llama2 or gpt4
Expand Down Expand Up @@ -140,7 +140,7 @@ public function prompt_completion($prompttext) {
throw new moodle_exception('misssingmodelerror', 'tool_aiconnect', '', null, 'Empty query model.');
}
$data = $this->get_prompt_data($prompttext);
$result = $this->make_request($data, $this->openaiapikey);
$result = $this->make_request($data, $this->apikey);

if (isset($result['choices'][0]['text'])) {
return $result['choices'][0]['text'];
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ Please note that the availability and functionality of these settings may depend

### Error Handling
The ai class throws moodle_exception exceptions in case of errors. You should handle these exceptions appropriately to provide meaningful feedback to the user.

PHPTests with the key are being developed and will require the following in config.php

```
define("AICONNECT_API_KEY", "putyourkeyhere");
```

0 comments on commit e5eda69

Please sign in to comment.