Open
Conversation
…ng, formalization) Reuses parts from wip/ls/ai_driver
only a certain amount of ai requests can happen simultaneously some variable renaming
featureflag for ai
– is a core utility for future add-ons
# Conflicts: # hanfor/config.dist.py # hanfor/lib_core/startup.py
…rent ai providers
# Conflicts: # hanfor/requirements/desc_highlighting.py
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Threading System & AI Request Integration
Threading
A dedicated unit now handles the distribution of parallel resources.
New Components
ThreadGroup– An arbitrarily extensible enum for grouping tasks. Groups can be selectively terminated viastop_group.SchedulingClass– Defines a task's priority and the minimum ratio of free resources required before the task is executed. This prevents outer tasks from clogging up resources when tasks spawn new tasks themselves.ThreadTask– The actual task submitted to the scheduler. The following parameters can be specified:functhreading.Eventas its last parameter (for stopping)scheduling_classSchedulingClasstask_groupThreadGroupassignmentsemaphorecallbackargskwargsExample:
TaskResult– Returned bysubmit(), mimicking thethreading.Threadinterface via.done()and.result()to track task completion and results.Scheduler
current_app.thread_handlerruns a persistent background thread that handles scheduling. Tasks are started based on priority, free-ratio, and other parameters - for example, if the given semaphore for this task is avaliable.Configuration
AI Requests
AI requests to various models and providers can now be made straightforwardly:
querycallbackscheduling_classproviderNone, the model set in the config is usedmodel_nameNone, the provider set in the config is usedapi_method_nameNone, the first method is usedextra_paramsAdding a new model / provider / method
model and provider must be entered in the “ai_config” file, using the same structure as shown there
To support a new model, a new
api_request_methodcan be implemented for the respective API interface. Theextra_paramscan be used flexibly as needed. Theai_api_methods_abstract_classmust be fully implemented.