Skip to content

Commit

Permalink
Change docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartorn committed May 27, 2024
1 parent d523973 commit e5b06d1
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 30 deletions.
181 changes: 171 additions & 10 deletions docs/README.html

Large diffs are not rendered by default.

166 changes: 165 additions & 1 deletion docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
@@ -1 +1,165 @@
# Welcome
# Quick Start

## Evaluating from your Jupyter notebook

Start by initializing a client.

```python
from giskard_hub.client import HubClient

# Note: API key and Hub URL can also be provided by setting env variables GSK_API_KEY and GSK_HUB_URL
client = HubClient(
api_key="GSK_API_KEY",
hub_url="GSK_HUB_URL",
)
```


Next, retrieve relevant objects from the server (project, model & dataset).

```python
from giskard_hub.data import Dataset, Model, Project

project: Project = client.get_projects()[0]
model: Model = client.get_models(project.id)[0]
dataset: Dataset = client.get_datasets(project.id)[0]
```

You can then launch an evaluation, which downloads the dataset to be sent to your LLM agent for completion.

```python
from typing import List
from giskard_hub.data import Evaluation

# This will contain the messages, expected outputs, policies, IDs, tags, notes, etc
to_complete: List[Evaluation] = client.evaluate(
model_id=model.id,
dataset_id=dataset.id,
)
```

You can then send this to your LLM agent for output completion.

```python
# Dummy LLM agent
def dummy_model(all_data: Evaluation):
# Simulated call to an agent and updating the evaluation
all_data.set_output("Sorry, I can't answer your question.")
# Alternatively, could be done like this
# all_data.output = ModelOutput(response=LLMMessage(role="assistant", content="Sorry, I can't answer your question."), metadata={})

for elt in to_complete:
dummy_model(elt)
```

You can then push the completed elements to the Hub. This will start the evaluation process on the Hub.

```python
updates = client.update_evaluations(to_complete)
```

Next, either head to the Hub to inspect the evaluation results in details, or get summarized results directly in your
development environment.

```python
# Extract the execution_id
execution_id = to_complete[0].execution_id

# Extract the results from the Hub
results = client.get_results(execution_id=execution_id)
results
```

## Evaluating using a Python script

```python
from typing import List
from giskard_hub.client import HubClient
from giskard_hub.data import Dataset, Evaluation, Model, Project


# Dummy LLM agent
def dummy_model(all_data: Evaluation):
# Simulated call to an agent and updating the evaluation
all_data.set_output("Sorry, I can't answer your question.")
# Alternatively, could be done like this
# all_data.output = ModelOutput(response=LLMMessage(role="assistant", content="Sorry, I can't answer your question."), metadata={})

if __name__ == "__main__":
# Note: API key and Hub URL can also be provided by setting env variables GSK_API_KEY and GSK_HUB_URL
client = HubClient(
api_key="GSK_API_KEY",
hub_url="GSK_HUB_URL",
)
project: Project = client.get_projects()[0]
model: Model = client.get_models(project.id)[0]
dataset: Dataset = client.get_datasets(project.id)[0]
to_complete: List[Evaluation] = client.evaluate(
model_id=model.id,
dataset_id=dataset.id,
)
execution_id = to_complete[0].execution_id
for elt in to_complete:
dummy_model(elt)

updates = client.update_evaluations(to_complete)

results = client.get_results(execution_id=execution_id)
print("Got results")
print(results)
```

## Evaluating using CLI

```bash
#!/bin/bash
set -eu
# Set env variable to avoid giving this info everytime
export GSK_API_KEY=GSK_API_KEY
export GSK_HUB_URL=GSK_HUB_URL
folder_path=./test-folder

rm -rf $folder_path
mkdir -p $folder_path

project_id=$(python -m giskard_hub.cli projects | jq --raw-output .[0].id)
model_id=$(python -m giskard_hub.cli models --project-id $project_id | jq --raw-output .[0].id)
dataset_id=$(python -m giskard_hub.cli datasets --project-id $project_id | jq --raw-output .[0].id)

python -m giskard_hub.cli evaluate --folder-path $folder_path --dataset-id $dataset_id --model-id $model_id --local-mode
execution_id=$(find $folder_path -type f | grep ".json$" | head -n1 | xargs -I {} jq --raw-output .execution_id {})

# Following line is faking a dummy LLM agent changing data in the json
find $folder_path -type f | grep ".json$" | xargs -I {} sed -i 's|"output": null|"output": "Sorry, I cant answer your question."|g' {} | sh
python -m giskard_hub.cli update-evaluations --evaluation-path $folder_path

python -m giskard_hub.cli results --execution-id $execution_id
```

## Evaluating a single dataset entry

```python
if __name__ == "__main__":
# Initialise client
client = HubClient(
api_key="2b437295-dabe-4084-ba03-cdb259e3e678",
hub_url="http://backend.llm.localhost/",
)

results = client.single_eval(
TransientEvaluation(
messages=[LLMMessage(role="user", content="What color is an orange ?")],
model_output=ModelOutput(
response=LLMMessage(role="assistant", content="An orange is green.")
),
model_description="You are an agent that give informations about fruits",
policies=[
"Agent must never say the word 'orange'",
"Agent must be polite",
],
expected_output="Orange.",
)
)
print("Got results")
print(results)
```
16 changes: 13 additions & 3 deletions docs/_sources/index.md.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Welcome to Hub client's documentation!
# Welcome to the Giskard Hub's client docs!

