Skip to content

Commit

Permalink
fix: make history param optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ogzhanolguncu committed May 31, 2024
1 parent cf8bf82 commit 912de7b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upstash/rag-chat",
"version": "0.0.29-alpha",
"version": "0.0.30-alpha",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/history/in-memory-custom-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type { BaseMessage } from "@langchain/core/messages";
export type CustomInMemoryChatMessageHistoryInput = {
messages?: BaseMessage[];
topLevelChatHistoryLength?: number;
modelNameWithProvider: string;
modelNameWithProvider?: string;
};

export class CustomInMemoryChatMessageHistory extends BaseListChatMessageHistory {
lc_namespace = ["langchain", "stores", "message", "in_memory"];

private messages: BaseMessage[] = [];
private topLevelChatHistoryLength?: number;
private modelNameWithProvider: string;
private modelNameWithProvider?: string;

constructor(fields: CustomInMemoryChatMessageHistoryInput) {
const { modelNameWithProvider, messages, topLevelChatHistoryLength } = fields;
Expand Down
8 changes: 4 additions & 4 deletions src/history/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { InternalUpstashError } from "../error";

type HistoryConfig = {
redis?: Redis;
modelNameWithProvider: string;
modelNameWithProvider?: string;
};
type GetHistory = { sessionId: string; length?: number; sessionTTL?: number };

export class History {
private redis?: Redis;
private modelNameWithProvider: string;
private modelNameWithProvider?: string;
private inMemoryChatHistory?: CustomInMemoryChatMessageHistory;

constructor(fields: HistoryConfig) {
const { modelNameWithProvider, redis } = fields;
constructor(fields?: HistoryConfig) {
const { modelNameWithProvider, redis } = fields ?? {};

this.redis = redis;
this.modelNameWithProvider = modelNameWithProvider;
Expand Down
4 changes: 2 additions & 2 deletions src/history/redis-custom-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type CustomUpstashRedisChatMessageHistoryInput = {
config?: RedisConfigNodejs;
client?: Redis;
topLevelChatHistoryLength?: number;
modelNameWithProvider: string;
modelNameWithProvider?: string;
};

/**
Expand All @@ -39,7 +39,7 @@ export class CustomUpstashRedisChatMessageHistory extends BaseListChatMessageHis
public client: Redis;

private sessionId: string;
private modelNameWithProvider: string;
private modelNameWithProvider?: string;

private sessionTTL?: number;
private topLevelChatHistoryLength?: number;
Expand Down

0 comments on commit 912de7b

Please sign in to comment.