INNER CODE UNIT · Python

rerenker_ai

essamamdani/search-result-scraper-markdown · main.py:193

def rerenker_ai(data: Dict[str, List[dict]], max_token: int = 2000) -> List[dict]:
    client = None
    model = None
    class ResultItem(BaseModel):
        title: str
        url: str
        content: str
    class SearchResult(BaseModel):
        results: List[ResultItem]
    system_message = (
        'You will be given a JSON format of search results and a search query. '
        'Extract only "exact and most" related search `results` based on the `query`. '
        'If the "content" field is empty, use the "title" or "url" field to determine relevance. '
        f' Return the results in same JSON format as you would be given, the JSON object must use the schema: {json.dumps(SearchResult.schema())}'
    )
    
    if AI_ENGINE == "groq":
        from groq import Groq

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…