Skip to content

Commit

Permalink
port to new microsoft ai chat protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
John Aziz authored and John Aziz committed Jul 24, 2024
1 parent 5038dde commit f704d8b
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 204 deletions.
127 changes: 108 additions & 19 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@fluentui/react-components": "^9.37.3",
"@fluentui/react-icons": "^2.0.221",
"@react-spring/web": "^9.7.3",
"@microsoft/ai-chat-protocol": "1.0.0-beta.20240610.1",
"dompurify": "^3.0.6",
"ndjson-readablestream": "^1.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
Expand Down
28 changes: 0 additions & 28 deletions frontend/src/api/api.ts

This file was deleted.

1 change: 0 additions & 1 deletion frontend/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./api";
export * from "./models";
34 changes: 12 additions & 22 deletions frontend/src/api/models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AIChatCompletion, AIChatCompletionDelta, AIChatCompletionOperationOptions } from "@microsoft/ai-chat-protocol";

export const enum RetrievalMode {
Hybrid = "rag",
Vectors = "vector",
Expand All @@ -11,11 +13,14 @@ export type ChatAppRequestOverrides = {
score_threshold?: number;
};

export type ResponseMessage = {
content: string;
role: string;
export type ChatAppRequestContext = {
overrides: ChatAppRequestOverrides;
};

export interface ChatAppRequestOptions extends AIChatCompletionOperationOptions {
context: ChatAppRequestContext;
}

export type Thought = {
title: string;
description: string;
Expand All @@ -34,25 +39,10 @@ export type ResponseContext = {
thoughts: Thought[];
};

export type ChatAppResponseOrError = {
message: ResponseMessage;
export interface ChatCompletionResponse extends AIChatCompletion {
context: ResponseContext;
session_state: string;
error?: string;
};
}

export type ChatAppResponse = {
message: ResponseMessage;
export interface ChatCompletionDeltaResponse extends AIChatCompletionDelta {
context: ResponseContext;
session_state: string | null;
};

export type ChatAppRequestContext = {
overrides?: ChatAppRequestOverrides;
};

export type ChatAppRequest = {
messages: ResponseMessage[];
context?: ChatAppRequestContext;
session_state: string | null;
};
}
4 changes: 2 additions & 2 deletions frontend/src/components/AnalysisPanel/AnalysisPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Pivot, PivotItem } from "@fluentui/react";

import { SupportingContent } from "../SupportingContent";
import { ChatAppResponse } from "../../api";
import { ChatCompletionResponse } from "../../api";
import { AnalysisPanelTabs } from "./AnalysisPanelTabs";
import { ThoughtProcess } from "./ThoughtProcess";

interface Props {
className: string;
activeTab: AnalysisPanelTabs;
onActiveTabChanged: (tab: AnalysisPanelTabs) => void;
answer: ChatAppResponse;
answer: ChatCompletionResponse;
}

const pivotItemDisabledStyle = { disabled: true, style: { color: "grey" } };
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Answer/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import DOMPurify from "dompurify";

import styles from "./Answer.module.css";

import { ChatAppResponse } from "../../api";
import { ChatCompletionResponse } from "../../api";
import { parseAnswerToHtml } from "./AnswerParser";
import { AnswerIcon } from "./AnswerIcon";
import { SpeechOutput } from "./SpeechOutput";

interface Props {
answer: ChatAppResponse;
answer: ChatCompletionResponse;
isSelected?: boolean;
isStreaming: boolean;
onThoughtProcessClicked: () => void;
Expand Down
Loading

0 comments on commit f704d8b

Please sign in to comment.