diff --git a/backend/fastapi_app.py b/backend/fastapi_app.py index 0ce04d7..b3a5bbf 100644 --- a/backend/fastapi_app.py +++ b/backend/fastapi_app.py @@ -38,11 +38,11 @@ async def get_image(prompt_dict: dict): async def get_text(request: Request): try: body = await request.json() - prompt = body.get('prompt') + messages = body.get('messages') except json.JSONDecodeError: raise HTTPException(status_code=500, detail="Cant decode JSON") - if not prompt: - raise HTTPException(status_code=400, detail="Prompt is required") + if not messages: + raise HTTPException(status_code=400, detail="Messages list is required") - return StreamingResponse(query_synapse_text(dendrite, metagraph, subtensor, prompt), media_type='text/event-stream') + return StreamingResponse(query_synapse_text(dendrite, metagraph, subtensor, messages), media_type='text/event-stream') diff --git a/backend/neurons/api.py b/backend/neurons/api.py index a5b034e..9282008 100644 --- a/backend/neurons/api.py +++ b/backend/neurons/api.py @@ -44,10 +44,10 @@ async def main(): bt.logging.error(f"General exception at step: {e}\n{traceback.format_exc()}") -async def query_synapse_text(dendrite, metagraph, subtensor, prompt): +async def query_synapse_text(dendrite, metagraph, subtensor, messages): try: axon = metagraph.axons[87] - syn = StreamPrompting(messages=[{"role": "user", "content": prompt}], engine="gpt-4-1106-preview", seed=1234) + syn = StreamPrompting(messages=messages, engine="gpt-4-1106-preview", seed=1234) responses = await dendrite([axon], syn, deserialize=False, streaming=True) for resp in responses: @@ -61,7 +61,7 @@ async def query_synapse_text(dendrite, metagraph, subtensor, prompt): def main(): config, wallet, subtensor, dendrite, metagraph = initialize() - # asyncio.run(query_synapse_text(dendrite, metagraph, subtensor, "tell me a story")) + # asyncio.run(query_synapse_text(dendrite, metagraph, subtensor, [{"role": "user", "content": "tell me a story"}])) asyncio.run(query_synapse_image(dendrite, metagraph, subtensor, "dragon")) diff --git a/web/public/favicon.ico b/web/public/favicon.ico index a11777c..b0224e3 100644 Binary files a/web/public/favicon.ico and b/web/public/favicon.ico differ diff --git a/web/public/taotensor.png b/web/public/taotensor.png new file mode 100644 index 0000000..43b7f62 Binary files /dev/null and b/web/public/taotensor.png differ diff --git a/web/public/taotensor_logo.jpeg b/web/public/taotensor_logo.jpeg new file mode 100644 index 0000000..7e84931 Binary files /dev/null and b/web/public/taotensor_logo.jpeg differ diff --git a/web/public/taotensor_logo.svg b/web/public/taotensor_logo.svg new file mode 100644 index 0000000..3ca9bfc --- /dev/null +++ b/web/public/taotensor_logo.svg @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/components/common/ImagePreview.tsx b/web/src/components/common/ImagePreview.tsx index 14116c8..b0f33d9 100644 --- a/web/src/components/common/ImagePreview.tsx +++ b/web/src/components/common/ImagePreview.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { CSSProperties, useState } from "react"; import { Button, Dialog, @@ -12,9 +12,10 @@ import { Close as CloseIcon } from "@mui/icons-material"; interface ImagePreviewProps { imageUrl: string; + style?: CSSProperties | undefined; } -const ImagePreview: React.FC = ({ imageUrl }) => { +const ImagePreview: React.FC = ({ imageUrl, style }) => { const [open, setOpen] = useState(false); const handleOpen = () => { @@ -26,7 +27,7 @@ const ImagePreview: React.FC = ({ imageUrl }) => { }; return ( -
+
Preview { messages[messages.length - 1]?.type === "text-loading" ) { fetchTextMessage( - messages[messages.length - 2].text, + messages.slice(0, -1).map((message) => ( + { + role: message.author === "user" ? "user" : "assistant", + content: message.text + })), onopen, onmessage, onerror, diff --git a/web/src/components/pages/chatPage/InputBar.tsx b/web/src/components/pages/chatPage/InputBar.tsx index f120684..a480bbc 100644 --- a/web/src/components/pages/chatPage/InputBar.tsx +++ b/web/src/components/pages/chatPage/InputBar.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useRef, useEffect } from "react"; import { Box, TextField, IconButton, MenuItem, Select } from "@mui/material"; import SendIcon from "@mui/icons-material/Send"; @@ -16,6 +16,7 @@ const InputBar: React.FC = ({ setMode, }) => { const [message, setMessage] = useState(""); + const inputRef = useRef(null); const handleSend = () => { if (message.trim()) { @@ -31,6 +32,12 @@ const InputBar: React.FC = ({ } }; + useEffect(() => { + if (inputRef.current && enabled) { + inputRef.current.focus(); + } + }) + return ( = ({