diff --git a/sijapi/__init__.py b/sijapi/__init__.py index 8f61793..74522bf 100644 --- a/sijapi/__init__.py +++ b/sijapi/__init__.py @@ -90,7 +90,7 @@ SUMMARY_CHUNK_OVERLAP = int(os.getenv("SUMMARY_CHUNK_OVERLAP", 256)) # measured SUMMARY_TPW = float(os.getenv("SUMMARY_TPW", 1.3)) # measured in tokens SUMMARY_LENGTH_RATIO = int(os.getenv("SUMMARY_LENGTH_RATIO", 4)) # measured as original to length ratio SUMMARY_MIN_LENGTH = int(os.getenv("SUMMARY_MIN_LENGTH", 150)) # measured in tokens -SUMMARY_MODEL = os.getenv("SUMMARY_MODEL", "dolphin-llama3:8b-256k") +SUMMARY_MODEL = os.getenv("SUMMARY_MODEL", "command-r:latest") SUMMARY_TOKEN_LIMIT = int(os.getenv("SUMMARY_TOKEN_LIMIT", 16384)) SUMMARY_INSTRUCT = os.getenv('SUMMARY_INSTRUCT', "You are an AI assistant that provides accurate summaries of text -- nothing more and nothing less. You must not include ANY extraneous text other than the sumary. Do not include comments apart from the summary, do not preface the summary, and do not provide any form of postscript. Do not add paragraph breaks. Do not add any kind of formatting. Your response should begin with, consist of, and end with an accurate plaintext summary.") SUMMARY_INSTRUCT_TTS = os.getenv('SUMMARY_INSTRUCT_TTS', "You are an AI assistant that provides email summaries for Sanjay. Your response will undergo Text-To-Speech conversion and added to Sanjay's private podcast. Providing adequate context (Sanjay did not send this question to you, he will only hear your response) but aiming for conciseness and precision, and bearing in mind the Text-To-Speech conversion (avoiding acronyms and formalities), summarize the following email.") diff --git a/sijapi/config/.env-example b/sijapi/config/.env-example index 3d3fdda..d293ccc 100644 --- a/sijapi/config/.env-example +++ b/sijapi/config/.env-example @@ -326,7 +326,7 @@ SYSTEM_MSG=You are a helpful AI assistant. DEFAULT_LLM=dolphin-mistral DEFAULT_VISION=llava-llama3 OPENAI_API_KEY=¿SECRET? # <--- not presently implemented for anything -SUMMARY_MODEL='dolphin-llama3:8b-256k' +SUMMARY_MODEL='command-r:latest' SUMMARY_CHUNK_SIZE=16384 SUMMARY_CHUNK_OVERLAP=100 SUMMARY_TPW=1.3 diff --git a/sijapi/config/img.yaml-example b/sijapi/config/img.yaml-example index 86bd56e..7159e81 100644 --- a/sijapi/config/img.yaml-example +++ b/sijapi/config/img.yaml-example @@ -7,7 +7,7 @@ scenes: API_NegativePrompt: "3d, bad art, illustrated, deformed, blurry, duplicate, video game, render, anime, cartoon, fake, tiling, out of frame, bad art, bad anatomy, 3d render, nsfw, worst quality, low quality, text, watermark, Thomas Kinkade, sentimental, kitsch, kitschy, twee, commercial, holiday card, comic, cartoon" llm_sys_msg: "You are a helpful AI who assists in generating prompts that will be used to generate highly realistic images. Distill the described image or scene to its visual essence, in the form of the most evocative and visually descriptive words, phrases, and sentence fragments. Emphasize tone, lighting, composition, and any interesting juxtapositions between foreground and background, or center of frame and outer frame areas. Strive for nuance and originality. Avoid cliches, common tropes, and sentimentality. Avoid vague or abstract concepts. Avoid any words or descriptions based on emotion or any senses besides vision. Strive to show rather than tell. Space is limited, so be efficient with your words." llm_pre_prompt: "Using the most visually descriptive sentence fragments, phrases, and words, distill the scene description to its essence, staying true to what it describes: " - prompt_model: "dolphin-llama3:70b" + prompt_model: "command-r:latest" workflows: - workflow: default.json size: 1024x768 @@ -19,7 +19,7 @@ scenes: API_NegativePrompt: "3d, bad art, illustrated, deformed, blurry, duplicate, video game, render, anime, cartoon, fake, tiling, out of frame, bad art, bad anatomy, 3d render, nsfw, worst quality, low quality, text, watermark, Thomas Kinkade, sentimental, kitsch, kitschy, twee, commercial, holiday card, comic, cartoon" llm_sys_msg: "You are a helpful AI who assists in generating prompts that will be used to generate highly realistic images. Distill the described image or scene to its visual essence, in the form of the most evocative and visually descriptive words, phrases, and sentence fragments. Emphasize tone, lighting, composition, and any interesting juxtapositions between foreground and background, or center of frame and outer frame areas. Strive for nuance and originality. Avoid cliches, common tropes, and sentimentality. Avoid vague or abstract concepts. Avoid any words or descriptions based on emotion or any senses besides vision. Strive to show rather than tell. Space is limited, so be efficient with your words." llm_pre_prompt: "Using the most visually descriptive sentence fragments, phrases, and words, distill the scene description to its essence, staying true to what it describes: " - prompt_model: "dolphin-llama3:70b" + prompt_model: "command-r:latest" workflows: - workflow: wallpaper.json size: 1024x640 @@ -33,7 +33,7 @@ scenes: API_NegativePrompt: "canvas frame, 3d, bad art, illustrated, deformed, blurry, duplicate, bad anatomy, worst quality, low quality, watermark, FastNegativeV2, easynegative, epiCNegative, easynegative, verybadimagenegative_v1.3, nsfw, nude" llm_sys_msg: "You are a helpful AI who assists in refining prompts that will be used to generate highly realistic portrait photos. Upon receiving a prompt, you refine it by simplifying and distilling it to its essence, retaining the most visually evocative and distinct elements from what was provided, focusing in particular on the pictured individual's eyes, pose, and other distinctive features. You may infer some visual details that were not provided in the prompt, so long as they are consistent with the rest of the prompt. Always use the most visually descriptive terms possible, and avoid any vague or abstract concepts. Do not include any words or descriptions based on other senses or emotions. Strive to show rather than tell. Space is limited, so be efficient with your words. Remember that the final product will be a still image, and action verbs are not as helpful as simple descriptions of position, appearance, background, etc." llm_pre_prompt: "Using the most visually descriptive sentence fragments, phrases, and words, distill this portrait photo to its essence: " - prompt_model: "dolphin-llama3:70b" + prompt_model: "command-r:latest" workflows: - workflow: selfie.json size: 768x1024 \ No newline at end of file diff --git a/sijapi/config/llm.yaml-example b/sijapi/config/llm.yaml-example index 5a51a35..1edc1be 100644 --- a/sijapi/config/llm.yaml-example +++ b/sijapi/config/llm.yaml-example @@ -6,7 +6,7 @@ chat: vision: model: llava-llama3 summary: - model: dolphin-llama3:8b-256k + model: 'command-r:latest' chunk-size: 16384 chunk-overlap: 256 length-ratio: 4 diff --git a/sijapi/utilities.py b/sijapi/utilities.py index f9ca3a7..5b1182e 100644 --- a/sijapi/utilities.py +++ b/sijapi/utilities.py @@ -52,31 +52,6 @@ def warn(text: str): logger.warning(text) def err(text: str): logger.error(text) def crit(text: str): logger.critical(text) -api_key_header = APIKeyHeader(name="Authorization", auto_error=False) - -def validate_api_key(request: Request, api_key: str = Depends(api_key_header)): - if request.url.path in API.PUBLIC: - return - - client_ip = ipaddress.ip_address(request.client.host) - trusted_subnets = [ipaddress.ip_network(subnet) for subnet in API.TRUSTED_SUBNETS] - if any(client_ip in subnet for subnet in trusted_subnets): - return - - # Check header-based API key - if api_key: - if api_key.lower().startswith("bearer "): - api_key = api_key.lower().split("bearer ")[-1] - if api_key in API.KEYS: - return - - # Check query-based API key - api_key_query = request.query_params.get("api_key") - if api_key_query in API.KEYS: - return - - raise HTTPException(status_code=401, detail="Invalid or missing API key") - def assemble_archive_path(filename: str, extension: str = None, date_time: dt_datetime = None, subdir: str = None) -> Tuple[Path, Path]: date_time = date_time or dt_datetime.now()