Giter Site home page Giter Site logo

cynthiasystems / javascriptclient Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 1.59 MB

Cynthia.js is a concise JavaScript client library designed to asynchronously interface with the Cynthia Cognitive Search API, simplifying the retrieval and handling of search results in web applications.

License: MIT License

JavaScript 100.00%

javascriptclient's Introduction

Cynthia JavaScript Client

Cynthia.js is a lightweight and powerful JavaScript library that integrates AI-powered search capabilities into web applications. This library provides an easy way to enhance your website's search functionality with intelligent, context-aware results.

JavaScript Magic Spell

Features

  • Easy integration
  • AI-powered search
  • Fast and lightweight
  • Customizable options
  • Cross-browser compatible

Getting Started

To start using Cynthia.js, simply include the script in your HTML file:

<script src="https://cynthiasystems.b-cdn.net/Cynthia.js"></script>

Example Usage

Here's an example of how to use Cynthia.js in your web application:

var cynthiaSearch = new CynthiaSearch({
    apiKey: 'your-api-key-here',
    modelName: 'YourModel',
    modelVersion: 'your-model-version',
    cynthiaHost: 'https://api.cynthia.io',  // Replace with your specific Cynthia host
    timeout: 5000  // Optional: specify timeout in milliseconds
});

function updateSearchResults(error, results) {
    if (error) {
        console.error('Search error:', error);
        return;
    }
    // Update the UI with the search results
    console.log('Search results:', results);
    // ... code to update the UI ...
}

// Perform a search when the user submits a query
document.getElementById('search-form').onsubmit = function(event) {
    event.preventDefault();
    var query = document.getElementById('search-input').value;
    cynthiaSearch.search(query, updateSearchResults);
};

Advanced Usage

Cynthia.js offers advanced configuration options and features for more fine-tuned control over your search functionality.

API Version Control

You can specify the API version you want to use:

var cynthiaSearch = new CynthiaSearch({
    apiKey: 'your-api-key-here',
    apiVersion: 'v1.0',
    modelName: 'YourModel',
    modelVersion: 'your-model-version',
    cynthiaHost: 'https://api.cynthia.io',
    timeout: 5000
});

Controlling Search Results

The search method accepts an optional options object as its second parameter, allowing you to control the number of results and enable auto-limiting:

var searchOptions = {
    top: 5,        // Limit to top 5 results
    autoLimit: true // Allow Cynthia to optimize result count for relevance
};

cynthiaSearch.search('your search query', searchOptions, function(error, results) {
    if (error) {
        console.error('Search error:', error);
        return;
    }
    console.log('Search results:', results);
    // Process and display results
});

Full Advanced Example

Here's a comprehensive example showcasing advanced usage:

var cynthiaSearch = new CynthiaSearch({
    apiKey: 'your-api-key-here',
    apiVersion: 'v1.0',
    modelName: 'YourModel',
    modelVersion: 'your-model-version',
    cynthiaHost: 'https://api.cynthia.io',
    timeout: 5000
});

function updateSearchResults(error, results) {
    if (error) {
        console.error('Search error:', error);
        return;
    }
    console.log('Search results:', results);
    // Process and display results
}

document.getElementById('search-form').onsubmit = function(event) {
    event.preventDefault();
    var query = document.getElementById('search-input').value;
    var searchOptions = {
        top: parseInt(document.getElementById('result-limit').value, 10),
        autoLimit: document.getElementById('auto-limit').checked
    };
    cynthiaSearch.search(query, searchOptions, updateSearchResults);
};

This example assumes you have form elements with IDs search-input, result-limit, and auto-limit in your HTML. It allows users to specify the number of results they want and whether to enable auto-limiting, providing a more customizable search experience.

License

Cynthia.js is released under the MIT License. See the LICENSE file in the repository for the full license text.

Contributing

We welcome contributions from the community. If you wish to contribute to Cynthia.js, please feel free to:

  1. Open issues for bug reports or feature requests
  2. Submit pull requests for bug fixes or new features

Before submitting a pull request, please ensure that your code adheres to the existing style and that all tests pass.

Contact

For more information about Cynthia.js, to report issues, or to get in touch with our team, please visit our website at https://cynthiasystems.com/.

We appreciate your interest in Cynthia.js and look forward to seeing how you use it in your projects!

javascriptclient's People

Contributors

cynthiaio avatar davidgeorgewilliams avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.