⚡️ azure gpt4 for increased speed

This commit is contained in:
Nate Sesti 2023-11-03 18:07:14 -07:00
parent 7e2239f30e
commit ef6273371a
7 changed files with 106 additions and 100 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -368,6 +368,9 @@ class Autopilot:
map(lambda x: x.dict(), await self.sdk.get_chat_context())
)
chat_history_str = template_alpaca_messages(chat_history)
if self.sdk.models.summarize is None:
return "New Session"
title = await self.sdk.models.summarize.complete(
f"{chat_history_str}\n\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: ",
max_tokens=20,

View file

@ -1,4 +1,4 @@
from typing import Callable, Coroutine, List, Optional, Union
from typing import Callable, List, Optional
import uuid
from pydantic import BaseModel, validator

View file

@ -164,14 +164,15 @@ class OpenAI(LLM):
if not hasattr(chunk, "choices") or len(chunk.choices) == 0:
continue
delta = chunk.choices[0].delta
if self.api_type == "azure":
# To smooth out the response streaming, which typically comes in bursts
if self.model == "gpt-4":
await asyncio.sleep(0.03)
else:
await asyncio.sleep(0.01)
yield chunk.choices[0].delta
yield delta
else:
async for chunk in await openai.Completion.acreate(
prompt=template_alpaca_messages(messages),

View file

@ -71,7 +71,6 @@ class ProxyServer(LLM):
if chunk.strip() != "":
loaded_chunk = json.loads(chunk)
yield loaded_chunk
await asyncio.sleep(0.01)
if self.model == "gpt-4":
await asyncio.sleep(0.03)

View file

@ -128,6 +128,7 @@ def prune_chat_history(
while (
tokens_removed < distance_from_third[i]
and total_tokens - total_tokens_removed > context_length
and len(lines) > 0
):
delta = count_tokens(lines.pop(-1), model_name)
tokens_removed += delta