Petr Tsvetkov
Generate a dataset for the labeling app
6676c5a
raw
history blame
981 Bytes
import time
from grazie.api.client.chat.prompt import ChatPrompt
from grazie.api.client.endpoints import GrazieApiGatewayUrls
from grazie.api.client.gateway import GrazieApiGatewayClient, GrazieAgent, AuthType
from grazie.api.client.profiles import LLMProfile
import config
client = GrazieApiGatewayClient(
grazie_agent=GrazieAgent(name="commit-rewriting-synthetic-end-to-start", version="dev"),
url=GrazieApiGatewayUrls.STAGING,
auth_type=AuthType.USER,
grazie_jwt_token=config.GRAZIE_API_JWT_TOKEN
)
def generate_for_prompt(prompt):
output = None
while output is None:
try:
output = output = client.chat(
chat=ChatPrompt()
.add_system("You are a helpful assistant.")
.add_user(prompt),
profile=LLMProfile("gpt-4-1106-preview")
).content
except:
time.sleep(config.GRAZIE_TIMEOUT_SEC)
assert output is not None
return output