Created
October 29, 2024 21:39
-
-
Save Akifcan/a8d6aa0bf38bf5c09d0b4fa862d4b7f3 to your computer and use it in GitHub Desktop.
product.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Anthropic from '@anthropic-ai/sdk' | |
@Injectable() | |
export class ProductService { | |
@Inject() configService: ConfigService | |
createProductDescription(productName: string){ | |
const anthropicConfig = this.configService.get<AntrhopicConfig>('anthropic') | |
const anthropic = new Anthropic({ apiKey: anthropicConfig.secret }) | |
const msg = await anthropic.messages.create({ | |
model: 'claude-3-5-sonnet-20240620', | |
max_tokens: 1000, | |
temperature: 0, | |
messages: [ | |
{ | |
role: 'user', | |
content: [ | |
{ | |
type: 'text', | |
text: `Create a description for this product ${productName}`, | |
}, | |
], | |
}, | |
], | |
}) | |
return msg | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment