updated and integrated backedn apis
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# api/models/requests.py
|
||||
from pydantic import BaseModel
|
||||
from typing import List,Dict
|
||||
from typing import List,Dict, Optional
|
||||
|
||||
class BaseRequest(BaseModel):
|
||||
pass
|
||||
@@ -13,7 +13,7 @@ class ChatMessage(BaseModel):
|
||||
class ChatRequest(BaseModel):
|
||||
query: str
|
||||
history: List[ChatMessage] = []
|
||||
|
||||
customer_metadata: Optional[Dict] = None # Customer info: name, email, phone, user_id
|
||||
|
||||
|
||||
class SurveyRequest(BaseModel):
|
||||
|
||||
+9
-2
@@ -23,13 +23,20 @@ async def chat_ai(
|
||||
logger.info(f"Starting chat request with query: {request.query}")
|
||||
logger.info(f"History length: {len(request.history)}")
|
||||
|
||||
# Extract customer metadata if provided
|
||||
customer_metadata = request.customer_metadata
|
||||
if customer_metadata:
|
||||
logger.info(f"Customer metadata provided: {list(customer_metadata.keys())}")
|
||||
else:
|
||||
logger.info("No customer metadata provided")
|
||||
|
||||
# Convert to internal Message format
|
||||
history = [Message(role=msg.role, content=msg.content) for msg in request.history]
|
||||
logger.info(f"Converted history to internal format: {len(history)} messages")
|
||||
|
||||
# Initialize DroneBot with history
|
||||
# Initialize DroneBot with history and customer metadata
|
||||
logger.info("Initializing DroneBot...")
|
||||
bot = DroneBot(history=history, use_openai_as_fallback=True)
|
||||
bot = DroneBot(history=history, use_openai_as_fallback=True, customer_metadata=customer_metadata)
|
||||
logger.info("DroneBot initialized successfully")
|
||||
|
||||
# Get response from DroneBot
|
||||
|
||||
Reference in New Issue
Block a user