""" REQUESTS LIBRARY """
import requests, json
PORTKEY_GATEWAY_URL = "https://api.portkey.ai/v1/chat/completions"
TRACE_ID = 'anyscale_portkey_test'
METADATA = {
"_environment": "production",
"_user": "userid123",
"_organisation": "orgid123",
"_prompt": "summarisationPrompt"
}
PORTKEY_HEADERS = {
'Authorization': 'Bearer ANYSCALE_KEY',
'Content-Type': 'application/json',
'x-portkey-api-key': 'PORTKEY_API_KEY',
'x-portkey-provider': 'anyscale',
# **************************************
'x-portkey-trace-id': TRACE_ID, # Send the trace id
'x-portkey-metadata': json.dumps(METADATA) # Send the metadata
# **************************************
}
DATA = {
"messages": [{"role": "user", "content": "What happens when you mix red & yellow?"}],
"model": "mistralai/Mistral-7B-Instruct-v0.1"
}
response = requests.post(PORTKEY_GATEWAY_URL, headers=PORTKEY_HEADERS, json=DATA)
print(response.text)