Code Generation (ibm/granite-34b-code-instruct)
POST {{baseUrl}}/ml/v1/text/generation?version=2023-05-29
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
version | string |
Request Body
{"input"=>"Using the directions below, generate Python code for the given task.\n\nInput: # Write a Python function that prints 'Hello World!' string 'n' times.\nOutput: def print_n_times(n):\n for i in range(n):\n print(\"Hello World!\")\n\n<end of code>\n\nInput: # Write a Python function, which generates sequence of prime numbers.\n# The function 'primes' will take the argument 'n', an int. It will return a list which contains all primes less than 'n'.\nOutput:", "parameters"=>{"decoding_method"=>"greedy", "max_new_tokens"=>1000, "min_new_tokens"=>1, "stop_sequences"=>["<end of code>"], "repetition_penalty"=>1}, "model_id"=>"ibm/granite-34b-code-instruct", "project_id"=>"{{projectId}}", "moderations"=>{"hap"=>{"input"=>{"enabled"=>true, "threshold"=>0.5, "mask"=>{"remove_entity_value"=>true}}, "output"=>{"enabled"=>true, "threshold"=>0.5, "mask"=>{"remove_entity_value"=>true}}}}}
RESPONSES
status: OK
{"model_id":"ibm/granite-34b-code-instruct","created_at":"2024-05-12T13:42:49.501Z","results":[{"generated_text":" def primes(n):\n primes = []\n for i in range(2, n):\n is_prime = True\n for j in range(2, i):\n if i % j == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n\n\u003cend of code\u003e","generated_token_count":79,"input_token_count":120,"stop_reason":"stop_sequence"}]}