mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 16:14:21 +00:00
Try/catch around github file decoding, await call to search in chat API, fix img width
This commit is contained in:
parent
b950889f47
commit
ef72508914
3 changed files with 10 additions and 3 deletions
|
@ -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:
|
||||||
content += chunk.decode("utf-8")
|
try:
|
||||||
|
content += chunk.decode("utf-8")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Unable to decode chunk from {file_url}")
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ def update(t: Optional[SearchType] = None, force: Optional[bool] = False, client
|
||||||
|
|
||||||
|
|
||||||
@api.get("/chat")
|
@api.get("/chat")
|
||||||
def chat(q: Optional[str] = None, client: Optional[str] = None):
|
async def chat(q: Optional[str] = None, client: Optional[str] = None):
|
||||||
if (
|
if (
|
||||||
state.processor_config is None
|
state.processor_config is None
|
||||||
or state.processor_config.conversation is None
|
or state.processor_config.conversation is None
|
||||||
|
@ -398,7 +398,7 @@ def chat(q: Optional[str] = None, client: Optional[str] = None):
|
||||||
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, 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…
Add table
Reference in a new issue