add divider
This commit is contained in:
parent
7967e6ab96
commit
554ef49a3e
|
|
@ -22,6 +22,18 @@
|
||||||
color: #e0e0e0;
|
color: #e0e0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-disclaimer {
|
||||||
|
text-align: center;
|
||||||
|
color: var(--vscode-editorBracketMatch-border);
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-container hr {
|
||||||
|
width: 100%;
|
||||||
|
border: none;
|
||||||
|
border-top: 1px solid var(--vscode-titleBar-inactiveBackground);
|
||||||
|
}
|
||||||
|
|
||||||
.messages-container {
|
.messages-container {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ export function AIConversation({ history, conversation }: { history: LLMMessage[
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='chat-container'>
|
<div className='chat-container'>
|
||||||
|
<p className='chat-disclaimer'>Chat based on {conversation.chat.api.name}. Check for mistakes.</p>
|
||||||
|
<hr/>
|
||||||
<div className='messages-container'>
|
<div className='messages-container'>
|
||||||
{history.filter(({ role }) => role !== 'developer').map((message, index) => (
|
{history.filter(({ role }) => role !== 'developer').map((message, index) => (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export type LLMMessage = {
|
||||||
};
|
};
|
||||||
|
|
||||||
interface LLM {
|
interface LLM {
|
||||||
|
readonly name: string;
|
||||||
chatCompletion(messages: LLMMessage[], signal: AbortSignal): AsyncGenerator<string>;
|
chatCompletion(messages: LLMMessage[], signal: AbortSignal): AsyncGenerator<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,6 +97,8 @@ async function *parseSSE(body: NonNullable<Response['body']>): AsyncGenerator<{
|
||||||
|
|
||||||
class OpenAI implements LLM {
|
class OpenAI implements LLM {
|
||||||
|
|
||||||
|
name = 'OpenAI';
|
||||||
|
|
||||||
constructor(private apiKey: string, private baseURL = 'https://api.openai.com') {}
|
constructor(private apiKey: string, private baseURL = 'https://api.openai.com') {}
|
||||||
|
|
||||||
async *chatCompletion(messages: LLMMessage[], signal: AbortSignal) {
|
async *chatCompletion(messages: LLMMessage[], signal: AbortSignal) {
|
||||||
|
|
@ -130,6 +133,7 @@ class OpenAI implements LLM {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Anthropic implements LLM {
|
class Anthropic implements LLM {
|
||||||
|
name = 'Anthropic';
|
||||||
constructor(private apiKey: string, private baseURL = 'https://api.anthropic.com') {}
|
constructor(private apiKey: string, private baseURL = 'https://api.anthropic.com') {}
|
||||||
async *chatCompletion(messages: LLMMessage[], signal: AbortSignal): AsyncGenerator<string> {
|
async *chatCompletion(messages: LLMMessage[], signal: AbortSignal): AsyncGenerator<string> {
|
||||||
const response = await fetch(new URL('./v1/messages', this.baseURL), {
|
const response = await fetch(new URL('./v1/messages', this.baseURL), {
|
||||||
|
|
@ -180,7 +184,7 @@ export class Conversation {
|
||||||
onChange = new EventEmitter<void>();
|
onChange = new EventEmitter<void>();
|
||||||
private _abortControllers = new Set<AbortController>();
|
private _abortControllers = new Set<AbortController>();
|
||||||
|
|
||||||
constructor(private chat: LLMChat, systemPrompt: string) {
|
constructor(public chat: LLMChat, systemPrompt: string) {
|
||||||
this.history = [{ role: 'developer', content: systemPrompt }];
|
this.history = [{ role: 'developer', content: systemPrompt }];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue