Pakistan's First Oracle Blog

Subscribe to Pakistan's First Oracle Blog feed
Blog By Fahd Mirza ChughtaiFahd Mirza
Updated: 16 hours 56 min ago

AnythingLLM - Any LLM, Any Document, Full Control, Full Privacy, Local, Secure

Sun, 2024-04-07 18:14

This video shows how to locally install AnythingLLM to privately and securly and remotely run any LLM with any RAG document. It all runs locally with zero required internet connectivity.

Categories: DBA Blogs

How to Install OpenDevin Locally

Sat, 2024-03-30 20:00

This is a step by step easy tutorial to locally install OpenDevin which is an open-source project aiming to replicate Devin, an autonomous AI software engineer who is capable of executing complex engineering tasks and collaborating actively with users on software development projects.

Commands Used:


Update OS:

sudo apt-get update

Install git:

sudo apt-get install git

Install Nodejs:

sudo apt-get install nodejs

Install npm:

sudo apt install npm

Install Rust:

curl --proto '=https' --tlsv1.3 -sSf | sh

Install docker:

sudo apt-get update

sudo apt-get install ca-certificates curl

sudo install -m 0755 -d /etc/apt/keyrings

sudo curl -fsSL -o /etc/apt/keyrings/docker.asc

sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:

echo \

  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \

  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \

  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin

Install conda:



Install uvicorn:

sudo apt install uvicorn

Backend Commands:

git clone

cd OpenDevin

conda create -n opendevin python=3.11

conda activate opendevin 

docker ps

docker pull

which python

python --version

/home/ubuntu/anaconda3/envs/opendevin/bin/python -m pip install pipenv

/home/ubuntu/anaconda3/envs/opendevin/bin/python -m pipenv install -v

/home/ubuntu/anaconda3/envs/opendevin/bin/python -m pipenv shell

uvicorn opendevin.server.listen:app --port 3000

Frontend Commands:

python -m pipenv requirements > requirements.txt && python -m pip install -r requirements.txt

PYTHONPATH=`pwd` /home/ubuntu/anaconda3/envs/opendevin/bin/python opendevin/ -d ./workspace/ -i 100 -t "Write a bash script that prints 'hello world'"

Categories: DBA Blogs

How to Create Urdu Hindi AI Model and Dataset from New Dataset

Fri, 2024-03-15 21:54

 This video is hands on step-by-step tutorial to create a new dataset, an AI model, fine-tune the model on dataset and then push it to hugging face.



import torch

major_version, minor_version = torch.cuda.get_device_capability()

# Must install separately since Colab has torch 2.2.1, which breaks packages

!pip install "unsloth[colab-new] @ git+"

if major_version >= 8:

    # Use this for new GPUs like Ampere, Hopper GPUs (RTX 30xx, RTX 40xx, A100, H100, L40)

    !pip install --no-deps packaging ninja flash-attn xformers trl peft accelerate bitsandbytes


    # Use this for older GPUs (V100, Tesla T4, RTX 20xx)

    !pip install --no-deps xformers trl peft accelerate bitsandbytes


!pip install einops

from unsloth import FastLanguageModel

import torch

max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!

dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+

load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.

