How I use AI to take perfect notes...without typing (Help needed)

Hello everyone,

I just finished up setting the workflow for notion (Hard code version) to get this to work and it was working smoothly yesterday. Today, while trying to upload a 45 min 23mb audio, I keep getting an error. I just paid to upgrade my pipedream account to see if that would help but still no avail. Says I have timed out.

Attached is the error code and also my current settings.
Anybody know what I can do differently



New error code after bumping up the time from 300 seconds to 500 seconds


image

@nelsonspam7 Did you get it sorted out? I’m still having problems. Been working at this for hours over 2 days.

No, unfortunately still having this issue. Are you having the same issue as me?

I’m not certain it’s the same issue…but I’m working through the same Thomas Frank program. I really like what I’m seeing as he presented it, but I’m about to give up. I’ve spent hours and upgraded my OpenIA…with no positive results.

Just wondering have any of you guys tried the Pipedream Workflow Link in this new section in the code heavy section?

No. Have you tried it?

Just tried it right now. It worked well here

Yes, that is what I used as well. Yesterday it worked fine. Today I tried to upload a longer audio clip (45 mins) and it’s giving the pictured errors in my original post. I’ll try again later with a much shorter clip but if the issue is the size, then it’s kind of pointless for me as that is why I needed it for. Hour long meetings!

Yes I understand. For longer audio clips the generated transcript becomes large. Since OpenAI ChatGPT has a token limit, we have to split the transcript into chunks and send it to OpenAI. The status code 429 means that too many chunks were sent in a short time interval.
Let me take a deeper look at the code and see if I can optimize it.

Thank you, Andrew!!

@nelsonspam7 can you test with this code?

import { Configuration, OpenAIApi } from "openai"
import { encode, decode } from "gpt-3-encoder"
import Bottleneck from "bottleneck";

function createPrompt(arr) {
  return `Analyze the transcript provided below, then provide the following:
Key "title:" - add a title.
Key "summary" - create a summary.
Key "main_points" - add an array of the main points. Limit each item to 100 words, and limit the list to 10 items.
Key "action_items:" - add an array of action items. Limit each item to 100 words, and limit the list to 5 items.
Key "follow_up:" - add an array of follow-up questions. Limit each item to 100 words, and limit the list to 5 items.
Key "stories:" - add an array of an stories, examples, or cited works found in the transcript. Limit each item to 200 words, and limit the list to 5 items.
Key "arguments:" - add an array of potential arguments against the transcript. Limit each item to 100 words, and limit the list to 5 items.
Key "related_topics:" - add an array of topics related to the transcript. Limit each item to 100 words, and limit the list to 5 items.
Key "sentiment" - add a sentiment analysis

Ensure that the final element of any array within the JSON object is not followed by a comma.

Transcript:

${arr}`;
}

const systemPrompt = `You are an assistant that only speaks JSON. Do not write normal text.
Example formatting:
{
    "title": "Notion Buttons",
    "summary": "A collection of buttons for Notion",
    "action_items": [
        "item 1",
        "item 2",
        "item 3"
    ],
    "follow_up": [
        "item 1",
        "item 2",
        "item 3"
    ],
    "arguments": [
        "item 1",
        "item 2",
        "item 3"
    ],
    "related_topics": [
        "item 1",
        "item 2",
        "item 3"
    ]
    "sentiment": "positive"
}`;

