Spaces:
Running
Running
Update server.py
Browse files
server.py
CHANGED
@@ -16,7 +16,7 @@ app = fastapi.FastAPI()
|
|
16 |
|
17 |
top_n = 50
|
18 |
|
19 |
-
@functools.lru_cache(maxsize=2*1024*1024*1024//(
|
20 |
def lru_search(query):
|
21 |
query_embed = vo.embed([query], model="voyage-large-2-instruct", input_type="query").embeddings[0]
|
22 |
similarities = np.dot(embed, query_embed)
|
@@ -29,7 +29,7 @@ def lru_search(query):
|
|
29 |
@app.get("/search")
|
30 |
def search(query: str):
|
31 |
# if query is too long, throw an error
|
32 |
-
if len(query) >
|
33 |
raise fastapi.HTTPException(status_code=400, detail="Query is too long")
|
34 |
top, sim = lru_search(query)
|
35 |
|
@@ -105,7 +105,7 @@ def read_root():
|
|
105 |
`
|
106 |
if (result.comment.trim() !== '') {
|
107 |
const comment = resultDiv.querySelector('#comment')
|
108 |
-
comment.innerHTML = marked.marked(
|
109 |
comment.classList.add('bg-gray-50', 'text-gray-900', 'px-2', 'py-1', 'mt-0.5', 'rounded-lg')
|
110 |
}
|
111 |
resultsDiv.appendChild(resultDiv)
|
|
|
16 |
|
17 |
top_n = 50
|
18 |
|
19 |
+
@functools.lru_cache(maxsize=2*1024*1024*1024//(400 + top_n*8))
|
20 |
def lru_search(query):
|
21 |
query_embed = vo.embed([query], model="voyage-large-2-instruct", input_type="query").embeddings[0]
|
22 |
similarities = np.dot(embed, query_embed)
|
|
|
29 |
@app.get("/search")
|
30 |
def search(query: str):
|
31 |
# if query is too long, throw an error
|
32 |
+
if len(query) > 400:
|
33 |
raise fastapi.HTTPException(status_code=400, detail="Query is too long")
|
34 |
top, sim = lru_search(query)
|
35 |
|
|
|
105 |
`
|
106 |
if (result.comment.trim() !== '') {
|
107 |
const comment = resultDiv.querySelector('#comment')
|
108 |
+
comment.innerHTML = `/-- ${marked.marked(result.comment.trim())} -/`
|
109 |
comment.classList.add('bg-gray-50', 'text-gray-900', 'px-2', 'py-1', 'mt-0.5', 'rounded-lg')
|
110 |
}
|
111 |
resultsDiv.appendChild(resultDiv)
|