Spaces:
Runtime error
Runtime error
File size: 1,453 Bytes
19d552f |
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 |
import requests
## Call the API using Python
def generate_output(payload):
# Sending the request
response = requests.post('https://uf9t072wj5ki2ho4.eu-west-1.aws.endpoints.huggingface.cloud/generate', json=payload)
# Handling the response
data = response.json()
return data
# Payload for the request
#
# payload1 = {
# "inputs": "Howdy!",
# "parameters": {
# "do_sample": False,
# "max_new_tokens": 40
# }
# }
#
# output1 = generate_output(payload1)
# print(f"output1: {output1}")
#
# formatted_input = (
# "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\nHowdy!<|eot_id|>"
# )
# payload2 = {
# "inputs": formatted_input,
# "parameters": {
# "do_sample": False,
# "max_new_tokens": 40
# }
# }
#
#
# output2 = generate_output(payload2)
# print(f"output2: {output2}")
#
# multi_turn_input = "<|begin_of_text|>" \
# "<|start_header_id|>user<|end_header_id|>\n\nHowdy!<|eot_id|>" \
# "<|start_header_id|>assistant<|end_header_id|>\n\nHowdy back atcha! What brings you to these here parts?<|eot_id|>" \
# "<|start_header_id|>user<|end_header_id|>\n\nMy assignments!<|eot_id|>"
#
# payload3 = {
# "inputs": multi_turn_input,
# "parameters": {
# "do_sample": False,
# "max_new_tokens": 40
# }
# }
#
#
# output3 = generate_output(payload3)
# print(f"output3: {output3}")
#
|