Workflow focus on generating code snippets or entire functions based on input specifications or natural language descriptions

Overview
1

Notes

Code Generation from Natural Language

Developers can use coding LLMs to translate natural language descriptions of algorithms or programming tasks into executable code. This functionality simplifies the process of converting high-level requirements into working implementations, enabling faster prototyping and development.

Code Generation Workflow

This workflow focus on generating code snippets or entire functions based on input specifications or natural language descriptions.

Model used

This workflow uses the wizardCoder-15B Model with defined prompt template optimized for code generation from natural language.

How to use the Code Generation workflow? 

Using Clarifai SDK

Export your PAT as an environment variable. Then, import and initialize the API Client.

Find your PAT in your security settings.

export CLARIFAI_PAT={your personal access token}

Prediction with the workflow

from clarifai.client.workflow import Workflow

workflow_url = 'https://clarifai.com/{{user_id}}/coding-template/workflows/code-generation'

text = 'Create a Python function named 'merge_sort' that takes a list of integers as input and returns a sorted list using the merge sort algorithm'

prediction = Workflow(workflow_url).predict_by_bytes(text.encode(), input_type="text")

# Get workflow results
print(prediction.results[0].outputs[-1].data.text.raw)

Using Workflow

To utilize the Code Completion workflow, you can input your instruction task prompt through the Blue Plus Try your own Input button and it will output code snippet.

  • Workflow ID
    code-generation
  • Description
    Workflow focus on generating code snippets or entire functions based on input specifications or natural language descriptions
  • Last Updated
    Jul 03, 2024
  • Privacy
    PUBLIC
  • Share