forked from Nutlope/twitterbio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
182 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
TOGETHER_API_KEY= | ||
OPENAI_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Switch } from '@headlessui/react'; | ||
import Image from 'next/image'; | ||
|
||
function classNames(...classes: any) { | ||
return classes.filter(Boolean).join(' '); | ||
} | ||
|
||
export default function Toggle({ isGPT, setIsGPT }: any) { | ||
return ( | ||
<Switch.Group as="div" className="flex items-center"> | ||
<Switch.Label | ||
as="span" | ||
className="mr-3 text-sm flex justify-center gap-2 items-center" | ||
> | ||
<Image | ||
src="/mistral-logo.jpeg" | ||
width={25} | ||
height={25} | ||
alt="1 icon" | ||
className={`${isGPT && 'opacity-50'}`} | ||
/> | ||
<span | ||
className={`font-medium ${isGPT ? 'text-gray-400' : 'text-gray-900'}`} | ||
> | ||
Mixtral | ||
</span>{' '} | ||
</Switch.Label> | ||
<Switch | ||
checked={isGPT} | ||
onChange={setIsGPT} | ||
className={classNames( | ||
isGPT ? 'bg-black' : 'bg-gray-200', | ||
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-offset-2' | ||
)} | ||
> | ||
<span | ||
aria-hidden="true" | ||
className={classNames( | ||
isGPT ? 'translate-x-5' : 'translate-x-0', | ||
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out' | ||
)} | ||
/> | ||
</Switch> | ||
<Switch.Label | ||
as="span" | ||
className="ml-3 text-sm flex justify-center gap-2 items-center" | ||
> | ||
<span | ||
className={`font-medium ${ | ||
!isGPT ? 'text-gray-400' : 'text-gray-900' | ||
}`} | ||
> | ||
GPT-3.5 | ||
</span>{' '} | ||
<Image | ||
src="/openai-logo.jpeg" | ||
width={30} | ||
height={30} | ||
alt="OpenAI logo" | ||
className={`${!isGPT && 'opacity-50'}`} | ||
/> | ||
</Switch.Label> | ||
</Switch.Group> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Together from 'together-ai'; | ||
|
||
if (!process.env.TOGETHER_API_KEY) { | ||
throw new Error('Missing env var from Together.ai'); | ||
} | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
const together = new Together({ | ||
auth: process.env.TOGETHER_API_KEY, | ||
}); | ||
|
||
const handler = async (req: Request): Promise<Response> => { | ||
const { prompt } = (await req.json()) as { | ||
prompt?: string; | ||
}; | ||
|
||
if (!prompt) { | ||
return new Response('No prompt in the request', { status: 400 }); | ||
} | ||
|
||
const stream = await together.inference( | ||
'mistralai/Mixtral-8x7B-Instruct-v0.1', | ||
{ | ||
prompt: prompt, | ||
max_tokens: 300, | ||
stream_tokens: true, | ||
} | ||
); | ||
|
||
return new Response(stream as ReadableStream, { | ||
headers: new Headers({ | ||
'Cache-Control': 'no-cache', | ||
}), | ||
}); | ||
}; | ||
|
||
export default handler; |
File renamed without changes.
Oops, something went wrong.