How to add my custom instruction to Openai Realtime Console demo?

I ve just launched GitHub - openai/openai-realtime-console: React app for inspecting, building and debugging with the Realtime API . It is awesome. Anyone knows where should I fix source code to add my custom instruction?

1 Like

Already found:

Now here is another question. How to add automatically stopping conversation (Disconnect) by some trigger (lets say, I said goodbye) or our talk ran to logical finish. I understand it is about disconnectConversation method, however how to implement abovementioned?

1 Like

I’d use function calling to let the model convey its detection of the user’s intent to end the conversation.

2 Likes

Sounds logical, however from realtime-console example openai-realtime-console/src/pages/ConsolePage.tsx at main · openai/openai-realtime-console · GitHub its not clear how can I for instance use function call for:

  • calling disconnectConversation() method
  • return some specific output response based on user input
client.addTool(
      {
        name: 'get_weather',
        description:
          'Retrieves the weather for a given lat, lng coordinate pair. Specify a label for the location.',
        parameters: {
          type: 'object',
          properties: {
            lat: {
              type: 'number',
              description: 'Latitude',
            },
            lng: {
              type: 'number',
              description: 'Longitude',
            },
            location: {
              type: 'string',
              description: 'Name of the location',
            },
          },
          required: ['lat', 'lng', 'location'],
        },
      },
      async ({ lat, lng, location }: { [key: string]: any }) => {
        setMarker({ lat, lng, location });
        setCoords({ lat, lng, location });
        const result = await fetch(
          `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lng}&current=temperature_2m,wind_speed_10m`
        );
        const json = await result.json();
        const temperature = {
          value: json.current.temperature_2m as number,
          units: json.current_units.temperature_2m as string,
        };
        const wind_speed = {
          value: json.current.wind_speed_10m as number,
          units: json.current_units.wind_speed_10m as string,
        };
        setMarker({ lat, lng, location, temperature, wind_speed });
        return json;
      }
    );