Helicone Community Page

Updated last year

Occasional Missing API Call from List of Requests

Hi,
We have seen some behavior lately where sometimes we are missing the log of our API call. We make 2 API calls in our app, one to ask the LLM to generate a better 'question' based on the chat history and its calling the GPT Completion API. We then make a second API call to the LLM with the actual user input and some context documents and its calling the GPT Chat API.

It's this second call that sometimes doesn't show up. Me and another engineer have both seen it. For reference I just tested 5 different questions and didn't see the second API call but on the 6th one it came through. I'm not sure what might be the cause of this as we are calling the Helicone API when making both our API calls.
V
C
J
21 comments
For reference this is the call to the second API
Plain Text
    
const OPENAI_API_KEY = process.env.OPENAI_API_KEY!;
const HELICONE_API_KEY = process.env.HELICONE_API_KEY!;
const HELICONE_CHAT_URL = "https://oai.hconeai.com/v1/chat/completions";

const res = await fetch(HELICONE_CHAT_URL, {
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${OPENAI_API_KEY}`,
        "Helicone-Retry-Enabled": "true",
        "Helicone-Auth": `Bearer ${HELICONE_API_KEY}`,
        "Helicone-Property-Id": id,
        "Helicone-Property-ConversationId": conversationId,
      },
      method: "POST",
      body: JSON.stringify({
        model: LLM_OPTIONS[llm].name,
        max_tokens: LLM_OPTIONS[llm].maxTokensForOutput,
        messages: chatHistory,
        temperature: temperature,
        top_p: 1,
        frequency_penalty: 0,
        presence_penalty: 0,
        stream: true,
        n: 1,
      }),
    });
Hey! Are you able to share the first chat message call?
Also, could you tell me where this code is being executed?
this is our first call, we are just generating a more contextual question to drive our embeddings generation for pinecone:
Plain Text
  
const OPENAI_API_KEY = process.env.OPENAI_API_KEY!;
const HELICONE_API_KEY = process.env.HELICONE_API_KEY!;
const HELICONE_COMPLETION_URL = "https://oai.hconeai.com/v1/completions";

const generatedQuestion = await fetch(HELICONE_COMPLETION_URL, {
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${OPENAI_API_KEY}`,
      "Helicone-Retry-Enabled": "true",
      "Helicone-Prompt-Format": "on",
      "Helicone-Auth": `Bearer ${HELICONE_API_KEY}`,
      "Helicone-Property-Id": id,
      "Helicone-Property-ConversationId": conversationId,
    },
    method: "POST",
    body: JSON.stringify({
      model: "text-davinci-003",
      prompt: serializedQuestionTemplate,
      max_tokens: 2048,
      temperature: 0.7,
    }),
  });
We are working in NextJS 13 and are deploying on Vercel
I was able to go through our DB logs and compare it to Helicone and I do indeed see missing API calls from just random conversations i pulled
Do you observe the same behavior when running this locally? I'm speculating this might be due to a timeout if it's being executed in a Vercel serverless function. Can you confirm?
So far I have not run into this issue locally (as far as I can tell) its moslty on our staging environment
The first API call is indeed on a serverless function (but thats not the one thats missing). The second one is on the edge and being streamed back to avoid the timeout issues. We still see the results outputted fine in our chat just not the log in Helicone πŸ˜“
Would you be able to try running this locally and attempt to reproduce it? Would be good to isolate if it is related to the environment. Also, even when Helicone did not log it, you definitely received the full output? I'm wondering if somehow you disconnected which stops our Cloudflare workers from processing the request and would cause you to not see the log.
I did run it locally and it logged fine πŸ˜“
I mean in my tests where it did not come through in staging I didn't see any impact on chat. It was only on the Helicone side where I didn't see the log output
Since logging in working fine locally, it appears the issue might not be specific to Helicone, but rather it could be an environment related problem. I've ran into a similar issue when working on my side projects before and what resolved it was ensuring my cloudflare workers were unbound which prevented them from terminating after x time and instead would continue for the entire duration of the request. Do you notice that the requests that do not log are longer duration than the others?
not really. it spins up in about the same amount of time
Have you all seen this issue with other folks using NextJS13 and Vercel for deployments?
Not that I am aware of. Would you like to set up a call and try to debug it together?
yes that would be helpful as we are pretty lost on why this is happening. what is your availability like this week to next?
I can meet tomorrow from 4-8pm EST.
Can we do tomorrow 4 PM EST? Is there a calendar invite we can send out or how should we do this...?
The problem is the body has \u0000 which is failing to be inserted into the database.

Postgres JSONB does not support that character as it is used internally.
Here is a better link about that: https://www.postgresql.org/message-id/8239.1500489054%40sss.pgh.pa.us

I have a PR up to fix this: https://github.com/Helicone/helicone/pull/600/files which removes that character before inserting into the DB
PR merged and pushed!
Add a reply
Sign up and join the conversation on Discord