Skip to content

Commit

Permalink
feat(ai): use libro config for libro ai
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk authored and BroKun committed Oct 8, 2024
1 parent 860d955 commit 35f143b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions libro-ai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies = [
"pydantic>=2.6.4",
"requests>=2.31.0",
"nbclient>=0.10.0",
"libro-core>=0.1.1",
]
readme = "README.md"
requires-python = ">= 3.10"
Expand Down
9 changes: 7 additions & 2 deletions libro-ai/src/libro_ai/chat/openai_chat_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from langchain.callbacks import get_openai_callback
from langchain_community.utilities.dalle_image_generator import DallEAPIWrapper
from IPython.display import display

from libro_core.config import libro_config

class OpenAIChat(LLMChat):
name: str = "chatgpt"
Expand All @@ -16,7 +16,12 @@ class OpenAIChat(LLMChat):

def load(self):
if is_langchain_installed():
self.chat = ChatOpenAI(model_name=self.model)
extra_params = {}
libro_ai_config = libro_config.get_config().get("libro-ai")
if libro_ai_config is not None:
if api_key := libro_ai_config.get("OPENAI_API_KEY"):
extra_params["api_key"] = api_key
self.chat = ChatOpenAI(model_name=self.model,**extra_params)
return True
return False

Expand Down

0 comments on commit 35f143b

Please sign in to comment.