Skip to content

Introduce prompt template for Python

Alexander Chueshev requested to merge py-codegen-prompt-template into main

This MR introduces the prompt template for Python by implementing:

  • PromptTemplate and PromptTemplateFewShot to construct generic templates with/without examples
  • ModelEngineCodegen and ModelEnginePalm to build the prompts and clean model outputs depending on the model

All pre/post-process operations have been moved to suggestions/processing/ops.
The codesuggestions/_assets folder now contains the prompt templates and examples per language. We can support new languages by simply adding relevant examples to the _assets folder.

Recommendations without prompt template:

from pydantic import BaseModel
# class with two fields name and description
class Item(BaseModel):
    name: str
    description: str

# class with two fields name and description

Recommendations with prompt template:

from pydantic import BaseModel
# class with two fields name and description
class Person(BaseModel):
    name: str
    description: str

Closes #96 (closed)

Edited by Alexander Chueshev

Merge request reports