Welcome to Portkey Forum

Updated 11 months ago

error message when not used required "messages" property

Thanks for sharing! If it is messagaes you're missing, it should ideally say: Error code: 400 - 'messages' is a required property :think:

Are you also using a Config with this?
1
S
V
r
5 comments
I am not using config with it. ๐Ÿ™‚

Yes, "messages" is a required property should be sufficient. Since Portkey would aim to adhere to openai standard experience, then it would say:
Plain Text
error: 400 invalid model ID
 code: "null"

      at new OpenAIError (:1:32)
      at new APIError 
Hmm, though our aim would be to elevate the error experience to make it clearer too.


Can you please share the code snippet that generated that error? Iโ€™ll check
Plain Text
import Portkey from "portkey-ai";
import ora from "ora";
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: "sk-openaikey***",
});

const portkey = new Portkey({
  apiKey: process.env.PORTKEY_API_KEY,
  virtualKey: process.env.ANYSCALE_VIRTUAL_KEY,
});

const spinner = ora("Reaching Mistral LLM via Portkey...").start();

const tools = [
  {
    type: "function",
    function: {
      name: "get_current_weather",
      description: "Get the current weather in a given location",
      parameters: {
        type: "object",
        properties: {
          location: {
            type: "string",
            description: "The city and state, e.g. San Francisco, CA",
          },
          unit: { type: "string", enum: ["celsius", "fahrenheit"] },
        },
        required: ["location"],
      },
    },
  },
];

// change "portkey" to "openai" incase you want to error with openai & vice versa
const chatCompletion = await portkey.chat.completions.create({
  model: "mistralai/Mixtral-8x7B-Instruct-v0.1",
  tools,
// to reproduce the error with comment the messages property
  messages: [
    { role: "system", content: "You are helpful assistant." },
    { role: "user", content: "What's the weather like in San Francisco?" },
  ],
  tool_choice: "auto",
});

console.log(chatCompletion.choices[0].message);

spinner.stop("Done");
I will fix this. Anyscale is sending a different type of error message which is not the usual openAI compliant error message that it sends.
Add a reply
Sign up and join the conversation on Discord