Updated styles
This commit is contained in:
parent
96cd404f5f
commit
781271aa59
@ -250,16 +250,21 @@ async def handle_tool_calls(message):
|
|||||||
ret = None
|
ret = None
|
||||||
else:
|
else:
|
||||||
ret = get_ticker_price(ticker)
|
ret = get_ticker_price(ticker)
|
||||||
tools_used.append(tool)
|
tools_used.append(f"{tool}({ticker})")
|
||||||
case 'summarize_site':
|
case 'summarize_site':
|
||||||
ret = await summarize_site(arguments.get('url'), arguments.get('question', 'what is the summary of this content?'))
|
url = arguments.get('url');
|
||||||
tools_used.append(tool)
|
question = arguments.get('question', 'what is the summary of this content?')
|
||||||
|
ret = await summarize_site(url, question)
|
||||||
|
tools_used.append(f"{tool}('{url}', '{question}')")
|
||||||
case 'get_current_datetime':
|
case 'get_current_datetime':
|
||||||
ret = get_current_datetime(arguments.get('timezone'))
|
tz = arguments.get('timezone')
|
||||||
tools_used.append(tool)
|
ret = get_current_datetime(tz)
|
||||||
|
tools_used.append(f"{tool}('{tz}')")
|
||||||
case 'get_weather_by_location':
|
case 'get_weather_by_location':
|
||||||
ret = get_weather_by_location(arguments.get('city'), arguments.get('state'))
|
city = arguments.get('city')
|
||||||
tools_used.append(tool)
|
state = arguments.get('state')
|
||||||
|
ret = get_weather_by_location(city, state)
|
||||||
|
tools_used.append(f"{tool}('{city}', '{state}')")
|
||||||
case _:
|
case _:
|
||||||
ret = None
|
ret = None
|
||||||
response.append({
|
response.append({
|
||||||
|
@ -1,51 +1,23 @@
|
|||||||
|
div {
|
||||||
|
box-sizing: border-box
|
||||||
|
}
|
||||||
|
|
||||||
.App {
|
.App {
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.App-logo {
|
|
||||||
height: 40vmin;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
|
||||||
.App-logo {
|
|
||||||
animation: App-logo-spin infinite 20s linear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.App-header {
|
|
||||||
background-color: #282c34;
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
text-align: center;
|
||||||
|
max-height: 100%;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: calc(10px + 2vmin);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.App-link {
|
|
||||||
color: #61dafb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes App-logo-spin {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
max-height: 100vh;
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 20px;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.query-box,
|
.query-box,
|
||||||
@ -71,12 +43,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.conversation {
|
.conversation {
|
||||||
|
display: flex;
|
||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
border: 1px solid #E0E0E0;
|
border: 1px solid #E0E0E0;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-message {
|
.user-message {
|
||||||
@ -87,14 +61,16 @@
|
|||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
min-width: 70%;
|
min-width: 80%;
|
||||||
max-width: 70%;
|
max-width: 80%;
|
||||||
justify-self: right;
|
justify-self: right;
|
||||||
display: flex;
|
display: flex;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: self-end;
|
||||||
|
align-self: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assistant-message {
|
.assistant-message {
|
||||||
@ -105,7 +81,6 @@
|
|||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
min-width: 70%;
|
min-width: 70%;
|
||||||
max-width: 70%;
|
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
justify-self: left;
|
justify-self: left;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -11,7 +11,7 @@ const url: string = "https://ai.ketrenos.com"
|
|||||||
const App = () => {
|
const App = () => {
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const [conversation, setConversation] = useState<MessageList>([{"role": "assistant", "content": "Connecting to server..."}]);
|
const [conversation, setConversation] = useState<MessageList>([{"role": "assistant", "content": "Connecting to server..."}]);
|
||||||
const conversationRef = useRef(null);
|
const conversationRef = useRef<any>(null);
|
||||||
const [processing, setProcessing] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [ws, setWs] = useState<WebSocket | undefined>(undefined);
|
const [ws, setWs] = useState<WebSocket | undefined>(undefined);
|
||||||
const [loaded, setLoaded] = useState<boolean>(false);
|
const [loaded, setLoaded] = useState<boolean>(false);
|
||||||
@ -21,9 +21,12 @@ const App = () => {
|
|||||||
const [user, setUser] = useState<string>("");
|
const [user, setUser] = useState<string>("");
|
||||||
const [userChange, setUserChange] = useState<string>("");
|
const [userChange, setUserChange] = useState<string>("");
|
||||||
|
|
||||||
const getApiUrl = (endpoint: string) => {
|
// Scroll to bottom of conversation when conversation updates
|
||||||
return `${url}/${endpoint}?sessionId=${sessionId}`;
|
useEffect(() => {
|
||||||
};
|
if (conversationRef.current) {
|
||||||
|
conversationRef.current.scrollTop = conversationRef.current.scrollHeight;
|
||||||
|
}
|
||||||
|
}, [conversation]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
@ -31,7 +34,7 @@ const App = () => {
|
|||||||
|
|
||||||
if (!pathParts.length) {
|
if (!pathParts.length) {
|
||||||
console.log("No session id -- creating a new session")
|
console.log("No session id -- creating a new session")
|
||||||
fetch(getApiUrl('/api/session'))
|
fetch('/api/session')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(`Session id: ${data.id} -- returned from server`)
|
console.log(`Session id: ${data.id} -- returned from server`)
|
||||||
@ -261,7 +264,7 @@ const App = () => {
|
|||||||
try {
|
try {
|
||||||
setProcessing(true);
|
setProcessing(true);
|
||||||
// Send query to server
|
// Send query to server
|
||||||
const response = await fetch(getApiUrl(`/api/chat/${sessionId}`), {
|
const response = await fetch(`/api/chat/${sessionId}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -298,83 +301,81 @@ const App = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="container" style={{ display: "flex", flexDirection: "column" }}>
|
||||||
<div className="container">
|
|
||||||
<div style={{display: "flex", flexDirection: "column"}}>
|
|
||||||
<div className="conversation" ref={conversationRef}>
|
|
||||||
{conversation.map((message, index) => {
|
|
||||||
const formattedContent = message.content
|
|
||||||
.split("\n")
|
|
||||||
.map((line) => line.replace(/^[^\s:]+:\s*/, ''))
|
|
||||||
.join("\n");
|
|
||||||
|
|
||||||
return (
|
<div className="conversation" ref={conversationRef}>
|
||||||
<div key={index} className={message.role === 'user' ? 'user-message' : 'assistant-message'}>
|
{conversation.map((message, index) => {
|
||||||
{message.metadata ? (
|
const formattedContent = message.content
|
||||||
<>
|
.split("\n")
|
||||||
<div className="metadata">{message.metadata.title}</div>
|
.map((line) => line.replace(/^[^\s:]+:\s*/, ''))
|
||||||
{ message.user && (
|
.join("\n");
|
||||||
<div>{message.user}</div>
|
|
||||||
) }
|
return (
|
||||||
<div>{formattedContent}</div>
|
<div key={index} className={message.role === 'user' ? 'user-message' : 'assistant-message'}>
|
||||||
</>
|
{message.metadata ? (
|
||||||
) : (
|
<>
|
||||||
<>
|
<div className="metadata">{message.metadata.title}</div>
|
||||||
{ message.user && (
|
{message.user && (
|
||||||
<div>{message.user}</div>
|
<div>{message.user}</div>
|
||||||
) }
|
)}
|
||||||
<div>{formattedContent}</div>
|
<div>{formattedContent}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
) : (
|
||||||
</div>
|
<>
|
||||||
);
|
{message.user && (
|
||||||
})}
|
<div>{message.user}</div>
|
||||||
<div style={{justifyContent: "center", display: "flex", paddingBottom: "0.5rem"}}>
|
)}
|
||||||
<PropagateLoader
|
<div>{formattedContent}</div>
|
||||||
size="10px"
|
</>
|
||||||
loading={processing}
|
)}
|
||||||
aria-label="Loading Spinner"
|
|
||||||
data-testid="loader"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
</div>
|
})}
|
||||||
|
<div style={{ justifyContent: "center", display: "flex", paddingBottom: "0.5rem" }}>
|
||||||
<div className="users" style={{display: "flex", flexDirection: "row"}}>
|
<PropagateLoader
|
||||||
<div>Users in this session: </div>
|
size="10px"
|
||||||
{users.map((name, index) => (
|
loading={processing}
|
||||||
<div key={index} className={user === name ? `user-active` : `user`}>
|
aria-label="Loading Spinner"
|
||||||
{name}
|
data-testid="loader"
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="query-box">
|
|
||||||
<input
|
|
||||||
disabled={connection ? false : true || processing}
|
|
||||||
type="text"
|
|
||||||
value={query}
|
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
|
||||||
onKeyDown={handleKeyPress}
|
|
||||||
placeholder="Enter your query..."
|
|
||||||
id="query-input"
|
|
||||||
/>
|
/>
|
||||||
<button onClick={sendQuery}>Send</button>
|
|
||||||
</div>
|
|
||||||
<div className="user-box">
|
|
||||||
<input
|
|
||||||
disabled={connection ? false : true}
|
|
||||||
type="text"
|
|
||||||
value={userChange}
|
|
||||||
onChange={(e) => setUserChange(e.target.value)}
|
|
||||||
onKeyDown={handleKeyPress}
|
|
||||||
placeholder="Change your name..."
|
|
||||||
id="user-input"
|
|
||||||
/>
|
|
||||||
<button onClick={sendUserChange}>Send</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
|
<div className="users" style={{ display: "flex", flexDirection: "row" }}>
|
||||||
|
<div>Users in this session: </div>
|
||||||
|
{users.map((name, index) => (
|
||||||
|
<div key={index} className={user === name ? `user-active` : `user`}>
|
||||||
|
{name}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="query-box">
|
||||||
|
<input
|
||||||
|
disabled={connection ? false : true || processing}
|
||||||
|
type="text"
|
||||||
|
value={query}
|
||||||
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
|
onKeyDown={handleKeyPress}
|
||||||
|
placeholder="Enter your query..."
|
||||||
|
id="query-input"
|
||||||
|
/>
|
||||||
|
<button onClick={sendQuery}>Send</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="user-box">
|
||||||
|
<input
|
||||||
|
disabled={connection ? false : true}
|
||||||
|
type="text"
|
||||||
|
value={userChange}
|
||||||
|
onChange={(e) => setUserChange(e.target.value)}
|
||||||
|
onKeyDown={handleKeyPress}
|
||||||
|
placeholder="Change your name..."
|
||||||
|
id="user-input"
|
||||||
|
/>
|
||||||
|
<button onClick={sendUserChange}>Send</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ body {
|
|||||||
sans-serif;
|
sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user