0

i'm quite new to Hugging face API. All i need is how to add target lagnuage and source language parameters to this code:

import requests
API_URL = "https://api-inference.huggingface.co/models/facebook/m2m100_418M"
headers = {"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}


def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()


output = query({"inputs": "The answer to the universe is", "parameters": "src_lang=en, tgt_lang=fr"})
print(output)


my code does not work. I have been trying the whole day. I don't want to use pipeline, i want to use API

Thank you in advance

  • Can you clarify what you mean by *doesn't work*? Do you get an exception, and empty response? What is the expected behaviour? – import random Oct 26 '22 at 04:23

0 Answers0