Skip to content

Commit

Permalink
feat(extension): add systemMessage param and other openAI models
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftEscape committed Sep 28, 2024
1 parent 454c8a9 commit 8de342d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
11 changes: 10 additions & 1 deletion firestore-chatgpt-bot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@

## Version 0.0.3

- Added new `GPT-4o` to the `MODEL` options. [Learn more here.](https://platform.openai.com/docs/models/gpt-4o)
- Added new `GPT-4o` to the `MODEL` options. [Learn more here.](https://platform.openai.com/docs/models/gpt-4o)

## Version 0.1.0

- Added `systemMessage` to configurable paramaters.
- Included (4) language models to the `MODEL` option. [Learn more here.](https://platform.openai.com/docs/models)
- GPT-4o mini `GPT-4o mini`
- o1-preview `o1-preview`
- o1-mini `o1-mini`
- GPT-4 Turbo `gpt-4-turbo`
21 changes: 20 additions & 1 deletion firestore-chatgpt-bot/extension.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: firestore-chatgpt-bot
version: 0.0.3 # Follow semver versioning
version: 0.1.0 # Follow semver versioning
specVersion: v1beta # Version of the Firebase Extensions specification

displayName: Chatbot with ChatGPT
Expand Down Expand Up @@ -113,6 +113,15 @@ params:
required: true
immutable: false

- param: SYSTEM_MESSAGE
label: System Message
description: >-
The default message that acts as an instruction for the model, ensuring it responds appropriately to the your queries.
type: string
example: You're an AI language model developed by OpenAI. Provide the user with clear and helpful assistance.
required: false
immutable: false

- param: LOCATION
label: Cloud Functions Location
description: >-
Expand Down Expand Up @@ -174,8 +183,18 @@ params:
options:
- label: GPT-4o
value: gpt-4o
- label: GPT-4o mini
value: gpt-4o-mini
- label: o1-preview
value: o1-preview
- label: o1-mini
value: o1-mini
- label: GPT-4 Turbo
value: gpt-4-turbo
- label: GPT-4 Turbo Preview
value: gpt-4-turbo-preview
- label: GPT-4 0125 Preview
value: gpt-4-0125-preview
- label: GPT-4 1106 Preview
value: gpt-4-1106-preview
- label: GPT-4
Expand Down
3 changes: 2 additions & 1 deletion firestore-chatgpt-bot/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
apiKey,
promptField,
responseField,
systemMessage,
collectionName,
parentMessageIdField,
} = config;
Expand All @@ -20,7 +21,7 @@ const {
const completionParams = logs.initialize(config);

// ChatGPT API Initialization
const chatgpt = new ChatGPTAPI({ apiKey, completionParams });
const chatgpt = new ChatGPTAPI({ apiKey, completionParams, ...(systemMessage ? { systemMessage } : {}) });

/**
* This is triggered whenever a document in the specified ${param:COLLECTION_NAME} is written.
Expand Down
2 changes: 2 additions & 0 deletions firestore-chatgpt-bot/functions/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Config {
model: string;
promptField: string;
responseField: string;
systemMessage: string;
collectionName: string;
temperature?: number;
topP?: number;
Expand All @@ -22,6 +23,7 @@ const config: Config = {
model: process.env.MODEL || "gpt-3.5-turbo",
promptField: process.env.PROMPT_FIELD || "prompt",
responseField: process.env.RESPONSE_FIELD || "response",
systemMessage: process.env.SYSTEM_MESSAGE || undefined,
collectionName: process.env.COLLECTION_NAME || "users/{userID}/messages",
temperature: process.env.TEMPERATURE
? parseFloat(process.env.TEMPERATURE)
Expand Down

0 comments on commit 8de342d

Please sign in to comment.