fixed bugs

This commit is contained in:
belviskhoremk
2026-02-22 23:46:16 +00:00
parent 88ca23adde
commit 6fc607e32c
7 changed files with 195 additions and 10 deletions

View File

@@ -32,11 +32,10 @@ class LLMService:
except Exception as e:
logger.error(f"LLM error ({provider}/{model}): {e}")
# Fallback to a basic model if available
if model != "accounts/fireworks/models/llama-v3p1-70b-instruct" and settings.fireworks_api_key:
logger.info("Falling back to Fireworks AI")
if model != "accounts/fireworks/models/kimi-k2-instruct-0905" and settings.fireworks_api_key:
return await self._call_fireworks(
messages,
"accounts/fireworks/models/llama-v3p1-70b-instruct",
"accounts/fireworks/models/kimi-k2-instruct-0905",
max_tokens,
temperature,
)
@@ -137,7 +136,7 @@ class LLMService:
max_tokens: int,
temperature: float,
) -> Dict[str, Any]:
import google.generativeai as genai
import google.genai as genai
genai.configure(api_key=settings.google_api_key)
gemini_model = genai.GenerativeModel(model)

View File

@@ -103,7 +103,7 @@ class RAGEngine:
messages.append({"role": "user", "content": query})
# Step 5: Generate response
model = chatbot_config.get("model", "accounts/fireworks/models/llama-v3p1-70b-instruct")
model = chatbot_config.get("model", "accounts/fireworks/models/kimi-k2-instruct-0905")
try:
result = await self.llm_svc.generate(
messages=messages,

View File

@@ -29,7 +29,6 @@ class VectorStoreService:
self.client = get_qdrant_client()
def create_collection(self, collection_name: str) -> bool:
"""Create a new collection for a chatbot"""
try:
self.client.create_collection(
collection_name=collection_name,
@@ -38,6 +37,12 @@ class VectorStoreService:
distance=Distance.COSINE,
),
)
# Create payload index for filtering/deleting by document_id
self.client.create_payload_index(
collection_name=collection_name,
field_name="document_id",
field_schema="keyword",
)
logger.info(f"Created collection: {collection_name}")
return True
except Exception as e:
@@ -102,12 +107,12 @@ class VectorStoreService:
) -> List[Dict[str, Any]]:
"""Search for similar vectors"""
try:
results = self.client.search(
results = self.client.query_points(
collection_name=collection_name,
query_vector=query_vector,
query=query_vector,
limit=limit,
score_threshold=score_threshold,
)
).points
return [
{
"id": str(r.id),