File size: 2,728 Bytes
9131d62
 
 
 
 
 
 
 
 
 
 
 
dff38c9
9131d62
 
 
 
dff38c9
9131d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
afc30f3
 
9131d62
 
 
afc30f3
9131d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
'''Set ENVIRONMENT to local for local app.py testing and spaces for running from docker image'''

import os

env  = os.environ.get('ENVIRONMENT', 'local')

if env == 'local':
    from dotenv import load_dotenv

    model_path = '../merged_llama2/'
    tokenizer_path = '../Llama2/7B/tokenizer.model'
    load_dotenv()
    embedding_path = "embedding_model/"

elif env == 'spaces':
    model_path = 'akfung/llama_supreme'
    tokenizer_path = 'akfung/llama_supreme'
    embedding_path = "/embedding_model/"

elif env == 'gcp':
    model_path = 'model/'
    tokenizer_path = 'tokenizer.model'
    bucket_name = 'phoenix-byte'
    os.environ["GCLOUD_PROJECT"] = "phoenix-byte"

conn_s = "postgresql://{user}:{password}@{host}:{port}/{db_name}".format(user=os.environ.get('DB_USER'),
                                                                         password=os.environ.get('DB_PASSWORD'),
                                                                         host=os.environ.get('DB_HOST'),  
                                                                         port=os.environ.get('DB_PORT'), 
                                                                         db_name=os.environ.get('DB_NAME'),
                                                                         )

justice_names = {'Alito',
    'Barrett',
    'Breyer',
    'Ginsburg',
    'Gorsuch',
    'Jackson',
    'Kagan',
    'Kavanaugh',
    'Kennedy',
    'Roberts',
    'Scalia',
    'Sotomayor',
    'Thomas',}

headers = {
    "Authorization": os.environ.get('runpod_api_key'),
    "Content-Type": "application/json"
}

streaming_url = os.environ.get('STREAMING_URL')
job_url = os.environ.get('JOB_URL')

default_payload = { "input": {
        "prompt": "Who is the president of the United States?",
        "apply_chat_template": True,
        "sampling_params": {
            "max_tokens": os.environ.get('max_new_tokens', 400),
            "n": 1,
            "best_of": None,
            "presence_penalty": 0.6,
            "frequency_penalty": 0,
            "temperature": 0.7,
            "top_k": 6,
            "use_beam_search": False,
            "stop": ["USER"],
            "ignore_eos": False,
            "logprobs": None
        }
    } }

max_new_tokens = os.environ.get('max_new_tokens', 100)

readme = """Provide a legal case description or click on Get Random Case to get a random case from Wikipedia's
    pending US Supreme Court cases. Choose a Supreme Court Justice to generate opinions according to what that particular Justice might
    have to say about this case, or select Court to generate opinions based on what the majority opinion might be.Click run to generate the predicted US Supreme Court opinion."""