Skip to content

Commit

Permalink
ver 0.4 - add newer models
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkaplan committed Feb 9, 2024
1 parent d5bbc5d commit 8c1c9b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3
0.4
5 changes: 3 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
GO_AZURE = False # default
OUTPUT_JSON = bool(strtobool(os.getenv('OUTPUT_JSON', 'false')))
DRY_RUN = bool(strtobool(os.getenv('DRY_RUN', 'false')))
OPENAI_MODEL = os.getenv('OPENAI_MODEL')


# First detect if we should invoke OpenAI via MS Azure or directly
Expand All @@ -62,7 +63,7 @@ async def dispatch(self, request: Request, call_next):

app.add_middleware(HTTPSRedirectMiddleware)

summarizer = Summarizer(go_azure=GO_AZURE, model='gpt-4-1106-preview', max_tokens=8192, output_json=OUTPUT_JSON)
summarizer = Summarizer(go_azure=GO_AZURE, model=OPENAI_MODEL, max_tokens=8192, output_json=OUTPUT_JSON)


async def fetch_text_from_url(url: str) -> str:
Expand All @@ -87,7 +88,7 @@ def get_index(request: Request, username: str = Depends(get_current_username)):

@app.post("/", response_class=HTMLResponse)
async def index(request: Request, text: str = Form(None), url: str = Form(None),
system_prompt: str = Form(None), model: str = Form('gpt-4'), token_count: int = Form(100),
system_prompt: str = Form(None), model: str = Form('model'), token_count: int = Form(100),
username: str = Depends(get_current_username)):
"""HTTP POST method for the default page. This gets called when the user already HTTP POSTs a text which should be summarized."""

Expand Down
4 changes: 2 additions & 2 deletions app/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def summarize(self, text: str, system_prompt: str = "") -> Tuple[str, str]:
log.info("Using MS AZURE!")
response = self.client.chat.completions.create(model=os.environ['ENGINE'],
messages=messages,
temperature=0.7,
temperature=0.3,
top_p=0.95,
stop=None,
max_tokens=self.max_tokens,
Expand All @@ -84,7 +84,7 @@ def summarize(self, text: str, system_prompt: str = "") -> Tuple[str, str]:
response_format = None
response = self.client.chat.completions.create(model=self.model,
messages=messages,
temperature=0.7,
temperature=0.3,
top_p=0.95,
stop=None,
max_tokens=self.max_tokens,
Expand Down
4 changes: 3 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ <h3>Summarize this</h3>
<select id="model" name="model">
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
<option value="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option>
<option value="gpt-3.5-turbo-0125" selected>gpt-3.5-turbo-0125 (16k)</option>
<option value="gpt-4">gpt-4</option>
<option value="gpt-4-32k">gpt-4-32k</option>
<option value="gpt-4-1106-preview" selected>gpt-4-1106-preview</option>
<option value="gpt-4-1106-preview">gpt-4-1106-preview</option>
<option value="gpt-4-0125-preview">gpt-4-0125-preview (128k)</option>
</select>
</div>
</div>
Expand Down

0 comments on commit 8c1c9b3

Please sign in to comment.