Skip to content

Commit

Permalink
fix: add model name with provider to history
Browse files Browse the repository at this point in the history
  • Loading branch information
ogzhanolguncu committed May 31, 2024
1 parent ca2144a commit cf8bf82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 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.27-alpha",
"version": "0.0.29-alpha",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
10 changes: 6 additions & 4 deletions src/history/redis-custom-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ export class CustomUpstashRedisChatMessageHistory extends BaseListChatMessageHis
* @returns Promise resolving to void.
*/
async addMessage(message: BaseMessage): Promise<void> {
message.response_metadata = {
...message.response_metadata,
modelNameWithProvider: this.modelNameWithProvider,
};
const messageToAdd = mapChatMessagesToStoredMessages([message]);
await this.client.lpush(
this.sessionId,
JSON.stringify({ ...messageToAdd[0], modelNameWithProvider: this.modelNameWithProvider })
);

await this.client.lpush(this.sessionId, JSON.stringify(messageToAdd[0]));
if (this.sessionTTL) {
await this.client.expire(this.sessionId, this.sessionTTL);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rag-chat-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class RAGChatBase {
}

/** This method first gets required params, then returns another function depending on streaming param input */
chainCall(chatOptions: ChatOptions, question: string, facts: string) {
protected chainCall(chatOptions: ChatOptions, question: string, facts: string) {
const formattedHistoryChain = RunnableSequence.from<CustomInputValues>([
{
chat_history: (input) => formatChatHistory(input.chat_history ?? []),
Expand Down

0 comments on commit cf8bf82

Please sign in to comment.