diff --git a/src/lib/ApiUtil.svelte b/src/lib/ApiUtil.svelte index 74b15e5f..e1173d86 100644 --- a/src/lib/ApiUtil.svelte +++ b/src/lib/ApiUtil.svelte @@ -1,6 +1,5 @@
-

- ChatGPT-web - is a simple one-page web interface to the OpenAI ChatGPT API. To use it, you need to register for - an OpenAI API key - first. OpenAI bills per token (usage-based), which means it is a lot cheaper than - ChatGPT Plus, unless you use - more than 10 million tokens per month. All messages are stored in your browser's local storage, so everything is - private. You can also close the browser tab and come back later to continue the conversation. -

-

- As an alternative to OpenAI, you can also use Petals swarm as a free API option for open chat models like Llama 2. -

+

+ ChatGPT-web + is a simple one-page web interface to the OpenAI ChatGPT API... +

+

As an alternative to OpenAI, you can enter your own OpenAI-compatible API endpoint, or use Petals swarm...

+
Set your OpenAI API key below: -
{ + on:submit|preventDefault={async (event) => { let val = '' if (event.target && event.target[0].value) { val = (event.target[0].value).trim() @@ -80,37 +91,69 @@ const setPetalsEnabled = (event: Event) => { autocomplete="off" class="input" class:is-danger={!hasModels} - class:is-warning={!apiKey} class:is-info={apiKey} + class:is-warning={!apiKey} + class:is-info={apiKey} value={apiKey} />

- -
{#if !apiKey}

- Please enter your OpenAI API key above to use Open AI's ChatGPT API. - At least one API must be enabled to use ChatGPT-web. + Please enter your OpenAI API key above to use OpenAI's ChatGPT API. At least one API must be enabled to use ChatGPT-web.

{/if}
- +
+
+ Set the API BASE URI for alternative OpenAI-compatible endpoints: +
{ + let val = '' + if (event.target && event.target[0].value) { + val = (event.target[0].value).trim() + } + if (await testApiEndpoint(val)) { + setGlobalSettingValueByKey('openAiEndpoint', val) + } + }} + > +

+ +

+

+ +

+
+ {#if apiError} +

{apiError}

+ {/if} +
+
+
{#if showPetalsSettings} @@ -140,30 +183,11 @@ const setPetalsEnabled = (event: Event) => {

- - - - {#if !pedalsEndpoint} -

- Please only use the default public API for testing. It's best to configure a private endpoint and enter it above for connection to the Petals swarm. -

- {/if} -

- Petals lets you run large language models at home by connecting to a public swarm, BitTorrent-style, without hefty GPU requirements. -

-

- You are encouraged to set up a Petals server to share your GPU resources with the public swarm. Minimum requirements to contribute Llama 2 completions are a GTX 1080 8GB, but the larger/faster the better. -

-

- If you're receiving errors while using Petals, check swarm health and consider adding your GPU to the swarm to help. -

-

- Because Petals uses a public swarm, do not send sensitive information when using Petals. -

{/if}
+ {#if apiKey}
@@ -173,4 +197,4 @@ const setPetalsEnabled = (event: Event) => {
{/if}
-