This commit is contained in:
Simon Knott 2025-02-13 10:35:10 +01:00
parent 9039c59c65
commit 2d11c291d8
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
3 changed files with 20 additions and 5 deletions

View file

@ -1,4 +1,19 @@
/* Main container */
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.chat-container {
flex: 1;
display: flex;

View file

@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
import Markdown from 'react-markdown'
import './aiConversation.css';
import { clsx } from '@web/uiUtils';
import { Conversation, LLMMessage } from '@isomorphic/llm';
import type { Conversation, LLMMessage } from './llm';
export function AIConversation({ history, conversation, firstPrompt }: { history: LLMMessage[], conversation: Conversation, firstPrompt?: LLMMessage }) {
const [input, setInput] = useState('');

View file

@ -108,7 +108,7 @@ class OpenAI implements LLM {
'x-pw-serviceworker': 'forward',
},
body: JSON.stringify({
model: 'gpt-4o',
model: 'gpt-4o', // TODO: make configurable
messages: messages.map(({ role, content }) => ({ role, content })),
stream: true,
}),
@ -140,7 +140,7 @@ class Anthropic implements LLM {
'x-pw-serviceworker': 'forward',
},
body: JSON.stringify({
model: 'claude-3-5-sonnet-20241022',
model: 'claude-3-5-sonnet-20241022', // TODO: make configurable
messages: messages.filter(({ role }) => role !== 'developer').map(({ role, content }) => ({ role, content })),
system: messages.find(({ role }) => role === 'developer')?.content,
max_tokens: 1024,
@ -173,7 +173,7 @@ class LLMChat {
}
}
class Conversation {
export class Conversation {
history: LLMMessage[];
onChange = new EventEmitter<void>();