Linting (width 120)
This commit is contained in:
		
							parent
							
								
									de60734234
								
							
						
					
					
						commit
						3c778e5a91
					
				| 
						 | 
				
			
			@ -1,12 +1,7 @@
 | 
			
		|||
<script lang="ts">
 | 
			
		||||
  //import { fetchEventSource } from "@microsoft/fetch-event-source";
 | 
			
		||||
 | 
			
		||||
  import {
 | 
			
		||||
    apiKeyStorage,
 | 
			
		||||
    chatsStorage,
 | 
			
		||||
    addMessage,
 | 
			
		||||
    clearMessages,
 | 
			
		||||
  } from "./Storage.svelte";
 | 
			
		||||
  import { apiKeyStorage, chatsStorage, addMessage, clearMessages } from "./Storage.svelte";
 | 
			
		||||
  import type { Message } from "./Types.svelte";
 | 
			
		||||
 | 
			
		||||
  import { marked } from "marked";
 | 
			
		||||
| 
						 | 
				
			
			@ -135,13 +130,9 @@
 | 
			
		|||
        {@html marked(message.content)}
 | 
			
		||||
        {#if message.usage}
 | 
			
		||||
          <p class="is-size-7">
 | 
			
		||||
            This message was generated using <span class="has-text-weight-bold"
 | 
			
		||||
              >{message.usage.total_tokens}</span
 | 
			
		||||
            >
 | 
			
		||||
            This message was generated using <span class="has-text-weight-bold">{message.usage.total_tokens}</span>
 | 
			
		||||
            tokens ~=
 | 
			
		||||
            <span class="has-text-weight-bold"
 | 
			
		||||
              >${(message.usage.total_tokens * token_price).toFixed(6)}</span
 | 
			
		||||
            >
 | 
			
		||||
            <span class="has-text-weight-bold">${(message.usage.total_tokens * token_price).toFixed(6)}</span>
 | 
			
		||||
          </p>
 | 
			
		||||
        {/if}
 | 
			
		||||
      </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,26 +8,13 @@
 | 
			
		|||
 | 
			
		||||
<article class="message">
 | 
			
		||||
  <div class="message-body">
 | 
			
		||||
    <strong
 | 
			
		||||
      ><a href="https://github.com/Niek/chatgpt-web">ChatGPT-web</a></strong
 | 
			
		||||
    >
 | 
			
		||||
    is a simple one-page web interface to the OpenAI ChatGPT API. To use it, you
 | 
			
		||||
    need to register for
 | 
			
		||||
    <a
 | 
			
		||||
      href="https://platform.openai.com/account/api-key"
 | 
			
		||||
      target="_blank"
 | 
			
		||||
      rel="noreferrer">an OpenAI API key</a
 | 
			
		||||
    >
 | 
			
		||||
    first. OpenAI bills per token (usage-based), which means it is a lot cheaper
 | 
			
		||||
    than
 | 
			
		||||
    <a
 | 
			
		||||
      href="https://openai.com/blog/chatgpt-plus"
 | 
			
		||||
      target="_blank"
 | 
			
		||||
      rel="noreferrer">ChatGPT Plus</a
 | 
			
		||||
    >, unless you use more than 10 million tokens per month. All messages are
 | 
			
		||||
    stored in your browser's local storage, so everything is
 | 
			
		||||
    <strong>private</strong>. You can also close the browser tab and come back
 | 
			
		||||
    later to continue the conversation.
 | 
			
		||||
    <strong><a href="https://github.com/Niek/chatgpt-web">ChatGPT-web</a></strong>
 | 
			
		||||
    is a simple one-page web interface to the OpenAI ChatGPT API. To use it, you need to register for
 | 
			
		||||
    <a href="https://platform.openai.com/account/api-key" target="_blank" rel="noreferrer">an OpenAI API key</a>
 | 
			
		||||
    first. OpenAI bills per token (usage-based), which means it is a lot cheaper than
 | 
			
		||||
    <a href="https://openai.com/blog/chatgpt-plus" target="_blank" rel="noreferrer">ChatGPT Plus</a>, unless you use
 | 
			
		||||
    more than 10 million tokens per month. All messages are stored in your browser's local storage, so everything is
 | 
			
		||||
    <strong>private</strong>. You can also close the browser tab and come back later to continue the conversation.
 | 
			
		||||
  </div>
 | 
			
		||||
</article>
 | 
			
		||||
<article class="message {!apiKey ? 'is-danger' : 'is-warning'}">
 | 
			
		||||
| 
						 | 
				
			
			@ -41,12 +28,7 @@
 | 
			
		|||
      }}
 | 
			
		||||
    >
 | 
			
		||||
      <p class="control is-expanded">
 | 
			
		||||
        <input
 | 
			
		||||
          aria-label="OpenAI API key"
 | 
			
		||||
          type="text"
 | 
			
		||||
          class="input {!apiKey ? 'is-danger' : ''}"
 | 
			
		||||
          value={apiKey}
 | 
			
		||||
        />
 | 
			
		||||
        <input aria-label="OpenAI API key" type="text" class="input {!apiKey ? 'is-danger' : ''}" value={apiKey} />
 | 
			
		||||
      </p>
 | 
			
		||||
      <p class="control">
 | 
			
		||||
        <button class="button is-info" type="submit">Save</button>
 | 
			
		||||
