Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -447,16 +447,17 @@ async def adv_web_search(
|
|
| 447 |
|
| 448 |
except Exception as e:
|
| 449 |
raise HTTPException(status_code=500, detail=f"Error during advanced search: {e}")
|
|
|
|
| 450 |
@app.post("/api/AI_search_google")
|
| 451 |
async def adv_web_search(
|
| 452 |
q: str,
|
| 453 |
-
model: str = "
|
| 454 |
max_results: int = 5,
|
| 455 |
timelimit: Optional[str] = None,
|
| 456 |
safesearch: str = "moderate",
|
| 457 |
region: str = "wt-wt",
|
| 458 |
# backend: str = "html",
|
| 459 |
-
max_chars: int =
|
| 460 |
system_prompt: str = "You are an advanced AI chatbot. Provide the best answer to the user based on Google search results.",
|
| 461 |
proxy: Optional[str] = None
|
| 462 |
):
|
|
@@ -482,13 +483,23 @@ async def adv_web_search(
|
|
| 482 |
|
| 483 |
# 3. Construct the prompt for the chat model
|
| 484 |
ai_prompt = (
|
| 485 |
-
f"User Query: {q}
|
| 486 |
-
f"
|
| 487 |
-
f"
|
| 488 |
-
f"
|
| 489 |
-
f"
|
| 490 |
-
f"
|
| 491 |
-
f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
)
|
| 493 |
|
| 494 |
# 4. Get the chat model's response using webs.chat
|
|
@@ -501,6 +512,7 @@ async def adv_web_search(
|
|
| 501 |
except Exception as e:
|
| 502 |
raise HTTPException(status_code=500, detail=f"Error during advanced search: {e}")
|
| 503 |
|
|
|
|
| 504 |
@app.get("/api/website_summarizer")
|
| 505 |
async def website_summarizer(url: str, proxy: Optional[str] = None):
|
| 506 |
"""Summarizes the content of a given URL using a chat model."""
|
|
|
|
| 447 |
|
| 448 |
except Exception as e:
|
| 449 |
raise HTTPException(status_code=500, detail=f"Error during advanced search: {e}")
|
| 450 |
+
|
| 451 |
@app.post("/api/AI_search_google")
|
| 452 |
async def adv_web_search(
|
| 453 |
q: str,
|
| 454 |
+
model: str = "claude-3-haiku", # Use webs.chat by default
|
| 455 |
max_results: int = 5,
|
| 456 |
timelimit: Optional[str] = None,
|
| 457 |
safesearch: str = "moderate",
|
| 458 |
region: str = "wt-wt",
|
| 459 |
# backend: str = "html",
|
| 460 |
+
max_chars: int = 6000,
|
| 461 |
system_prompt: str = "You are an advanced AI chatbot. Provide the best answer to the user based on Google search results.",
|
| 462 |
proxy: Optional[str] = None
|
| 463 |
):
|
|
|
|
| 483 |
|
| 484 |
# 3. Construct the prompt for the chat model
|
| 485 |
ai_prompt = (
|
| 486 |
+
f"User Query: **{q}**\n\n"
|
| 487 |
+
f"**Objective:** Provide a comprehensive and informative response to the user's query based on the extracted content from Google search results. Your answer should be structured in Markdown format for clarity and readability.\n\n"
|
| 488 |
+
f"**Response Structure:**\n"
|
| 489 |
+
f"1. **Answer:**\n"
|
| 490 |
+
f" - Begin with a clear and concise answer to the user's question.\n\n"
|
| 491 |
+
f"2. **Key Points:**\n"
|
| 492 |
+
f" - Highlight essential details or facts relevant to the query using bullet points.\n\n"
|
| 493 |
+
f"3. **Contextual Information:**\n"
|
| 494 |
+
f" - Provide any necessary background or additional context that enhances understanding, using paragraphs as needed.\n\n"
|
| 495 |
+
f"4. **Summary of Search Results:**\n"
|
| 496 |
+
f" - Summarize key findings from the search results, emphasizing diversity in perspectives if applicable, formatted as a list.\n\n"
|
| 497 |
+
f"5. **Sources:**\n"
|
| 498 |
+
f" - List all sources of information with clickable links for further reading, ensuring proper citation of the extracted content, formatted as follows:\n"
|
| 499 |
+
f" - [Source Title](URL)\n\n"
|
| 500 |
+
f"**Search Results:**\n{extracted_text}\n\n"
|
| 501 |
+
f"---\n\n"
|
| 502 |
+
f"*Note: Ensure that all sections are clearly marked and that the response is easy to navigate.*"
|
| 503 |
)
|
| 504 |
|
| 505 |
# 4. Get the chat model's response using webs.chat
|
|
|
|
| 512 |
except Exception as e:
|
| 513 |
raise HTTPException(status_code=500, detail=f"Error during advanced search: {e}")
|
| 514 |
|
| 515 |
+
|
| 516 |
@app.get("/api/website_summarizer")
|
| 517 |
async def website_summarizer(url: str, proxy: Optional[str] = None):
|
| 518 |
"""Summarizes the content of a given URL using a chat model."""
|