Skip to content

Commit

Permalink
Updated Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
PapaRascal2020 committed Sep 27, 2024
1 parent 4c70d83 commit 07d2ab3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
6 changes: 1 addition & 5 deletions stubs/default/resources/views/Pages/chatroom.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@section('content')
<!-- Header -->
<header class="bg-slate-900 shadow p-4 flex justify-between items-center text-white">
<h1 class="text-xl text-white font-semibold">Conversation <small class="text-sm">(id: {{$conversationId}}) - Engine: {{($config->model != '') ? $config->model : 'Auto-Select'}}</small></h1>
<h1 class="text-xl text-white font-semibold">Conversation <small class="text-sm">(id: {{$conversationId}}) - Model: {{ $config['model'] ?? 'Auto-Select'}}</small></h1>

<div>
<a href="/sidekick/chat" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700">New Chat</a>
Expand Down Expand Up @@ -40,7 +40,6 @@

<x-sidekick-form url="/sidekick/chat/update">
<input id="conversation_id" type="hidden" name="conversation_id" value="{{$conversationId}}" />
<input id="engine" type="hidden" name="engine" value="{{$config->model}}" />
<label class="inline-flex items-center cursor-pointer">
<input type="checkbox" id="stream" name="stream" value="" class="sr-only peer">
<div class="relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
Expand All @@ -56,7 +55,6 @@
const form = document.getElementById('sidekick-form');
const container = document.getElementById('scrollableDiv');
const messageInput = document.getElementById('prompt');
const engine = document.getElementById('engine');
const stream = document.getElementById('stream');
const conversationId = document.getElementById('conversation_id');
const responseContainer = document.getElementById('response-container');
Expand Down Expand Up @@ -121,7 +119,6 @@
body: JSON.stringify({
message: message,
conversation_id: conversationId.value,
engine: engine.value,
stream: true
})
}).then(async (response) => {
Expand Down Expand Up @@ -170,7 +167,6 @@ function handleCallback() {
body: JSON.stringify({
message: message,
conversation_id: conversationId.value,
engine: engine.value,
stream: false
})
}).then(promise => promise.text()).then(response => {
Expand Down
2 changes: 1 addition & 1 deletion stubs/default/resources/views/Shared/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<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}}"
<a href="/sidekick/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>
Expand Down
9 changes: 5 additions & 4 deletions stubs/default/routes/web.sidekick.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
Route::post('/sidekick/chat', function (Request $request) {

// These are the settings from the drop down on the front end.
$config = json_decode($request->get('config'));
$config = json_decode($request->get('config'), true);

// This is the system prompt the user wants the AI to use
$systemPrompt = $request->get('prompt');

// Call sidekick and send the first message
$conversation = sidekickConversation()->begin(
driver: new $config->engine(),
model: $config->model,
driver: new $config['engine'](),
model: $config['model'],
systemPrompt: $systemPrompt
);

Expand Down Expand Up @@ -43,7 +43,8 @@
return view('Pages.chatroom', [
'conversationId' => $conversation->model->id,
'config' => [
'model' => $conversation->model->class,
'engine' => $conversation->model->class,
'model' => $conversation->model->model,
],
'messages' => $conversation->model->messages,
'conversations' => sidekickConversation()->database()->all('id', 'model')
Expand Down

0 comments on commit 07d2ab3

Please sign in to comment.