model, tokenizer = FastLanguageModel.from_pretrained(

    model_name = "unsloth/gemma-7b-bnb-4bit", # Choose ANY! eg teknium/OpenHermes-2.5-Mistral-7B

    max_seq_length = max_seq_length,

    dtype = dtype,

    load_in_4bit = load_in_4bit,

    token = " ", # use one if using gated models like meta-llama/Llama-2-7b-hf


model = FastLanguageModel.get_peft_model(


    r = 16, # Choose any number > 0 ! Suggested 8, 16, 32, 64, 128

    target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",

                      "gate_proj", "up_proj", "down_proj",],

    lora_alpha = 16,

    lora_dropout = 0, # Supports any, but = 0 is optimized

    bias = "none",    # Supports any, but = "none" is optimized

    use_gradient_checkpointing = True,

    random_state = 3407,

    use_rslora = False,  # We support rank stabilized LoRA

    loftq_config = None, # And LoftQ


alpaca_prompt = """ذیل میں ایک ہدایت ہے جو فلم کے نام کی وضاحت کرتی ہے، اس کے ساتھ ایک ان پٹ بھی ہے جو مزید دستاویزات فراہم کرتا ہے۔ گانے کے بول لکھنے کے لیے ایک لمحہ نکالیں جو فلم کے نام کے معنی سے میل کھاتا ہے۔

### Instruction:


### Input:


### Response:


EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN

def formatting_prompts_func(examples):

    instructions = examples["urdu_instruction"]

    inputs       = examples["urdu_input"]

    outputs      = examples["urdu_output"]

    texts = []

    for instruction, input, output in zip(instructions, inputs, outputs):

        # Must add EOS_TOKEN, otherwise your generation will go on forever!

        text = alpaca_prompt.format(instruction, input, output) + EOS_TOKEN


    return { "text" : texts, }


from datasets import load_dataset

dataset = load_dataset("fahdmirzac/urdu_bollywood_songs_dataset", split = "train")

dataset =, batched = True,)

from huggingface_hub import login

access_token = "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"


from trl import SFTTrainer

from transformers import TrainingArguments

trainer = SFTTrainer(

    model = model,

    tokenizer = tokenizer,

    train_dataset = dataset,

    dataset_text_field = "text",

    max_seq_length = max_seq_length,

    dataset_num_proc = 2,

    packing = False, # Can make training 5x faster for short sequences.

    args = TrainingArguments(

        per_device_train_batch_size = 2,

        gradient_accumulation_steps = 4,

        warmup_steps = 5,

        max_steps = 100,

        learning_rate = 2e-4,

        fp16 = not torch.cuda.is_bf16_supported(),

        bf16 = torch.cuda.is_bf16_supported(),

        logging_steps = 1,

        optim = "adamw_8bit",

        weight_decay = 0.01,

        lr_scheduler_type = "linear",

        seed = 3407,

        output_dir = "outputs",



trainer_stats = trainer.train()

FastLanguageModel.for_inference(model) # Enable native 2x faster inference

inputs = tokenizer(



        "دیے گئے فلم کے نام کے بارے میں ایک مختصر گیت کے بول لکھیں۔", # instruction

        "کیوں پیار ہو گیا", # input

        "", # output - leave this blank for generation!


], return_tensors = "pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True)


FastLanguageModel.for_inference(model) # Enable native 2x faster inference

inputs = tokenizer(



        "دیے گئے فلم کے نام کے بارے میں ایک مختصر گیت کے بول لکھیں۔", # instruction

        "رنگ", # input

        "", # output - leave this blank for generation!


], return_tensors = "pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True)


model.push_to_hub("fahdmirzac/Gemma_Urdu_Hindi_Bollywood_Songs", token = "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")

Categories: DBA Blogs

Using Claude 3 Haiku Vision with Amazon Bedrock Locally

Fri, 2024-03-15 02:58

 This video is a hands-on guide as how to use vision features of Anthropic's Claude 3 Haiku AI model with Amazon Bedrock.

Code Used:

import boto3
import json
import base64
from botocore.exceptions import ClientError

bedrock = boto3.client(service_name="bedrock-runtime",region_name='us-east-1')

modelId = "anthropic.claude-3-haiku-20240307-v1:0"

accept = "application/json"
contentType = "application/json"

# prompt = "What is written in this image?"
# image_path = "./images/ab55.png"

# prompt = "How many faces are there in this image and what are the expressions of those faces?"
# image_path = "./images/expression.png"

# prompt = "Tell me a short story about this image."
# image_path = "./images/hiking.png"

prompt = "What's the location in this image?"
image_path = "./images/whereisthis.png"

with open(image_path, "rb") as image_file:
    image = base64.b64encode("utf8")

request_body = {
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 2048,
    "messages": [
            "role": "user",
            "content": [
                    "type": "text",
                    "text": prompt,
                    "type": "image",
                    "source": {
                        "type": "base64",
                        "media_type": "image/png",
                        "data": image,

    response = bedrock.invoke_model(

    # Process and print the response
    result = json.loads(response.get("body").read())
    input_tokens = result["usage"]["input_tokens"]
    output_tokens = result["usage"]["output_tokens"]
    output_list = result.get("content", [])

    # print("Invocation details:")
    # print(f"- The input length is {input_tokens} tokens.")
    # print(f"- The output length is {output_tokens} tokens.")

    # print(f"- The model returned {len(output_list)} response(s):")
    for output in output_list:

except ClientError as err:
        "Couldn't invoke Claude 3 Haiku Vision. Here's why: %s: %s",
Categories: DBA Blogs

Create AI Agent in AWS with Boto3 Code

Thu, 2024-03-14 22:03

 This video is a step-by-step tutorial with code as how to create Amazon Bedrock AI agents with boto3 in Python to integrate with Lambda.

Code used: Just use any lambda with it of your choice.

import logging
import boto3
import time
import yaml
import json
import io
from botocore.exceptions import ClientError

def create_agent(bedrock, agent_name, foundation_model, role_arn, instruction):
        # Create a low-level client with the service name
        response = bedrock.create_agent(
    except ClientError as e:
        logging.error(f"Couldn't create agent due to: {e}")
        return response["agent"]

def create_agent_action_group(bedrock, name, description, agent_id, agent_version, function_arn, api_schema):
        response = bedrock.create_agent_action_group(
            actionGroupExecutor={"lambda": function_arn},
            apiSchema={"payload": api_schema},
        agent_action_group = response["agentActionGroup"]
    except ClientError as e:
        print(f"Error: Couldn't create agent action group. Here's why: {e}")
        return agent_action_group

def prepare_agent(bedrock, agent_id):
        prepared_agent_details = bedrock.prepare_agent(agentId=agent_id)
    except ClientError as e:
        print(f"Couldn't prepare agent. {e}")
        return prepared_agent_details

def create_agent_alias(bedrock, name, agent_id):
        response = bedrock.create_agent_alias(
            agentAliasName=name, agentId=agent_id
        agent_alias = response["agentAlias"]
    except ClientError as e:
        print(f"Couldn't create agent alias. {e}")
        return agent_alias

def main():
    # Define your parameters
    bedrock = boto3.client(service_name='bedrock-agent',region_name='us-east-1')
    agent_name = 'AstroAI'
    foundation_model = 'anthropic.claude-v2'
    role_arn = 'bedrock role arn'
    instruction = 'Your task is to generate unique and insightful daily horoscopes for individuals \
                   based on their zodiac sign. Start by analyzing the general characteristics and common \
                   themes associated with each zodiac sign. Consider traits, challenges, opportunities, \
                   and the emotional and physical wellbeing of individuals under each sign. Use this \
                   understanding to create personalized, relevant, and engaging horoscopes that offer \
                   guidance, reflection, and encouragement for the day ahead. Ensure the horoscopes \
                   are varied and resonate with the unique qualities of each sign, contributing \
                   positively to the users day.'

    # Call the create_agent function
        agent = create_agent(bedrock, agent_name, foundation_model, role_arn, instruction)
        agent_id = agent['agentId']
        print(f"Agent created successfully: {agent_id}")
    except ClientError:
        print("Failed to create the agent.")


        with open("api_schema.yaml") as file:
            description="AI Astrologer"
            agentgroup = create_agent_action_group(bedrock, name, description, agent_id, agent_version, function_arn, api_schema)                
    except ClientError as e:
        print(f"Couldn't create agent action group. Here's why: {e}")


    agentprepared = prepare_agent(bedrock, agent_id)                


    agentalias = create_agent_alias(bedrock, name, agent_id)

if __name__ == "__main__":

Categories: DBA Blogs

Immutable Data Integrity with Oracle's Blockchain Tables

Sat, 2024-03-02 16:24

 Blockchain tables in Oracle Database implement a unique data organization model, forming chains of insert-only rows. Each row, excluding the first, links back to the previous row using cryptographic hashing. This hashing method leverages row data and the hash of the preceding row to identify any unauthorized modifications through specialized verification procedures. The added capability to store user signatures significantly enhances security against tampering and unauthorized alterations.

Beyond thwarting unauthorized changes initiated by rogue or compromised insiders, blockchain tables boast powerful functionality:

  • Identification of illicit modifications made by circumventing Oracle Database protocols.
  • Detection of user impersonation and unauthorized data insertions on behalf of another user.
  • Safeguarding against data tampering, certifying that all data inserted into the table was done legitimately.
  • The chaining mechanism ensures that each row remains linked to its predecessor through cryptographic hashing. Altering any row disrupts this chain, immediately signaling tampering. However, this additional layer of security necessitates increased processing time during commit operations to chain rows effectively.

Let's explore how to create and interact with a blockchain table in Oracle Database through the following example:

-- Creating a blockchain table

SQL> CREATE BLOCKCHAIN TABLE secure_data_table (data_value VARCHAR2(128), sequence_number NUMBER)



     HASHING USING "SHA2_512" VERSION "v1";    

Table created.

-- Inserting data into the blockchain table

SQL> INSERT INTO secure_data_table VALUES ('Value1', 1);

1 row created.


Commit complete.

-- Querying metadata of the blockchain table

SQL> SELECT column_id, column_name, nullable, hidden_column

     FROM all_tab_cols

     WHERE table_name LIKE 'SECURE_DATA_%'

     ORDER BY column_id;

-- Viewing blockchain table details

SQL> SELECT * FROM dba_blockchain_tables;

In this example, secure_data_table is our blockchain table, ensuring immutable data integrity and providing robust security against unauthorized changes. The SHA2_512 hashing algorithm is employed to maintain the integrity of each chained row, guaranteeing data authenticity and traceability within Oracle Database's secure environment.

Categories: DBA Blogs

Access AWS S3 Bucket from Oracle Database

Thu, 2024-02-29 16:11

 If you want to access any object stored in an AWS S3 bucket from Oracle database, then dbms_cloud package is your friend, provided you are using Oracle Autonomous database. 

An AWS S3 (Simple Storage Service) bucket is a scalable storage resource in the cloud provided by Amazon Web Services. It allows you to store and retrieve any amount of data from anywhere on the web. S3 buckets are highly durable, secure, and can be configured to support various use cases including website hosting, data backup, and content distribution.

The DBMS_CLOUD package in Oracle Database is a PL/SQL package that provides procedures to interact with Oracle Cloud Infrastructure services, specifically for loading data into Oracle Database from external data sources such as object storage in Oracle Cloud. It enables seamless integration between Oracle Database and cloud-based storage for data loading operations, making it easier to ingest large volumes of data into the database from cloud-based sources. The package includes procedures like COPY_DATA for copying data from cloud storage to database tables, and CREATE_CREDENTIAL for managing credentials needed to access cloud storage securely. This package simplifies data loading tasks and enhances integration capabilities between Oracle Database and Oracle Cloud services.

In order to access the object from S3 bucket, make sure you have created a database user in Oracle with proper credentials, and also you have AWS IAM credentials to access S3 bucket.

Step 1: First, you need to create a credential in Oracle Database that allows access to your AWS S3 bucket. This credential will store the AWS access key ID and secret access key securely.



    credential_name => 'MY_AWS_CREDENTIAL',

    username => 'AWS_ACCESS_KEY_ID',

    password => 'AWS_SECRET_ACCESS_KEY'




Step 2: Now, you can use the DBMS_CLOUD package to select data from a file in your AWS S3 bucket and load it into a table in Oracle Database.


  v_data CLOB;



    credential_name => 'MY_AWS_CREDENTIAL',

    object_uri => 'https://s3.<region><bucket_name>/<file_key>'


  -- Process the retrieved data (example: print the data)





Categories: DBA Blogs

How AI Transcription Can Make Your Next Job Interview More Effective

Thu, 2024-02-29 01:47

 If you are looking to use AI Transcription during your job interview to get help from LLM, then this video is going to help you immensely.

In the rapidly evolving landscape of recruitment, the integration of Artificial Intelligence (AI) tools has been a game-changer, especially AI transcription services. These services, which convert speech into a written or electronic text document, are now being increasingly utilized during candidate interviews. This innovative approach is not just about efficiency; it's about transforming the interview process into a more insightful, fair, and strategic component of talent acquisition. Let's delve into the merits of using AI transcription in candidate interviews and how it is reshaping the future of hiring.

Enhanced Accuracy and Objectivity

One of the paramount benefits of using AI transcription is the enhanced accuracy and objectivity it brings to the recruitment process. Traditional note-taking methods during interviews are inherently flawed, prone to human error, and can be biased. AI transcription, on the other hand, captures every word as it is spoken, ensuring that nothing is missed or misinterpreted. This verbatim record allows hiring managers to review the interview with a fine-tooth comb, ensuring that decisions are made based on what was actually said, rather than on recollection or interpretation.

Improved Candidate Experience

The candidate experience is crucial in attracting top talent. AI transcription contributes to a more engaging and less intimidating interview environment. Candidates can speak freely, knowing that their responses are being accurately recorded. This level of precision in capturing responses allows candidates to feel heard and valued, improving their overall experience and perception of the company. Furthermore, the efficiency of AI transcription speeds up the interview process, enabling quicker feedback and follow-ups, which candidates appreciate.

Accessibility and Inclusivity

AI transcription makes interviews more accessible and inclusive, breaking down barriers for candidates who may be deaf or hard of hearing. By providing real-time transcription, these candidates can participate fully in the interview process, ensuring equal opportunities for all. This commitment to inclusivity not only enhances the company's reputation but also widens the talent pool by making it more diverse.

Streamlined Analysis and Decision Making

The comprehensive data captured by AI transcription allows for a more streamlined analysis of candidates' responses. Hiring teams can utilize this data to identify patterns, evaluate key competencies, and make more informed decisions. AI tools can also highlight specific skills and qualifications mentioned during the interview, making it easier to assess candidates against job requirements. This data-driven approach reduces the likelihood of cognitive biases affecting hiring decisions and helps in selecting the best fit for the role.

Enhanced Collaboration Among Hiring Teams

AI transcription facilitates better collaboration among hiring team members, especially in scenarios where not all members can attend every interview. The transcribed interviews can be easily shared, allowing team members to review and provide input at their convenience. This collaborative approach ensures a more comprehensive evaluation of candidates, drawing on diverse perspectives within the team.

Legal Compliance and Record-Keeping

In today's litigious environment, maintaining accurate records of candidate interviews can be crucial for legal compliance. AI transcription provides an exact record of the conversation, which can be invaluable in defending against claims of discrimination or bias. This level of documentation ensures that the hiring process is transparent and defensible, safeguarding the company against potential legal challenges.


The adoption of AI transcription in candidate interviews is more than just a nod to technological advancement; it's a strategic move towards making the recruitment process more accurate, fair, and inclusive. By enhancing the accuracy of interviews, improving candidate experience, and streamlining decision-making, AI transcription is setting a new standard in talent acquisition. As companies continue to seek competitive advantages in attracting top talent, the use of AI in recruitment processes, especially transcription, is likely to become not just common but essential.

Categories: DBA Blogs

Tutorial to Implement RAG with Gemma Model Locally

Mon, 2024-02-26 20:20

 Unlock the power of Retrieval-Augmented Generation (RAG) locally using the Gemma model with our detailed step-by-step tutorial. Learn how to enhance your projects by integrating RAG for insightful document processing and AI-driven content generation. Perfect for developers, data scientists, and AI enthusiasts eager to leverage advanced NLP techniques on their own documents. No prior RAG experience required!

Commands Used:

pip install -U "transformers==4.38.1" --upgrade

pip install -q pypdf

pip install -q python-dotenv

pip install  llama-index==0.10.12

pip install -q gradio

pip install einops

pip install accelerate

pip install llama-index-llms-huggingface

pip install llama-index-embeddings-fastembed

pip install fastembed

import logging

import sys

logging.basicConfig(stream=sys.stdout, level=logging.INFO)


from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

from llama_index.llms.huggingface import HuggingFaceLLM

from llama_index.core import Settings

documents = SimpleDirectoryReader("/home/ubuntu/pdfs").load_data()

from llama_index.embeddings.fastembed import FastEmbedEmbedding

embed_model = FastEmbedEmbedding(model_name="BAAI/bge-small-en-v1.5")

Settings.embed_model = embed_model

Settings.chunk_size = 512

from llama_index.core import PromptTemplate

system_prompt = "You are a Q&A assistant. Your goal is to answer questions as accurately as possible based on the instructions and context provided."

query_wrapper_prompt = PromptTemplate("<|USER|>{query_str}<|ASSISTANT|>")

from huggingface_hub.hf_api import HfFolder 

HfFolder.save_token('<your huggingface token from>')

import torch

llm = HuggingFaceLLM(



    generate_kwargs={"temperature": 0.7, "do_sample": False},






    tokenizer_kwargs={"max_length": 4096},

    model_kwargs={"torch_dtype": torch.float16}


Settings.llm = llm

Settings.chunk_size = 512

index = VectorStoreIndex.from_documents(documents)

query_engine = index.as_query_engine()

def predict(input, history):

  response = query_engine.query(input)

  return str(response)


import gradio as gr



Categories: DBA Blogs

Using JSON in Oracle Database Natively

Sat, 2024-02-24 16:36

 Oracle Database seamlessly integrates JSON (JavaScript Object Notation) with its robust RDBMS features, offering full support for transactions, indexing, declarative querying, and views among other functionalities.

JSON is a lightweight data interchange format widely employed for representing structured data due to its human-friendly readability and machine-friendly parsing capabilities. It utilizes key-value pairs enclosed in curly braces {}. Each key is a string followed by a colon :, and its value can be a string, number, boolean, array, object, or null. JSON arrays are ordered lists enclosed in square brackets [], while objects represent collections of key-value pairs. This versatile format finds extensive use in web development, APIs, and system-to-system data exchanges owing to its simplicity, adaptability, and clarity—a near subset of JavaScript's object literal notation.

When leveraging JSON within Oracle Database, the typical workflow involves:

Step 1: Creating a JSON-Enabled Table:

CREATE TABLE json_purchase_orders



   po_document JSON);

Step 2: Inserting JSON Data into the Table:

INSERT INTO json_purchase_orders



          '{"PONumber": 1600,

            "Reference": "ABULL-20140421",

            "Requestor": "Alexis Bull",

            "User": "ABULL",

            "CostCenter": "A50",

            "ShippingInstructions": {...},

            "SpecialInstructions": null,

            "AllowPartialShipment": true,

            "LineItems": [...]}');

Step 3: Querying JSON Data from the Table:

SELECT po.po_document.PONumber

FROM json_purchase_orders po;

By leveraging Oracle Database's native JSON support, developers gain the flexibility to seamlessly integrate JSON data within the relational model, enabling efficient storage, retrieval, and manipulation of JSON documents alongside traditional SQL operations. This unified approach empowers enterprises to harness the best of both worlds—structured data management and JSON flexibility—within a single, powerful database environment.

Categories: DBA Blogs

Build Your Own Audio Transcription Tool with AI

Fri, 2024-02-23 22:45

 In this video, you will learn how to deploy a LLM based application intro production by using Amazon Bedrock, Amazon Transcribe to summarize audio files with ASR model, Titan. 


import boto3
import json
import uuid
import time
from jinja2 import Template

bedrock_runtime = boto3.client('bedrock-runtime', region_name='us-east-1')

s3_client = boto3.client(service_name='s3', region_name='ap-southeast-2')

transcribe_client = boto3.client('transcribe', region_name='ap-southeast-2')

bucket_name='<replace your bucket name here>'

#file_name = 'angry.mp3'
file_name = 'happy.mp3'

job_name = 'transcription-job-' + str(uuid.uuid4())

response = transcribe_client.start_transcription_job(
    Media={'MediaFileUri': f's3://{bucket_name}/{file_name}'},
        'ShowSpeakerLabels': True,
        'MaxSpeakerLabels': 2

while True:
    status = transcribe_client.get_transcription_job(TranscriptionJobName=job_name)
    if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:

if status['TranscriptionJob']['TranscriptionJobStatus'] == 'COMPLETED':
    # Load the transcript from S3.
    transcript_key = f"{job_name}.json"
    transcript_obj = s3_client.get_object(Bucket=bucket_name, Key=transcript_key)
    transcript_text = transcript_obj['Body'].read().decode('utf-8')
    transcript_json = json.loads(transcript_text)
    output_text = ""
    current_speaker = None
    items = transcript_json['results']['items']
    for item in items:
        speaker_label = item.get('speaker_label', None)
        content = item['alternatives'][0]['content']
        # Start the line with the speaker label:
        if speaker_label is not None and speaker_label != current_speaker:
            current_speaker = speaker_label
            output_text += f"\n{current_speaker}: "
        # Add the speech content:
        if item['type'] == 'punctuation':
            output_text = output_text.rstrip()
        output_text += f"{content} "
    # Save the transcript to a text file
    with open(f'{job_name}.txt', 'w') as f:

with open(f'{job_name}.txt', "r") as file:
    transcript =

template_string = """ I need to summarize a conversation. The transcript of the
conversation is between the <data> XML like tags.


The summary must contain a one word sentiment analysis, and
a list of issues, problems or causes of friction
during the conversation. The output must be provided in
JSON format shown in the following example.

Example output:
    "sentiment": <sentiment>,
    "issues": [
            "topic": <topic>,
            "summary": <issue_summary>,

Write the JSON output and nothing more.

Here is the JSON output:   """

data = {
    'transcript' : transcript

template = Template(template_string)

prompt = template.render(data)

kwargs = {
    "modelId": "amazon.titan-text-express-v1",
    "contentType": "application/json",
    "accept": "*/*",
    "body": json.dumps(
            "inputText": prompt,
            "textGenerationConfig": {
                "maxTokenCount": 512,
                "temperature": 0,
                "topP": 0.9

response = bedrock_runtime.invoke_model(**kwargs)

response_body = json.loads(response.get('body').read())
generation = response_body['results'][0]['outputText']

Categories: DBA Blogs

Manage and Run Gemma LLM with Keras Locally

Fri, 2024-02-23 01:59

This video shows how to install and manage Gemma LLM with Keras. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.


!pip install keras --upgrade

!pip install kaggle

from google.colab import files

uploaded = files.upload()

for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded[fn])))
# Then move kaggle.json into the folder where the API expects to find it.
!mkdir -p ~/.kaggle/ && mv kaggle.json ~/.kaggle/ && chmod 600 ~/.kaggle/kaggle.json

!pip install keras_nlp --upgrade
!pip install keras --upgrade

import os

os.environ["KERAS_BACKEND"] = "jax"

import keras_nlp
import keras
import tensorflow as tf
import time


preprocessor = keras_nlp.models.GemmaPreprocessor.from_preset(

gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_2b_en")

gemma_lm.generate("which one came first, egg or chicken?", max_length=130)


Categories: DBA Blogs

Oracle GoldenGate Script for Troubleshooting

Thu, 2024-02-22 21:28

Oracle GoldenGate is a comprehensive software product that enables real-time data integration, replication, and synchronization across heterogeneous systems. It supports continuous data streaming with minimal latency and offers high availability and data integrity. GoldenGate facilitates data replication between different database platforms, including Oracle Database, Microsoft SQL Server, MySQL, and others, allowing organizations to achieve real-time data integration for analytics, reporting, disaster recovery, and distributed data environments. Its capabilities include data transformation, filtering, conflict resolution, and support for complex replication topologies, making it a powerful solution for maintaining synchronized data across diverse IT landscapes.

This script checks if Oracle Golden Gate process is running or not and give the exact starting point to catch up:


. /etc/profile

#. /home/oracle/.bash_profile 

YYMMDD=`date +%Y%m%d`






export ORACLE_HOME=/u01/app/oracle/product/

export PATH=$ORACLE_HOME/bin:$PATH/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/local/lib


HOSTNAME=`uname -n | tr '[a-z]' '[A-Z]'`


echo "###########################################"

echo "GG Check Up `basename $0` started t `date`"

#check if maint flag is on

if [ -f /home/oracle/work/${ORACLE_SID}_maintenance.on ] ; then

   echo "Maintenance flag is on .... stop "

   exit 0


### Check GG processes

cd /ggs

echo "info all" | /ggs/ggsci | sed -e '1,/^Program/d' -e '/^GGSCI/,$d' -e '/^ *$/d' | tee $WRK_FL

echo " "

cat $WRK_FL | grep -v 'RUNNING'| grep -iv 'test' | tee $BAD_FL


if [ -f $BAD_FL ] ; then

   non_run_cnt=`wc -l $BAD_FL |awk '{print $1}'`


echo "GG Process Not Running: $non_run_cnt "

if [[ $non_run_cnt -gt 0 ]] ; then

   echo "\nEmail support team ($DBA_MAIL_ADDR) about failed processes "

   cat $BAD_FL

   mailx -s "$HOSTNAME : ALERT: One or more Goldengate Process in ${ORACLE_SID} are down ($non_run_cnt)!!!" $DBA_MAIL_ADDR < $BAD_FL



echo "GG Check Up `basename $0` finished at `date`"

echo "###########################################"

} 2>&1 | tee $LOG_FL 


Categories: DBA Blogs

Oracle ML and Predictive Analytics with AI

Wed, 2024-02-07 21:47

 In today's data-driven world, businesses are constantly seeking ways to gain a competitive edge. One of the most potent tools at their disposal is predictive analytics, powered by artificial intelligence (AI). This dynamic combination enables organizations to anticipate future trends, behaviors, and outcomes with unprecedented accuracy, revolutionizing decision-making processes across industries.

Predictive analytics leverages historical data, statistical algorithms, and machine learning techniques to identify patterns and forecast future events. By analyzing vast datasets, AI algorithms can discern hidden correlations and extrapolate insights that human intuition alone may overlook. Whether it's predicting customer behavior, optimizing supply chains, or mitigating risks, the applications of predictive analytics with AI are limitless.

One of the primary advantages of predictive analytics with AI is its ability to enhance operational efficiency and drive strategic decision-making. By harnessing AI-powered predictive models, businesses can anticipate market fluctuations, optimize resource allocation, and streamline processes. For instance, retailers can forecast demand patterns to optimize inventory levels, minimizing stockouts and overstock situations.

Fusion Analytics facilitates seamless integration with Oracle Fusion Cloud ERP and provides easy access to various data sources such as weather, demographics, and supply chain routes. This comprehensive approach allows users to visualize data in a three-dimensional, geospatial format, providing deeper insights into potential implications.

The predictive capabilities of Fusion Analytics are versatile and applicable across different departments within your organization. For instance, finance teams can utilize these capabilities to identify late payments and predict future revenue risks associated with specific customers. HR teams can conduct cluster analysis to identify correlations between employee satisfaction and customer satisfaction, or utilize diversity analysis to monitor indicators of adverse impact in hiring, terminations, and promotions.

Moreover, what sets Fusion Analytics apart is its user-friendly interface, enabling business professionals with varying levels of data expertise to leverage predictive capabilities independently. You don't need to be a data scientist to explore scenarios and make informed decisions. This accessibility has led to widespread adoption among diverse clientele, as businesses leverage Fusion Analytics to anticipate and adapt to changes effectively.

At the heart of Fusion Analytics is machine learning, which drives its predictive capabilities, empowering organizations to operate more successfully by harnessing the power of data-driven insights.

In conclusion, predictive analytics with AI represents a paradigm shift in how businesses leverage data to gain insights and drive innovation, and Oracle ML takes it to next level. By harnessing the power of AI algorithms, organizations can unlock hidden patterns in data, anticipate future trends, and make informed decisions with confidence. As the technology continues to evolve, its transformative impact on businesses and society is only expected to grow, ushering in a new era of predictive intelligence.

Categories: DBA Blogs

Step by Step Guide to Configure Amazon Bedrock with VPC Endpoints and PrivateLink

Thu, 2024-02-01 04:20

This video is step by step tutorial to setup AWS Bedrock with VPC Endpoints and PrivateLink to build secure and private generative AI applications.


Step 0: Make sure that Private subnet with private route table without any route to internet is there.

Step 1: Create 2 SG  = Bedrock-Endpoint-SG and Bedrock-Lambda-SG

Step 2: In Bedrock-Lambda-SG , ADD Bedrock-EndPoint-SG for all traffic in INBOUND, and OUTBOUND FOR

Step 3: In Bedrock-EndpointP-SG, Add Bedrock-Lambda-SG for all traffic in INBOUND and OUTBOUND 

Step 4: Create 2 endpoints bedrock, bedrock-runtime in private subnet and attach Bedrock-EndpointP-SG with both

Step 5: Create lambda function, set time to 15 seconds, and attach Bedrock-Lambda-SG, lambda execution role should have bedrock permissions

Lambda Code:

import boto3

import json

def lambda_handler(event,context):

    bedrock = boto3.client(





    # Bedrock Runtime client used to invoke and question the models

    bedrock_runtime = boto3.client(




    models = bedrock.list_foundation_models().get('modelSummaries')

    for model in models:

        print(model['modelName'] + ', Input=' + '-'.join(model['inputModalities']) + ', Output=' + ''.join(model['outputModalities']) + ', Provider=' + model['providerName'])





Categories: DBA Blogs

How to Identify Oracle Database Orphan Sessions

Fri, 2024-01-26 00:17

 In the world of database management, particularly with Oracle databases, "orphan sessions" are a common issue that can affect performance and resource utilization. 

In Oracle databases, an orphan session, sometimes known as a "zombie session," is a session that remains in the database even though its corresponding client process has terminated. These sessions no longer have a user actively interacting with them, yet they consume system resources and can hold locks, leading to performance degradation and blocking issues.

Orphan sessions can occur due to various reasons such as:

  • Network issues that disrupt the connection between the client and the server.
  • Application or client crashes that terminate the session abnormally.
  • Database bugs or misconfigurations.

Queries to Identify Orphan Sessions:

SELECT s.sid, s.serial#, p.spid, s.username, s.program
FROM v$session s
JOIN v$process p ON p.addr = s.paddr

This query lists active sessions, excluding background processes. It provides session identifiers (sid, serial#), the operating system process identifier (spid), and the username and program name. Orphan sessions often show NULL or unusual entries in the program column.

SELECT s.sid, s.serial#, p.spid, s.username, s.program
FROM v$session s
JOIN v$process p ON p.addr = s.paddr
AND NOT EXISTS (SELECT NULL FROM v$process WHERE spid = s.process);

This query filters the sessions where the client process (spid) associated with the session does not exist in the v$process view, indicating a potential orphan.

SELECT s.sid, s.serial#, l.object_id, o.object_name, o.object_type
FROM v$session s
JOIN dba_objects o ON o.object_id = l.object_id
JOIN v$lock l ON s.sid = l.sid
WHERE s.sid IN (SELECT sid FROM v$session WHERE ... /* Conditions from above queries */);

This query identifies locks held by sessions suspected to be orphans, which is useful for understanding the impact of these sessions on the database.

How to Manage Orphan Sessions:

Manual Termination: Using the ALTER SYSTEM KILL SESSION command to terminate the identified orphan sessions. Or Kill at OS level with kill -9 spid command.

Automated Monitoring and Cleanup: Implementing automated scripts or database jobs to periodically identify and clean up orphan sessions.

Prevention: Addressing the root causes, such as network stability and application robustness, can reduce the occurrence of orphan sessions.

Categories: DBA Blogs

Oracle OCI's Generative AI Service: A New Era in Cloud Computing

Thu, 2024-01-25 23:47

 The world of cloud computing is witnessing a revolutionary change with the introduction of Oracle Cloud Infrastructure's (OCI) Generative AI Service. This innovative offering from Oracle is a testament to the rapidly evolving field of artificial intelligence (AI), particularly in the realm of generative models. As businesses and developers seek more efficient and creative solutions, Oracle's new service stands out as a significant milestone.

What is Oracle OCI's Generative AI Service?

Oracle's OCI Generative AI Service is a cloud-based platform that provides users with access to powerful generative AI models. These models are capable of creating a wide range of content, including text, images, and possibly even audio or video in the future. The service is designed to integrate seamlessly with other OCI offerings, ensuring a cohesive and efficient cloud computing experience.

Key Features and Capabilities

Advanced AI Models

At the heart of OCI's Generative AI Service are state-of-the-art AI models that have been trained on vast datasets. These models can generate high-quality, original content based on user inputs, making them invaluable for a variety of applications.

Scalability and Performance

Oracle's robust cloud infrastructure ensures that the Generative AI Service can scale to meet the demands of any project, big or small. This scalability is crucial for handling large-scale AI tasks without compromising on performance or speed.

Integration with OCI Ecosystem

The service is designed to work seamlessly with other OCI products, such as data storage, analytics, and security services. This integration allows for a more streamlined workflow, as users can easily access and combine different OCI services.

Use Cases

The potential applications of Oracle OCI's Generative AI Service are vast and varied. Here are a few examples:

Content Creation

For marketers and content creators, the service can generate written content, images, and potentially other forms of media. This capability can significantly speed up the content creation process and inspire new ideas.

Business Intelligence

Businesses can leverage the AI's ability to analyze and synthesize information to gain insights from data. This can aid in decision-making, trend analysis, and strategy development.

Research and Development

In the R&D sector, the service can assist in generating hypotheses, modeling complex systems, and even predicting outcomes, thereby accelerating the pace of innovation.

Security and Ethics

Oracle recognizes the importance of ethical AI use and has implemented measures to ensure the responsible deployment of its Generative AI Service. This includes safeguards against generating harmful or biased content and maintaining user privacy and data security.

Getting Started with OCI Generative AI Service

To start using the service, users need to have an Oracle Cloud account. Oracle provides comprehensive documentation and support to help users integrate the AI service into their projects.


Oracle OCI's Generative AI Service is a groundbreaking addition to the cloud computing landscape. It offers immense potential for businesses, developers, and creators to harness the power of AI for generating content and gaining insights. As the technology continues to evolve, it will be exciting to see the innovative applications that emerge from this platform.

Oracle's commitment to integrating advanced AI capabilities into its cloud services is a clear indicator of the transformative impact AI is set to have across industries. The OCI Generative AI Service is not just a tool; it's a gateway to a future where AI and cloud computing work hand in hand to unlock new possibilities.

Categories: DBA Blogs

Top Code LLM in the World - Locally Install Stable Code 3B without GPU

Thu, 2024-01-18 01:27

This video walks through step by step guide to locally install top code AI Model which can run on CPU and its very small in size. 


pip install transformers torch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
inputs = tokenizer("write me a script in Java to reverse a list", return_tensors="pt").to(model.device)
tokens = model.generate(
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
Categories: DBA Blogs

How to Install NVIDIA Drivers on AWS EC2 Instance Windows

Sun, 2024-01-14 18:40

 This video shows how to install NVIDIA drivers for Windows in AWS EC2 Instance G4DN and other instance types.

Commands Used:

msiexec.exe /i

aws --version 

In new windows, aws configure and set your IAM user key id and secret access key

Run below in Powershell as administrator:

Install-Module -Name AWS.Tools.Installer

$Bucket = "ec2-windows-nvidia-drivers"

$KeyPrefix = "latest"

$LocalPath = "$home\Desktop\NVIDIA"

$Objects = Get-S3Object -BucketName $Bucket -KeyPrefix $KeyPrefix -Region us-east-1

foreach ($Object in $Objects) {

    $LocalFileName = $Object.Key

    if ($LocalFileName -ne '' -and $Object.Size -ne 0) {

        $LocalFilePath = Join-Path $LocalPath $LocalFileName

        Copy-S3Object -BucketName $Bucket -Key $Object.Key -LocalFile $LocalFilePath -Region us-east-1



Categories: DBA Blogs

Talk with Comics Using AI in Any Language

Sat, 2024-01-13 23:26

 This video shows step by step demo with code as how to analyze comics in any language and talk to them using LlamaIndex and ChatGPT.

Code Used:

%pip install llama_index ftfy regex tqdm
%pip install git+
%pip install torch torchvision
%pip install matplotlib scikit-image
%pip install -U qdrant_client

import os

openai_api_key = os.environ['OPENAI_API_KEY']

from PIL import Image
import matplotlib.pyplot as plt
import os

image_paths = []
for img_path in os.listdir("./urdu"):
    image_paths.append(str(os.path.join("./urdu", img_path)))

def plot_images(image_paths):
    images_shown = 0
    plt.figure(figsize=(25, 12))
    for img_path in image_paths:
        if os.path.isfile(img_path):
            image =

            plt.subplot(2, 2, images_shown + 1)

            images_shown += 1
            if images_shown >= 9:


from llama_index.multi_modal_llms.openai import OpenAIMultiModal
from llama_index import SimpleDirectoryReader

image_documents = SimpleDirectoryReader("./urdu").load_data()

openai_mm_llm = OpenAIMultiModal(
    model="gpt-4-vision-preview", api_key=openai_api_key, max_new_tokens=1500

response_eng = openai_mm_llm.complete(
    prompt="Describe the comic strip panels as an alternative text",


Categories: DBA Blogs