"response_format": { "type": "json_object" },
PromptRenderData
object does not have that field is it expected? class PromptRenderData(BaseModel): messages: Optional[List[ChatCompletionMessage]] = None prompt: Optional[str] = None model: Optional[str] = None suffix: Optional[str] = None max_tokens: Optional[int] = None temperature: Optional[float] = None top_k: Optional[int] = None top_p: Optional[float] = None n: Optional[int] = None stop_sequences: Optional[List[str]] = None timeout: Union[float, None] = None functions: Optional[List[Function]] = None function_call: Optional[Union[None, str, Function]] = None logprobs: Optional[bool] = None top_logprobs: Optional[int] = None echo: Optional[bool] = None stop: Optional[Union[str, List[str]]] = None presence_penalty: Optional[int] = None frequency_penalty: Optional[int] = None best_of: Optional[int] = None logit_bias: Optional[Dict[str, int]] = None user: Optional[str] = None organization: Optional[str] = None tool_choice: Optional[Union[None, str]] = None tools: Optional[List[Tool]] = None
[{ "content": [ { "type": "text", "text": "You are an helpful AI assistant. My name is {{name}}" } ], "role": "system" },{{history_messages}},{ "content": [ { "type": "text", "text": "{{input}}" } ], "role": "user" }]
variables= {"name" : "portkey"}
variables= {"name" : "portkey", "history_messages" : []}
from langchain_openai import ChatOpenAI from portkey_ai import createHeaders, PORTKEY_GATEWAY_URL PORTKEY_API_KEY = "..." VIRUTAL_KEY = "..." # Virtual Key I created portkey_headers = createHeaders(api_key=PORTKEY_API_KEY,virtual_key= VIRUTAL_KEY) llm = ChatOpenAI(api_key="x", base_url=PORTKEY_GATEWAY_URL, default_headers=portkey_headers, model="gemini-1.5-pro") llm.invoke("What is the meaning of life, universe and everything?")
pip install -U langchain-core portkey_ai langchain-openai
before starting