Skip to content

Latest commit

 

History

History
352 lines (264 loc) · 12.2 KB

parameters.mdx

File metadata and controls

352 lines (264 loc) · 12.2 KB
title description
Parameters
A comprehensive guide for using GROQA API parameters effectively

GROQA API Parameters Guide

This guide will help you understand and utilize the various parameters available in the GROQA API to customize your search queries and responses.

Parameters for search and search_stream methods

The search query or question you want to ask. This is the primary input for your search. Be as specific as possible in your query. Optional date for context.
Format example: `Today is Monday 16 of September 2024 and the time is 6:36 PM`.

If not provided, the API uses the current date of the server.
Country code for search context. This helps in providing localized results. See the supported locations below. Enable or disable pro mode for more advanced search capabilities. Language code for the response. "auto" will auto-detect based on the query. see the supported languages below. Format of the answer. Options: "text", "markdown", or "html". Type of the search : `general` or `news` Set the `verbose_mode` parameter to `True` get more detailed information in the response. Include citations in the response Return Sources Return Images if provided in the response (Depends on the search query and the google API) Can be `hour`, `day`, `week`, `month`, `year`, `anytime`. Impact the search results recency.

Parameters for custom_search and custom_search_stream methods

System prompt : The system prompt is the prompt that will be used to generate the response. User prompt : The user prompt is the prompt that will be used to perform the web search. be as specific as possible and let the system prompt handle the details of the response. Country code for search context. This helps in providing localized results. Enable or disable pro mode for more advanced search capabilities. Type of the search : `general` or `news` The amount of randomness in the response, valued between 0 inclusive and 1 exclusive. Higher values are more random, and lower values are more deterministic. The nucleus sampling threshold, valued between 0 and 1 inclusive. For each subsequent token, the model considers the results of the tokens with top_p probability mass. We recommend either altering top_k or top_p, but not both. Return Sources Return Images Can be `hour`, `day`, `week`, `month`, `year`, `anytime`. Impact the search results recency.

Parameters for get_website_text , get_website_screenshot, get_website_markdown methods

The URL of the website you want to scrap or get a screenshot from it.

Parameters for query_from_url method

The URL of the website you want to interact with. The question you want to ask. Language code for the response. "auto" will auto-detect based on the query. Format of the answer. Options: "text", "markdown", or "html".

Supported Locations

The location parameter accepts various country codes to provide localized search results. Here's a comprehensive list of supported locations:

Use the appropriate country code to get results relevant to a specific region. For example, use "jp" for Japan-specific results or "br" for Brazil-focused searches.

Supported Languages

The response_language parameter allows you to specify the language of the API response:

auto : auto detect user question language

Response Structure

Depending on the method you use, the response structure will vary:

search and custom_search method

The main response from the language model. A list of relevant images (if available). set `return_images` to `True` to include images in the result A list of sources used to generate the response. set return_sources to `True` to include sources in the result The response time.

search_stream and custom_search_stream method

The streaming response is divided into chunks, each with a type field:

A part of the language model's response. A list of sources. A list of images.

get_website_screenshot method

The URL where the screenshot can be accessed. The response time.

get_website_text method

The TEXT extracted from URL The response time.

get_website_markdown method

The TEXT in MARKDOWN format extracted from URL The response time.

query_from_url method

The LLM response The response time.

Best Practices

Be as specific as possible in your `query` parameter to get more accurate results.
<Accordion title="Custom Search advice">
    Use the custom_search or custom_search_stream to write your own system and user prompts for more specific queries.
    always be specific with the user prompt since it will be used for the web search.
    Remember to include date context if needed in your system prompt.
    if you need citations, you must add the citation prompt in the System prompt.
</Accordion>



<Accordion title="Leverage Date Context">
    Use the `date_context` parameter when searching for time-sensitive information. 

    Use this format : `today is 8 of october and the time is 6 PM`
</Accordion>
<Accordion title="Optimize for Locale">
    Combine `location` and `response_language` parameters for the most relevant local results.
</Accordion>
<Accordion title="Choose the Right Answer Type">
    Select the appropriate `answer_type` based on how you plan to display the results in your application.
</Accordion>
<Accordion title="Write a good user prompt">
    in the `custom_search` and `custom_search_stream` methods, be as specific as possible, let the `system_prompt`handle the details of the response.

    be aware that the `user_prompt` will be used to perform the web search.
</Accordion>

By understanding and effectively using these parameters, you can maximize the power of the GROQA API in your applications. Happy coding!