Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated OpenAiEndpoint.ts #276

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions JS/edgechains/lib/src/lib/endpoints/OpenAiEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,41 @@ export class OpenAiEndpoint {

return responce[0].message.content;
}

async gptFnTestGenerator(prompt: string): Promise<string> {
const responce = await axios
.post(
"https://api.openai.com/v1/chat/completions",
{
model: this.model,
messages: [
{
role: this.role,
content: prompt,
},
],
temperature: this.temprature,
},
{
headers: {
Authorization: "Bearer " + this.apiKey,
"content-type": "application/json",
},
}
)
.then(function (response) {
return response.data.choices;
})
.catch(function (error) {
if (error.response) {
console.log("Server responded with status code:", error.response.status);
console.log("Response data:", error.response.data);
} else if (error.request) {
console.log("No response received:", error.request);
} else {
console.log("Error creating request:", error.message);
}
});
return responce[0].message.content;
}
}
90 changes: 45 additions & 45 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"dependencies": {
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.54.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
Loading