This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import httpx | |
| from pprint import pprint | |
| from dotenv import load_dotenv | |
| from openai.types import CreateEmbeddingResponse | |
| _ = load_dotenv("../.env") | |
| from openai import ( | |
| OpenAI, APIError, RateLimitError, APITimeoutError, APIConnectionError, ChatCompletion, | |
| ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import numpy as np | |
| from databricks.vector_search.client import VectorSearchClient | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| DATABRICKS_WORKSPACE_URL = os.getenv("DATABRICKS_WORKSPACE_URL") | |
| access_token_dbx = os.getenv("access_token_dbx") | |
| VECTOR_SEARCH_ENDPOINT = os.getenv("VECTOR_SEARCH_ENDPOINT") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## set postgres data folder: | |
| 1. set env PGDATA = "C:/Development/psql_data" | |
| 2. RUN | |
| go inside bin folder of postgres and RUN | |
| initdb -D %PGDATA% | |
| ## create user | |
| > createuser.exe -U <ROLE> --superuser --pwprompt <USERNAME> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import concurrent.futures | |
| import collections | |
| import threading | |
| import time | |
| import random | |
| from fastapi import FastAPI, BackgroundTasks | |
| from fastapi.responses import JSONResponse | |
| t_pool = concurrent.futures.ThreadPoolExecutor(max_workers=3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import socket | |
| def parse_http_request(request): | |
| headers, _, body = request.partition("\r\n\r\n") | |
| request_line = headers.splitlines()[0] | |
| method, path, _ = request_line.split() | |
| return method, path, headers, body | |
| server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3' | |
| services: | |
| zookeeper: | |
| # image: confluentinc/cp-zookeeper:latest | |
| image: bitnami/zookeeper:3.9 | |
| container_name: zookeeper | |
| ports: | |
| - "2181:2181" | |
| environment: | |
| ALLOW_ANONYMOUS_LOGIN: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app --max-requests 100 --max-requests-jitter 10 --threads 5 | |
| # .......................................................................................... | |
| import asyncio | |
| import os | |
| import logging | |
| # from asyncio.log import logger | |
| from time import sleep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| permission issues: | |
| > ls -l /var/run/docker.sock | |
| > sudo chmod 666 /var/run/docker.sock | |
| # for DockerFIle | |
| Create a Docker Image: (assuming you already have Dockerfile in ur folder) | |
| > docker build -t <my-any-image-name> . | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| what is the time duration of SSE for keep-alive connection ? | |
| The time duration of an SSE (Server-Sent Events) keep-alive connection can vary depending on several factors, including: | |
| Server configuration: The server can specify a keep-alive timeout using the Keep-Alive header or other configuration settings. | |
| Client configuration: The client can also specify a keep-alive timeout using the Keep-Alive header or other configuration settings. | |
| Network conditions: Network conditions, such as latency and packet loss, can affect the keep-alive timeout. | |
| Typically, the keep-alive timeout for SSE connections ranges from a few seconds to several minutes. Here are some common values: | |
| Default timeout: 30 seconds to 1 minute | |
| Typical timeout: 1-5 minutes | |
| Maximum timeout: 30 minutes to 1 hour |
NewerOlder