Skip to content

Commit

Permalink
dry
Browse files Browse the repository at this point in the history
  • Loading branch information
supa-thibaud committed Sep 11, 2024
1 parent b3da087 commit c9cb104
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def wait_for_server(self, timeout=300, interval=5):
return True
except requests.RequestException:
pass
time.sleep(interval)
time.sleep(interval)
raise TimeoutError("Server failed to start within the timeout period.")

def shutdown(self):
Expand All @@ -102,7 +102,7 @@ class OpenAIRequest:
def __init__(self, base_url="http://0.0.0.0:30000/v1", api_key="EMPTY"):
self.client = openai.Client(base_url=base_url, api_key=api_key)

async def request_chat_completions(self, model="default", messages=None, max_tokens=100, stream=False, frequency_penalty=0.0, n=1, stop=None, temperature=1.0, top_p=1.0):
async def request_chat_completions(self, model="default", messages=None, max_tokens=100, stream=False, frequency_penalty=0.0, n=1, stop=None, temperature=1.0, top_p=1.0, dry_multiplier=0, dry_base=1.75, dry_allowed_length=2, dry_penalty_last_n=0, dry_sequence_breakers='"\\n", ":", "\\"", "*"'):
if messages is None:
messages = [
{"role": "system", "content": "You are a helpful AI assistant"},
Expand All @@ -118,7 +118,12 @@ async def request_chat_completions(self, model="default", messages=None, max_tok
n=n,
stop=stop,
temperature=temperature,
top_p=top_p
top_p=top_p,
dry_multiplier=dry_multiplier,
dry_base=dry_base,
dry_allowed_length=dry_allowed_length,
dry_penalty_last_n=dry_penalty_last_n,
dry_sequence_breakers=dry_sequence_breakers,
)

if stream:
Expand All @@ -127,7 +132,7 @@ async def request_chat_completions(self, model="default", messages=None, max_tok
else:
yield response.to_dict()

async def request_completions(self, model="default", prompt="The capital of France is", max_tokens=100, stream=False, frequency_penalty=0.0, n=1, stop=None, temperature=1.0, top_p=1.0):
async def request_completions(self, model="default", prompt="The capital of France is", max_tokens=100, stream=False, frequency_penalty=0.0, n=1, stop=None, temperature=1.0, top_p=1.0, dry_multiplier=0, dry_base=1.75, dry_allowed_length=2, dry_penalty_last_n=0, dry_sequence_breakers='"\\n", ":", "\\"", "*"'):
response = self.client.completions.create(
model=model,
prompt=prompt,
Expand All @@ -137,7 +142,12 @@ async def request_completions(self, model="default", prompt="The capital of Fran
n=n,
stop=stop,
temperature=temperature,
top_p=top_p
top_p=top_p,
dry_multiplier=dry_multiplier,
dry_base=dry_base,
dry_allowed_length=dry_allowed_length,
dry_penalty_last_n=dry_penalty_last_n,
dry_sequence_breakers=dry_sequence_breakers,
)

if stream:
Expand Down

0 comments on commit c9cb104

Please sign in to comment.