Skip to content

Instantly share code, notes, and snippets.

@Akifcan
Created October 29, 2024 21:39
Show Gist options
  • Save Akifcan/a8d6aa0bf38bf5c09d0b4fa862d4b7f3 to your computer and use it in GitHub Desktop.
Save Akifcan/a8d6aa0bf38bf5c09d0b4fa862d4b7f3 to your computer and use it in GitHub Desktop.
product.service.ts
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