create-message-kit 1.0.8 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -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: any,
63
+ params: { [key: string]: string | number | string[] | undefined },
64
64
  ) {
65
65
  // Filter out undefined parameters
66
- let filteredParams: { [key: string]: any } = {};
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 OpenAI from "openai";
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(userPrompt: string, systemPrompt: string) {
8
- let messages = [];
9
- messages.push({
10
- role: "system",
11
- content: systemPrompt,
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",