Spaces:
Sleeping
Sleeping
Commit Β·
6d4062f
1
Parent(s): 38105c3
Minor Bugs Fixed
Browse files- back_end/config.py +1 -1
- back_end/core/embeddings.py +2 -5
- back_end/core/splitter.py +1 -1
- back_end/main.py +1 -9
- front_end/app.js +2 -4
back_end/config.py
CHANGED
|
@@ -364,4 +364,4 @@ SUPERVISOR_SYSTEM_PROMPT = """
|
|
| 364 |
"""
|
| 365 |
|
| 366 |
|
| 367 |
-
MAX_FILES_TO_CREATE_VECTOR_DB = 6000
|
|
|
|
| 364 |
"""
|
| 365 |
|
| 366 |
|
| 367 |
+
MAX_FILES_TO_CREATE_VECTOR_DB = 6000
|
back_end/core/embeddings.py
CHANGED
|
@@ -28,10 +28,7 @@ class _SFRCodeEmbeddings(Embeddings):
|
|
| 28 |
def __init__(self, model_path='Salesforce/SFR-Embedding-Code-400M_R'):
|
| 29 |
print("Loading local SFR Code Model to GPU via ST...")
|
| 30 |
|
| 31 |
-
|
| 32 |
-
# Automatically detect the hardware
|
| 33 |
-
hardware_device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 34 |
-
self.model = SentenceTransformer(model_path, device=hardware_device, trust_remote_code=True)
|
| 35 |
self.model.max_seq_length = 1024
|
| 36 |
self.model[0].auto_model.register_forward_pre_hook(_inject_position_ids_hook, with_kwargs=True)
|
| 37 |
|
|
@@ -115,4 +112,4 @@ def get_vector_db() -> Chroma:
|
|
| 115 |
embedding_function=local_embedding_fn,
|
| 116 |
collection_name=CHROMA_COLLECTION_NAME,
|
| 117 |
)
|
| 118 |
-
return vector_db
|
|
|
|
| 28 |
def __init__(self, model_path='Salesforce/SFR-Embedding-Code-400M_R'):
|
| 29 |
print("Loading local SFR Code Model to GPU via ST...")
|
| 30 |
|
| 31 |
+
self.model = SentenceTransformer(model_path, device='cuda', trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
| 32 |
self.model.max_seq_length = 1024
|
| 33 |
self.model[0].auto_model.register_forward_pre_hook(_inject_position_ids_hook, with_kwargs=True)
|
| 34 |
|
|
|
|
| 112 |
embedding_function=local_embedding_fn,
|
| 113 |
collection_name=CHROMA_COLLECTION_NAME,
|
| 114 |
)
|
| 115 |
+
return vector_db
|
back_end/core/splitter.py
CHANGED
|
@@ -193,4 +193,4 @@ def custom_splitter(docs: List[Document],current_dir: Path) -> List[Document]:
|
|
| 193 |
print(f"Original Files Processed : {len(docs)}")
|
| 194 |
print(f"Total Chunks Generated : {len(all_chunks)}")
|
| 195 |
|
| 196 |
-
return all_chunks
|
|
|
|
| 193 |
print(f"Original Files Processed : {len(docs)}")
|
| 194 |
print(f"Total Chunks Generated : {len(all_chunks)}")
|
| 195 |
|
| 196 |
+
return all_chunks
|
back_end/main.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
# main.py
|
| 2 |
-
from fastapi.staticfiles import StaticFiles
|
| 3 |
from fastapi import FastAPI
|
| 4 |
from fastapi.responses import StreamingResponse
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
|
@@ -190,11 +189,4 @@ async def chat_stream(request: ChatRequest):
|
|
| 190 |
yield format_chat_chunk("end", "[END]")
|
| 191 |
await asyncio.sleep(0.01)
|
| 192 |
|
| 193 |
-
return StreamingResponse(generate_response(), media_type="text/event-stream")
|
| 194 |
-
|
| 195 |
-
# 1. Find the path to the front_end folder
|
| 196 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 197 |
-
frontend_dir = os.path.join(current_dir, "..", "front_end")
|
| 198 |
-
|
| 199 |
-
# 2. Tell FastAPI to serve your index.html when people visit the main URL
|
| 200 |
-
app.mount("/", StaticFiles(directory=frontend_dir, html=True), name="frontend")
|
|
|
|
| 1 |
# main.py
|
|
|
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from fastapi.responses import StreamingResponse
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
| 189 |
yield format_chat_chunk("end", "[END]")
|
| 190 |
await asyncio.sleep(0.01)
|
| 191 |
|
| 192 |
+
return StreamingResponse(generate_response(), media_type="text/event-stream")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
front_end/app.js
CHANGED
|
@@ -138,8 +138,7 @@ function startAnalysis() {
|
|
| 138 |
// βββββββββββββββββββββββββββββββββββββββββββββ
|
| 139 |
async function connectToBackend(repoUrl) {
|
| 140 |
try {
|
| 141 |
-
|
| 142 |
-
const response = await fetch('/init-repo', {
|
| 143 |
method: 'POST',
|
| 144 |
headers: { 'Content-Type': 'application/json' },
|
| 145 |
body: JSON.stringify({ url: repoUrl }),
|
|
@@ -418,8 +417,7 @@ async function sendMessage() {
|
|
| 418 |
let fullMarkdown = '';
|
| 419 |
|
| 420 |
try {
|
| 421 |
-
|
| 422 |
-
const response = await fetch('/chat', {
|
| 423 |
method: 'POST',
|
| 424 |
headers: { 'Content-Type': 'application/json' },
|
| 425 |
body: JSON.stringify({ message: text }),
|
|
|
|
| 138 |
// βββββββββββββββββββββββββββββββββββββββββββββ
|
| 139 |
async function connectToBackend(repoUrl) {
|
| 140 |
try {
|
| 141 |
+
const response = await fetch('http://localhost:8000/init-repo', {
|
|
|
|
| 142 |
method: 'POST',
|
| 143 |
headers: { 'Content-Type': 'application/json' },
|
| 144 |
body: JSON.stringify({ url: repoUrl }),
|
|
|
|
| 417 |
let fullMarkdown = '';
|
| 418 |
|
| 419 |
try {
|
| 420 |
+
const response = await fetch('http://localhost:8000/chat', {
|
|
|
|
| 421 |
method: 'POST',
|
| 422 |
headers: { 'Content-Type': 'application/json' },
|
| 423 |
body: JSON.stringify({ message: text }),
|