Skip to content

Fix cot reflection #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion optillm.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def execute_single_approach(approach, system_prompt, initial_query, client, mode
c=server_config['rstar_c'])
return rstar.solve(initial_query)
elif approach == "cot_reflection":
return cot_reflection(system_prompt, initial_query, client, model, return_full_response=server_config['return_full_response'])
return cot_reflection(system_prompt, initial_query, client, model, return_full_response=server_config['return_full_response'], request_config=request_config)
elif approach == 'plansearch':
return plansearch(system_prompt, initial_query, client, model, n=server_config['n'])
elif approach == 'leap':
Expand Down
2 changes: 1 addition & 1 deletion optillm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

# Version information
__version__ = "0.1.18"
__version__ = "0.1.19"

# Get the path to the root optillm.py
spec = util.spec_from_file_location(
Expand Down
16 changes: 12 additions & 4 deletions optillm/cot_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@

logger = logging.getLogger(__name__)

def cot_reflection(system_prompt, initial_query, client, model: str, return_full_response: bool=False):
def cot_reflection(system_prompt, initial_query, client, model: str, return_full_response: bool=False, request_config: dict = None):
cot_completion_tokens = 0

# Extract temperature and max_tokens from request_config with defaults
temperature = 0.6 # Default to 0.6 as requested
max_tokens = 4096 # Default to 4096 as requested

if request_config:
temperature = request_config.get('temperature', temperature)
max_tokens = request_config.get('max_tokens', max_tokens)
cot_prompt = f"""
{system_prompt}

Expand Down Expand Up @@ -32,15 +40,15 @@ def cot_reflection(system_prompt, initial_query, client, model: str, return_full
</output>
"""

# Make the API call
# Make the API call using user-provided or default parameters
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": cot_prompt},
{"role": "user", "content": initial_query}
],
temperature=0.7,
max_tokens=4096
temperature=temperature,
max_tokens=max_tokens
)

# Extract the full response
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="optillm",
version="0.1.18",
version="0.1.19",
packages=find_packages(include=['optillm', 'optillm.*']), # This ensures all subpackages are included
py_modules=['optillm'],
package_data={
Expand Down