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

feat(BambooLLM): adding implementation for bamboollm updated version #1462

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading