Skip to content

Commit

Permalink
feat: rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
joschkabraun committed Oct 11, 2023
1 parent d694293 commit 53d1d1e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ code & prompts without waiting for all previous, valid LLM responses. Simply add
[a local redis cache](https://redis.io/docs/getting-started/install-stack/):

```python
from parea import init
from parea import init, RedisCache

init()
init(cache=RedisCache())
```

Above will use the default redis cache at `localhost:6379` with no password. You can also specify your redis database by:
Expand All @@ -44,13 +44,15 @@ Above will use the default redis cache at `localhost:6379` with no password. You
from parea import init, RedisCache

cache = RedisCache(
host=os.getenv("REDIS_HOST", "localhost"), # default value
port=int(os.getenv("REDIS_PORT", 6379)), # default value
password=os.getenv("REDIS_PASSWORT", None) # default value
host=os.getenv("REDIS_HOST", "localhost"), # default value
port=int(os.getenv("REDIS_PORT", 6379)), # default value
password=os.getenv("REDIS_PASSWORT", None) # default value
)
init(cache=cache) # default value
init(cache=cache)
```

If you set `cache = None` for `init`, no cache will be used.

### Automatically log all your LLM call traces

You can automatically log all your LLM traces to the Parea dashboard by setting the `PAREA_API_KEY` environment variable or specifying it in the `init` function.
Expand All @@ -60,7 +62,10 @@ in your local setup & code.
```python
from parea import init

init(api_key=os.getenv("PAREA_API_KEY")) # default value
init(
api_key=os.getenv("PAREA_API_KEY"), # default value
cache=...
)
```


Expand Down
8 changes: 4 additions & 4 deletions parea/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ def async_wrapper(fn, **kwargs):

def run_benchmark(args):
parser = argparse.ArgumentParser()
parser.add_argument("--user_func", help="User function to test e.g., path/to/user_code.py:argument_chain", type=str)
parser.add_argument("--inputs", help="Path to the input CSV file", type=str)
parser.add_argument("--func", help="Function to test e.g., path/to/my_code.py:argument_chain", type=str)
parser.add_argument("--csv_path", help="Path to the input CSV file", type=str)
parser.add_argument("--redis_host", help="Redis host", type=str, default=os.getenv("REDIS_HOST", "localhost"))
parser.add_argument("--redis_port", help="Redis port", type=int, default=int(os.getenv("REDIS_PORT", 6379)))
parser.add_argument("--redis_password", help="Redis password", type=str, default=None)
parsed_args = parser.parse_args(args)

fn = load_from_path(*parsed_args.user_func.rsplit(":", 1))
fn = load_from_path(*parsed_args.func.rsplit(":", 1))

data_inputs = read_input_file(parsed_args.inputs)
data_inputs = read_input_file(parsed_args.csv_path)

redis_logs_key = f"parea-trace-logs-{int(time.time())}"
os.putenv("_parea_redis_logs_key", redis_logs_key)
Expand Down
4 changes: 2 additions & 2 deletions parea/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class Parea:
api_key: str = field(init=True, default="")
_client: HTTPClient = field(init=False, default=HTTPClient())
cache: Cache = field(init=True, default=RedisCache())
cache: Cache = field(init=True, default=None)

def __attrs_post_init__(self):
self._client.set_api_key(self.api_key)
Expand Down Expand Up @@ -96,7 +96,7 @@ async def arecord_feedback(self, data: FeedbackRequest) -> None:
_initialized_parea_wrapper = False


def init(api_key: str = os.getenv("PAREA_API_KEY"), cache: Cache = RedisCache()) -> None:
def init(api_key: str = os.getenv("PAREA_API_KEY"), cache: Cache = None) -> None:
Parea(api_key=api_key, cache=cache)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "parea-ai"
packages = [{ include = "parea" }]
version = "0.2.8"
version = "0.2.9"
description = "Parea python sdk"
readme = "README.md"
authors = ["joel-parea-ai <[email protected]>"]
Expand Down

0 comments on commit 53d1d1e

Please sign in to comment.