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

Added Poe-api as LLM reference #425

Closed
wants to merge 7 commits into from
Closed
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
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,42 @@ pandas_ai.generate_features(df)
pandas_ai.plot_histogram(df, column="gdp")
```

### POE-API As LLM Reference

```
To use Pandas-ai without using OPENAI API use Poe-api

Get Your TOKEN from poe.com by just creating account don't need to add any billing

To get Token click Inspect -> Application -> Cookies -> p-b value
BOTS REFERENCE :

"chinchilla": "ChatGPT",
"a2": "Claude-instant",
"capybara": "Assistant",
"a2_100k": "Claude-instant-100k",
"llama_2_7b_chat": "Llama-2-7b",
"llama_2_13b_chat": "Llama-2-13b",
"a2_2": "Claude-2-100k",
"llama_2_70b_chat": "Llama-2-70b",
"agouti": "ChatGPT-16k",
"beaver": "GPT-4",
"vizcacha": "GPT-4-32k",
"acouchy": "Google-PaLM"

If you want to use ChatGPT use bot name as chinchilla

Example usage

from pandasai import PandasAI
from pandasai.llm.poe_api import POEAPI

llm = POEAPI(bot_name='chinchilla',token = '')
pandas_ai = PandasAI(llm)

```


Learn more about the shortcuts [here](https://pandas-ai.readthedocs.io/en/latest/shortcuts/).

## 🔒 Privacy & Security
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ watchdog==2.1.9
# via mkdocs
zipp==3.8.0
# via importlib-metadata

poe-api
75 changes: 75 additions & 0 deletions pandasai/llm/poe_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Poe-Api LLMs

This module provides a family of commercially / non-commercially available
LLMs maintained by Quora
Example:
Use below example to call POEAPI supporrted models
>>> from pandasai.llm.poe_api import POEAPI
"""
import os
import requests
from typing import Optional

from pandasai.prompts.base import Prompt
from .base import LLM


class POEAPI(LLM):
"""POEAPI LLMs API
Base LLM class is extended to support POEAPILLM.Below example shows how
we can use override certain configurations to change model's behaviour.
Example:
>>> import pandas as pd
>>> from pandasai import PandasAI
>>> from pandasai.llm.POEAPI import POEAPI
>>> model = POEAPI(bot_name='', token='')
>>> df_ai = PandasAI(model)
>>> response = df_ai(df, prompt='What is the sum of the GDP in this table?')


"""



def __init__(
self,
bot_name: str,
token : str,
**kwargs,
) -> None:
self.bot_name = bot_name
self.token = token
"""
POEAPI client for using Pandas AI
Args:
bot_name: The name of the model.
token: The token of the Poe API.

"""

try:
import poe

self.poe_api_bot = poe.Client(token=self.token


)
except ImportError:
raise ImportError(
"Unable to import poe-api python package "
"Please install it with `pip install -U poe-api`"
)




@property
def type(self) -> str:
return "POEAPI"

def call(self, instruction: Prompt, value: str, suffix: str = "") -> str:
prompt = str(instruction)
prompt = prompt + value + suffix
for chunk in self.poe_api_bot.send_message(self.bot_name ,prompt,):
pass
return chunk['text']
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ google-generativeai = { version = "^0.1.0rc2", optional = true }
google-cloud-aiplatform = { version = "^1.26.1", optional = true }
langchain = { version = "^0.0.199", optional = true}
beautifulsoup4 = { version = "^4.12.2", optional = true }
poe-api = "0.5.2"

[tool.poetry.group.dev.dependencies]
black = "^23.3.0"
Expand Down
18 changes: 18 additions & 0 deletions tests/llms/test_poeapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest.mock import patch
from pandasai.llm.poe_api import POEAPI


class TestPOEAPI(unittest.TestCase):
"""Unit tests for the base POE LLM class"""

def setUp(self):
self.bot_name = "chinchilla"
self.token = ''

self.poe_api_bot = POEAPI(
model_name=self.model_name,
)

def test_type(self, ):

assert self.poe_api_bot.type == "POEAPI"