Skip to content

Commit

Permalink
fix linting, remove test stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Dec 4, 2023
1 parent 2fcaa03 commit f4f09b2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on: pull_request

jobs:
linting:
uses: yext/slapshot-reusable-workflows/.github/workflows/run-linting.yml@v1
uses: yext/slapshot-reusable-workflows/.github/workflows/run-linting.yml@v1
6 changes: 3 additions & 3 deletions src/CoreProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { ChatCoreImpl } from "./infra/ChatCoreImpl";
import { ChatConfig, InternalConfig, ChatCore } from "./models";

/**
* Provider for the ChatCore library. This is a test
* Provider for the ChatCore library.
*
* @public
*/
export function provideChatCore(config : ChatConfig ): ChatCore {
return new ChatCoreImpl(config)
export function provideChatCore(config: ChatConfig): ChatCore {
return new ChatCoreImpl(config);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/infra/ChatCoreImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export class ChatCoreImpl implements ChatCore {
constructor(chatConfig: ChatConfig, internalConfig: InternalConfig = {}) {
this.chatConfig = chatConfig;
this.httpService = new HttpServiceImpl();
this.endpoints = chatConfig.endpoints ?? EndpointsFactory.getEndpoints(this.chatConfig);
this.internalConfig = internalConfig
this.endpoints =
chatConfig.endpoints ?? EndpointsFactory.getEndpoints(this.chatConfig);
this.internalConfig = internalConfig;
}

async getNextMessage(request: MessageRequest): Promise<MessageResponse> {
Expand All @@ -39,7 +40,7 @@ export class ChatCoreImpl implements ChatCore {
...request,
version: this.chatConfig.version,
promptPackage: this.internalConfig.promptPackage,
aiMode: this.internalConfig.aiMode
aiMode: this.internalConfig.aiMode,
};
const rawResponse = await this.httpService.post(
this.endpoints.chat,
Expand Down Expand Up @@ -74,7 +75,7 @@ export class ChatCoreImpl implements ChatCore {
...request,
version: this.chatConfig.version,
promptPackage: this.internalConfig.promptPackage,
aiMode: this.internalConfig.aiMode
aiMode: this.internalConfig.aiMode,
};
const rawResponse = await this.httpService.post(
this.endpoints.chatStream,
Expand Down
18 changes: 13 additions & 5 deletions test-node-cjs/node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import http from "http";
import { ChatConfig, InternalConfig, MessageRequest, StreamEventName, provideChatCoreInternal } from "@yext/chat-core";
import {
ChatConfig,
InternalConfig,
MessageRequest,
StreamEventName,
provideChatCoreInternal,
} from "@yext/chat-core";
import dotenv from "dotenv";

dotenv.config();
Expand All @@ -14,17 +20,19 @@ const config: ChatConfig = {
},
};

const internalConfig: InternalConfig = { /** for testing pursposes */}
const internalConfig: InternalConfig = {
/** for testing pursposes */
};

const request: MessageRequest = {
messages: [
{
timestamp: "2023-05-17T19:21:21.915Z",
source: "USER",
text: "How do I send an email?",
}
]
}
},
],
};

async function stream(res: any) {
const chatCore = provideChatCoreInternal(config, internalConfig);
Expand Down
7 changes: 3 additions & 4 deletions tests/ChatCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ describe("URL and http request construction", () => {
foo: "bar",
},
messages: [],

},
"my-api-key"
);
Expand All @@ -156,7 +155,7 @@ describe("URL and http request construction", () => {

const configWithVersion: ChatConfig = {
...defaultConfig,
version: '42',
version: "42",
};

it("sets custom version when specified for Chat API", async () => {
Expand All @@ -167,7 +166,7 @@ describe("URL and http request construction", () => {
"https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message",
{ v: defaultApiVersion },
{
version: '42',
version: "42",
conversationId: "my-id",
context: {
foo: "bar",
Expand All @@ -186,7 +185,7 @@ describe("URL and http request construction", () => {
"https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message/streaming",
{ v: defaultApiVersion },
{
version: '42',
version: "42",
conversationId: "my-id",
context: {
foo: "bar",
Expand Down

0 comments on commit f4f09b2

Please sign in to comment.