Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nestjs-chatgpt

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-chatgpt - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

dist/chatgpt/chatgpt.service.d.ts
import { CreateChatgptDto } from './dto/create-chatgpt.dto';
import { ChatGptResponse } from './dto/response-chatgpt.dto';
export declare class ChatGptService {
generateText({ prompt, apiKey }: CreateChatgptDto): Promise<string>;
generateTextGPT3({ prompt, apiKey }: CreateChatgptDto): Promise<ChatGptResponse>;
generateText({ prompt, model, apiKey }: CreateChatgptDto): Promise<ChatGptResponse>;
}
//# sourceMappingURL=chatgpt.service.d.ts.map

@@ -16,8 +16,11 @@ "use strict";

let ChatGptService = class ChatGptService {
async generateText({ prompt, apiKey }) {
console.log(prompt);
async generateTextGPT3({ prompt, apiKey }) {
return this.generateText({ prompt, model: 'text-davinci-003', apiKey });
}
;
async generateText({ prompt, model, apiKey }) {
try {
const response = await axios_1.default.post('https://api.openai.com/v1/completions', {
model: 'text-davinci-003',
prompt: prompt,
model,
prompt,
temperature: 1,

@@ -31,3 +34,3 @@ max_tokens: 100,

});
return response.data.choices[0].text;
return response.data;
}

@@ -34,0 +37,0 @@ catch (error) {

export declare class CreateChatgptDto {
prompt: string;
model?: string;
apiKey: string;
}
//# sourceMappingURL=create-chatgpt.dto.d.ts.map
{
"name": "nestjs-chatgpt",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/engcfraposo/nestjs-chatgpt",

@@ -30,7 +30,3 @@ "email": "engcfraposo@gmail.com",

"typescript": "^4.9.4"
},
"repository": {
"type": "git",
"url": "git+https://github.com/engcfraposo/-nestjs-chatgpt.git"
}
}

@@ -37,2 +37,16 @@ ## ChatGptService

const createChatgptDto: CreateChatgptDto = { prompt, apiKey };
return this.chatGptService.generateTextGPT3(createChatgptDto);
}
}
```
```ts
@Injectable()
export class MyController {
constructor(private readonly chatGptService: ChatGptService) {}
async generateText(prompt: string, model: string, apiKey: string): Promise<string> {
const createChatgptDto: CreateChatgptDto = { prompt, model, apiKey };
return this.chatGptService.generateText(createChatgptDto);

@@ -48,6 +62,12 @@ }

```ts
@Injectable()
const generatedTextGPT3 = await this.generateTextGPT3('What is the meaning of life?', 'my-api-key');
console.log(generatedText);
```
```ts
@Injectable()
const generatedText = await this.generateText('What is the meaning of life?', 'my-api-key');
const generatedTextGPT3 = await this.generateText('What is the meaning of life?', 'text-davinci-003','my-api-key');
console.log(generatedText);

@@ -54,0 +74,0 @@

@@ -8,4 +8,6 @@ import { HttpException, Injectable } from '@nestjs/common';

export class ChatGptService {
async generateText({ prompt, apiKey }: CreateChatgptDto): Promise<string> {
console.log(prompt)
async generateTextGPT3({ prompt, apiKey }: CreateChatgptDto) {
return this.generateText({ prompt, model:'text-davinci-003', apiKey })
};
async generateText({ prompt, model, apiKey }: CreateChatgptDto) {
try {

@@ -15,4 +17,4 @@ const response = await axios.post<ChatGptResponse>(

{
model: 'text-davinci-003',
prompt: prompt,
model,
prompt,
temperature: 1,

@@ -28,3 +30,3 @@ max_tokens: 100,

);
return response.data.choices[0].text;
return response.data;
} catch (error) {

@@ -31,0 +33,0 @@ throw new HttpException('Falha ao gerar texto', error.response.status);

export class CreateChatgptDto {
prompt: string;
model?: string;
apiKey: string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc