- 
                Notifications
    You must be signed in to change notification settings 
- Fork 105
Add conversational search #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 28 commits
      Commits
    
    
            Show all changes
          
          
            29 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      7604609
              
                Add method to update workspace settings
              
              
                Strift 4897fbf
              
                add CRUD methods
              
              
                Strift 51f4400
              
                Refactor
              
              
                Strift cd2b8df
              
                Add chat completion streaming
              
              
                Strift e52759c
              
                Lint
              
              
                Strift 1395b8d
              
                Run phpstan
              
              
                Strift f87bde4
              
                Fix doc types
              
              
                Strift b063d4b
              
                Add get/update methods for chat settings
              
              
                Strift b09585f
              
                Fix incorrect exception catch block
              
              
                Strift 0cc3972
              
                lint
              
              
                Strift 2b98215
              
                Update src/Http/Client.php
              
              
                Strift bde19cc
              
                Update src/Http/Client.php
              
              
                Strift c2ee6ca
              
                Merge branch 'main' into feat/add-chat-api
              
              
                Strift cb6c0bb
              
                Improve chat workspaces type hints
              
              
                Strift b6ae3bb
              
                Make workspaceName non-empty-string
              
              
                Strift c91b873
              
                Throw exception if token is not available
              
              
                Strift dd6aef9
              
                Update types and tests
              
              
                Strift 340b57f
              
                Merge branch 'main' into feat/add-chat-api
              
              
                Strift eafe1f2
              
                Merge branch 'main' into feat/add-chat-api
              
              
                Strift d78323d
              
                Update src/Contracts/ChatWorkspacesResults.php
              
              
                Strift 4dce531
              
                Update src/Contracts/ChatWorkspacesResults.php
              
              
                Strift 72e933e
              
                Require prompts settings search params to be non-empty
              
              
                Strift 586c3c6
              
                Add type hints to chat workspace settings
              
              
                Strift fb27035
              
                Added typehints to chat workspaces results
              
              
                Strift 56c6996
              
                Add import and use only class name
              
              
                Strift 84b8ee0
              
                Lint
              
              
                Strift f67b66b
              
                Import streaminterface and use class name
              
              
                Strift 4990e74
              
                Make class attributes private
              
              
                Strift 2b0b414
              
                Make chats property private
              
              
                Strift File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace Meilisearch\Contracts; | ||
