This python package help to interact with Generative AI - Large Language Models. It interacts with AIaaS LLM , AIaaS embedding , AIaaS Audio set of APIs to cater the request.
Project description
AIaaS Falcon
Description
Generative AI - LLM library interacts with specific API, allowing operations such as listing models, creating embeddings, and generating text based on certain configurations.
Installation
Ensure you have the requests
and google-api-core
libraries installed:
pip install aiaas-falcon
Usage
-
Initialization:
from aiaas_falcon import Falcon # Assuming the class is saved in a file named falcon_client.py falcon = Falcon(api_key="<Your_API_Key>", host_name_port="<Your_Host_Name_Port>")
-
Listing Models:
models = falcon_client.list_models() print(models)
-
Creating an Embedding:
response = falcon_client.create_embedding(file_path="<Your_File_Path>") print(response)
-
Generating Text:
response = falcon_client.generate_text(chat_history=[], query="<Your_Query>") print(response)
Methods
list_models(self)
- Retrieves available models.create_embedding(self, file_path)
- Creates embeddings from a provided file.generate_text(self, chat_history=[], query="", use_default=1, conversation_config={}, config={})
- Generates text based on provided parameters.
# Example usage
from aiaas_falcon import Falcon # Make sure the Falcon class is imported
# Initialize the Falcon object with the API key, host name and port
falcon = Falcon(api_key='_____API_KEY_____', host_name_port='34.16.138.59:8888', transport="rest")
# List available models
model = falcon.list_models()['models']
# Check if any model is available
if model:
# Create an embedding
response = falcon.create_embedding(['/content/01Aug2023.csv'])
print(response)
print('Embedding Success')
# Define a prompt
prompt = 'What is Account status key?'
# Generate text based on the prompt and other parameters
completion = falcon.generate_text(
query=prompt,
chat_history=[],
use_default=1,
conversation_config={
"k": 5,
"fetch_k": 50000,
"bot_context_setting": "Do note that Your are a data dictionary bot. Your task is to fully answer the user's query based on the information provided to you."
},
config={"max_new_tokens": 1200, "temperature": 0.4, "top_k": 40, "top_p": 0.95, "batch_size": 256}
)
print(completion)
print("Generate Success")
else:
print("No suitable model found")
Conclusion
The Falcon API Client simplifies interactions with the specified API, providing a straightforward way to perform various operations such as listing models, creating embeddings, and generating text.
Authors
Google Colab
- [ Get start with aiaas_falcon ]] (https://colab.research.google.com/drive/1k5T_FO9SnlN0zOQfR7WFXSRFkfgiL1cE?usp=sharing)
Badges
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aiaas_falcon-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 128cd20e126e36fff6674ea145f4cd00bf4f3e31493e969ea13dd80e3e056cc2 |
|
MD5 | c6b30d67ee235ab63b1c0f18c8664851 |
|
BLAKE2b-256 | 789af66230263b7e9370089e7ae9d8810fd2db86068c94bb674d4c5daa630cb4 |