Welcome to Portkey Forum

Updated 11 months ago

Documentation Bug: Async Function getPromptTemplate()

At a glance

The post discusses a documentation bug in the getPromptTemplate() function, where the render_response object does not have a nested .data.data structure, but rather just .data. A community member suggests a TypeScript definition for the PortKeyRenderResponse type, which the community members indicate they will add to the documentation. The community members also confirm that the documentation has been updated to address the issue.

Documentation bug:

Plain Text
async function getPromptTemplate() {
    const render_response = await portkey.prompts.render({
        promptID: "PROMPT_ID",
        variables: { "movie":"Dune 2" }
    })
    return render_response.data.data;
}


render_response has no nested object .data.data. It has .data.

Also, have you considered typescript def for the response?
H
C
V
3 comments
Here is a start on a typedef

Plain Text
type PortKeyRenderResponse = {
  success: boolean;
  data: {
    model: string;
    n: number;
    top_p: number;
    max_tokens: number;
    temperature: number;
    response_format: any;
    presence_penality: number;
    frequency_penalty: number;
    prompt_id: string;
    messages: {
      role: string;
      content: string;
    }[];
  };
};
Hey!

Thanks for sharing this. We will be adding this specific type definition of the prompt render. 🌟
Thanks for pointing this out as well, @Hans Magnus. Have fixed it on the docs!
Add a reply
Sign up and join the conversation on Discord