🔧 fix: Improve Endpoint Handling and Address Edge Cases (#1486)

* fix(TEndpointsConfig): resolve property access issues with typesafe helper function

* fix: undefined or null endpoint edge case

* refactor(mapEndpoints -> endpoints): renamed module to be more general for endpoint handling, wrote unit tests, export all helpers
This commit is contained in:
Danny Avila 2024-01-04 10:17:15 -05:00 committed by GitHub
parent 42f2353509
commit 9864fc8700
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 275 additions and 99 deletions

View file

@ -45,19 +45,23 @@ export default function ChatForm({ index = 0 }) {
<div className="flex w-full items-center">
<div className="[&:has(textarea:focus)]:border-token-border-xheavy border-token-border-heavy shadow-xs dark:shadow-xs relative flex w-full flex-grow flex-col overflow-hidden rounded-2xl border border-black/10 bg-white shadow-[0_0_0_2px_rgba(255,255,255,0.95)] dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:shadow-[0_0_0_2px_rgba(52,53,65,0.95)] [&:has(textarea:focus)]:shadow-[0_2px_6px_rgba(0,0,0,.05)]">
<Images files={files} setFiles={setFiles} setFilesLoading={setFilesLoading} />
<Textarea
value={text}
disabled={requiresKey}
onChange={(e: ChangeEvent<HTMLTextAreaElement>) => setText(e.target.value)}
setText={setText}
submitMessage={submitMessage}
endpoint={endpoint}
/>
{endpoint && (
<Textarea
value={text}
disabled={requiresKey}
onChange={(e: ChangeEvent<HTMLTextAreaElement>) => setText(e.target.value)}
setText={setText}
submitMessage={submitMessage}
endpoint={endpoint}
/>
)}
<AttachFile endpoint={endpoint ?? ''} disabled={requiresKey} />
{isSubmitting && showStopButton ? (
<StopButton stop={handleStopGenerating} setShowStopButton={setShowStopButton} />
) : (
<SendButton text={text} disabled={filesLoading || isSubmitting || requiresKey} />
endpoint && (
<SendButton text={text} disabled={filesLoading || isSubmitting || requiresKey} />
)
)}
</div>
</div>