π Welcome to AskSage Open Source Repo, a community aimed at providing code π§βπ», documentationπ, and proof-of-concept projects for interacting with the AskSage API. This repository serves as an unofficial resource for paid subscribers seeking practical guidance on utilizing the API. If you have any questions email us [email protected]
MIT License
Welcome to the AskSage Overview repository! π
This repository is a work in progress project π· and is intended to be a collection of sample code π§βπ» and documentation π on interacting with AskSage via the AskSage API. Additional content may include actual steps πͺ within the AskSage platform, but for the most part this repository will focus on utilizing the API and creating mini proof-of-concept projects.
Examples provided will cover a wide range of topics related to generative AI and will be designed to be accessible to users with varying levels of experience with AI and programming. At the moment we have provided a list of ideas of what will be covered in this repository and will be updated as more content is added.
Note: Only the AskSage API is available to paid subscribers. π΅π
This is a community-driven effort to provide additional resources and examples for users of AskSage π.
Visit the official AskSage website here.
If you are interested in contributing to this repository, please see the Contributing Guidelines for more information.
If you have any questions or need help, feel free to reach out to the maintainers of this repository or the AskSage team directly.
Note: the content in this repository may be outdated or incorrect, so please refer to the official AskSage documentation for the most up-to-date information.
AskSage is a agnostic Generative AI platform that gives access to a wide range of AI models and tools. The platform is designed to be easy to use and integrate into existing workflows that can be further customized to meet the needs of the user/organization.
Uniquely designed to be agnostic, AskSage provides access to a wide range of models that can be used for a variety of tasks. Some of the models available include but not limited to:
Model Name | Description |
---|---|
Azure OpenAI | Cutting-edge language models developed by OpenAI and hosted on the Azure platform. |
Azure Gov OpenAI | Cutting-edge language models developed by OpenAI and hosted on the Azure Gov platform. |
Google Gemini Pro | Language models developed by Google and optimized for various natural language processing tasks. |
LLMA3 | A large language model developed by Meta that excels in generating high-quality text. |
Mistral | A powerful language model developed by Mistral that can generate creative and coherent text. |
Claude 3 | A language model developed by Anthropic that focuses on generating code and programming-related text. |
Cohere | A language model developed by Cohere Technologies that specializes in generating code. |
OpenAI Whisper | A language model developed by OpenAI that enables speech-to-text capabilities. |
DALL-E v3 | A language model developed by OpenAI that specializes in generating images. |
Here is the actual list of available models on the AskSage platform as of April 19, 2024:
models = ["cohere", "mpt-7b-chat", "claude2", "claude-3-opus", "claude-3-sonnet", "llma3", "aws-bedrock-titan", "google-bison", "google-gemini-pro", "mistral-large", "openai_gpt", "gpt4", "gpt4-32k", "gpt4-vision", "gpt35-16k", "gpt-gov", "gpt4-gov", "dall-e-2", "dall-e-3", "davinci"]
More models can be added by the AskSage team that are specific to a user's needs. (additional costs may apply)
Note: The models listed above are subject to change and more models may be added in the future.
There are two main ways to interact with AskSage:
The AskSage API provides a RESTful interface for interacting with the models available through the platform. Users can send requests to the API and receive responses in JSON format. The API is designed to be easy to use and integrate into existing workflows.
Overall, this repository will provide setup instructions, examples, and other resources as one begins to explore the capabilities of Generative AI and how it can be used in real-world scenarios.
The AskSage API is documented using Swagger, which provides detailed information about the available endpoints, request parameters, response formats, and authentication methods. The API documentation can be accessed using the following links:
Python API Client: https://pypi.org/project/asksageclient/
This information is used to authenticate and get access to the AskSage API. Also, the user can create datasets and get access to the server API.
The following table shows the available endpoints in the User API:
Endpoint | Description |
---|---|
/get-token-with-api-key | Get an access token with API Key and email |
/get-user-logins | Get your last logins (limited to 5 by default) |
/get-user-logs | Get your last prompts |
/add-dataset | Add a new dataset |
/delete-datasets | Deletes a dataset |
This information is used to interact with the AskSage API. The user can query models, select/get personas, get datasets, train models and more.
The following table shows the available endpoints in the Server API:
Endpoint | Description |
---|---|
/query | Main endpoint for generating completions based on the user's input |
/query_with_file | Query with file endpoint for generating completions based on the user's input |
/follow_up_questions | Endpoint for generating follow-up questions based on the user's input |
/tokenizer | Endpoint for getting tokens of string value |
/get-personas | Endpoint for getting the tokens of string |
/get-datasets | Returns a list of available datasets |
/get-plugins | Returns a list of available plugins |
/get-train | Trains the model based on the user's input |
/file | Converts a supported file to plain/text |
Function Name | Description |
---|---|
add_dataset |
Adds a new dataset |
delete_dataset |
Deletes a specified dataset |
assign_dataset |
Assigns a dataset |
get_user_logs |
Retrieves all logs for user |
get_user_logins |
Retrieves login information for a specific user |
query |
Interact with the /query endpoint of the Ask Sage API. |
query_with_file |
Executes a query using a file |
query_plugin |
Executes a query using a specific plugin |
follow_up_questions |
Interact with the /follow-up-questions endpoint of the Ask Sage API. |
tokenizer |
Interact with the /tokenizer endpoint of the Ask Sage API. |
get_personas |
Get the available personas from the Ask Sage service. |
get_datasets |
Get the available datasets from the Ask Sage service. |
get_plugins |
Get the available plugins from the Ask Sage service. |
count_monthly_tokens |
Get the count of monthly training tokens spent for this user from the Ask Sage service. |
count_monthly_teach_tokens |
Counts the number of teach tokens used in a month |
train |
Train the model based on the provided content. |
train_with_file |
Train the dataset based on the provided file. |
file |
Upload a file to the Ask Sage service. |
In the Example section, we will provide examples of how to use these endpoints to interact with the AskSage API and generate text using the models available on the platform.
The AskSage API uses token-based authentication to ensure that only authorized users can access the API. Do not share your API token/key with anyone and keep it secure at all times.
Navigate to the menu options and select the 'Account & Tokens' option.
Scroll down to the 'API Keys' section and click on the 'Generate API Key' button.
Create a new API Key by selecting the 'Create a new API Key' button. Provide a unique name for the API Key and click on the 'Submit' button.
The API Key will be generated and displayed on the screen. Copy the API Key and store it in a secure location.
Here is a sample code snippet in Python that demonstrates how to obtain an access token using your email address and API key:
import requests # Import the requests library if not already installed using pip install requests
# Set the API endpoint URL
url = "https://api.asksage.ai/user/get-token-with-api-key" # URL for the API token endpoint
# Set the email and password parameters
params = {
"email": "your_email@your_domain.com", # Enter your email address
"api_key": "your_api_key", # Enter your API Key
}
# Send a POST request to the API endpoint
response = requests.post(url, json=params)
# Print the response
print(response.json())
# or utilize get-token-with-api-key endpoint
params = {
"email": "your_email@your_domain.com", # Enter your email address
"api_key": "your_api_key" # Enter your API key
}
response = requests.post(url, json=params)
print(response.json())
After using 'get-token-with-api-key', you should receive a response containing the access token that can be used to authenticate future requests to the AskSage API.
{'response': {'access_token': 'string_generated'}, 'status': '200'}
Recommend storing the access token in a secure location and not hardcoding it into your code. It is recommended to use environment variables or a configuration file to store sensitive information like access tokens.
Here are the steps to access the AskSage API with the API Key
API Key - The API key is a unique identifier that is associated with the user's account and is used to grant access to the API. AskSage provides a python client that can be used to interact with the API, which will use the API key and user email to authenticate user.
from asksageclient import AskSageClient # Import the AskSageClient class from the asksageclient module, if not already installed using pip install asksageclient
# authenticate using your email and API key references - both the user and server API URLs
client = AskSageClient(email="your_email@your_domain.com", api_key="your_api_key")
"""
class AskSageClient(
email: str,
api_key: str,
user_base_url: str = 'https://api.asksage.ai/user',
server_base_url: str = 'https://api.asksage.ai/server'
)
"""
From here the user can use the client object to interact with the AskSage API endpoints for the user and server API. Similarly, the user email and password should be stored in a secure location and not hardcoded into the code.
Reference https://pypi.org/project/asksageclient/ for more information on the AskSageClient.
The AskSage API returns responses in JSON format, which is a common data format used for exchanging data between a client and a server. The JSON response will contain the output generated by the model, as well as any additional information that may be relevant to the request.
These examples will be more focused on how one can interact with the AskSage API and what to expect in the response. Additionally, some mini projects will be created to demonstrate the capabilities of Generative AI and how it can be used in real-world scenarios. Although this repository is focused on the AskSage API, the examples will be general enough to be applied to other platforms that provide similar services but may have different endpoints or parameters.
Note: The examples at the moment are more focused on text-based models but will be expanded to the interaction of LLM's with other data types like images, audio, and video (multi-modal models). Going into those examples will lead to more complex projects and will require more resources and time to complete.
After installing packages from requirements.txt
, you may need to restart your Jupyter kernel to use the updated packages. This ensures that the newly installed libraries are loaded correctly.
β Done β
This is not really an example but more of a discussion on the ethical implications of using AI and how to mitigate any potential risks. We place a strong emphasis that a user needs to be well trained on how AI works, but also provide a clear understanding that what is generated through GenAI tools may not always be correct.
β Done β
This example will cover how to use the AskSage API endpoints and what to expect in the responses at a high level. The follow on examples will show how the endpoints can be used in a real-world scenarios to create useful applications, tools, or services.
π§ In Construction π§ --> Full Release Coming Soon!
This example will cover how to interact with a LLM model and how to use prompt engineering to generate high-quality text to be used to guide the model in generating the desired output. Prompt engineering is a powerful and necessary skill that can be used to control the output of a language model and generate text that meets specific criteria or requirements.
π§ In Construction π§
For the most part, LLM models are trained on large datasets that contain a wide range of text from various sources and are not guaranteed to be relevant to the user's specific needs. However, on Ask Sage, users can create custom datasets that contain text that is relevant to their domain or use case and use it with methods like Retrieval-Augmented Generation (RAG) to improve the performance of the model. Thus, this example will cover how to create a custom dataset and use it with a LLM model to generate text that is more relevant to the user's needs. More detailed information will be provided within the example on how the model works/integrates with the dataset.
π§ In Construction π§
The number of LLM models available in today is vast and will continue to grow as more research is done in the field of generative AI. This example will cover how to compare different LLM models using Ask Sage agnostic API method, and evaluate their performance based on various criteria such as text quality, coherence, creativity, and more. Users can use this information to select the best model for their needs and make informed decisions about which model to use in their projects.
To go to this section click Comparing LLM Models
π§ In Construction π§
This is a unique project and will probably be outdated in the future but, LLMs are text-based models that generate text based on the input provided by the user, but what if we wanted to generate a diagram without having to manually create it? For example let's say we wanted a flowchart, mind map, Gantt chart, or any other type of diagram. This example will cover how we use mermaid.js a text-based diagram creation tool to generate diagrams based on the text generated by the LLM model.
To go to this section click Diagram Creation With LLMs
π§ In Construction π§
What about being able to deploy a LLM model on a edge device like a Raspberry Pi or Jetson Nano? This example will cover how to deploy a LLM model on a edge device and generate text utilizing the Asksage API.
To go to this section click LLM Deployment On A Edge Device
π§ In Construction π§
How do we evaluate the performance of a LLM model and monitor its progress over time? This example will cover how to create a dashboard that displays key metrics and insights about the LLM model. Users can use this dashboard to track the performance of the model and make informed decisions about how to improve it over time.
But first, we will use @arize-ai phoenix open source tool to create a dashboard that displays key metrics and insights about the LLM model.
π§ In Construction π§
Let's create a network of chatbots that can communicate with each other and generate text based on each other's output. This example will cover how to create a chatbot network using LLM models and simulate a conversation between the chatbots. Users can use this network to generate creative and engaging text that can be used in a variety of applications, scenarios, and modeling use cases.
To go to this section click LLM Chatbot Network
Here we are providing a list of additional examples that originate from users asking for specific examples or use cases. If you have a specific example or use case you would like to see, please reach out to us and we will do our best to create an example that meets your needs. The best way to reach out to us is by joining our discord server and posting your request there Discord - AskSage π¬:
The AskSage API may return errors in certain situations, such as when an invalid request is made or when the rate limit is exceeded. Users should be familiar with the error codes and messages returned by the API and handle them appropriately in their code.
Here are some best practices to keep in mind when working with the AskSage API:
We will provide additional pdf documents that will contain resources related to GenerativeAI (GenAI). This document will include links to articles, books, tutorials, videos, and other content that may be helpful for users who are interested in learning more about generative AI and how to use it effectively.
Our goal is to provide a comprehensive list of resources that cover a wide range of topics related to generative AI, including natural language processing, computer vision, reinforcement learning, and more. We will also include resources that cover specific models and tools that are commonly used in the field of generative AI.
If you have any suggestions for resources to include in this document, please feel free to reach out to us and we will do my best to add them to the list.
Happy learning! ππ§ π
We will be providing a list of vocabulary that are important to know when working with Generative AI or Machine Learning. These terms will help users understand the terminology used in the field of AI/Machine Learning and how to apply it in their projects.
For example here are some terms to know when working with Generative AI:
To view the full list of definitions click Defintions To Know
Here are some features or enhancements that we would like to see added to the AskSage API:
Each item will have a link to the example that will be created to demonstrate where the feature or enhancement can be used.
Any bugs or issues found in the AskSage API should be reported to the AskSage team directly. If you encounter any problems with the API, please reach out to the AskSage team for assistance. Additionally, you can report bugs or issues in this repository and we will test and verify them before forwarding them to the AskSage team.
This repository is licensed under the MIT License. See the LICENSE file for more information.
A special thanks to everyone contributing and the AskSage team for creating a flexible and powerful platform that enables users to explore the possibilities of generative AI. We appreciate your hard work and dedication to providing a valuable resource for the community. Also, a big thank you to the future contributors and users who will help make this repository a valuable resource for all. ππ