diff --git a/.gitignore b/.gitignore index 50c275c3..cdfecf56 100644 --- a/.gitignore +++ b/.gitignore @@ -619,4 +619,4 @@ MigrationBackup/ /LocalREADME.md LocalREADME.md .env -/parea/cookbook/tmp/ +/cookbook/tmp/ diff --git a/README.md b/README.md index f19ade31..b75c817f 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,35 @@ -# Parea Python SDK +

+Test, evaluate & monitor your AI application +

-
+

+Test, evaluate & monitor your AI application +

-[![Build status](https://github.com/parea-ai/parea-sdk/workflows/build/badge.svg?branch=master&event=push)](https://github.com/parea-ai/parea-sdk/actions?query=workflow%3Abuild) -[![Dependencies Status](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)](https://github.com/parea-ai/parea-sdk/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +

+PyPI +PyPI - Downloads from official pypistats +License +

+ +

+🐦 Twitter/X +  •   +📢 Discord +  •   +Parea AI +  •   +📙 Documentation +

-[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/parea-ai/parea-sdk/blob/master/.pre-commit-config.yaml) -[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://github.com/parea-ai/parea-sdk/releases) -[![License](https://img.shields.io/github/license/parea-ai/parea-sdk)](https://github.com/parea-ai/parea-sdk/blob/master/LICENSE) -Parea python sdk +[Parea AI](https://www.parea.ai) provides a SDK to evaluate & monitor your AI applications. Below you can see quickstarts to: -
+- [evaluate & test](#evaluating-your-llm-app) your LLM App +- [instrument logging & observability](#logging--observability) for your LLM App +- [deploying prompts](#deploying-prompts) to enable collaboration between engineers & subject-matter experts -[Python SDK Docs](https://docs.parea.ai/api-reference/sdk/python) +Our full docs are [here](https://docs.parea.ai/). ## Installation @@ -28,127 +43,161 @@ or install with `Poetry` poetry add parea-ai ``` + ## Evaluating Your LLM App -You can evaluate any step of your LLM app by wrapping it with a decorator, called `trace`, and specifying the evaluation -function(s). -The scores associated with the traces will be logged to the Parea [dashboard](https://app.parea.ai/logs) and/or in a -local CSV file if you don't have a Parea API key. +Testing your AI app means to execute it over a dataset and score it with an evaluation function. +This is done in Parea by defining & running experiments. +Below you can see can example of how to test a greeting bot with the Levenshtein distance metric. -Evaluation functions receive an argument `log` (of type [Log](parea/schemas/models.py)) and should return a -float. You don't need to start from scratch, there are pre-defined evaluation -functions for [general purpose](parea/evals/general), -[chat](parea/evals/chat), [RAG](parea/evals/rag), and [summarization](parea/evals/summary) apps :) +```python +from parea import Parea, trace +from parea.evals.general import levenshtein + +p = Parea(api_key="<>") # replace with Parea AI API key + +# use the trace decorator to score the output with the Levenshtein distance +@trace(eval_funcs=[levenshtein]) +def greeting(name: str) -> str: + return f"Hello {name}" + +data = [ + {"name": "Foo", "target": "Hi Foo"}, + {"name": "Bar", "target": "Hello Bar"}, +] + +p.experiment( + name="Greeting", + data=data, + func=greeting, +).run() +``` -You can define evaluation functions locally or use the ones you have deployed to -Parea's [Test Hub](https://app.parea.ai/test-hub). -If you choose the latter option, the evaluation happens asynchronously and non-blocking. +In the snippet above, we used the `trace` decorator to capture any inputs & outputs of the function. +This decorator also enables to score the output by executing the `levenshtein` eval in the background. +Then, we defined an experiment via `p.experiment` to evaluate our function (`greeting`) over a dataset (here a list of dictionaries). +Finally, calling `run` will execute the experiment, and create a report of outputs, scores & traces for any sample of the dataset. +You can find a link to the executed experiment [here](). (todo: fill-in experiment) -A fully locally working cookbook can be found [here](parea/cookbook/openai/tracing_and_evaluating_openai_endpoint.py). -Alternatively, you can add the following code to your codebase to get started: -```python -import os -from parea import Parea, InMemoryCache, trace -from parea.schemas.log import Log -Parea(api_key=os.getenv("PAREA_API_KEY"), cache=InMemoryCache()) # use InMemoryCache if you don't have a Parea API key +### More Resources +Read more about how to write, run & analyze experiments in our [docs](https://docs.parea.ai/evaluation/overview). -def locally_defined_eval_function(log: Log) -> float: - ... +## Logging & Observability -@trace(eval_func_names=['deployed_eval_function_name'], eval_funcs=[locally_defined_eval_function]) -def function_to_evaluate(*args, **kwargs) -> ...: - ... -``` +By wrapping the respective clients, you can automatically log all your LLM calls to OpenAI & Anthropic. +Additionally, using the `trace` decorator you can create hierarchical traces of your LLM application to e.g. associate LLM calls with the retrieval step of a RAG pipeline. +You can see the full observability documentation [here](https://docs.parea.ai/observability/overview) and our integrations into LangChain, Instructor, DSPy, LiteLLM & more [here](https://docs.parea.ai/integrations/langchain). -### Run Experiments +### Automatically log all your OpenAI calls -You can run an experiment for your LLM application by defining the `Experiment` class and passing it the name, the data and the -function you want to run. You need annotate the function with the `trace` decorator to trace its inputs, outputs, latency, etc. -as well as to specify which evaluation functions should be applied to it (as shown above). +To automatically log any OpenAI call, you can wrap the OpenAI client with the Parea client using the `wrap_openai_client` method. ```python -from parea import Experiment +from openai import OpenAI +from parea import Parea + +client = OpenAI(api_key="OPENAI_API_KEY") -Experiment( - name="Experiment Name", # Name of the experiment (str) - data=[{"n": "10"}], # Data to run the experiment on (list of dicts) - func=function_to_evaluate, # Function to run (callable) +# All you need to do is add these two lines +p = Parea(api_key="PAREA_API_KEY") # replace with your API key +p.wrap_openai_client(client) + +response = client.chat.completions.create( + model="gpt-4o", + messages=[ + { + "role": "user", + "content": "Write a Hello World program in Python using FastAPI.", + } + ], ) +print(response.choices[0].message.content) ``` -Then you can run the experiment by using the `experiment` command and give it the path to the python file. -This will run your experiment with the specified inputs and create a report with the results which can be viewed under -the [Experiments tab](https://app.parea.ai/experiments). +### Automatically log all your Anthropic calls -```bash -parea experiment -``` +To automatically log any Anthropic call, you can wrap the Anthropic client with the Parea client using the `wrap_anthropic_client` method. -Full working example in our [docs](https://docs.parea.ai/evaluation/offline/experiments). +```python +import anthropic +from parea import Parea + +p = Parea(api_key="PAREA_API_KEY") # replace with your API key + +client = anthropic.Anthropic() +p.wrap_anthropic_client(client) + +message = client.messages.create( + model="claude-3-opus-20240229", + max_tokens=1024, + messages=[ + { + "role": "user", + "content": "Write a Hello World program in Python using FastAPI.", + } + ], +) +print(message.content[0].text) +``` -## Debugging Chains & Agents +### Nested traces -You can iterate on your chains & agents much faster by using a local cache. This will allow you to make changes to your -code & prompts without waiting for all previous, valid LLM responses. Simply add these two lines to the beginning your -code and start -[a local redis cache](https://redis.io/docs/getting-started/install-stack/): +By using the `trace` decorator, you can create hierarchical traces of your LLM application. ```python -from parea import Parea, InMemoryCache +from openai import OpenAI +from parea import Parea, trace -Parea(cache=InMemoryCache()) -``` +client = OpenAI(api_key="OPENAI_API_KEY") # replace with your API key -If you set `cache = None` for `Parea`, no cache will be used. +p = Parea(api_key="PAREA_API_KEY") # replace with your API key +p.wrap_openai_client(client) -### Benchmark your LLM app across many inputs -You can benchmark your LLM app across many inputs by using the `benchmark` command. This will run your the entry point -of your app with the specified inputs and create a report with the results. +# We generally recommend creating a helper function to make LLM API calls. +def llm(messages: list[dict[str, str]]) -> str: + response = client.chat.completions.create(model="gpt-4o", messages=messages) + return response.choices[0].message.content -```bash -parea benchmark --func app:main --csv_path benchmark.csv -``` -The CSV file will be used to fill in the arguments to your function. The report will be a CSV file of all the traces. If -you -set your Parea API key, the traces will also be logged to the Parea dashboard. Note, for this feature you need to have a -redis cache running. Please, raise a GitHub issue if you would like to use this feature without a redis cache. +# This will give the Span the name of the function. +# Without the decorator the default name for all LLM call logs is `llm-openai` +@trace +def hello_world(lang: str, framework: str): + return llm([{"role": "user", "content": f"Write a Hello World program in {lang} using {framework}."}]) -### Automatically log all your LLM call traces +@trace +def critique_code(code: str): + return llm([{"role": "user", "content": f"How can we improve this code: \n {code}"}]) -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 `Parea` initialization. -This will help you debug issues your customers are facing by stepping through the LLM call traces and recreating the -issue -in your local setup & code. +# Our top level function is called chain. By adding the trace decorator here, +# all sub-functions will automatically be logged and associated with this trace. +# Notice, you can also add metadata to the trace, we'll revisit this functionality later. +@trace(metadata={"purpose": "example"}, end_user_identifier="John Doe") +def chain(lang: str, framework: str) -> str: + return critique_code(hello_world(lang, framework)) -```python -from parea import Parea -Parea( - api_key=os.getenv("PAREA_API_KEY"), # default value - cache=... -) +print(chain("Python", "FastAPI")) ``` -## Use a deployed prompt - -```python -import os +## Deploying Prompts -from dotenv import load_dotenv +Deployed prompts enable collaboration with non-engineers such as product managers & subject-matter experts. +Users can iterate, refine & test prompts on Parea's playground. +After tinkering, you can deploy that prompt which means that it is exposed via an API endpoint to integrate it into your application. +Checkout our full docs [here](https://docs.parea.ai/platform/deployment). +```python from parea import Parea from parea.schemas.models import Completion, UseDeployedPrompt, CompletionResponse, UseDeployedPromptResponse -load_dotenv() -p = Parea(api_key=os.getenv("PAREA_API_KEY")) +p = Parea(api_key="") # You will find this deployment_id in the Parea dashboard deployment_id = '' @@ -178,55 +227,9 @@ def main(): deployed_prompt: UseDeployedPromptResponse = p.get_prompt(data=test_get_prompt) print("\n\n") print(deployed_prompt) - - -async def main_async(): - completion_response: CompletionResponse = await p.acompletion(data=test_completion) - print(completion_response) - deployed_prompt: UseDeployedPromptResponse = await p.aget_prompt(data=test_get_prompt) - print("\n\n") - print(deployed_prompt) ``` -### Logging results from LLM providers [Example] - -```python -import os - -import openai -from dotenv import load_dotenv - -from parea import Parea - -load_dotenv() - -openai.api_key = os.getenv("OPENAI_API_KEY") - -p = Parea(api_key=os.getenv("PAREA_API_KEY")) - -x = "Golang" -y = "Fiber" -messages = [{ - "role": "user", - "content": f"Write a hello world program using {x} and the {y} framework." -}] -model = "gpt-3.5-turbo" -temperature = 0.0 - - -# define your OpenAI call as you would normally and we'll automatically log the results -def main(): - openai.chat.completions.create(model=model, temperature=temperature, messages=messages).choices[0].message.content -``` - -### Open source community features - -Ready-to-use [Pull Requests templates](https://github.com/parea-ai/parea-sdk/blob/master/.github/PULL_REQUEST_TEMPLATE.md) -and several [Issue templates](https://github.com/parea-ai/parea-sdk/tree/master/.github/ISSUE_TEMPLATE). -- Files such as: `LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, and `SECURITY.md` are generated automatically. -- [Semantic Versions](https://semver.org/) specification - with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). ## 🛡 License @@ -239,7 +242,7 @@ See [LICENSE](https://github.com/parea-ai/parea-sdk/blob/master/LICENSE) for mor ```bibtex @misc{parea-sdk, - author = {joel-parea-ai}, + author = {joel-parea-ai,joschkabraun}, title = {Parea python sdk}, year = {2023}, publisher = {GitHub}, diff --git a/assets/PareaLogoLight.png b/assets/PareaLogoLight.png new file mode 100644 index 00000000..04f2c7de Binary files /dev/null and b/assets/PareaLogoLight.png differ diff --git a/parea/cookbook/anthropic/tracing_anthropic.py b/cookbook/anthropic/tracing_anthropic.py similarity index 100% rename from parea/cookbook/anthropic/tracing_anthropic.py rename to cookbook/anthropic/tracing_anthropic.py diff --git a/parea/cookbook/anthropic/tracing_anthropic_tool_use.py b/cookbook/anthropic/tracing_anthropic_tool_use.py similarity index 87% rename from parea/cookbook/anthropic/tracing_anthropic_tool_use.py rename to cookbook/anthropic/tracing_anthropic_tool_use.py index f9466137..2087f53e 100644 --- a/parea/cookbook/anthropic/tracing_anthropic_tool_use.py +++ b/cookbook/anthropic/tracing_anthropic_tool_use.py @@ -3,8 +3,8 @@ import anthropic from dotenv import load_dotenv +from cookbook.assets.data.anthropic_tool_use_examples import missing_information, multiple_tool_use, single_tool_use from parea import Parea -from parea.cookbook.assets.data.anthropic_tool_use_examples import missing_information, multiple_tool_use, single_tool_use load_dotenv() diff --git a/parea/cookbook/anthropic/tracing_with_images_anthropic.py b/cookbook/anthropic/tracing_with_images_anthropic.py similarity index 100% rename from parea/cookbook/anthropic/tracing_with_images_anthropic.py rename to cookbook/anthropic/tracing_with_images_anthropic.py diff --git a/parea/cookbook/assets/data/2022-letter.txt b/cookbook/assets/data/2022-letter.txt similarity index 100% rename from parea/cookbook/assets/data/2022-letter.txt rename to cookbook/assets/data/2022-letter.txt diff --git a/parea/cookbook/__init__.py b/cookbook/assets/data/__init__.py similarity index 100% rename from parea/cookbook/__init__.py rename to cookbook/assets/data/__init__.py diff --git a/parea/cookbook/assets/data/anthropic_tool_use_examples.py b/cookbook/assets/data/anthropic_tool_use_examples.py similarity index 100% rename from parea/cookbook/assets/data/anthropic_tool_use_examples.py rename to cookbook/assets/data/anthropic_tool_use_examples.py diff --git a/parea/cookbook/assets/data/openai_input_examples.py b/cookbook/assets/data/openai_input_examples.py similarity index 100% rename from parea/cookbook/assets/data/openai_input_examples.py rename to cookbook/assets/data/openai_input_examples.py diff --git a/parea/cookbook/assets/data/state_of_the_union.txt b/cookbook/assets/data/state_of_the_union.txt similarity index 100% rename from parea/cookbook/assets/data/state_of_the_union.txt rename to cookbook/assets/data/state_of_the_union.txt diff --git a/parea/cookbook/assets/img/dashboard.png b/cookbook/assets/img/dashboard.png similarity index 100% rename from parea/cookbook/assets/img/dashboard.png rename to cookbook/assets/img/dashboard.png diff --git a/parea/cookbook/assets/img/dashboard_detailed_view.png b/cookbook/assets/img/dashboard_detailed_view.png similarity index 100% rename from parea/cookbook/assets/img/dashboard_detailed_view.png rename to cookbook/assets/img/dashboard_detailed_view.png diff --git a/parea/cookbook/assets/img/deployed_prompts.png b/cookbook/assets/img/deployed_prompts.png similarity index 100% rename from parea/cookbook/assets/img/deployed_prompts.png rename to cookbook/assets/img/deployed_prompts.png diff --git a/parea/cookbook/assets/img/feedback.png b/cookbook/assets/img/feedback.png similarity index 100% rename from parea/cookbook/assets/img/feedback.png rename to cookbook/assets/img/feedback.png diff --git a/parea/cookbook/assets/img/logs.png b/cookbook/assets/img/logs.png similarity index 100% rename from parea/cookbook/assets/img/logs.png rename to cookbook/assets/img/logs.png diff --git a/parea/cookbook/assets/img/meta_data.png b/cookbook/assets/img/meta_data.png similarity index 100% rename from parea/cookbook/assets/img/meta_data.png rename to cookbook/assets/img/meta_data.png diff --git a/parea/cookbook/assets/img/trace_log_view.png b/cookbook/assets/img/trace_log_view.png similarity index 100% rename from parea/cookbook/assets/img/trace_log_view.png rename to cookbook/assets/img/trace_log_view.png diff --git a/parea/cookbook/dspy/dspy_examples.py b/cookbook/dspy/dspy_examples.py similarity index 100% rename from parea/cookbook/dspy/dspy_examples.py rename to cookbook/dspy/dspy_examples.py diff --git a/parea/cookbook/dspy/dspy_threading.py b/cookbook/dspy/dspy_threading.py similarity index 100% rename from parea/cookbook/dspy/dspy_threading.py rename to cookbook/dspy/dspy_threading.py diff --git a/parea/cookbook/dspy/tracing_and_evaluation_tutorial.ipynb b/cookbook/dspy/tracing_and_evaluation_tutorial.ipynb similarity index 100% rename from parea/cookbook/dspy/tracing_and_evaluation_tutorial.ipynb rename to cookbook/dspy/tracing_and_evaluation_tutorial.ipynb diff --git a/parea/cookbook/enpoints_for_datasets.py b/cookbook/endpoints_for_datasets.py similarity index 100% rename from parea/cookbook/enpoints_for_datasets.py rename to cookbook/endpoints_for_datasets.py diff --git a/parea/cookbook/evals_and_experiments/RAG_experiment_with_auto_evals.py b/cookbook/evals_and_experiments/RAG_experiment_with_auto_evals.py similarity index 100% rename from parea/cookbook/evals_and_experiments/RAG_experiment_with_auto_evals.py rename to cookbook/evals_and_experiments/RAG_experiment_with_auto_evals.py diff --git a/parea/cookbook/evals_and_experiments/async_experiments.py b/cookbook/evals_and_experiments/async_experiments.py similarity index 100% rename from parea/cookbook/evals_and_experiments/async_experiments.py rename to cookbook/evals_and_experiments/async_experiments.py diff --git a/parea/cookbook/evals_and_experiments/deployed_prompt_and_dataset.py b/cookbook/evals_and_experiments/deployed_prompt_and_dataset.py similarity index 100% rename from parea/cookbook/evals_and_experiments/deployed_prompt_and_dataset.py rename to cookbook/evals_and_experiments/deployed_prompt_and_dataset.py diff --git a/parea/cookbook/evals_and_experiments/deployed_prompt_dataset_and_eval.py b/cookbook/evals_and_experiments/deployed_prompt_dataset_and_eval.py similarity index 100% rename from parea/cookbook/evals_and_experiments/deployed_prompt_dataset_and_eval.py rename to cookbook/evals_and_experiments/deployed_prompt_dataset_and_eval.py diff --git a/parea/cookbook/evals_and_experiments/experiment_test_substeps.py b/cookbook/evals_and_experiments/experiment_test_substeps.py similarity index 100% rename from parea/cookbook/evals_and_experiments/experiment_test_substeps.py rename to cookbook/evals_and_experiments/experiment_test_substeps.py diff --git a/parea/cookbook/evals_and_experiments/list_experiments.py b/cookbook/evals_and_experiments/list_experiments.py similarity index 100% rename from parea/cookbook/evals_and_experiments/list_experiments.py rename to cookbook/evals_and_experiments/list_experiments.py diff --git a/parea/cookbook/evals_and_experiments/modify_dataset_before_experiment.py b/cookbook/evals_and_experiments/modify_dataset_before_experiment.py similarity index 100% rename from parea/cookbook/evals_and_experiments/modify_dataset_before_experiment.py rename to cookbook/evals_and_experiments/modify_dataset_before_experiment.py diff --git a/parea/cookbook/evals_and_experiments/run_experiment.py b/cookbook/evals_and_experiments/run_experiment.py similarity index 100% rename from parea/cookbook/evals_and_experiments/run_experiment.py rename to cookbook/evals_and_experiments/run_experiment.py diff --git a/parea/cookbook/evals_and_experiments/run_experiment_balanced_acc.py b/cookbook/evals_and_experiments/run_experiment_balanced_acc.py similarity index 100% rename from parea/cookbook/evals_and_experiments/run_experiment_balanced_acc.py rename to cookbook/evals_and_experiments/run_experiment_balanced_acc.py diff --git a/parea/cookbook/evals_and_experiments/run_experiment_evas_with_reason.py b/cookbook/evals_and_experiments/run_experiment_evas_with_reason.py similarity index 100% rename from parea/cookbook/evals_and_experiments/run_experiment_evas_with_reason.py rename to cookbook/evals_and_experiments/run_experiment_evas_with_reason.py diff --git a/parea/cookbook/evals_and_experiments/run_experiment_using_saved_test_collection.py b/cookbook/evals_and_experiments/run_experiment_using_saved_test_collection.py similarity index 100% rename from parea/cookbook/evals_and_experiments/run_experiment_using_saved_test_collection.py rename to cookbook/evals_and_experiments/run_experiment_using_saved_test_collection.py diff --git a/parea/cookbook/guidance/tracing_guidance.py b/cookbook/guidance/tracing_guidance.py similarity index 100% rename from parea/cookbook/guidance/tracing_guidance.py rename to cookbook/guidance/tracing_guidance.py diff --git a/parea/cookbook/instructor/instructor_blog_example_simple.py b/cookbook/instructor/instructor_blog_example_simple.py similarity index 100% rename from parea/cookbook/instructor/instructor_blog_example_simple.py rename to cookbook/instructor/instructor_blog_example_simple.py diff --git a/parea/cookbook/instructor/instructor_blog_example_validation_context.py b/cookbook/instructor/instructor_blog_example_validation_context.py similarity index 100% rename from parea/cookbook/instructor/instructor_blog_example_validation_context.py rename to cookbook/instructor/instructor_blog_example_validation_context.py diff --git a/parea/cookbook/instructor/instructor_evals.py b/cookbook/instructor/instructor_evals.py similarity index 100% rename from parea/cookbook/instructor/instructor_evals.py rename to cookbook/instructor/instructor_evals.py diff --git a/parea/cookbook/instructor/instructor_streaming.py b/cookbook/instructor/instructor_streaming.py similarity index 100% rename from parea/cookbook/instructor/instructor_streaming.py rename to cookbook/instructor/instructor_streaming.py diff --git a/parea/cookbook/langchain/trace_class_call_method.py b/cookbook/langchain/trace_class_call_method.py similarity index 100% rename from parea/cookbook/langchain/trace_class_call_method.py rename to cookbook/langchain/trace_class_call_method.py diff --git a/parea/cookbook/langchain/trace_langchain_RAG_evals.py b/cookbook/langchain/trace_langchain_RAG_evals.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_RAG_evals.py rename to cookbook/langchain/trace_langchain_RAG_evals.py diff --git a/parea/cookbook/langchain/trace_langchain_RAG_with_experiment.py b/cookbook/langchain/trace_langchain_RAG_with_experiment.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_RAG_with_experiment.py rename to cookbook/langchain/trace_langchain_RAG_with_experiment.py diff --git a/parea/cookbook/langchain/trace_langchain_anthropic_function_calling.py b/cookbook/langchain/trace_langchain_anthropic_function_calling.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_anthropic_function_calling.py rename to cookbook/langchain/trace_langchain_anthropic_function_calling.py diff --git a/parea/cookbook/langchain/trace_langchain_azure_RAG_with_experiment.py b/cookbook/langchain/trace_langchain_azure_RAG_with_experiment.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_azure_RAG_with_experiment.py rename to cookbook/langchain/trace_langchain_azure_RAG_with_experiment.py diff --git a/parea/cookbook/langchain/trace_langchain_bedrock_rag.py b/cookbook/langchain/trace_langchain_bedrock_rag.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_bedrock_rag.py rename to cookbook/langchain/trace_langchain_bedrock_rag.py diff --git a/parea/cookbook/langchain/trace_langchain_inside_trace_decorator.py b/cookbook/langchain/trace_langchain_inside_trace_decorator.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_inside_trace_decorator.py rename to cookbook/langchain/trace_langchain_inside_trace_decorator.py diff --git a/parea/cookbook/langchain/trace_langchain_rag_agents.py b/cookbook/langchain/trace_langchain_rag_agents.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_rag_agents.py rename to cookbook/langchain/trace_langchain_rag_agents.py diff --git a/parea/cookbook/langchain/trace_langchain_rag_question_answering.py b/cookbook/langchain/trace_langchain_rag_question_answering.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_rag_question_answering.py rename to cookbook/langchain/trace_langchain_rag_question_answering.py diff --git a/parea/cookbook/langchain/trace_langchain_simple.py b/cookbook/langchain/trace_langchain_simple.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_simple.py rename to cookbook/langchain/trace_langchain_simple.py diff --git a/parea/cookbook/langchain/trace_langchain_with_deployed_prompt.py b/cookbook/langchain/trace_langchain_with_deployed_prompt.py similarity index 100% rename from parea/cookbook/langchain/trace_langchain_with_deployed_prompt.py rename to cookbook/langchain/trace_langchain_with_deployed_prompt.py diff --git a/parea/cookbook/marvin/trace_marvin.py b/cookbook/marvin/trace_marvin.py similarity index 100% rename from parea/cookbook/marvin/trace_marvin.py rename to cookbook/marvin/trace_marvin.py diff --git a/parea/cookbook/openai/dynamic_few_shot_injection_with_evals.py b/cookbook/openai/dynamic_few_shot_injection_with_evals.py similarity index 100% rename from parea/cookbook/openai/dynamic_few_shot_injection_with_evals.py rename to cookbook/openai/dynamic_few_shot_injection_with_evals.py diff --git a/parea/cookbook/openai/simple_experiment_with_openai.py b/cookbook/openai/simple_experiment_with_openai.py similarity index 100% rename from parea/cookbook/openai/simple_experiment_with_openai.py rename to cookbook/openai/simple_experiment_with_openai.py diff --git a/parea/cookbook/openai/trace_class_call_method.py b/cookbook/openai/trace_class_call_method.py similarity index 100% rename from parea/cookbook/openai/trace_class_call_method.py rename to cookbook/openai/trace_class_call_method.py diff --git a/parea/cookbook/openai/tracing_and_evaluating_openai_endpoint.py b/cookbook/openai/tracing_and_evaluating_openai_endpoint.py similarity index 100% rename from parea/cookbook/openai/tracing_and_evaluating_openai_endpoint.py rename to cookbook/openai/tracing_and_evaluating_openai_endpoint.py diff --git a/parea/cookbook/openai/tracing_azure_open_ai.py b/cookbook/openai/tracing_azure_open_ai.py similarity index 94% rename from parea/cookbook/openai/tracing_azure_open_ai.py rename to cookbook/openai/tracing_azure_open_ai.py index 22045c0d..b3cf23b3 100644 --- a/parea/cookbook/openai/tracing_azure_open_ai.py +++ b/cookbook/openai/tracing_azure_open_ai.py @@ -4,8 +4,8 @@ from dotenv import load_dotenv from openai.lib.azure import AsyncAzureOpenAI, AzureOpenAI +from cookbook.assets.data.openai_input_examples import functions_example, simple_example from parea import Parea, trace -from parea.cookbook.assets.data.openai_input_examples import functions_example, simple_example load_dotenv() diff --git a/parea/cookbook/openai/tracing_open_ai_streams.py b/cookbook/openai/tracing_open_ai_streams.py similarity index 91% rename from parea/cookbook/openai/tracing_open_ai_streams.py rename to cookbook/openai/tracing_open_ai_streams.py index e02f59ff..ee823af2 100644 --- a/parea/cookbook/openai/tracing_open_ai_streams.py +++ b/cookbook/openai/tracing_open_ai_streams.py @@ -4,8 +4,8 @@ from dotenv import load_dotenv from openai import AsyncOpenAI, OpenAI +from cookbook.assets.data.openai_input_examples import functions_example, simple_example_json from parea import Parea, trace -from parea.cookbook.assets.data.openai_input_examples import functions_example, simple_example_json load_dotenv() diff --git a/parea/cookbook/openai/tracing_openai_assistant_endpoint.py b/cookbook/openai/tracing_openai_assistant_endpoint.py similarity index 100% rename from parea/cookbook/openai/tracing_openai_assistant_endpoint.py rename to cookbook/openai/tracing_openai_assistant_endpoint.py diff --git a/parea/cookbook/openai/tracing_templated_llm_calls.py b/cookbook/openai/tracing_templated_llm_calls.py similarity index 100% rename from parea/cookbook/openai/tracing_templated_llm_calls.py rename to cookbook/openai/tracing_templated_llm_calls.py diff --git a/parea/cookbook/openai/tracing_tool_calling.py b/cookbook/openai/tracing_tool_calling.py similarity index 100% rename from parea/cookbook/openai/tracing_tool_calling.py rename to cookbook/openai/tracing_tool_calling.py diff --git a/parea/cookbook/openai/tracing_with_images_open_ai.py b/cookbook/openai/tracing_with_images_open_ai.py similarity index 100% rename from parea/cookbook/openai/tracing_with_images_open_ai.py rename to cookbook/openai/tracing_with_images_open_ai.py diff --git a/parea/cookbook/openai/tracing_with_open_ai_endpoint_directly.py b/cookbook/openai/tracing_with_open_ai_endpoint_directly.py similarity index 100% rename from parea/cookbook/openai/tracing_with_open_ai_endpoint_directly.py rename to cookbook/openai/tracing_with_open_ai_endpoint_directly.py diff --git a/parea/cookbook/openai/tracing_with_openai_requests_api.py b/cookbook/openai/tracing_with_openai_requests_api.py similarity index 95% rename from parea/cookbook/openai/tracing_with_openai_requests_api.py rename to cookbook/openai/tracing_with_openai_requests_api.py index ce2863ea..d1d47f35 100644 --- a/parea/cookbook/openai/tracing_with_openai_requests_api.py +++ b/cookbook/openai/tracing_with_openai_requests_api.py @@ -3,8 +3,8 @@ import httpx from dotenv import load_dotenv +from cookbook.assets.data.openai_input_examples import functions_example, simple_example, tool_calling_example from parea import Parea, aprocess_stream_and_yield, convert_openai_raw_to_log, process_stream_and_yield, trace -from parea.cookbook.assets.data.openai_input_examples import functions_example, simple_example, tool_calling_example from parea.wrapper import get_formatted_openai_response load_dotenv() diff --git a/parea/cookbook/openai/tracing_with_openai_with_functions.py b/cookbook/openai/tracing_with_openai_with_functions.py similarity index 100% rename from parea/cookbook/openai/tracing_with_openai_with_functions.py rename to cookbook/openai/tracing_with_openai_with_functions.py diff --git a/parea/cookbook/parea_llm_proxy/deployments/fetching_and_using_parea_deployments.py b/cookbook/parea_llm_proxy/deployments/fetching_and_using_parea_deployments.py similarity index 100% rename from parea/cookbook/parea_llm_proxy/deployments/fetching_and_using_parea_deployments.py rename to cookbook/parea_llm_proxy/deployments/fetching_and_using_parea_deployments.py diff --git a/parea/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py b/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py similarity index 100% rename from parea/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py rename to cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py diff --git a/parea/cookbook/parea_llm_proxy/dynamic_few_shot_injection.py b/cookbook/parea_llm_proxy/dynamic_few_shot_injection.py similarity index 100% rename from parea/cookbook/parea_llm_proxy/dynamic_few_shot_injection.py rename to cookbook/parea_llm_proxy/dynamic_few_shot_injection.py diff --git a/parea/cookbook/parea_llm_proxy/tracing_with_Parea_sdk.ipynb b/cookbook/parea_llm_proxy/tracing_with_Parea_sdk.ipynb similarity index 100% rename from parea/cookbook/parea_llm_proxy/tracing_with_Parea_sdk.ipynb rename to cookbook/parea_llm_proxy/tracing_with_Parea_sdk.ipynb diff --git a/parea/cookbook/parea_llm_proxy/tracing_with_agent.py b/cookbook/parea_llm_proxy/tracing_with_agent.py similarity index 100% rename from parea/cookbook/parea_llm_proxy/tracing_with_agent.py rename to cookbook/parea_llm_proxy/tracing_with_agent.py diff --git a/parea/cookbook/parea_llm_proxy/tracing_with_function_calling_and_chains.ipynb b/cookbook/parea_llm_proxy/tracing_with_function_calling_and_chains.ipynb similarity index 100% rename from parea/cookbook/parea_llm_proxy/tracing_with_function_calling_and_chains.ipynb rename to cookbook/parea_llm_proxy/tracing_with_function_calling_and_chains.ipynb diff --git a/parea/cookbook/parea_llm_proxy/tracing_with_parea_streaming.py b/cookbook/parea_llm_proxy/tracing_with_parea_streaming.py similarity index 100% rename from parea/cookbook/parea_llm_proxy/tracing_with_parea_streaming.py rename to cookbook/parea_llm_proxy/tracing_with_parea_streaming.py diff --git a/parea/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py b/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py similarity index 100% rename from parea/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py rename to cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py diff --git a/parea/cookbook/tracing_with_threading.py b/cookbook/tracing_with_threading.py similarity index 100% rename from parea/cookbook/tracing_with_threading.py rename to cookbook/tracing_with_threading.py diff --git a/parea/cookbook/use_dataset_for_finetuning.py b/cookbook/use_dataset_for_finetuning.py similarity index 100% rename from parea/cookbook/use_dataset_for_finetuning.py rename to cookbook/use_dataset_for_finetuning.py diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 5cdc06f4..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM python:3.9-slim-buster - -ENV LANG=C.UTF-8 \ - LC_ALL=C.UTF-8 \ - PATH="${PATH}:/root/.poetry/bin" - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - curl \ - && rm -rf /var/lib/apt/lists/* - -COPY pyproject.toml ./ - -# Install Poetry -RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | POETRY_HOME=/opt/poetry python && \ - cd /usr/local/bin && \ - ln -s /opt/poetry/bin/poetry && \ - poetry config virtualenvs.create false - -# Allow installing dev dependencies to run tests -ARG INSTALL_DEV=false -RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi" - -CMD mkdir -p /workspace -WORKDIR /workspace diff --git a/docker/README.md b/docker/README.md deleted file mode 100644 index 477a9c53..00000000 --- a/docker/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Docker for parea-sdk - -## Installation - -To create Docker you need to run: - -```bash -make docker-build -``` - -which is equivalent to: - -```bash -make docker-build VERSION=latest -``` - -You may provide name and version for the image. -Default name is `IMAGE := parea`. -Default version is `VERSION := latest`. - -```bash -make docker-build IMAGE=some_name VERSION=0.1.0 -``` - -## Usage - -```bash -docker run -it --rm \ - -v $(pwd):/workspace \ - parea bash -``` - -## How to clean up - -To uninstall docker image run `make docker-remove` with `VERSION`: - -```bash -make docker-remove VERSION=0.1.0 -``` - -you may also choose the image name - -```bash -make docker-remove IMAGE=some_name VERSION=latest -``` - -If you want to clean all, including `build` and `pycache` run `make cleanup` diff --git a/parea/cookbook/assets/data/__init__.py b/parea/cookbook/assets/data/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/parea/cookbook/parea_llm_proxy/__init__.py b/parea/cookbook/parea_llm_proxy/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/parea/cookbook/parea_llm_proxy/deployments/__init__.py b/parea/cookbook/parea_llm_proxy/deployments/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/parea/wrapper/anthropic/anthropic.py b/parea/wrapper/anthropic/anthropic.py index c4e6dda0..e843cdad 100644 --- a/parea/wrapper/anthropic/anthropic.py +++ b/parea/wrapper/anthropic/anthropic.py @@ -9,8 +9,7 @@ from parea.cache.cache import Cache from parea.helpers import timezone_aware_now -from parea.schemas import CacheRequest, LLMInputs -from parea.schemas import ModelParams +from parea.schemas import CacheRequest, LLMInputs, ModelParams from parea.schemas import Role as PareaRole from parea.schemas import TraceLog from parea.utils.trace_utils import make_output, trace_data diff --git a/pyproject.toml b/pyproject.toml index 4708f0f0..c9132347 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "parea-ai" packages = [{ include = "parea" }] -version = "0.2.181" +version = "0.2.182" description = "Parea python sdk" readme = "README.md" authors = ["joel-parea-ai "]