Add uploaded images to research mode, code slash command, include code references

This commit is contained in:
sabaimran 2024-10-23 21:45:17 -07:00 committed by Debanjum Singh Solanky
parent 5acf40c440
commit a11b5293fb
3 changed files with 18 additions and 12 deletions

View file

@ -301,6 +301,9 @@ export function TrainOfThought(props: TrainOfThoughtProps) {
const iconColor = props.primary ? convertColorToTextClass(props.agentColor) : "text-gray-500"; const iconColor = props.primary ? convertColorToTextClass(props.agentColor) : "text-gray-500";
const icon = chooseIconFromHeader(header, iconColor); const icon = chooseIconFromHeader(header, iconColor);
let markdownRendered = DOMPurify.sanitize(md.render(props.message)); let markdownRendered = DOMPurify.sanitize(md.render(props.message));
// Remove any header tags from markdownRendered
markdownRendered = markdownRendered.replace(/<h[1-6].*?<\/h[1-6]>/g, "");
return ( return (
<div <div
className={`${styles.trainOfThoughtElement} break-all items-center ${props.primary ? "text-gray-400" : "text-gray-300"} ${styles.trainOfThought} ${props.primary ? styles.primary : ""}`} className={`${styles.trainOfThoughtElement} break-all items-center ${props.primary ? "text-gray-400" : "text-gray-300"} ${styles.trainOfThought} ${props.primary ? styles.primary : ""}`}

View file

@ -690,14 +690,14 @@ async def chat(
inferred_queries: List[Any] = [] inferred_queries: List[Any] = []
defiltered_query = defilter_query(q) defiltered_query = defilter_query(q)
if conversation_commands == [ConversationCommand.Default] or is_automated_task: if conversation_commands == [ConversationCommand.Default]:
async for research_result in execute_information_collection( async for research_result in execute_information_collection(
request=request, request=request,
user=user, user=user,
query=defiltered_query, query=defiltered_query,
conversation_id=conversation_id, conversation_id=conversation_id,
conversation_history=meta_log, conversation_history=meta_log,
query_images=raw_images, query_images=uploaded_images,
agent=agent, agent=agent,
send_status_func=partial(send_event, ChatEvent.STATUS), send_status_func=partial(send_event, ChatEvent.STATUS),
user_name=user_name, user_name=user_name,
@ -956,16 +956,17 @@ async def chat(
): ):
yield result yield result
## Send Gathered References ## Send Gathered References
async for result in send_event( async for result in send_event(
ChatEvent.REFERENCES, ChatEvent.REFERENCES,
{ {
"inferredQueries": inferred_queries, "inferredQueries": inferred_queries,
"context": compiled_references, "context": compiled_references,
"onlineContext": online_results, "onlineContext": online_results,
}, "codeContext": code_results,
): },
yield result ):
yield result
if pending_research: if pending_research:
## Gather Code Results ## Gather Code Results

View file

@ -232,6 +232,8 @@ def get_conversation_command(query: str, any_references: bool = False) -> Conver
return ConversationCommand.Summarize return ConversationCommand.Summarize
elif query.startswith("/diagram"): elif query.startswith("/diagram"):
return ConversationCommand.Diagram return ConversationCommand.Diagram
elif query.startswith("/code"):
return ConversationCommand.Code
# If no relevant notes found for the given query # If no relevant notes found for the given query
elif not any_references: elif not any_references:
return ConversationCommand.General return ConversationCommand.General