Workflow help to predict and suggest possible python code completions based on the previous context, you just need to input python context code and coding LLMs

Overview
1

Notes

Code Completion and Auto-Suggestion for python

Coding LLMs can predict and suggest code completions that can assist developers by providing context-aware code completions as they type, reducing the need to memorize syntax and API specifications. This feature is particularly useful for accelerating coding tasks and reducing errors.

Code Completion Python Workflow

This workflow help to predict and suggest possible python code completions based on the previous context, you just need to input python context code and coding LLMs can predict and suggest code completions.

Model used

This workflow uses the codeLlama-70b-Python Model with defined prompt template optimized for code completion.

How to use the Code Completion 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-completion-python'

text = 'def calculate_discount(total_amount'

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 previous context code or partial code through the Blue Plus Try your own Input button and it will predict and suggest code completions.

  • Workflow ID
    code-completion-python
  • Description
    Workflow help to predict and suggest possible python code completions based on the previous context, you just need to input python context code and coding LLMs can predict and suggest code completions
  • Last Updated
    May 20, 2024
  • Privacy
    PUBLIC
  • Share