Skip to content

Commit

Permalink
Restored chat history on sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
PapaRascal2020 committed Sep 27, 2024
1 parent 9aec931 commit 4c70d83
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
8 changes: 8 additions & 0 deletions stubs/default/resources/views/Shared/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
</div>
<nav class="space-y-4">
<a href="/sidekick/chat" class="block text-white hover:bg-gray-600 px-4 py-2 rounded">Chats</a>
@if(isset($conversations))
@foreach($conversations as $conversation)
<a href="/sidekick/playground/chat/{{$conversation->id}}"
class="block text-white text-xs hover:bg-gray-600 px-6 py-2 rounded">
{{($conversation->model != '') ? $conversation->model : 'Auto-Select'}} : {{explode('-', $conversation->id)[0]}}
</a>
@endforeach
@endif
<a href="/sidekick/completion" class="block text-white hover:bg-gray-600 px-4 py-2 rounded">Completion</a>
<a href="/sidekick/image" class="block text-white hover:bg-gray-600 px-4 py-2 rounded">Image Generation</a>
<a href="/sidekick/audio" class="block text-white hover:bg-gray-600 px-4 py-2 rounded">Audio Generation</a>
Expand Down
50 changes: 35 additions & 15 deletions stubs/default/routes/web.sidekick.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
// Return the conversation to the browser
return view('Pages.chatroom', [
'conversationId' => $conversation->model->id,
'options' => $conversation->model->class,
'messages' => $conversation->model->messages
'config' => [
'model' => $conversation->model->class,
],
'messages' => $conversation->model->messages,
'conversations' => sidekickConversation()->database()->all('id', 'model')
]);
});

Expand All @@ -56,7 +59,7 @@
});

Route::get('/sidekick/completion', function () {
return view('Pages.completion');
return view('Pages.completion', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::post('/sidekick/completion', function (Request $request) {
Expand All @@ -70,7 +73,7 @@
});

Route::get('/sidekick/audio', function () {
return view('Pages.audio');
return view('Pages.audio', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::post('/sidekick/audio', function (Request $request) {
Expand All @@ -84,7 +87,11 @@
$savedFile = sidekick(new OpenAi)->utilities()->store($audio, 'audio/mpeg');

// Return the base64 encoded audio file to the front end
return view('Pages.audio', ['audio' => base64_encode($audio), 'savedFile' => $savedFile]);
return view('Pages.audio', [
'audio' => base64_encode($audio),
'savedFile' => $savedFile,
'conversations' => sidekickConversation()->database()->all('id', 'model')
]);
});

Route::post('/sidekick/image', function (Request $request) {
Expand All @@ -97,54 +104,67 @@

$savedFile = sidekick(new OpenAi)->utilities()->store($image['data'][0]['url'], 'image/png');

return view('Pages.image', ['image' => $image['data'][0]['url'], 'savedFile' => $savedFile]);
return view('Pages.image', [
'image' => $image['data'][0]['url'],
'savedFile' => $savedFile,
'conversations' => sidekickConversation()->database()->all('id', 'model')
]);
});

Route::post('/sidekick/transcribe', function (Request $request) {
$response = sidekick(new OpenAi)->transcribe()->audioFile(
model:'whisper-1',
filePath:$request->get('prompt')
);
return view('Pages.transcribe', ['response' => $response]);
return view('Pages.transcribe', [
'response' => $response,
'conversations' => sidekickConversation()->database()->all('id', 'model')
]);
});

Route::post('/sidekick/embedding', function (Request $request) {
$response = sidekick(new OpenAi)->embedding()->make(
model:'text-embedding-3-large',
input: $request->get('prompt'),
);
return view('Pages.embedding', ['response' => $response]);
return view('Pages.embedding', [
'response' => $response,
'conversations' => sidekickConversation()->database()->all('id', 'model')
]);
});

Route::get('/sidekick/moderate', function () {
return view('Pages.moderate');
return view('Pages.moderate', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::post('/sidekick/moderate', function (Request $request) {
$response = sidekick(new OpenAi)->moderate()->text(
model:'text-moderation-latest',
content: $request->get('prompt')
);
return view('Pages.moderate', ['response' => $response]);
return view('Pages.moderate', [
'response' => $response,
'conversations' => sidekickConversation()->database()->all('id', 'model')
]);
});

Route::get('/sidekick/image', function () {
return view('Pages.image');
return view('Pages.image', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::get('/sidekick/transcribe', function () {
return view('Pages.transcribe');
return view('Pages.transcribe', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::get('/sidekick/embedding', function () {
return view('Pages.embedding');
return view('Pages.embedding', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::get('/sidekick/chat', function () {
return view('Pages.chat');
return view('Pages.chat', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

Route::get('/sidekick', function () {
return view('Pages.index');
return view('Pages.index', ['conversations' => sidekickConversation()->database()->all('id', 'model')]);
});

0 comments on commit 4c70d83

Please sign in to comment.