Skip to content

Commit

Permalink
Fix renderModelOptions provider
Browse files Browse the repository at this point in the history
  • Loading branch information
UdaraJay committed Jan 6, 2024
1 parent 7acb736 commit f2f0fd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/renderer/pages/Pile/Editor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Editor = memo(
deletePost,
} = usePost(postPath, { isReply, parentPostPath, reloadParentPost, isAI });
const { getThread } = useThread();
const { ai, model, type, prompt } = useAIContext();
const { ai, provider, model, prompt } = useAIContext();
const { addNotification, removeNotification } = useToastsContext();

const isNew = !postPath;
Expand Down Expand Up @@ -249,15 +249,17 @@ const Editor = memo(
if (context.length === 0) return;

const stream = await ai.chat.completions.create({
model: model,
model: 'gpt-4',
stream: true,
max_tokens: 200,
messages: context,
});

for await (const part of stream) {
let token = '';
if (type == 'openai') {
console.log('model', model);
if (provider == 'openai') {
console.log('part.choices[0]', part);
token = part.choices[0].delta.content;
} else {
token = part.message.content;
Expand Down
17 changes: 11 additions & 6 deletions src/renderer/pages/Pile/Settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,26 @@ export default function Settings() {
};

const renderModelOptions = () => {
return Object.keys(availableModelsProviders).map((model, index) => {
return Object.keys(availableModelsProviders).map((_provider, index) => {
return (
<button
key={`model-${model}`}
className={`${styles.model} ${provider == model && styles.current}`}
key={`model-${_provider}`}
className={`${styles.model} ${
provider == _provider && styles.current
}`}
onClick={() => {
setProvider(model);
setProvider(_provider);
if (_provider == 'openai') {
setModel('gpt-4');
}
}}
>
{model === 'openai' ? (
{_provider === 'openai' ? (
<OpenAIIcon className={styles.icon} />
) : (
<OllamaIcon className={`${styles.icon} ${styles.ollama}`} />
)}
{availableModelsProviders[model]}
{availableModelsProviders[_provider]}
</button>
);
});
Expand Down

0 comments on commit f2f0fd2

Please sign in to comment.