Skip to content
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
12 changes: 9 additions & 3 deletions aif_gen/generate/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ async def _generate_sample(
meta_prompt_nonce = f'{prompt_idx}'

async with async_semaphore:
output = None
if cache is not None:
output = await cache.get(meta_prompt, nonce=meta_prompt_nonce)
else:

if output is None: # Cache miss or no cache - make API call
response = await client.chat.completions.create(
model=model_name,
messages=[{'role': 'user', 'content': meta_prompt}],
Expand Down Expand Up @@ -306,9 +308,11 @@ async def _generate_sample(
task_prompt = task_prompt1 + task_prompt2

async with async_semaphore:
output = None
if cache is not None:
output = await cache.get(task_prompt1 + task_prompt2)
else:

if output is None: # Cache miss or no cache - make API calls
futures = []
for response_prompt in [task_prompt1, task_prompt2]:
coro = client.chat.completions.create(
Expand Down Expand Up @@ -346,9 +350,11 @@ async def _generate_sample(
else:
task_prompt = response_mapper.generate_prompt(task, prompt)
async with async_semaphore:
output = None
if cache is not None:
output = await cache.get(task_prompt)
else:

if output is None: # Cache miss or no cache - make API call
response = await client.chat.completions.create(
model=model_name,
messages=[{'role': 'user', 'content': task_prompt}],
Expand Down
4 changes: 2 additions & 2 deletions aif_gen/generate/mappers/response_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ResponseMapper(ResponseMapperBase):
"""

NUM_PREFERENCE_AXES_SAMPLES: int = 3
PREFERENCE_INCLUSION_PROB_POS: float = 0.5
PREFERENCE_INCLUSION_PROB_NEG: float = 0.5
PREFERENCE_INCLUSION_PROB_POS: float = 0.8
PREFERENCE_INCLUSION_PROB_NEG: float = 0.8

def __init__(self, suffix_context: Optional[str] = None) -> None:
self._suffix_context = suffix_context
Expand Down
Loading