Skip to content

Commit

Permalink
fix: language and footnote
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed May 22, 2024
1 parent d7d738f commit 82a211e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
28 changes: 21 additions & 7 deletions src/components/remark-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,33 @@ const production: RehypeReactOptions = {
return (
<HoverCard openDelay={0} onOpenChange={open => {
if (open) {
const a = document.querySelector(`${props.href} a:first-child`) as HTMLAnchorElement | null;
if (a) {
setLink({ title: a.textContent ?? a.href, href: a.href });
} else {
setLink(undefined);
const id = props.href?.replace(/^#/, '');
if (id) {
const li = document.getElementById(id);
if (li) {
const a = li.querySelector(`a:first-child`) as HTMLAnchorElement | null;
if (a) {
setLink({ title: a.textContent ?? a.href, href: a.href });
return;
}
}
}
setLink(undefined);
}
}}>
<HoverCardTrigger asChild>
<a {...props} />
<a
{...props}
className={cn(props.className, 'cursor-default')}
href={undefined}
onClick={event => {
event.preventDefault();
event.stopPropagation();
}}
/>
</HoverCardTrigger>
<HoverCardPortal>
<HoverCardContent className="p-1 w-[200px] overflow-hidden rounded-lg border text-xs">
<HoverCardContent onPointerDownOutside={e => e.preventDefault()} className="p-1 w-[200px] overflow-hidden rounded-lg border text-xs">
<HoverCardArrow className="fill-border" />
<MessageContextSourceCard title={link?.title} href={link?.href} />
</HoverCardContent>
Expand Down
15 changes: 12 additions & 3 deletions src/core/services/llamaindex/chating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,19 @@ export class LlamaindexChatService extends AppChatService {
trace,
));

const promptContext = {
...kgContext,
sources: Array.from(allSources.values()).map((source, index) => ({
ordinal: index + 1,
...source
})),
originalQuestion: options.userInput,
}

// Build Query Engine.
const { textQa, refine } = prompts;
const textQaPrompt = this.getPrompt(textQa, defaultTextQaPrompt, kgContext);
const refinePrompt = this.getPrompt(refine, defaultRefinePrompt, kgContext);
const textQaPrompt = this.getPrompt(textQa, defaultTextQaPrompt, promptContext);
const refinePrompt = this.getPrompt(refine, defaultRefinePrompt, promptContext);
const responseBuilder = new CompactAndRefine(serviceContext, textQaPrompt, refinePrompt);
const responseSynthesizer = new ResponseSynthesizer({
serviceContext,
Expand All @@ -297,7 +306,7 @@ export class LlamaindexChatService extends AppChatService {
content: message.content,
additionalKwargs: {},
}));
const condenseMessagePrompt = this.getPrompt(prompts?.condenseQuestion, defaultCondenseQuestionPrompt, kgContext);
const condenseMessagePrompt = this.getPrompt(prompts?.condenseQuestion, defaultCondenseQuestionPrompt, promptContext);
const chatEngine = new CondenseQuestionChatEngine({
serviceContext,
queryEngine,
Expand Down

0 comments on commit 82a211e

Please sign in to comment.