Skip to content

Commit a858f21

Browse files
committed
Update optillm.py
1 parent 7beeb4f commit a858f21

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

optillm.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,20 @@ def parse_combined_approach(model: str, known_approaches: list, plugin_approache
368368
def execute_single_approach(approach, system_prompt, initial_query, client, model, request_config: dict = None, request_id: str = None):
369369
if approach in known_approaches:
370370
if approach == 'none':
371-
# Extract kwargs from the request data
372-
kwargs = {}
373-
if hasattr(request, 'json'):
374-
data = request.get_json()
375-
messages = data.get('messages', [])
376-
# Copy all parameters except 'stream', 'model' and 'messages'
377-
kwargs = {k: v for k, v in data.items()
378-
if k not in ['model', 'messages', 'stream', 'optillm_approach']}
371+
# Use the request_config that was already prepared and passed to this function
372+
kwargs = request_config.copy() if request_config else {}
373+
374+
# Remove items that are handled separately by the framework
375+
kwargs.pop('n', None) # n is handled by execute_n_times
376+
kwargs.pop('stream', None) # stream is handled by proxy()
377+
378+
# Reconstruct original messages from system_prompt and initial_query
379+
messages = []
380+
if system_prompt:
381+
messages.append({"role": "system", "content": system_prompt})
382+
if initial_query:
383+
messages.append({"role": "user", "content": initial_query})
384+
379385
response = none_approach(original_messages=messages, client=client, model=model, request_id=request_id, **kwargs)
380386
# For none approach, we return the response and a token count of 0
381387
# since the full token count is already in the response

0 commit comments

Comments
 (0)