more
This commit is contained in:
parent
9039c59c65
commit
2d11c291d8
|
|
@ -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 {
|
.chat-container {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
import './aiConversation.css';
|
import './aiConversation.css';
|
||||||
import { clsx } from '@web/uiUtils';
|
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 }) {
|
export function AIConversation({ history, conversation, firstPrompt }: { history: LLMMessage[], conversation: Conversation, firstPrompt?: LLMMessage }) {
|
||||||
const [input, setInput] = useState('');
|
const [input, setInput] = useState('');
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ class OpenAI implements LLM {
|
||||||
'x-pw-serviceworker': 'forward',
|
'x-pw-serviceworker': 'forward',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
model: 'gpt-4o',
|
model: 'gpt-4o', // TODO: make configurable
|
||||||
messages: messages.map(({ role, content }) => ({ role, content })),
|
messages: messages.map(({ role, content }) => ({ role, content })),
|
||||||
stream: true,
|
stream: true,
|
||||||
}),
|
}),
|
||||||
|
|
@ -140,7 +140,7 @@ class Anthropic implements LLM {
|
||||||
'x-pw-serviceworker': 'forward',
|
'x-pw-serviceworker': 'forward',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
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 })),
|
messages: messages.filter(({ role }) => role !== 'developer').map(({ role, content }) => ({ role, content })),
|
||||||
system: messages.find(({ role }) => role === 'developer')?.content,
|
system: messages.find(({ role }) => role === 'developer')?.content,
|
||||||
max_tokens: 1024,
|
max_tokens: 1024,
|
||||||
|
|
@ -173,7 +173,7 @@ class LLMChat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Conversation {
|
export class Conversation {
|
||||||
history: LLMMessage[];
|
history: LLMMessage[];
|
||||||
onChange = new EventEmitter<void>();
|
onChange = new EventEmitter<void>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue