mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 02:27:10 +00:00
Resolve diffs in api.py to make /chat endpoint async with new request parameter
This commit is contained in:
commit
db3026739d
4 changed files with 16 additions and 5 deletions
6
src/khoj/interface/web/assets/org.min.js
vendored
6
src/khoj/interface/web/assets/org.min.js
vendored
|
@ -614,8 +614,10 @@ var Org = (function () {
|
||||||
var notBlankNextToken = this.lexer.peekNextToken();
|
var notBlankNextToken = this.lexer.peekNextToken();
|
||||||
if (blankToken && !notBlankNextToken.isListElement())
|
if (blankToken && !notBlankNextToken.isListElement())
|
||||||
this.lexer.pushToken(blankToken); // Recover blank token only when next line is not listElement.
|
this.lexer.pushToken(blankToken); // Recover blank token only when next line is not listElement.
|
||||||
if (notBlankNextToken.indentation <= rootIndentation)
|
// End of the list if hit less indented line or end of directive
|
||||||
break; // end of the list
|
if (notBlankNextToken.indentation <= rootIndentation ||
|
||||||
|
(notBlankNextToken.type === Lexer.tokens.directive && notBlankNextToken.endDirective))
|
||||||
|
break;
|
||||||
|
|
||||||
var element = this.parseElement(); // recursive
|
var element = this.parseElement(); // recursive
|
||||||
if (element)
|
if (element)
|
||||||
|
|
|
@ -414,6 +414,10 @@
|
||||||
border: 1px solid rgb(229, 229, 229);
|
border: 1px solid rgb(229, 229, 229);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -152,7 +152,10 @@ class GithubToJsonl(TextToJsonl):
|
||||||
content = ""
|
content = ""
|
||||||
for chunk in response.iter_content(chunk_size=2048):
|
for chunk in response.iter_content(chunk_size=2048):
|
||||||
if chunk:
|
if chunk:
|
||||||
|
try:
|
||||||
content += chunk.decode("utf-8")
|
content += chunk.decode("utf-8")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Unable to decode chunk from {file_url}")
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
|
@ -393,7 +393,7 @@ def update(
|
||||||
|
|
||||||
|
|
||||||
@api.get("/chat")
|
@api.get("/chat")
|
||||||
def chat(
|
async def chat(
|
||||||
request: Request,
|
request: Request,
|
||||||
q: Optional[str] = None,
|
q: Optional[str] = None,
|
||||||
client: Optional[str] = None,
|
client: Optional[str] = None,
|
||||||
|
@ -436,7 +436,9 @@ def chat(
|
||||||
with timer("Searching knowledge base took", logger):
|
with timer("Searching knowledge base took", logger):
|
||||||
result_list = []
|
result_list = []
|
||||||
for query in inferred_queries:
|
for query in inferred_queries:
|
||||||
result_list.extend(search(query, n=5, r=True, score_threshold=-5.0, dedupe=False))
|
result_list.extend(
|
||||||
|
await search(query, request=request, n=5, r=True, score_threshold=-5.0, dedupe=False)
|
||||||
|
)
|
||||||
compiled_references = [item.additional["compiled"] for item in result_list]
|
compiled_references = [item.additional["compiled"] for item in result_list]
|
||||||
|
|
||||||
# Switch to general conversation type if no relevant notes found for the given query
|
# Switch to general conversation type if no relevant notes found for the given query
|
||||||
|
|
Loading…
Reference in a new issue