Skip to content

Instantly share code, notes, and snippets.

def visualize_knowledge_graph(kg):
print (kg.keys())
dot = Digraph(comment="Knowledge Graph")
# Add nodes
for node in kg['nodes']:
dot.node(str(node['id']), node['label'], color=node['color'])
# Add edges
for edge in kg['edges']:
import sys, os
# your paths, below is just an example on mac
sys.path .extend ( ['/opt/homebrew/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python311.zip', '/opt/homebrew/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11', '/opt/homebrew/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload'] )
os.environ["SERPAPI_API_KEY"] = "xxx"
from serpapi import GoogleSearch
def serp_search (query_json) :
@rkreddyp
rkreddyp / report_prompt.txt
Created October 20, 2023 09:59
report_prompt
# Your Role
You are an excellent research analyst of a topic thats given to you, can do excellent analysis on the topic from all
angles and write a comprehensive report on the topic.
Your task is to write a comprehensive report to fulfill the objective given to you.
# Objective
Qualcomm Stock for Medium Term Investment
# Your Task
def ask_llm_to_get_filter (items, query):
all_text = get_all_items (items)
#all_text = get_all_above_score (items, 0.9)
role = 'you are an expert at going through text and finding filter expressions inside text given for specific task. Only use the functions you have been provided with.'
desc = """
# how to find the filter expresison
- the filter expressions have characters with dots inside them.
- the task that the filter expression will help with is right around the that filter expression
- you must pick one filter expression that best suits the task , the event filter must not have OR or AND
from langchain.document_loaders import WebBaseLoader
from langchain.document_loaders import TextLoader
url = 'https://developer.okta.com/docs/reference/api/event-types/#catalog'
loader = TextLoader ('/tmp/okta_events.txt')
scrape_data = loader.load()
index_name = 'oktaevents'
# Chunk your data up into smaller documents
index_name = 'oktaevents'
index = pinecone.Index(index_name)
embed = OpenAIEmbeddings()
embedding = openai.Embedding.create(
input=query,
model="text-embedding-ada-002"
)
vector = embedding["data"][0]["embedding"]
import json
import pandas as pd
from functools import wraps
from typing import Any, Callable
from pydantic import validate_arguments, BaseModel, validate_call, model_validator, create_model, TypeAdapter
import requests, time, pinecone
from bs4 import BeautifulSoup
from langchain.indexes import VectorstoreIndexCreator
from langchain.document_loaders import UnstructuredURLLoader
import boto3
import pandas as pd
from botocore.exceptions import NoCredentialsError
def get_all_guardduty_alerts(max_results_per_detector=50):
client = boto3.client('guardduty')
all_alerts = []
try:
# List all GuardDuty detectors
curl -H "Content-Type: application/json" -X POST https://vulns-cve-prod.transilienceapp.com/get_cve_info -d '{"cve_id":"CVE-2024-6387"}'
[
{
"vulnerable_products": "[{'vendor_name': 'Red Hat, Inc.', 'vendor_product': 'Red Hat Enterprise Linux', 'vendor_software': 'OpenSSH (sshd)', 'operating_system': 'Linux', 'vendor_version': '6', 'vendor_max_vulnerable_version_including': 'NA', 'vendor_min_vulnerable_version_including': 'NA', 'vulnerable_reason': \"A signal handler race condition was found in OpenSSH's server (sshd), where a client does not authenticate within LoginGraceTime seconds (120 by default, 600 in old OpenSSH versions), then sshd's SIGALRM handler is called asynchronously. However, this signal handler calls various functions that are not async-signal-safe, for example, syslog().\", 'precondition_configuration': 'Client does not authenticate within LoginGraceTime seconds.', 'criticalcondition_configuration': 'NA', 'discrepancy': False, 'discrepancy_reason': 'NA'}, {'vendor_name': 'Red Hat,