Skip to content

Commit

Permalink
Feat/add new openai llm models (#334)
Browse files Browse the repository at this point in the history
* feat(frontend): update OpenAi models and maxToken select's

* fix: update openai model to use the most recent

* fix: adjust max token for gpt-3 turbo

* fix: duplicating models

* fix: openai model type list
  • Loading branch information
vasconceloscezar authored Jun 14, 2023
1 parent 33f49ee commit 3b7390d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
4 changes: 2 additions & 2 deletions backend/llm/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

openai_api_key = os.environ.get("OPENAI_API_KEY")
openai.api_key = openai_api_key
summary_llm = guidance.llms.OpenAI('gpt-3.5-turbo', caching=False)
summary_llm = guidance.llms.OpenAI('gpt-3.5-turbo-0613', caching=False)


def llm_summerize(document):
Expand Down Expand Up @@ -40,7 +40,7 @@ def llm_evaluate_summaries(question, summaries, model):
if not model.startswith('gpt'):
logger.info(
f'Model {model} not supported. Using gpt-3.5-turbo instead.')
model = 'gpt-3.5-turbo'
model = 'gpt-3.5-turbo-0613'
logger.info(f'Evaluating summaries with {model}')
evaluation_llm = guidance.llms.OpenAI(model, caching=False)
evaluation = guidance("""
Expand Down
4 changes: 2 additions & 2 deletions backend/models/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@


class ChatMessage(BaseModel):
model: str = "gpt-3.5-turbo"
model: str = "gpt-3.5-turbo-0613"
question: str
# A list of tuples where each tuple is (speaker, text)
history: List[Tuple[str, str]]
temperature: float = 0.0
max_tokens: int = 256
use_summarization: bool = False
chat_id: Optional[UUID] = None,
chat_id: Optional[UUID] = None,
25 changes: 22 additions & 3 deletions frontend/app/config/components/ModelConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Field from "@/lib/components/ui/Field";
import {
BrainConfig,
Model,
PaidModels,
anthropicModels,
models,
paidModels,
Expand All @@ -12,7 +13,7 @@ import { UseFormRegister } from "react-hook-form";

interface ModelConfigProps {
register: UseFormRegister<BrainConfig>;
model: Model;
model: Model | PaidModels;
openAiKey: string | undefined;
temperature: number;
maxTokens: number;
Expand All @@ -25,6 +26,24 @@ export const ModelConfig = ({
temperature,
maxTokens,
}: ModelConfigProps): JSX.Element => {
const defineMaxTokens = (model: Model | PaidModels): number => {
//At the moment is evaluating only models from OpenAI
switch (model) {
case "gpt-3.5-turbo":
return 3000;
case "gpt-3.5-turbo-0613":
return 3000;
case "gpt-3.5-turbo-16k":
return 14000;
case "gpt-4":
return 6000;
case "gpt-4-0613":
return 6000;
default:
return 3000;
}
};

return (
<>
<div className="border-b border-gray-300 mt-8 mb-8">
Expand Down Expand Up @@ -85,8 +104,8 @@ export const ModelConfig = ({
<input
type="range"
min="256"
max="3000"
step="1"
max={defineMaxTokens(model)}
step="32"
value={maxTokens}
{...register("maxTokens")}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const BrainConfigContext = createContext<ConfigContext | undefined>(
);

const defaultBrainConfig: BrainConfig = {
model: "gpt-3.5-turbo",
model: "gpt-3.5-turbo-0613",
temperature: 0,
maxTokens: 500,
keepLocal: true,
Expand Down
5 changes: 3 additions & 2 deletions frontend/lib/context/BrainConfigProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export type ConfigContext = {
};

// export const openAiModels = ["gpt-3.5-turbo", "gpt-4"] as const; ## TODO activate GPT4 when not in demo mode
export const openAiModels = ["gpt-3.5-turbo"] as const;
export const openAiPaidModels = ["gpt-3.5-turbo", "gpt-4"] as const;

export const openAiModels = ["gpt-3.5-turbo","gpt-3.5-turbo-0613","gpt-3.5-turbo-16k"] as const;
export const openAiPaidModels = ["gpt-3.5-turbo","gpt-3.5-turbo-0613","gpt-3.5-turbo-16k","gpt-4","gpt-4-0613"] as const;

export const anthropicModels = [
// "claude-v1",
Expand Down

2 comments on commit 3b7390d

@vercel
Copy link

@vercel vercel bot commented on 3b7390d Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

quivrapp – ./frontend

quivrapp-git-main-quivr-app.vercel.app
quivrapp-quivr-app.vercel.app
quiver-two.vercel.app
quivr.app
www.quivr.app

@vercel
Copy link

@vercel vercel bot commented on 3b7390d Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./docs

docs-git-main-quivr-app.vercel.app
docs-quivr-app.vercel.app
quivr-ten.vercel.app
brain.quivr.app

Please sign in to comment.