export default defineComponent({
  props: {
    openai: {
      type: "app",
      app: "openai",
    },
  },
  methods: {
    // Split the transcript into shorter strings if needed, based on GPT token limit
    splitTranscript(encodedTranscript, maxTokens) {
      const stringsArray = [];
      let currentIndex = 0;

      while (currentIndex < encodedTranscript.length) {
        let endIndex = Math.min(currentIndex + maxTokens, encodedTranscript.length);

        // Find the next period
        while (endIndex < encodedTranscript.length && decode([encodedTranscript[endIndex]]) !== ".") {
          endIndex++;
        }

        // Include the period in the current string
        if (endIndex < encodedTranscript.length) {
          endIndex++;
        }

        // Add the current chunk to the stringsArray
        const chunk = encodedTranscript.slice(currentIndex, endIndex);
        stringsArray.push(decode(chunk));

        currentIndex = endIndex;
      }

      return stringsArray;
    },
    // Function to send transcript string(s) to Chat API
    async sendToChat(openai, stringsArray) {
      const limiter = new Bottleneck({
        maxConcurrent: 5,
      });
      const results = limiter.schedule(() => {
        const tasks = stringsArray.map((arr) => this.chat(openai, arr));
        return Promise.all(tasks);
      });
      return results;
    },
    async chat(openai, prompt) {
      return openai.createChatCompletion({
        model: "gpt-3.5-turbo",
        messages: [
          {
            role: "user",
            content: createPrompt(prompt),
          },
          {
            role: "system",
            content: systemPrompt,
          },
        ],
        temperature: 0.2,
      });
    },
  },
  async run({ steps, $ }) {
    // Import the transcript from the previous step
    const transcript = steps.create_transcription.$return_value.transcription

    // Set the max number of input tokens
    const maxTokens = 2000

    // Initialize OpenAI
    const openAIkey = this.openai.$auth.api_key
    const configuration = new Configuration({
      apiKey: openAIkey,
    });
    const openai = new OpenAIApi(configuration);

    const encoded = encode(transcript);
    const stringsArray = this.splitTranscript(encoded, maxTokens);
    const result = await this.sendToChat(openai, stringsArray);
    return result;
  },
});
3 Likes

Got this to work on a longer recording (1h). Testing with a few more to confirm. Thank you!!

Can you explain the main changes to what the code does vs the original? Should this overcome all time limits - eg, would it be expected to work for a 5hr recording?

Andrew, I think I got this to work. Thank you for your help! I am going to test a few more files just to be sure and report back. I have two questions:

  1. I have ChatGPT pro but I dont think it is in the work flow. How do I change it from ChatGPT3.5 to ChatGpt 4?

  2. Do I change my settings from 500 seconds back to 300 and what should I keep my memory at? This is specifically for the settings in the workflow of pipedream.

Again, I can’t thank you enough!!

@gabriel.dane.509 awesome, thank for you for the feedback! There were two main changes in the code:

  1. After chunking the text into smaller ones, it sends these chunks in parallel to OpenAI
  2. It uses Bottleneck to send at max 5 requests simultaneously

I’ll see with the Pipedream team if they can update the code in the workflow link in Thomas’ page.

Re: 5h+ or longer recordings, I’m not sure. The workflow may timeout but it’s worth testing

1 Like

@nelsonspam7 that’s great to hear! Regarding your questions:

  1. For this workflow, I think gpt-3.5-turbo works well and is a lot cheaper and faster. Is there a reason you want to change it to gpt-4? To see if you have access through the API, create a new OpenAI Chat step and select your account, and see if gpt-4 model option shows up to you like in this screenshot:

    If it doesn’t and you have another account, you’ll have to Connect a New Account for OpenAI.
  2. You can try changing it to 300 seconds if 500 seconds incurs into more credits being used. In terms of memory, I think the minimum (256MB) is enough. I’ve never had a problem with memory with OpenAI workflows.

Well, I figured if I have gpt 4 I may as well use it. I also figured it would give me better responses? Or is that not the case? I will try and see if I have access now.

This is all I see

@nelsonspam7 yeah gpt-4 is way better in some cases, but in this case for transcripts and analyzing text it’s not tradeoff that’s worth it, since it is a lot more expensive.

In your screenshot, can you check the Model prop below the account?

Though if you have really long audios gpt-4 can be better, since you can pass more tokens (text) to it in one request, resulting in less requests overall. That might be something worth investigating.
In the code step, on line 120: const maxTokens = 2000, if you have gpt-4 you can try changing it to 6000.