Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting OpenAI model in settings #1386

Merged
merged 5 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fern/docs/pages/manual/llms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ llm:

openai:
api_key: <your_openai_api_key> # You could skip this configuration and use the OPENAI_API_KEY env var instead
model: <openai_model_to_use> # Optional: Defaults to gpt-3.5-turbo
```

And run PrivateGPT loading that profile you just created:
Expand Down
6 changes: 4 additions & 2 deletions private_gpt/components/llm/llm_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def __init__(self, settings: Settings) -> None:
case "openai":
from llama_index.llms import OpenAI

openai_settings = settings.openai.api_key
self.llm = OpenAI(api_key=openai_settings)
openai_settings = settings.openai
self.llm = OpenAI(
api_key=openai_settings.api_key, model=openai_settings.model
)
case "mock":
self.llm = MockLLM()
4 changes: 4 additions & 0 deletions private_gpt/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ class SagemakerSettings(BaseModel):

class OpenAISettings(BaseModel):
api_key: str
model: str = Field(
"gpt-3.5-turbo",
description=("OpenAI Model to use. Example: 'gpt-4'."),
)


class UISettings(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ sagemaker:

openai:
api_key: ${OPENAI_API_KEY:}
model: gpt-4
aly-shehata marked this conversation as resolved.
Show resolved Hide resolved
Loading