Skip to content

Commit

Permalink
Add ability to change temp parameter and clean up examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ncoop57 committed Oct 15, 2024
1 parent fed5288 commit 4d9cbe7
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 96 deletions.
13 changes: 7 additions & 6 deletions fastdata/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
__all__ = ['FastData']

# %% ../nbs/00_core.ipynb 3
import concurrent.futures

from claudette import *
from fastcore.utils import *
from ratelimit import limits, sleep_and_retry
from tqdm import tqdm

import concurrent.futures

# %% ../nbs/00_core.ipynb 4
class FastData:
def __init__(self,
Expand All @@ -26,10 +26,10 @@ def set_rate_limit(self, calls: int, period: int):
"""Set a new rate limit."""
@sleep_and_retry
@limits(calls=calls, period=period)
def rate_limited_call(prompt: str, schema, sp: str):
def rate_limited_call(prompt: str, schema, temp: float, sp: str):
return self.cli.structured(
prompt,
temp=1,
temp=temp,
tools=schema,
)[0]

Expand All @@ -39,18 +39,19 @@ def generate(self,
prompt_template: str,
inputs: list[dict],
schema,
temp: float = 1.,
sp: str = "You are a helpful assistant.",
max_workers: int = 64) -> list[dict]:

def process_input(input_data):
try:
prompt = prompt_template.format(**input_data)
response = self._rate_limited_call(
return self._rate_limited_call(
prompt=prompt,
schema=schema,
temp=temp,
sp=sp
)
return response
except Exception as e:
print(f"Error processing input: {e}")
return None
Expand Down
Loading

0 comments on commit 4d9cbe7

Please sign in to comment.