fix ts sdk, tests pass

This commit is contained in:
phact 2025-12-16 23:19:08 -05:00
parent 20664c5064
commit 7ab0e5b011
4 changed files with 16 additions and 23 deletions

View file

@ -12,7 +12,6 @@ import type {
ConversationListResponse,
DoneEvent,
Message,
SearchFilters,
Source,
SourcesEvent,
StreamEvent,
@ -69,11 +68,11 @@ export class ChatStream implements AsyncIterable<StreamEvent>, Disposable {
};
if (this.options.chatId) {
body.chat_id = this.options.chatId;
body["chat_id"] = this.options.chatId;
}
if (this.options.filters) {
body.filters = this.options.filters;
body["filters"] = this.options.filters;
}
this._response = await this.client._request("POST", "/api/v1/chat", {
@ -212,11 +211,11 @@ export class ChatClient {
};
if (options.chatId) {
body.chat_id = options.chatId;
body["chat_id"] = options.chatId;
}
if (options.filters) {
body.filters = options.filters;
body["filters"] = options.filters;
}
const response = await this.client._request("POST", "/api/v1/chat", {
@ -260,11 +259,11 @@ export class ChatClient {
const conversations: Conversation[] = (data.conversations || []).map(
(c: Record<string, unknown>) => ({
chatId: c.chat_id,
title: c.title || "",
createdAt: c.created_at || null,
lastActivity: c.last_activity || null,
messageCount: c.message_count || 0,
chatId: c["chat_id"],
title: c["title"] || "",
createdAt: c["created_at"] || null,
lastActivity: c["last_activity"] || null,
messageCount: c["message_count"] || 0,
})
);
@ -282,9 +281,9 @@ export class ChatClient {
const messages: Message[] = (data.messages || []).map(
(m: Record<string, unknown>) => ({
role: m.role,
content: m.content,
timestamp: m.timestamp || null,
role: m["role"],
content: m["content"],
timestamp: m["timestamp"] || null,
})
);

View file

@ -139,7 +139,7 @@ export class OpenRAGClient {
const response = await fetch(url, {
method,
headers,
body: options.body,
body: options.body ?? null,
signal: controller.signal,
});

View file

@ -3,7 +3,7 @@
*/
import type { OpenRAGClient } from "./client";
import type { SearchFilters, SearchQueryOptions, SearchResponse } from "./types";
import type { SearchQueryOptions, SearchResponse } from "./types";
export class SearchClient {
constructor(private client: OpenRAGClient) {}
@ -26,7 +26,7 @@ export class SearchClient {
};
if (options?.filters) {
body.filters = options.filters;
body["filters"] = options.filters;
}
const response = await this.client._request("POST", "/api/v1/search", {

View file

@ -115,13 +115,7 @@ describe.skipIf(SKIP_TESTS)("OpenRAG TypeScript SDK Integration", () => {
describe("Search", () => {
it("should search documents", async () => {
// Ensure document is ingested
await client.documents.ingest({ filePath: testFilePath });
// Wait for indexing
await new Promise((resolve) => setTimeout(resolve, 2000));
// Search
// Documents already ingested by previous tests
const results = await client.search.query("orange kangaroos jumping");
expect(results.results).toBeDefined();