Skip to content

Commit

Permalink
feat(BambooLLM): adding implementation for bamboollm updated version (#…
Browse files Browse the repository at this point in the history
…1462)

* feat(BambooLLM): adding implementation for bamboollm updated version

* remove exta print statement

* fix: exception message

* Update pandasai/__init__.py

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
  • Loading branch information
ArslanSaleem and ellipsis-dev[bot] authored Dec 9, 2024
1 parent 2631b8b commit b12cb49
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pandasai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def load(dataset_path: str, virtualized=False) -> DataFrame:
global _dataset_loader
dataset_full_path = os.path.join(find_project_root(), "datasets", dataset_path)
if not os.path.exists(dataset_full_path):
api_key = os.environ.get("PANDAAI_API_KEY", None)
api_url = os.environ.get("PANDAAI_API_URL", None)
api_key = os.environ.get("PANDASAI_API_KEY", None)
api_url = os.environ.get("PANDASAI_API_URL", None)
if not api_url or not api_key:
raise PandasAIApiKeyError(
"Set PANDAAI_API_URL and PANDAAI_API_KEY in environment to pull dataset from the remote server"
"Please set the PANDASAI_API_URL and PANDASAI_API_KEY environment variables to pull the dataset from the remote server."
)

request_session = get_pandaai_session()
Expand Down
4 changes: 2 additions & 2 deletions pandasai/dataframe/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ def push(self):
)

def pull(self):
api_key = os.environ.get("PANDAAI_API_KEY", None)
api_key = os.environ.get("PANDASAI_API_KEY", None)

if not api_key:
raise PandasAIApiKeyError(
"Set PANDAAI_API_URL and PANDAAI_API_KEY in environment to pull dataset to the remote server"
"Set PANDASAI_API_URL and PANDASAI_API_KEY in environment to pull dataset to the remote server"
)

request_session = get_pandaai_session()
Expand Down
8 changes: 4 additions & 4 deletions pandasai/helpers/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def make_request(
url = urljoin(self._endpoint_url, self._version_path + path)
if headers is None:
headers = {
"Authorization": f"Bearer {self._api_key}",
"x-authorization": f"Bearer {self._api_key}",
"Content-Type": "application/json", # or any other headers you need
}

Expand Down Expand Up @@ -99,11 +99,11 @@ def make_request(


def get_pandaai_session():
api_url = os.environ.get("PANDAAI_API_URL", None)
api_key = os.environ.get("PANDAAI_API_KEY", None)
api_url = os.environ.get("PANDASAI_API_URL", None)
api_key = os.environ.get("PANDASAI_API_KEY", None)
if not api_url or not api_key:
raise PandasAIApiKeyError(
"Set PANDAAI_API_URL and PANDAAI_API_KEY in environment to push/pull dataset to the remote server"
"Set PANDASAI_API_URL and PANDASAI_API_KEY in environment to push/pull dataset to the remote server"
)

return Session(endpoint_url=api_url, api_key=api_key)
7 changes: 4 additions & 3 deletions pandasai/llm/bamboo_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ def __init__(
self._session = Session(endpoint_url=endpoint_url, api_key=api_key)

def call(self, instruction: BasePrompt, _context=None) -> str:
data = instruction.to_json()
response = self._session.post("/llm/chat", json=data)
return response["data"]
response = self._session.post(
"/query", json={"prompt": instruction.to_string()}
)
return response["answer"]

@property
def type(self) -> str:
Expand Down

0 comments on commit b12cb49

Please sign in to comment.