新增回调接口url前缀

This commit is contained in:
zhh
2025-10-27 11:29:26 +08:00
parent 8c66e90919
commit 86fa6c0860
3 changed files with 9 additions and 6 deletions

View File

@@ -258,7 +258,7 @@ class AsyncStylistAgent:
context += "\nPlease recommend the next single item based on the selected items, user's request, and style guide."
return context
async def run_styling_process(self, request_summary, stylist_path, start_outfit=None, user_id="test"):
async def run_styling_process(self, request_summary, stylist_path, start_outfit=None, user_id="test", callback_url=""):
if start_outfit is None:
start_outfit = []
self.outfit_items = start_outfit if start_outfit else []
@@ -365,7 +365,7 @@ class AsyncStylistAgent:
'Connection': "keep-alive",
'Content-Type': "application/json"
}
url = 'https://83aa2db8e006.ngrok-free.app/api/style/callback'
url = f'{callback_url}/api/style/callback'
response = post_request(url=url, data=json.dumps(response_data), headers=headers)
logger.info(response.text)
return response_data

View File

@@ -22,6 +22,7 @@ class AgentRequestModel(BaseModel):
user_id: str
num_outfits: int
stylist_path: str
callback_url: str
class LCAgent(ls.LitAPI):
@@ -79,7 +80,8 @@ class LCAgent(ls.LitAPI):
stylist_name=request.stylist_path,
start_outfit=[],
num_outfits=request.num_outfits,
user_id=request.user_id)
user_id=request.user_id,
callback_url=request.callback_url)
logger.info("\n--- Final Recommendation Results ---")
for i, path in enumerate(recommendation_results.get("successful_outfits", [])):
@@ -101,7 +103,7 @@ class LCAgent(ls.LitAPI):
return summary
async def recommend_outfit(self, request_summary: str, stylist_name: str, start_outfit=None, num_outfits: int = 1,
user_id: str = "test"):
user_id: str = "test", callback_url: str = None):
"""
基于用户的对话历史和需求,推荐一套搭配。
@@ -119,7 +121,8 @@ class LCAgent(ls.LitAPI):
request_summary=request_summary,
stylist_path=stylist_name,
start_outfit=start_outfit,
user_id=user_id
user_id=user_id,
callback_url=callback_url
)
tasks.append(task)
print(f"--- Starting {num_outfits} concurrent outfit generation tasks. ---")

View File

@@ -33,7 +33,7 @@ def post_request(url, data=None, json_data=None, headers=None, auth=None, timeou
if __name__ == '__main__':
url = 'https://83aa2db8e006.ngrok-free.app/api/style/callback'
url = 'https://0dd6f6504aff.ngrok-free.app/api/style/callback'
object_data = {
'outfit_id': "test",