Skip to content

Commit

Permalink
Title, User Prompt, system prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
lahiru321 committed Nov 1, 2023
2 parents 6b2d63a + 655765b commit 79848e7
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 81 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/webpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: NodeJS with Webpack

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Build
run: |
npm install
npm run build
63 changes: 33 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/services/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ export class OpenAiApi {
});
}
// Asynchronous function to generate text from the OpenAI API
async generateText(prompt, model = "gpt-3.5-turbo", max_tokens = 500, temperature = 0.85) {
async generateText(systemPrompt, prompt, model = "gpt-3.5-turbo", max_tokens = 500, temperature = 0.85) {
// Send a request to the OpenAI API to generate text
try {
const response = await this.openAI.chat.completions.create({
model,
messages: [{ role: "user", content: prompt }],
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: prompt },
],
max_tokens,
n: 1,
temperature,
Expand All @@ -25,4 +28,5 @@ export class OpenAiApi {
return JSON.stringify(e);
}
}

}
Loading

0 comments on commit 79848e7

Please sign in to comment.