|  | ||
| /** | ||
| * @phpstan-type ChatWorkspacePromptsArray array{ | ||
| * system: string, | ||
| * searchDescription: string, | ||
| * searchQParam: non-empty-string, | ||
| * searchIndexUidParam: non-empty-string | ||
| * } | ||
| */ | ||
| class ChatWorkspacePromptsSettings extends Data | ||
| { | ||
| private string $system; | ||
| private string $searchDescription; | ||
| /** | ||
| * @var non-empty-string | ||
| */ | ||
| private string $searchQParam; | ||
| /** | ||
| * @var non-empty-string | ||
| */ | ||
| private string $searchIndexUidParam; | ||
|  | ||
| /** | ||
| * @param ChatWorkspacePromptsArray $params | ||
| */ | ||
| public function __construct(array $params) | ||
| { | ||
| parent::__construct($params); | ||
|  | ||
| $this->system = $params['system']; | ||
| $this->searchDescription = $params['searchDescription']; | ||
| $this->searchQParam = $params['searchQParam']; | ||
| $this->searchIndexUidParam = $params['searchIndexUidParam']; | ||
| } | ||
|  | ||
| public function getSystem(): string | ||
| { | ||
| return $this->system; | ||
| } | ||
|  | ||
| public function getSearchDescription(): string | ||
| { | ||
| return $this->searchDescription; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string | ||
| */ | ||
| public function getSearchQParam(): string | ||
| { | ||
| return $this->searchQParam; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string | ||
| */ | ||
| public function getSearchIndexUidParam(): string | ||
| { | ||
| return $this->searchIndexUidParam; | ||
| } | ||
|  | ||
| /** | ||
| * @return ChatWorkspacePromptsArray | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'system' => $this->system, | ||
| 'searchDescription' => $this->searchDescription, | ||
| 'searchQParam' => $this->searchQParam, | ||
| 'searchIndexUidParam' => $this->searchIndexUidParam, | ||
| ]; | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace Meilisearch\Contracts; | ||
|  | ||
| /** | ||
| * @phpstan-type ChatWorkspaceSource 'openAi'|'azureOpenAi'|'mistral'|'gemini'|'vLlm' | ||
| */ | ||
| class ChatWorkspaceSettings extends Data | ||
|         
                  Strift marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| { | ||
| /** | ||
| * @var ChatWorkspaceSource | ||
| */ | ||
| private string $source; | ||
| /** | ||
| * @var non-empty-string|null | ||
| */ | ||
| private ?string $orgId; | ||
| /** | ||
| * @var non-empty-string|null | ||
| */ | ||
| private ?string $projectId; | ||
| /** | ||
| * @var non-empty-string|null | ||
| */ | ||
| private ?string $apiVersion; | ||
| /** | ||
| * @var non-empty-string|null | ||
| */ | ||
| private ?string $deploymentId; | ||
| /** | ||
| * @var non-empty-string|null | ||
| */ | ||
| private ?string $baseUrl; | ||
| private ?string $apiKey; | ||
| private ChatWorkspacePromptsSettings $prompts; | ||
|  | ||
| /** | ||
| * @param array{ | ||
| * source: ChatWorkspaceSource, | ||
| * orgId?: non-empty-string, | ||
| * projectId?: non-empty-string, | ||
| * apiVersion?: non-empty-string, | ||
| * deploymentId?: non-empty-string, | ||
| * baseUrl?: non-empty-string, | ||
| * apiKey?: string, | ||
| * prompts: array{ | ||
| * system: string, | ||
| * searchDescription: string, | ||
| * searchQParam: non-empty-string, | ||
| * searchIndexUidParam: non-empty-string | ||
| * } | ||
| * } $params | ||
| */ | ||
| public function __construct(array $params) | ||
| { | ||
| parent::__construct($params); | ||
|  | ||
| $this->source = $params['source']; | ||
| $this->orgId = $params['orgId'] ?? null; | ||
| $this->projectId = $params['projectId'] ?? null; | ||
| $this->apiVersion = $params['apiVersion'] ?? null; | ||
| $this->deploymentId = $params['deploymentId'] ?? null; | ||
| $this->baseUrl = $params['baseUrl'] ?? null; | ||
| $this->apiKey = $params['apiKey'] ?? null; | ||
| $this->prompts = new ChatWorkspacePromptsSettings($params['prompts']); | ||
| } | ||
|  | ||
| /** | ||
| * @return ChatWorkspaceSource | ||
| */ | ||
| public function getSource(): string | ||
| { | ||
| return $this->source; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string|null | ||
| */ | ||
| public function getOrgId(): ?string | ||
| { | ||
| return $this->orgId; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string|null | ||
| */ | ||
| public function getProjectId(): ?string | ||
| { | ||
| return $this->projectId; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string|null | ||
| */ | ||
| public function getApiVersion(): ?string | ||
| { | ||
| return $this->apiVersion; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string|null | ||
| */ | ||
| public function getDeploymentId(): ?string | ||
| { | ||
| return $this->deploymentId; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string|null | ||
| */ | ||
| public function getBaseUrl(): ?string | ||
| { | ||
| return $this->baseUrl; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-empty-string|null | ||
| */ | ||
| public function getApiKey(): ?string | ||
| { | ||
| return $this->apiKey; | ||
| } | ||
|  | ||
| public function getPrompts(): ChatWorkspacePromptsSettings | ||
| { | ||
| return $this->prompts; | ||
| } | ||
|  | ||
| /** | ||
| * @return array{ | ||
| * source: ChatWorkspaceSource, | ||
| * orgId?: non-empty-string, | ||
| * projectId?: non-empty-string, | ||
| * apiVersion?: non-empty-string, | ||
| * deploymentId?: non-empty-string, | ||
| * baseUrl?: non-empty-string, | ||
| * apiKey?: string, | ||
| * prompts: array{ | ||
| * system: string, | ||
| * searchDescription: string, | ||
| * searchQParam: non-empty-string, | ||
| * searchIndexUidParam: non-empty-string | ||
| * } | ||
| * } | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'source' => $this->source, | ||
| 'orgId' => $this->orgId, | ||
| 'projectId' => $this->projectId, | ||
| 'apiVersion' => $this->apiVersion, | ||
| 'deploymentId' => $this->deploymentId, | ||
| 'baseUrl' => $this->baseUrl, | ||
| 'apiKey' => $this->apiKey, | ||
| 'prompts' => $this->prompts->toArray(), | ||
| ]; | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace Meilisearch\Contracts; | ||
|  | ||
| class ChatWorkspacesResults extends Data | ||
| { | ||
| /** | ||
| * @var non-negative-int | ||
| */ | ||
| private int $offset; | ||
|  | ||
| /** | ||
| * @var non-negative-int | ||
| */ | ||
| private int $limit; | ||
|  | ||
| /** | ||
| * @var non-negative-int | ||
| */ | ||
| private int $total; | ||
|  | ||
| public function __construct(array $params) | ||
| { | ||
| parent::__construct($params['results']); | ||
|  | ||
| $this->offset = $params['offset']; | ||
| $this->limit = $params['limit']; | ||
| $this->total = $params['total']; | ||
| } | ||
|  | ||
| /** | ||
| * @return array<int, array{uid: string}> | ||
| */ | ||
| public function getResults(): array | ||
| { | ||
| return $this->data; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-negative-int | ||
| */ | ||
| public function getOffset(): int | ||
| { | ||
| return $this->offset; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-negative-int | ||
| */ | ||
| public function getLimit(): int | ||
| { | ||
| return $this->limit; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-negative-int | ||
| */ | ||
| public function getTotal(): int | ||
| { | ||
| return $this->total; | ||
| } | ||
|  | ||
| /** | ||
| * @return array{ | ||
| * results: array, | ||
| * offset: non-negative-int, | ||
| * limit: non-negative-int, | ||
| * total: non-negative-int | ||
| * } | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'results' => $this->data, | ||
| 'offset' => $this->offset, | ||
| 'limit' => $this->limit, | ||
| 'total' => $this->total, | ||
| ]; | ||
| } | ||
|  | ||
| /** | ||
| * @return non-negative-int | ||
| */ | ||
| public function count(): int | ||
| { | ||
| return \count($this->data); | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.