Skip to content

Commit 51375f8

Browse files
committed
server/llm: combine langchain implementations in a single file -- add tests
1 parent a602031 commit 51375f8

File tree

6 files changed

+503
-40
lines changed

6 files changed

+503
-40
lines changed

src/.claude/settings.local.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
"WebFetch(domain:github.com)",
1212
"WebFetch(domain:cocalc.com)",
1313
"WebFetch(domain:doc.cocalc.com)",
14-
"Bash(npm show:*)"
14+
"Bash(npm show:*)",
15+
"Bash(prettier -w:*)"
1516
],
1617
"deny": []
1718
}
18-
}
19+
}

src/packages/server/llm/custom-openai.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function evaluateCustomOpenAI(
5353

5454
const prompt = ChatPromptTemplate.fromMessages([
5555
["system", system ?? ""],
56-
new MessagesPlaceholder("chat_history"),
56+
new MessagesPlaceholder("history"),
5757
["human", "{input}"],
5858
]);
5959

@@ -65,11 +65,10 @@ export async function evaluateCustomOpenAI(
6565
runnable: chain,
6666
config: { configurable: { sessionId: "ignored" } },
6767
inputMessagesKey: "input",
68-
historyMessagesKey: "chat_history",
68+
historyMessagesKey: "history",
6969
getMessageHistory: async () => {
70-
const { messageHistory, tokens } = await transformHistoryToMessages(
71-
history,
72-
);
70+
const { messageHistory, tokens } =
71+
await transformHistoryToMessages(history);
7372
historyTokens = tokens;
7473
return messageHistory;
7574
},
@@ -86,7 +85,7 @@ export async function evaluateCustomOpenAI(
8685
}
8786
output += content;
8887
opts.stream?.(content);
89-
88+
9089
// Collect the final result to check for usage metadata
9190
if (finalResult) {
9291
finalResult = concat(finalResult, chunk);
@@ -109,7 +108,7 @@ export async function evaluateCustomOpenAI(
109108
output_tokens,
110109
total_tokens,
111110
});
112-
111+
113112
return {
114113
output,
115114
total_tokens,

0 commit comments

Comments
 (0)