-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_label.py
38 lines (28 loc) · 996 Bytes
/
generate_label.py
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
#generate this label
import replicate
import os
import sys
import json
# Set your API token
def generate_label(description):
for event in replicate.stream(
"mistralai/mixtral-8x7b-instruct-v0.1",
input={
"top_k": 50,
"top_p": 0.9,
"prompt": f"Write a shore and concise label for the work {description} in the following format: Title, Year: 2024, Medium, Dimensions, Collection, Location",
"temperature": 0.6,
"system_prompt": "You are a very helpful, respectful and honest assistant.",
"length_penalty": 1,
"max_new_tokens": 1024,
"prompt_template": "<s>[INST] {prompt} [/INST] ",
"presence_penalty": 0
},
):
print(str(event), end="")
if __name__ == "__main__":
description = sys.argv[1]
replicate_api_key = sys.argv[2]
# Set API key
os.environ["REPLICATE_API_TOKEN"] = replicate_api_key
generate_label(description)