| 
						 | 
				
			
			@ -54,9 +36,7 @@
 | 
			
		|||
    </form>
 | 
			
		||||
 | 
			
		||||
    {#if !apiKey}
 | 
			
		||||
      <p class="help is-danger">
 | 
			
		||||
        Please enter your OpenAI API key above to use ChatGPT-web
 | 
			
		||||
      </p>
 | 
			
		||||
      <p class="help is-danger">Please enter your OpenAI API key above to use ChatGPT-web</p>
 | 
			
		||||
    {/if}
 | 
			
		||||
  </div>
 | 
			
		||||
</article>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,13 +19,10 @@
 | 
			
		|||
            <li>
 | 
			
		||||
              <a
 | 
			
		||||
                href={"#"}
 | 
			
		||||
                class="panel-block {!apiKey
 | 
			
		||||
                  ? 'is-disabled'
 | 
			
		||||
                  : ''} {activeChatId === chat.id
 | 
			
		||||
                class="panel-block {!apiKey ? 'is-disabled' : ''} {activeChatId === chat.id
 | 
			
		||||
                  ? 'has-background-light'
 | 
			
		||||
                  : ''}"
 | 
			
		||||
                on:click|preventDefault={() => (activeChatId = chat.id)}
 | 
			
		||||
                >Chat {chat.id}</a
 | 
			
		||||
                on:click|preventDefault={() => (activeChatId = chat.id)}>Chat {chat.id}</a
 | 
			
		||||
              >
 | 
			
		||||
            </li>
 | 
			
		||||
          {/each}
 | 
			
		||||
| 
						 | 
				
			
			@ -38,9 +35,7 @@
 | 
			
		|||
    <li>
 | 
			
		||||
      <a
 | 
			
		||||
        href={"#"}
 | 
			
		||||
        class="panel-block {!apiKey ? 'is-disabled' : ''} {activeChatId
 | 
			
		||||
          ? ''
 | 
			
		||||
          : 'has-background-light'}"
 | 
			
		||||
        class="panel-block {!apiKey ? 'is-disabled' : ''} {activeChatId ? '' : 'has-background-light'}"
 | 
			
		||||
        on:click|preventDefault={() => {
 | 
			
		||||
          activeChatId = null;
 | 
			
		||||
        }}><span class="greyscale mr-2">🔑</span> API key</a
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,8 +10,7 @@
 | 
			
		|||
    const chats = get(chatsStorage);
 | 
			
		||||
 | 
			
		||||
    // Find the max chatId
 | 
			
		||||
    const chatId =
 | 
			
		||||
      chats.reduce((maxId, chat) => Math.max(maxId, chat.id), 0) + 1;
 | 
			
		||||
    const chatId = chats.reduce((maxId, chat) => Math.max(maxId, chat.id), 0) + 1;
 | 
			
		||||
 | 
			
		||||
    // Add a new chat
 | 
			
		||||
    chats.push({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue