create-message-kit 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,10 +60,12 @@ export async function handler(context: HandlerContext) {
|
|
60
60
|
function generateFrameURL(
|
61
61
|
baseUrl: string,
|
62
62
|
transaction_type: string,
|
63
|
-
params:
|
63
|
+
params: { [key: string]: string | number | string[] | undefined },
|
64
64
|
) {
|
65
65
|
// Filter out undefined parameters
|
66
|
-
let filteredParams: {
|
66
|
+
let filteredParams: {
|
67
|
+
[key: string]: string | number | string[] | undefined;
|
68
|
+
} = {};
|
67
69
|
|
68
70
|
for (const key in params) {
|
69
71
|
if (params[key] !== undefined) {
|
@@ -1,15 +1,23 @@
|
|
1
|
-
import
|
1
|
+
import dotenv from "dotenv";
|
2
|
+
dotenv.config();
|
2
3
|
|
4
|
+
import OpenAI from "openai";
|
3
5
|
const openai = new OpenAI({
|
4
6
|
apiKey: process.env.OPEN_AI_API_KEY,
|
5
7
|
});
|
6
8
|
|
7
|
-
export async function textGeneration(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
export async function textGeneration(
|
10
|
+
userPrompt: string,
|
11
|
+
systemPrompt: string,
|
12
|
+
chatHistory?: any[],
|
13
|
+
) {
|
14
|
+
let messages = chatHistory ? [...chatHistory] : []; // Start with existing chat history
|
15
|
+
if (messages.length === 0) {
|
16
|
+
messages.push({
|
17
|
+
role: "system",
|
18
|
+
content: systemPrompt,
|
19
|
+
});
|
20
|
+
}
|
13
21
|
messages.push({
|
14
22
|
role: "user",
|
15
23
|
content: userPrompt,
|