summaryrefslogtreecommitdiffstats
path: root/ora/model.py
blob: 69eca5265edd9c5e0db7310bec3b107d9954892e (plain) (blame)
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
from uuid     import uuid4
from requests import post

class CompletionModel:
    system_prompt = None
    description   = None
    createdBy     = None
    createdAt     = None
    slug          = None
    id            = None
    
    def create(
        system_prompt: str = 'You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible', 
        description  : str = 'ChatGPT Openai Language Model',
        name         : str = 'gpt-3.5'):

        CompletionModel.system_prompt = system_prompt
        CompletionModel.description   = description
        CompletionModel.slug          = name
        
        response = post('https://ora.sh/api/assistant', json = {
            'prompt'     : system_prompt,
            'userId'     : f'auto:{uuid4()}',
            'name'       : name,
            'description': description})
        
        CompletionModel.id        = response.json()['id']
        CompletionModel.createdBy = response.json()['createdBy']
        CompletionModel.createdAt = response.json()['createdAt']
        
        return CompletionModel
    
clau