aws-samples / aws-samples/amplify-ai-examples

Pass data into the conversation

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
55
Forks
65
PR merge metrics
No merged PRs in 30d

Description

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: https://github.com/aws-amplify/amplify-ui/issues/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;

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.