Skip to content

Pass data into the conversation #1

Description

@blipps199

I've tried following a few how tos but they always lead to errors. Is there a way to pass in my own data into the conversation? Below is some code I found here: aws-amplify/amplify-ui#5773

import { type ClientSchema, a, defineData, defineFunction } from "@aws-amplify/backend";

export const getWeather = defineFunction({
  name: 'getWeather',
  entry: './getWeather.ts',
});

const schema = a.schema({
  chat: a.conversation({
    aiModel: a.ai.model("Claude 3 Haiku"),
    systemPrompt: `You are a helpful assistant`,
    tools: [
      {
        query: a.ref('getWeather'),
        description: 'Get current weather information',
      },
    ],
  }),

  chatNamer: a
    .generation({
      aiModel: a.ai.model("Claude 3 Haiku"),
      systemPrompt: `You are a helpful assistant that writes descriptive names for conversations. Names should be 2-10 words long`,
    })
    .arguments({
      content: a.string(),
    })
    .returns(
      a.customType({
        name: a.string(),
      })
    )
    .authorization((allow) => [allow.authenticated()]),
});

export type Schema = ClientSchema<typeof schema>;

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: "userPool",
  },
});

Error:

Failed to instantiate data construct
Caused By: Tool "getWeather" defined in @conversation directive has no matching Query field definition

Resolution: See the underlying error message for more details.

I really wanted to pass in data from a query. Maybe even a custom SQL query from my PG database. However, I cannot seem to find an API reference that tells me what I can pass into the conversation. At the end of the day all I really want to do is pass in some data so I can ask the chatbot questions about said data. Any help would be awesome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions