TakoClient
Initialization
knowledge_search()
Search for knowledge cards based on a natural language query.Parameters
- text (
str): The natural language query string - source_indexes (
Optional[List[KnowledgeSearchSourceIndex]]): Priority order of sources to search. Search stops when results are found in first index.- Valid values:
KnowledgeSearchSourceIndex.TAKO,KnowledgeSearchSourceIndex.WEB,KnowledgeSearchSourceIndex.CONNECTED_DATA - Default:
[KnowledgeSearchSourceIndex.TAKO]
- Valid values:
- output_settings (
Optional[KnowledgeSearchRequestOutputSettings]): Settings for controlling knowledge card outputs - country_code (
Optional[str]): ISO3166-1 alpha-2 country code (e.g., ‘US’, ‘CA’, ‘GB’). Default: “US”
Returns
KnowledgeSearchResults object containing:
request_id: Unique request identifieroutputs.knowledge_cards: List of knowledge cards with:card_id: Unique card identifiertitle: Card titledescription: Detailed descriptionwebpage_url: Interactive card URLimage_url: Static image URLembed_url: Embeddable iframe URLsources: Data sources informationmethodologies: Data collection methodologiescard_type: Type of card (chart, table, text, etc.)
Example
get_image()
Retrieve a static image for a knowledge card.Parameters
- card_id (
str): The ID of the knowledge card
Returns
bytes: The image content as bytes
Example
beta_visualize()
Create visualizations from datasets or files.Parameters
- tako_formatted_dataset (
Optional[TakoDataFormatDataset]): Dataset in Tako Data Format - file_id (
Optional[str]): ID of uploaded file to visualize - query (
Optional[str]): Query with visualization instructions - model (
Optional[VisualizeSupportedModels]): Model to useo3o4-miniqwen-3-32bllama-3.3-70bqwen-3-coder-480bqwen-3-235b-a22b-instruct-2507qwen-3-235b-a22b-thinking-2507
- output_settings (
Optional[KnowledgeSearchRequestOutputSettings]): Output control settings - viz_component_type (
Optional[UserRequestedVizComponentType]): Visualization typebartimeseriespiescatterboxplotchoroplethheatmaptimelinewaterfall
tako_formatted_dataset or file_id must be provided, but not both.
Returns
KnowledgeSearchResults: Visualization results as knowledge cards
Example
beta_upload_file()
Upload a file to Tako for visualization and analysis.Parameters
- file_path (
str): Path to the file to upload - file_context (
Optional[str]): Context description to help Tako understand the file
Returns
str: The file ID for use in other methods
Example
beta_file_connector()
Connect to a file hosted at a URL for Tako to download and analyze.Parameters
- file_url (
str): URL of the file to connect to - file_id (
Optional[str]): ID of existing file to update. If not provided, creates new file
Returns
dict: Response containing:
message: Status messageid: File IDmetadata: File metadata including creation/update timestamps
Example
beta_file_info()
Get information about an uploaded file.Parameters
- file_id (
str): The ID of the file to get information for
Returns
dict: Response containing file information including:
file_id: The unique file identifierlast_updated_at: ISO timestamp of last update (nullable)key: File key in storage (nullable)schema: Schema information withschema_idanddisplay_name(nullable)file_url: Downloadable file URL (nullable)file_context: Context description provided during upload (nullable)segment_id: Segment identifier (nullable)source: File source information (nullable)cleaned_files: Array of processed file versions with metadataconnected_private_index: Connected private index ID (nullable)
Example
beta_update_file()
Update metadata for an uploaded file in Tako.Parameters
- file_id (
str): The ID of the file to update - display_name (
Optional[str]): New display name for the file - file_context (
Optional[str]): Updated context description to help Tako understand the file - source (
Optional[str]): Updated source information for the file
Returns
dict: Response containing updated file information
Example
beta_delete_file()
Delete an uploaded file from Tako.Parameters
- file_id (
str): The ID of the file to delete
Returns
bool: Returns True if the file was successfully deleted, or raises an exception if the deletion fails
Example
beta_chart_insights()
Get insights from a chart in a Tako Knowledge Card.Parameters
- card_id (
str): The ID of the chart to get insights for
Returns
dict: Response containing:
insights: List of insights extracted from the visualizationdescription: Optional description of the chart insights
Example
AsyncTakoClient
For asynchronous operations, useAsyncTakoClient with the same methods but with async/await:
Common Response Format
Most methods returnKnowledgeSearchResults: