Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass data into the conversation #1

Open
blipps199 opened this issue Nov 16, 2024 · 1 comment
Open

Pass data into the conversation #1

blipps199 opened this issue Nov 16, 2024 · 1 comment

Comments

@blipps199
Copy link

blipps199 commented Nov 16, 2024

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.

@atierian
Copy link
Member

Hey @blipps199, thanks for opening this issue!

There were some updates a few days ago prior to the GA launch that likely led to the issue you're seeing. So first things first, make sure you pull the current main branch of this repo as a starting point.

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.

What you're describing here is tool use. Check out our documentation on Tools and let me know if you have any questions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants