repo_id stringclasses 1
value | file_path stringlengths 8 82 | content stringlengths 23 44.3k |
|---|---|---|
CloudWhisperCustomBot | Makefile | # List of targets and their descriptions
.PHONY: help
help:
@echo "Note: The following commands will change the status of 'cloud_whisper' database.\n"
@echo "Available targets:"
@echo " migrate Create a new Migration File."
@echo " upgrade Upgrade to a later version."
@echo " dow... |
CloudWhisperCustomBot | Dockerfile | # Dockerfile
FROM python:3.11-slim-bullseye
# Set the working directory
WORKDIR /CloudWhisperCustomBot
COPY requirements.txt .
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y dumb-init
RUN apt-get install -y curl
RUN apt-get install -y lsb-release
RUN apt-get install -y wget
RUN apt-... |
CloudWhisperCustomBot | docker-compose.yml | services:
cloud_whisper_fe:
container_name: cloud_whisper_fe
build: ../cloud-whisper-frontend
command: npm run build
environment:
REACT_APP_API_URL: https://cloudwhisper-stage.wanclouds.ai/
REACT_APP_AUTH_REDIRECT_URI: https://cloudwhisper-stage.wanclouds.ai/users/wc/callback
REACT_A... |
CloudWhisperCustomBot | alembic.ini | # A generic, single database configuration.
[alembic]
# path to migration scripts.
# Use forward slashes (/) also on windows to provide an os agnostic path
script_location = migrations
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the ... |
CloudWhisperCustomBot | pyproject.toml | [tool.ruff]
line-length = 120
target-version = "py311"
[tool.ruff.format]
indent-style = "tab"
quote-style = "double"
[tool.poetry]
name = "CloudWhisperCustomBot"
version = "0.1.0"
description = "Chat with your API in Natural Language"
authors = ["syedfurqan <syedfurqan@wanclouds.net>"]
[build-system]
requires = ["p... |
CloudWhisperCustomBot | requirements.txt | aiohttp==3.9.0
alembic==1.9.0
alembic_postgresql_enum==1.3.0
anthropic==0.34.2
asyncpg==0.27.0
bcrypt==4.1.3
celery==5.3.1
celery-singleton==0.3.1
faiss-cpu==1.7.4
fastapi==0.104.1
httpx==0.27.0
langchain==0.0.351
langchain-community==0.0.3
langchain-core==0.1.1
loguru==0.7.2
llama-index==0.10.58
llama-index-vector-sto... |
CloudWhisperCustomBot | README.md | # CloudWhisperCustomBot |
CloudWhisperCustomBot | app/main.py | from contextlib import asynccontextmanager
from fastapi import APIRouter, FastAPI
from fastapi.middleware.cors import CORSMiddleware
from loguru import logger
from qdrant_client import models
from qdrant_client.http.exceptions import UnexpectedResponse
from app.core.config import settings, setup_app_logging, neo4j_dr... |
CloudWhisperCustomBot | app/__init__.py | from app.api_discovery.discovery import discover_api_data
from app.worker.cypher_store import qdrant
from app.worker.scheduled_tasks import track_and_update_activity_status
__all__ = ["discover_api_data", "qdrant", "track_and_update_activity_status"]
|
CloudWhisperCustomBot | app/redis_scheduler.py | from datetime import timedelta
from celery import Celery
from celery.signals import worker_ready
from celery_singleton import clear_locks
from app.core.config import settings
broker = settings.redis.REDIS_URL
celery_app = Celery(
'whisper-celery',
broker=broker,
include=[
'app.api_discovery',
... |
CloudWhisperCustomBot | app/worker/scheduled_tasks.py | import asyncio
import httpx
import mailchimp_transactional as MailchimpTransactional
from celery_singleton import Singleton
from loguru import logger
from mailchimp_transactional.api_client import ApiClientError
from sqlalchemy import select
from app.models import Profile, ActivityTracking
from app.redis_scheduler im... |
CloudWhisperCustomBot | app/worker/cypher_store.py | import time
from llama_index.core import VectorStoreIndex, ServiceContext
from llama_index.core.ingestion import IngestionPipeline
from llama_index.core.schema import TextNode
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai import OpenAI
from llama_index.vector_stores.qdrant impo... |
CloudWhisperCustomBot | app/web/__init__.py | from fastapi import APIRouter
from app.web.chats import whisper_chats
from app.web.clouds import whisper_clouds
# from app.web.knowledge_graphs import whisper_knowledge_graphs
from app.web.profiles import whisper_profiles
from app.web.profiles import router
from app.web.websockets import websockets_chats
from app.web.... |
CloudWhisperCustomBot | app/web/profiles/schemas.py | from typing import Optional, Dict
from pydantic import BaseModel
from enum import Enum
class UpdateAppearanceRequest(BaseModel):
appearance: Optional[Dict] = None
class OnboardingStatus(str, Enum):
app_tour = "app_tour"
action_tour = "action_tour"
onboarded = "onboarded"
class UpdateOnboardingStat... |
CloudWhisperCustomBot | app/web/profiles/__init__.py | from .api import whisper_profiles, router
__all__ = ["whisper_profiles", "router"]
|
CloudWhisperCustomBot | app/web/profiles/api.py | from http import HTTPStatus
import httpx
from loguru import logger
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import JSONResponse
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select
from app import models
from app.api_discovery.utils import update_profile_wi... |
CloudWhisperCustomBot | app/web/common/consts.py | CREATED_AT_FORMAT_WITH_MILLI_SECONDS = '%Y-%m-%dT%H:%M:%S.%fZ'
|
CloudWhisperCustomBot | app/web/common/templates.py | ROUTE_TEMPLATE = """You are a team member of the 'Cloud Whisperer' project by Wanclouds, an expert Cloud Support Engineer specializing in cloud backups, disaster recovery, and migrations. Your expertise covers major public clouds (IBM Cloud, AWS, Google Cloud, Microsoft Azure) and Wanclouds' offerings. You assist poten... |
CloudWhisperCustomBot | app/web/common/utils.py | import aiohttp
import asyncio
import httpx
import json
import requests
import time
from fastapi import HTTPException
from loguru import logger
from sqlalchemy import select, update
from sqlalchemy.orm import selectinload
from app import models
from app.api_discovery.utils import update_profile_with_vpcplus_api_key
fro... |
CloudWhisperCustomBot | app/web/common/chats_websockets_utils.py | from types import AsyncGeneratorType
import aiohttp
import types
import asyncio
import httpx
import json
import re
from datetime import datetime
from fastapi import HTTPException
from fastapi.security import HTTPAuthorizationCredentials
from loguru import logger
from sqlalchemy import asc
from sqlalchemy.future import... |
CloudWhisperCustomBot | app/web/common/db_deps.py | import asyncio
from typing import AsyncGenerator
from contextlib import asynccontextmanager
from loguru import logger
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
AsyncSessionLocal = sessionmaker(
bind=create_as... |
CloudWhisperCustomBot | app/web/common/deps.py | import httpx
from fastapi import Depends, Header, HTTPException, WebSocketException
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from httpx import Response
from loguru import logger
from app.api_discovery.utils import update_profile_with_vpcplus_api_key
from app.core.config import settings
fro... |
CloudWhisperCustomBot | app/web/common/api_path_to_fields.json | {
"Create IBM VPC backup": {
"v1/ibm/clouds": {
"GET": {
"fields": [
"id",
"name"
]
}
},
"v1/ibm/geography/regions": {
"GET": {
"fields": [
"id",
"name",
"display_name"
]
}
},
"v1/ibm/vpcs": {... |
CloudWhisperCustomBot | app/web/common/cloud_setup_instruction_messages.py | API_KEY_MESSAGE ="""Cloud Whisper requires a VPC+ API key to discover data and perform actions. Please follow these steps to create your API key:\n
1. Create your VPC+ API Key: \n \t \n
a. Click on User name in the bottom left corner and select Settings \n \t \n
b. Navigate to the "API Key" section \n \t \n
c.... |
CloudWhisperCustomBot | app/web/activity_tracking/neo4j_query.py | get_vpc_backups_query = """
MATCH (v:VPC)
OPTIONAL MATCH (b:VPCBackup {name: v.name})
WITH v, b
WHERE b IS NULL AND v.cloud_id = '{cloud_id}'
RETURN v.cloud_id, v.name
"""
get_iks_backups_query = """
MATCH (v:KubernetesCluster)
OPTIONAL MATCH (b:IKSBackupDetails {name: v.name})
WITH v, b
WHERE b IS NULL AND v.cloud_id... |
CloudWhisperCustomBot | app/web/activity_tracking/__init__.py | from .api import activity_tracking_n_recommendations
__all__ = ["activity_tracking_n_recommendations"]
|
CloudWhisperCustomBot | app/web/activity_tracking/api.py | from math import ceil
from typing import List, Optional
from typing import Annotated
from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.ext.asyncio import AsyncSession
from loguru import logger
from sqlalchemy import select
from pydantic import conint
from sqlalchemy.orm import undefer
from s... |
CloudWhisperCustomBot | app/web/chats/schemas.py | import datetime
import typing as t
import uuid
from enum import Enum
from pydantic import BaseModel, Field
class MessageTypeEnum(str, Enum):
Human = 'Human'
Assistant = 'Assistant'
class ChatTypeEnum(str, Enum):
QnA = 'QnA'
Action = 'Action'
class MessageType(BaseModel):
type: MessageTypeEnum... |
CloudWhisperCustomBot | app/web/chats/__init__.py | from .api import whisper_chats
__all__ = ["whisper_chats"]
|
CloudWhisperCustomBot | app/web/chats/api.py | import json
import time
from http import HTTPStatus
from math import ceil
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import HTTPAuthorizationCredentials
from loguru import logger
from pydantic import conint
from sqlalchemy import func
from sqlalchemy import select, desc, update, asc
fr... |
CloudWhisperCustomBot | app/web/clouds/schemas.py | from pydantic import BaseModel
from typing import List, Optional
class CloudAccount(BaseModel):
id: str
name: str
class CloudAccountsResponse(BaseModel):
ibm_cloud_accounts: Optional[List[CloudAccount]] = []
ibm_softlayer_cloud_accounts: Optional[List[CloudAccount]] = []
aws_cloud_accounts: Optio... |
CloudWhisperCustomBot | app/web/clouds/__init__.py | from .api import whisper_clouds
__all__ = ["whisper_clouds"]
|
CloudWhisperCustomBot | app/web/clouds/api.py | import requests
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import HTTPAuthorizationCredentials
from app.core.config import settings
from app.web.clouds.schemas import CloudAccountsResponse, CloudAccount
from app.web.common import deps
from app.web.common.deps import security
whisper_c... |
CloudWhisperCustomBot | app/web/websockets/schemas.py | import typing as t
from pydantic import BaseModel, Field
class MessageRequest(BaseModel):
text: str
type: t.Optional[str] = "Human"
class ChatRequest(BaseModel):
question: str
chat_id: t.Optional[str] = Field(default=None, max_length=32, min_length=32, regex="^[0-9a-fA-F]+$")
action_id: t.Optional... |
CloudWhisperCustomBot | app/web/websockets/__init__.py | from .api import websockets_chats
__all__ = ["websockets_chats"]
|
CloudWhisperCustomBot | app/web/websockets/api.py | import json
import time
from fastapi import APIRouter, Depends, HTTPException, WebSocket, WebSocketException, WebSocketDisconnect
from fastapi.security import HTTPAuthorizationCredentials
from loguru import logger
from sqlalchemy import select, desc
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm i... |
CloudWhisperCustomBot | app/whisper/consts.py | WHISPER_USER_ROLE = 'user'
WHISPER_ASSISTANT_ROLE = 'assistant'
|
CloudWhisperCustomBot | app/whisper/utils/config_reader.py | import json
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CONFIG_DIR = os.path.join(BASE_DIR, 'utils')
class ConfigLoader:
def __init__(self, intent):
self.validation_config = {}
self.dependencies_config = {}
self.intent = intent
@staticmethod
d... |
CloudWhisperCustomBot | app/whisper/utils/prompt.py | DB_RESULT_FORMAT_PROMPT = """
You are an expert database analyst AI tasked with formatting database results into clear, readable markdown tables while preserving any accompanying text. Your goal is to present the information in a way that's easy for users to understand and analyze.
Here is the database result you need... |
CloudWhisperCustomBot | app/whisper/utils/__init__.py | from .config_reader import ConfigLoader
__all__ = ['ConfigLoader']
|
CloudWhisperCustomBot | app/whisper/utils/json_loader.py | import json
from pathlib import Path
from typing import List, Optional, Union
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
class JSONLoader(BaseLoader):
def __init__(
self,
file_path: Union[str, Path],
content_key: Optio... |
CloudWhisperCustomBot | app/whisper/utils/pagination_utils.py | import re
from loguru import logger
def generate_count_query(cypher_query):
# Regular expression to match full MATCH or OPTIONAL MATCH clauses, including node patterns and conditions
match_pattern = re.compile(r'(OPTIONAL\s+MATCH|MATCH)\s+\([^\)]+\)[^\n\r]*(?:\s*WHERE[^\n\r]*)?', re.IGNORECASE)
# Remove ... |
CloudWhisperCustomBot | app/whisper/utils/validators.py | import re
import uuid
import requests
from app.whisper.utils import ConfigLoader
alphanumeric_error = "'{value}' for the '{key}' attribute must be alphanumeric."
uuid_error = "'{value}' for the '{key}' attribute must be a valid UUID."
dependency_error_msg = "{dependencies} must be provided before '{key}'."
BASE_URL... |
CloudWhisperCustomBot | app/whisper/utils/action_engine/consts.py | from enum import Enum
ibm_region_mapper = {
"dallas": "us-south",
"dallas tx": "us-south",
"dallas texas": "us-south",
"sydney": "au-syd",
"sydney au": "au-syd",
"sydney australia": "au-syd",
"london": "eu-gb",
"london uk": "eu-gb",
"london united kingdom": "eu-gb",
"frankfurt":... |
CloudWhisperCustomBot | app/whisper/utils/action_engine/__init__.py | from app.whisper.utils.action_engine.complex_base import ComplexActionPhaseClaude
from app.whisper.utils.action_engine.base import ActionPhaseClaude
__all__ = ['ActionPhaseClaude', 'ComplexActionPhaseClaude']
|
CloudWhisperCustomBot | app/whisper/utils/action_engine/complex_base.py | import ast
import copy
import json
import re
import requests
from anthropic import APIConnectionError, RateLimitError, APIStatusError
from loguru import logger
from app.web.common.utils import update_activity_tracking
from app.whisper.consts import WHISPER_USER_ROLE
from app.whisper.llms.anthropic import AnthropicLLM... |
CloudWhisperCustomBot | app/whisper/utils/action_engine/base.py | import copy
import json
import re
import uuid
import requests
from anthropic import APIConnectionError, RateLimitError, APIStatusError
from loguru import logger
from app.web.common.utils import update_activity_tracking
from app.whisper.consts import WHISPER_USER_ROLE, WHISPER_ASSISTANT_ROLE
from app.whisper.llms.anth... |
CloudWhisperCustomBot | app/whisper/utils/qna_bot/consts.py | ibm_region_mapper = {
"dallas": "us-south",
"dallas tx": "us-south",
"dallas texas": "us-south",
"sydney": "au-syd",
"sydney au": "au-syd",
"sydney australia": "au-syd",
"london": "eu-gb",
"london uk": "eu-gb",
"london united kingdom": "eu-gb",
"frankfurt": "eu-de",
"frankfur... |
CloudWhisperCustomBot | app/whisper/utils/qna_bot/__init__.py | from app.whisper.utils.action_engine.base import ActionPhaseClaude
__all__ = ['ActionPhaseClaude'] |
CloudWhisperCustomBot | app/whisper/utils/qna_bot/base.py | import mailchimp_transactional as MailchimpTransactional
from anthropic import APIConnectionError, RateLimitError, APIStatusError
from loguru import logger
from mailchimp_transactional.api_client import ApiClientError
from app.core.config import settings
from app.whisper.llms.anthropic import AnthropicLLM
from app.whi... |
CloudWhisperCustomBot | app/whisper/utils/migration_action_engine/consts.py | ibm_region_mapper = {
"dallas": "us-south",
"dallas tx": "us-south",
"dallas texas": "us-south",
"sydney": "au-syd",
"sydney au": "au-syd",
"sydney australia": "au-syd",
"london": "eu-gb",
"london uk": "eu-gb",
"london united kingdom": "eu-gb",
"frankfurt": "eu-de",
"frankfur... |
CloudWhisperCustomBot | app/whisper/utils/migration_action_engine/prompt.py | SYSTEM = """You are an AI support agent for Wanclouds, a partner of IBM Cloud, assisting with datacenter migrations as part of IBM's Datacenter Modernization initiative. Your primary role is to help customers affected by the closure of legacy datacenters, such as Dal09 (Dallas 9), by collecting essential information fo... |
CloudWhisperCustomBot | app/whisper/utils/migration_action_engine/__init__.py | from app.whisper.utils.migration_action_engine.base import MigrationActionPhaseClaude
__all__ = ['MigrationActionPhaseClaude'] |
CloudWhisperCustomBot | app/whisper/utils/migration_action_engine/base.py | from datetime import datetime
import json
import copy
import mailchimp_transactional as MailchimpTransactional
from mailchimp_transactional.api_client import ApiClientError
import requests
from anthropic import APIConnectionError, RateLimitError, APIStatusError
from loguru import logger
# from jsonschema import val... |
CloudWhisperCustomBot | app/whisper/utils/neo4j/prompt.py | SYSTEM = """You are a helpful Neo4j assistant who generates intelligent Cypher queries to help user finds out information from a Neo4j graph database based on the provided schema definition, without giving any explanation.
<instructions>Strictly follow these instructions:
1. Use only the provided relationship types an... |
CloudWhisperCustomBot | app/whisper/utils/neo4j/queries.py | node_properties_query = """
CALL apoc.meta.data()
YIELD label, other, elementType, type, property
WHERE NOT type = "RELATIONSHIP" AND elementType = "node"
AND label CONTAINS '{user_id}'
AND NOT property CONTAINS "discovered_at"
WITH label AS nodeLabels, collect(property) AS properties
RETURN {{labels: nodeLabels,... |
CloudWhisperCustomBot | app/whisper/utils/neo4j/client.py | from loguru import logger
from app.whisper.consts import WHISPER_USER_ROLE, WHISPER_ASSISTANT_ROLE
from app.whisper.llms.anthropic import AnthropicLLM
from app.whisper.utils.neo4j.prompt import SYSTEM, PAGINATED_SYSTEM
from app.whisper.utils.neo4j.queries import rel_query, classic_rel_query, rel_properties_query, node... |
CloudWhisperCustomBot | app/whisper/utils/openapi/spec.py | """Utility functions for parsing an OpenAPI spec."""
from __future__ import annotations
import copy
import json
import logging
import re
from enum import Enum
from pathlib import Path
from typing import Dict, List, Optional, TYPE_CHECKING, Union
import requests
import yaml
from langchain_core.pydantic_v1 import Valid... |
CloudWhisperCustomBot | app/whisper/utils/openapi/conversion_utils.py | from __future__ import annotations
import json
import re
from collections import defaultdict
from typing import Any, Callable, Dict, List, Optional, Tuple, TYPE_CHECKING
import requests
from langchain_community.tools.openapi.utils.api_models import APIOperation
from app.whisper.utils.openapi.spec import OpenAPISpec
... |
CloudWhisperCustomBot | app/whisper/utils/information_retrieval_engine/prompt.py | SYSTEM = """You are a team member of the 'Cloud Whisperer' project by Wanclouds, an expert Cloud Support Engineer specializing in cloud backups, disaster recovery, and migrations. Your expertise covers major public clouds (IBM Cloud, AWS, Google Cloud, Microsoft Azure) and Wanclouds' offerings. It assists potential cus... |
CloudWhisperCustomBot | app/whisper/utils/information_retrieval_engine/__init__.py | from app.whisper.utils.action_engine.base import ActionPhaseClaude
__all__ = ['ActionPhaseClaude'] |
CloudWhisperCustomBot | app/whisper/utils/information_retrieval_engine/unbacked_resource_queries.py |
def get_backup_queries(cloud_id, resource_type):
base_query_vpc = """
MATCH (v:VPC)
OPTIONAL MATCH (b:VPCBackup {name: v.name, cloud_id: v.cloud_id})
WITH v, b
WHERE b IS NULL
"""
base_query_iks = """
MATCH (v:KubernetesCluster)
OPTIONAL MATCH (b:IKSBackupDetails {name: v.name,... |
CloudWhisperCustomBot | app/whisper/utils/information_retrieval_engine/base.py | import json
import re
from datetime import datetime, timedelta, timezone
from anthropic import APIConnectionError, RateLimitError, APIStatusError
from app.api_discovery.discovery_task import execute_paginated_api
from app.core.config import settings
from app.web.common import db_deps
from app.web.common.templates impo... |
CloudWhisperCustomBot | app/whisper/old_implementation/phases/__init__.py | from app.whisper.old_implementation.phases.action.action_phase import ActionPhase
__all__ = ["ActionPhase"]
|
CloudWhisperCustomBot | app/whisper/old_implementation/phases/action/action_phase.py | import json
from urllib.parse import urlparse
from loguru import logger
from requests import Response
from app.whisper.llms.openai import OpenAILLM
from app.whisper.old_implementation.validators import JSONValidator
from app.whisper.utils.openapi.conversion_utils import openapi_spec_to_openai_fn
from app.whisper.util... |
CloudWhisperCustomBot | app/whisper/old_implementation/phases/action/specs/api_path_to_fields.json | {
"Create IBM VPC backup": {
"v1/ibm/clouds": {
"GET": {
"fields": [
"id",
"name"
]
}
},
"v1/ibm/geography/regions": {
"GET": {
"fields": [
"id",
"name",
"display_name"
]
}
},
"v1/ibm/vpcs": {... |
CloudWhisperCustomBot | app/whisper/old_implementation/phases/action/config/extract_and_validate_tool.json | {
"type": "function",
"function": {
"name": "extract_and_validate",
"description": "Extract schema from the given chat history and validate it against validation criteria",
"parameters": {
"type": "object",
"properties": {}
}
}
}
|
CloudWhisperCustomBot | app/whisper/old_implementation/phases/action/config/validation_criteria.json | {
"id": {
"validation_fn": "is_valid_uuid"
},
"name": {
"validation_fn": "is_alphanumeric"
},
"ibm_cloud": {
"available_resources": "v1/ibm/clouds"
},
"region": {
"available_resources": "v1/ibm/geography/regions"
},
"ibm_vpc": {
"available_resources": "v1/ibm/vpcs"
},
"ibm_cos_... |
CloudWhisperCustomBot | app/whisper/old_implementation/phases/action/config/dependencies.json | {
"Create IBM VPC backup": {
"region": ["ibm_cloud"],
"ibm_vpc": ["ibm_cloud"]
},
"Create IBM COS bucket backup": {
"region": ["ibm_cloud"],
"ibm_cos_bucket_instance": ["ibm_cloud"],
"bucket_id": ["ibm_cloud", "cloud_object_storage_id"]
},
"List IBM COS buckets": {
"region_id": ["cloud... |
CloudWhisperCustomBot | app/whisper/old_implementation/validators/__init__.py | from .request_json_validator import JSONValidator
__all__ = ['JSONValidator']
|
CloudWhisperCustomBot | app/whisper/old_implementation/validators/request_json_validator.py | import re
import uuid
import requests
from app.whisper.utils.config_reader import ConfigLoader
from loguru import logger
alphanumeric_error = "'{value}' for the '{key}' attribute must be alphanumeric."
uuid_error = "'{value}' for the '{key}' attribute must be a valid UUID."
dependency_error_msg = "{dependencies} must... |
CloudWhisperCustomBot | app/whisper/llms/openai.py | import loguru
import requests
from dotenv import load_dotenv
from openai import OpenAI
from tenacity import retry, stop_after_attempt, wait_random_exponential
from app.whisper.llms.base_llm import BaseLLM
from app.core.config import settings
class OpenAILLM(BaseLLM):
def __init__(self, model=None):
if no... |
CloudWhisperCustomBot | app/whisper/llms/anthropic.py | import json
from loguru import logger
from tenacity import retry, stop_after_attempt, wait_random_exponential
from anthropic import Anthropic, AnthropicBedrock, APIConnectionError, APIStatusError
from app.core.config import settings
from app.whisper.consts import WHISPER_USER_ROLE, WHISPER_ASSISTANT_ROLE
from app.whis... |
CloudWhisperCustomBot | app/whisper/llms/mistral.py | import asyncio
import os
import aiohttp
from loguru import logger
from app.whisper.llms.base_llm import BaseLLM
class MistralLLM(BaseLLM):
MISTRAL_HOST = os.environ.get('MISTRAL_HOST', "35.232.5.43")
MISTRAL_PORT = os.environ.get('MISTRAL_PORT', "9090")
MISTRAL_PATH = f'http://{MISTRAL_HOST}:{MISTRAL_P... |
CloudWhisperCustomBot | app/whisper/llms/base_llm.py | from abc import ABC, abstractmethod
class BaseLLM(ABC):
@abstractmethod
def process(self, *args, **kwargs):
pass
@abstractmethod
def format_chat_history(self, chat_history):
pass
|
CloudWhisperCustomBot | app/whisper/llms/groq.py | from groq import Groq
from loguru import logger
from tenacity import retry, stop_after_attempt, wait_random_exponential
from app.core.config import settings
class GroqLLM:
def __init__(self, model="llama-3.1-8b-instant"):
self.model = model
self.groq_api_key = settings.groq.GROQ_API_KEY
s... |
CloudWhisperCustomBot | app/knowledge_graph/spec_resolver.py | import json
def resolve_ref(ref, components):
if ref.startswith("#/components/schemas/"):
ref_name = ref.split("/")[-1]
# if ref_name == 'DisasterRecoveryBackupOut':
# return {}
print(components.get("schemas", {}).get(ref_name, {}))
return components.get("schemas", {}).... |
CloudWhisperCustomBot | app/models/cost_report.py | import uuid
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.sql import func
from app.models.base import Base
class CloudCostReport(Base):
ID_KEY = "id",
USER_ID_KEY = "user_id",
CLOUD_ID_KEY = "cloud_id",
RESOURCE_JSON_KEY = "r... |
CloudWhisperCustomBot | app/models/activity_tracking.py | import uuid
from sqlalchemy import Column
from sqlalchemy import select
from sqlalchemy.sql.sqltypes import String, Text, JSON, Boolean
from sqlalchemy.sql.schema import ForeignKey
from sqlalchemy.orm import deferred
from loguru import logger
from app import models
from app.models.base import Base
class ActivityTra... |
CloudWhisperCustomBot | app/models/__init__.py | from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .chat import Chat, Message, Action
from .profile import Profile
from .activity_tracking import ActivityTracking
from .chat import Chat, Message, Action
from .profile import Profile
from .activity_tracking import ActivityTracking
__all__ = ['Action',... |
CloudWhisperCustomBot | app/models/chat.py | import uuid
from sqlalchemy import Column, Enum
from sqlalchemy.orm import relationship
from sqlalchemy.sql.schema import ForeignKey
from sqlalchemy.sql.sqltypes import Boolean, String, Text, TIMESTAMP
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.sql.expression import text
from app.models.base imp... |
CloudWhisperCustomBot | app/models/profile.py | import uuid
from sqlalchemy import Column, Enum
from sqlalchemy.orm import relationship
from sqlalchemy.sql.sqltypes import Boolean, String, TIMESTAMP, JSON
from sqlalchemy.dialects.postgresql import JSONB
from app.models.base import Base
from app.web.profiles.schemas import OnboardingStatus
class Profile(Base):
... |
CloudWhisperCustomBot | app/models/base.py | from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
|
CloudWhisperCustomBot | app/api_discovery/delete_redundant_node_task.py | from app.core.config import neo4j_driver as driver
def delete_redundant_nodes(user_id, timestamp):
with driver.session() as session:
query = f"""MATCH (n) WHERE n.discovered_at < {timestamp} AND n.user_id = '{user_id}' DETACH DELETE n;"""
session.write_transaction(lambda tx, q=query: tx.run(q))
... |
CloudWhisperCustomBot | app/api_discovery/classic_api_schema.json | {
"v1/softlayer/accounts": {
"id=softlayer_cloud_id": {
"v1/softlayer/discover": {
"/pid=root_id+associated_tasks[*].id=task_id": [
"v1/ibm/workflows/{root_id}/tasks/{task_id}"
]
}
}
}
} |
CloudWhisperCustomBot | app/api_discovery/neo4j_query.py | import anthropic
import openai
from loguru import logger
from neo4j import GraphDatabase
history = []
node_properties_query = """
CALL apoc.meta.data()
YIELD label, other, elementType, type, property
WHERE NOT type = "RELATIONSHIP" AND elementType = "node"
WITH label AS nodeLabels,
collect(CASE WHEN property <>... |
CloudWhisperCustomBot | app/api_discovery/node_rel.json | {
"v1/ibm/vpcs": {
"Nodes": [
"VPC",
"Acl",
"AddressPrefix",
"VirtualServerInstanceGroup",
"VirtualServerInstance",
"KubernetesCluster",
"LoadBalancer",
"NetworkAcl",
"PublicGateway",
"RoutingTable",
"SecurityGroup",
"Subnet",
"Tag",
... |
CloudWhisperCustomBot | app/api_discovery/utils.py | import base64
import hashlib
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from loguru import logger
from sqlalchemy import update
from app.core.config import settings
from app.web.common import db_deps
def encrypt_api_key(api_key):
"""Encrypt api_key"""
if not api_key:
r... |
CloudWhisperCustomBot | app/api_discovery/discovery_task.py | import itertools
import json
import time
from datetime import datetime
import requests
from itertools import groupby
from loguru import logger
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
from app.core.config import neo4j_driver as driver
from app.core.config import settings
# Load ... |
CloudWhisperCustomBot | app/api_discovery/api_schema.json | {
"v1/ibm/clouds": {"id": {"cloud_id": [
"v1/ibm/kubernetes_clusters",
"v1/ibm/cloud_object_storages/keys",
"v1/ibm/vpcs",
"v1/ibm/geography/regions",
"v1/ibm/instance_template_constructs",
"v1/ibm/draas_blueprints?resource_type=IBMVpcNetwork",
"v1/ibm/draas_b... |
CloudWhisperCustomBot | app/api_discovery/discovery.py | import asyncio
import httpx
import mailchimp_transactional as MailchimpTransactional
from celery_singleton import Singleton
from loguru import logger
from mailchimp_transactional.api_client import ApiClientError
from sqlalchemy import select, update, func
from app.api_discovery.discovery_task import start_discovery, ... |
CloudWhisperCustomBot | app/api_discovery/classic-node-rel.json | {
"v1/ibm/workflows/{root_id}/tasks/{task_id}": {
"Nodes": [
"ClassicCloud",
"ClassicDatacenter",
"ClassicLocationStatus",
"ClassicBareMetal",
"ClassicBareMetalStatus",
"ClassicNetworkVlan",
"ClassicVirtualGuest",
"ClassicSecurityGroup",
"ClassicRule",
"... |
CloudWhisperCustomBot | app/core/config.py | import os
import sys
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.vectorstores import FAISS, VectorStore
from loguru import logger
from neo4j import GraphDatabase
from pathlib import Path
from pydantic import AnyHttpUrl, AnyUrl, BaseSettings
from typing import List, Optional
import logging
fro... |
CloudWhisperCustomBot | app/core/logging.py | import logging
from types import FrameType
from typing import cast
from loguru import logger
class InterceptHandler(logging.Handler):
def emit(self, record: logging.LogRecord) -> None: # pragma: no cover
# Get corresponding Loguru level if it exists
try:
level = logger.level(record.l... |
CloudWhisperCustomBot | migrations/script.py.mako | """${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: U... |
CloudWhisperCustomBot | migrations/README | Generic single-database configuration with an async dbapi.
|
CloudWhisperCustomBot | migrations/env.py | import asyncio
from logging.config import fileConfig
from sqlalchemy import pool
from sqlalchemy.engine import Connection
from sqlalchemy.ext.asyncio import async_engine_from_config
from alembic import context
from app.models.base import Base
from app.core.config import settings
# this is the Alembic Config object,... |
CloudWhisperCustomBot | migrations/versions/4a431d838915_.py | """empty message
Revision ID: 4a431d838915
Revises: 933e5e67d032
Create Date: 2024-09-03 04:59:18.509767
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '4a431d838915'
down_revis... |
CloudWhisperCustomBot | migrations/versions/325ce6b01196_.py | """empty message
Revision ID: 325ce6b01196
Revises: cbe4893ba969
Create Date: 2024-08-24 18:55:16.284670
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '325ce6b01196'
down_revisio... |
CloudWhisperCustomBot | migrations/versions/14e9d53952a9_.py | """empty message
Revision ID: 14e9d53952a9
Revises: 6408613d0565
Create Date: 2024-11-26 10:36:46.527741
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '14e9d53952a9'
down_revision: Union[str, None] = '6408613d0565'
bra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.