-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature add initial support for images (#150)
* Add support for images * Delete Theoriq.pdf * limit logs for payload * Fixes
- Loading branch information
Showing
16 changed files
with
272 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .prompt_builder import PromptBuilder | ||
from .llm_prompt_config_object import LLMPromptConfigObject, LLMPromptConfigSpec |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Dict | ||
|
||
|
||
def truncate_dict_values_to_str(data: Dict, max_length: int = 20): | ||
""" | ||
Truncates dictionary values that are longer than max_length and returns a string representation. | ||
The truncated value shows both the start and end of the original value. Handles nested dictionaries recursively. | ||
Parameters: | ||
data (dict): The dictionary with values to be truncated. | ||
max_length (int): The maximum length of each value before truncation. Default is 20. | ||
Returns: | ||
str: A string representation of the dictionary with truncated values. | ||
""" | ||
|
||
def truncate_value(value): | ||
if isinstance(value, dict): | ||
return truncate_dict_values_to_str(value, max_length) | ||
elif isinstance(value, list): | ||
return [truncate_value(item) for item in value] | ||
elif isinstance(value, str) and len(value) > max_length: | ||
half_length = (max_length - 3) // 2 | ||
return value[:half_length] + "..." + value[-half_length:] | ||
else: | ||
return value | ||
|
||
truncated_items = [] | ||
|
||
for key, value in data.items(): | ||
truncated_value = truncate_value(value) | ||
truncated_items.append(f"{key}: {truncated_value}") | ||
|
||
return "{ " + ", ".join(truncated_items) + " }" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
"""Init file.""" | ||
|
||
import os | ||
|
||
|
||
def get_data_filename(filename: str): | ||
return os.path.join(os.path.dirname(__file__), "data", filename) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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
Oops, something went wrong.