Skip to content
TheChatArchiveThe Chat Archive
Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)Hugging Face OpenAssistant Conversations (oasst2)

Can you write me a python script to connect to the Seeq Rest API?

In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
  1. User

    Can you write me a python script to connect to the Seeq Rest API?

  2. Assistant
    import requests
    
    # Set the API endpoint URL
    url = 'https://seeqinstance.com/api/v1/'
    
    # Set the API token
    api_token = 'your_api_token_here'
    
    # Set the headers for the HTTP requests
    headers = {
        'Authorization': f'Token {api_token}',
        'Content-Type': 'application/json'
    }
    
    # Define a function to make GET requests to the API
    def get_request(endpoint):
        response = requests.get(url + endpoint, headers=headers)
        return response.json()
    
    # Define a function to make POST requests to the API
    def post_request(endpoint, data):
        response = requests.post(url + endpoint, headers=headers, json=data)
        return response.json()
    
    # Example usage
    # Make a GET request to the 'tags' endpoint to get a list of all tags
    tags = get_request('tags')
    print(tags)
    
    # Make a POST request to create a new asset
    new_asset_data = {
        'name': 'My New Asset',
        'description': 'A description of my new asset'
    }
    response = post_request('assets', new_asset_data)
    print(response)