
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@aws-amplify/graphql-conversation-transformer
Advanced tools
Amplify GraphQL @conversation transformer
The @conversation
transformer is a powerful tool for quickly and easily creating AI-powered conversation routes within your AWS AppSync API. This transformer leverages the capabilities of large language models to enable dynamic, context-aware conversations in your GraphQL schema.
The @conversation
directive is defined as follows:
directive @conversation(
aiModel: String!
systemPrompt: String!
functionName: String
tools: [ToolMap]
inferenceConfiguration: ConversationInferenceConfiguration
) on FIELD_DEFINITION
input ToolMap {
name: String
description: String
}
input ConversationInferenceConfiguration {
maxTokens: Int
temperature: Float
topP: Float
}
To use the @conversation
directive, add it to a field in your GraphQL schema. This field should be of type ConversationMessage
and should be part of the Mutation
type.
type Mutation {
sendMessage(conversationId: ID!, content: String!): ConversationMessage
@conversation(aiModel: "anthropic.claude-3-haiku-20240307-v1:0", systemPrompt: "You are a helpful AI assistant.")
}
To find the necessary GraphQL types to use with the @conversation
directive, see src/graphql-types/conversation-schema-types.ts
.
The @conversation
directive accepts the following configuration options:
aiModel
(required): Specifies the AI model to be used for generating responses.systemPrompt
(required): Defines the initial prompt that sets the context for the AI model.functionName
(optional): Specifies a custom Lambda function to handle the conversation logic.tools
(optional): An array of tool configurations that the AI can use during the conversation.inferenceConfiguration
(optional): Fine-tunes the AI model's behavior with parameters like maxTokens
, temperature
, and topP
.When you use the @conversation
directive, the transformer generates several AWS resources to support the conversation functionality:
DynamoDB Tables:
AppSync Resolvers:
Lambda Function:
functionName
is provided)IAM Roles and Policies:
AppSync Data Sources:
type Mutation {
chat(conversationId: ID!, message: String!): ConversationMessage
@conversation(
aiModel: "anthropic.claude-3-haiku-20240307-v1:0"
systemPrompt: "You are a friendly AI assistant. Respond to user queries in a helpful and concise manner."
)
}
type Mutation {
customerSupport(conversationId: ID!, inquiry: String!): ConversationMessage
@conversation(
aiModel: "anthropic.claude-3-haiku-20240307-v1:0"
systemPrompt: "You are a customer support AI. Help users with their product inquiries and issues."
tools: [
{ name: "getProductInfo", description: "Retrieves detailed information about a product" }
{ name: "checkOrderStatus", description: "Checks the status of a customer's order" }
]
inferenceConfiguration: { maxTokens: 500, temperature: 0.7, topP: 0.9 }
)
}
Craft Clear System Prompts: The system prompt sets the tone and context for the conversation route. Make it specific and aligned with your use case.
Use Appropriate AI Models: Choose AI models that suit your application's needs in terms of capabilities and response time.
Implement Error Handling: Always handle potential errors client-side code.
Monitor and Optimize: Regularly review the performance and costs associated with your conversation route.
If you encounter issues while using the @conversation
transformer, consider the following:
Check Your Schema: Ensure your GraphQL schema is valid and the @conversation
directive is used correctly.
Verify AWS Resources: Check that all required AWS resources have been created successfully.
Review Logs: Examine CloudWatch logs for any errors in your Lambda functions or AppSync resolvers.
Test Incrementally: When adding complex features like custom tools, test each addition incrementally to isolate potential issues.
FAQs
Amplify GraphQL @conversation transformer
We found that @aws-amplify/graphql-conversation-transformer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.