-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add MultiContextProcessor class
This commit introduces the MultiContextProcessor class, which is designed to handle the processing of multiple contexts with a selected prompt group and output settings. The MultiContextProcessor class provides the following functionality: Processes multiple context files grouped by name. Reads the content of each file and processes it with the selected prompt group. Organizes the results into a dictionary where keys are group names and values are lists of results for each file in the group. Saves the results to separate text files named according to the group and result index. This class enhances the flexibility and modularity of the code by separating the prompt building, launching, and result saving logic for multi-context processing. Signed-off-by: Fred Zimmerman <[email protected]>
- Loading branch information
Fred Zimmerman
committed
Aug 25, 2024
1 parent
610e9f6
commit 4f70a8a
Showing
5 changed files
with
62 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import json | ||
from importlib import resources | ||
|
||
import streamlit as st | ||
|
||
|
||
def filter_dict(dictionary, filter_text): | ||
return {k: v for k, v in dictionary.items() if | ||
filter_text.lower() in k.lower() or ( | ||
isinstance(v, dict) and filter_text.lower() in v.get('prompt', '').lower())} | ||
|
||
|
||
def load_json_file(file_name): | ||
try: | ||
with resources.files('Codexes2Gemini.resources.prompts').joinpath(file_name).open('r') as file: | ||
return json.load(file) | ||
except Exception as e: | ||
st.error(f"Error loading JSON file: {e}") | ||
return {} |