Quantcast
Channel: Active questions tagged code-completion - Stack Overflow
Viewing all articles
Browse latest Browse all 96

Hugging Face /hf-inference/v1/chat/completions returns 422 in Eclipse plugin

$
0
0

I'm building an Eclipse plugin for code completion using the Hugging Face API. My plugin sends a prompt to the endpoint:

https://router.huggingface.co/hf-inference/v1/chat/completions

I replaced the old endpoint (https://api-inference.huggingface.co) as recommended.
Here’s my Java request code:

String json = "{"+"\"inputs\": \"" + safePrompt +"\""+"}";RequestBody body = RequestBody.create(json, MediaType.parse("application/json"));Request request = new Request.Builder()        .url("https://router.huggingface.co/hf-inference/v1/chat/completions")        .addHeader("Authorization", "Bearer " + hfToken)        .post(body)        .build();try (Response response = client.newCall(request).execute()) {    System.out.println(response.code());    System.out.println(response.body().string());}

When I run this, I always get:

Response code: 422Raw body length: 24

Can someone suggest a free Hugging Face model that works for code completion in Java/Eclipse?

EDIT

(Copied from OP's comment.)
The model I am using:

{"model": "darkc0de/XortronCriminalComputingConfig","messages": [        {"role": "user","content": "safePrompt"        }    ],"stream": false}

Viewing all articles
Browse latest Browse all 96

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>