Skip to content

Commit

Permalink
Update agent.module.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jul 23, 2024
1 parent 0e1a327 commit 0173929
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions indexer/src/app/modules/agent.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ import { DynamicModule, Logger, Module } from '@nestjs/common';
import { pull } from 'langchain/hub';
import { HttpService } from '@nestjs/axios';

const formatChatHistory = (chatHistory: string | string[]) => {
const formatChatHistory = (chatHistory: any) => {
if (Array.isArray(chatHistory)) {
const updatedChat = chatHistory
.map((dialogTurn: any) => {
if (dialogTurn['role'] == 'user') {
return `Human: ${dialogTurn['content']}`;
.map((dialogTurn: HumanMessage | AIMessage | SystemMessage) => {
const mType = dialogTurn._getType();
if (mType == 'human') {
return `Human: ${dialogTurn.content}`;
}
if (dialogTurn['role'] == 'assistant') {
return `AI: ${dialogTurn['content']}`;
if (mType === 'ai') {
return `AI: ${dialogTurn.content}`;
}
if (dialogTurn['role'] == 'system') {
return `System: ${dialogTurn['content']}`;
if (mType == 'system') {
return `System: ${dialogTurn.content}`;
}
})
.join('\n');
Expand Down

0 comments on commit 0173929

Please sign in to comment.