The giskard_hub library allows you to interact with the Giskard Hub, a platform that centralizes the validation process
of LLM applications, empowering product teams to ensure all functional, business & legal requirements are met, and
keeping them in close contact with the development team to avoid delayed deployment timelines.

The giskard_hub Python library provides a simple way for developers and data scientists to manage and evaluate LLM
applications in their development workflow during the prototyping phase and for continuous integration testing.

Read the quick start guide to get up and running with the giskard_hub library. You will learn how to download datasets,
upload LLM agent outputs to the Giskard Hub and execute evaluations from a notebook, script or CLI.

```{toctree}
:caption: Getting Started
Expand All @@ -8,13 +18,13 @@
README
```

```{toctree}
<!-- ```{toctree}
:caption: Example
:maxdepth: 2
:hidden:

./examples/example.ipynb
```
``` -->


```{toctree}
Expand Down
4 changes: 1 addition & 3 deletions docs/examples/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
<link href="../_static/favicon.ico" rel="icon"/>
<link href="../search.html" rel="search" title="Search"/>
<link href="../genindex.html" rel="index" title="Index"/>
<link href="../sources.html" rel="next" title="giskard_hub"/>
<link href="../README.html" rel="prev" title="Welcome"/>
<script>
<!-- Prevent Flash of wrong theme -->
const userPreference = localStorage.getItem('darkMode');
Expand Down Expand Up @@ -76,7 +74,7 @@
<div class="overflow-y-auto h-full w-full relative pr-6"><nav class="table w-full min-w-full my-6 lg:my-8">
<p class="caption" role="heading"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../README.html">Welcome</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html">Quick Start</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Code</span></p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<div class="overflow-y-auto h-full w-full relative pr-6"><nav class="table w-full min-w-full my-6 lg:my-8">
<p class="caption" role="heading"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="README.html">Welcome</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html">Quick Start</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Code</span></p>
<ul>
Expand Down
21 changes: 14 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<meta content="white" media="(prefers-color-scheme: light)" name="theme-color"/>
<meta content="black" media="(prefers-color-scheme: dark)" name="theme-color"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<title>Welcome to Hub client’s documentation! | Hub client documentation</title>
<meta content="Welcome to Hub client’s documentation! | Hub client documentation" property="og:title"/>
<meta content="Welcome to Hub client’s documentation! | Hub client documentation" name="twitter:title"/>
<title>Welcome to the Giskard Hub’s client docs! | Hub client documentation</title>
<meta content="Welcome to the Giskard Hub’s client docs! | Hub client documentation" property="og:title"/>
<meta content="Welcome to the Giskard Hub’s client docs! | Hub client documentation" name="twitter:title"/>
<link href="_static/pygments.css?v=8d216cef" rel="stylesheet" type="text/css"/>
<link href="_static/theme.css?v=8958d2b4" rel="stylesheet" type="text/css"/>
<link href="_static/copybutton.css?v=76b2166b" rel="stylesheet" type="text/css"/>
<link href="_static/favicon.ico" rel="icon"/>
<link href="search.html" rel="search" title="Search"/>
<link href="genindex.html" rel="index" title="Index"/>
<link href="README.html" rel="next" title="Welcome"/>
<link href="README.html" rel="next" title="Quick Start"/>
<script>
<!-- Prevent Flash of wrong theme -->
const userPreference = localStorage.getItem('darkMode');
Expand Down Expand Up @@ -75,7 +75,7 @@
<div class="overflow-y-auto h-full w-full relative pr-6"><nav class="table w-full min-w-full my-6 lg:my-8">
<p class="caption" role="heading"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="README.html">Welcome</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html">Quick Start</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Code</span></p>
<ul>
Expand All @@ -93,8 +93,15 @@
<main class="relative py-6 lg:gap-10 lg:py-8 xl:grid xl:grid-cols-[1fr_300px]">
<div class="w-full min-w-0 mx-auto">
<div id="content" role="main">
<section id="welcome-to-hub-client-s-documentation">
<h1>Welcome to Hub client’s documentation!<a class="headerlink" href="#welcome-to-hub-client-s-documentation" title="Link to this heading"></a></h1>
<section id="welcome-to-the-giskard-hub-s-client-docs">
<h1>Welcome to the Giskard Hub’s client docs!<a class="headerlink" href="#welcome-to-the-giskard-hub-s-client-docs" title="Link to this heading"></a></h1>
<p>The giskard_hub library allows you to interact with the Giskard Hub, a platform that centralizes the validation process
of LLM applications, empowering product teams to ensure all functional, business &amp; legal requirements are met, and
keeping them in close contact with the development team to avoid delayed deployment timelines.</p>
<p>The giskard_hub Python library provides a simple way for developers and data scientists to manage and evaluate LLM
applications in their development workflow during the prototyping phase and for continuous integration testing.</p>
<p>Read the quick start guide to get up and running with the giskard_hub library. You will learn how to download datasets,
upload LLM agent outputs to the Giskard Hub and execute evaluations from a notebook, script or CLI.</p>



Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<div class="overflow-y-auto h-full w-full relative pr-6"><nav class="table w-full min-w-full my-6 lg:my-8">
<p class="caption" role="heading"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="README.html">Welcome</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html">Quick Start</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Code</span></p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<div class="overflow-y-auto h-full w-full relative pr-6"><nav class="table w-full min-w-full my-6 lg:my-8">
<p class="caption" role="heading"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="README.html">Welcome</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html">Quick Start</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Code</span></p>
<ul>
Expand Down
Loading

0 comments on commit e5b06d1

Please sign in to comment.