-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathConversationModel.php
More file actions
94 lines (85 loc) · 2.13 KB
/
Copy pathConversationModel.php
File metadata and controls
94 lines (85 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace Typesense;
use Http\Client\Exception as HttpClientException;
use Typesense\Exceptions\TypesenseClientError;
/**
* Class ConversationModel
*
* @package \Typesense
*/
class ConversationModel
{
/**
* @var string
*/
private string $id;
/**
* @var ApiCall
*/
private ApiCall $apiCall;
/**
* ConversationModel constructor.
*
* @param string $id
* @param ApiCall $apiCall
*/
public function __construct(string $id, ApiCall $apiCall)
{
$this->id = $id;
$this->apiCall = $apiCall;
}
/**
* Update a conversation model.
*
* @example
* $client->conversations->typesenseModels['model-1']->update(['model_name' => 'openai/gpt-4', 'max_bytes' => 16384])
*
* @see https://typesense.org/docs/latest/api/conversational-search-rag.html
*
* @param array $params
*
* @return array
* @throws TypesenseClientError|HttpClientException
*/
public function update(array $params): array
{
return $this->apiCall->put($this->endPointPath(), $params);
}
/**
* Retrieve a conversation model.
*
* @example
* $client->conversations->typesenseModels['model-1']->retrieve()
*
* @see https://typesense.org/docs/latest/api/conversational-search-rag.html
*
* @return array
* @throws TypesenseClientError|HttpClientException
*/
public function retrieve(): array
{
return $this->apiCall->get($this->endPointPath(), []);
}
/**
* Delete a conversation model.
*
* @example
* $client->conversations->typesenseModels['model-1']->delete()
*
* @see https://typesense.org/docs/latest/api/conversational-search-rag.html
*
* @return array
* @throws TypesenseClientError|HttpClientException
*/
public function delete(): array
{
return $this->apiCall->delete($this->endPointPath());
}
/**
* @return string
*/
public function endPointPath(): string
{
return sprintf('%s/%s', ConversationModels::RESOURCE_PATH, encodeURIComponent($this->id));
}
}