Skip to content

Commit

Permalink
Merge branch 'main' into deploy-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier committed Jun 10, 2024
2 parents ab2da20 + 6ef051a commit dee960f
Show file tree
Hide file tree
Showing 23 changed files with 967 additions and 372 deletions.
3 changes: 3 additions & 0 deletions docs/assets/images/ragna-tutorial-components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 12 additions & 21 deletions docs/examples/gallery_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
# - [OpenAI](https://openai.com/)
# - [ragna.assistants.Gpt35Turbo16k][]
# - [ragna.assistants.Gpt4][]
# - [llamafile](https://github.com/Mozilla-Ocho/llamafile)
# - [ragna.assistants.LlamafileAssistant][]
# - [Ollama](https://ollama.com/)
# - [ragna.assistants.OllamaGemma2B][]
# - [ragna.assistants.OllamaLlama2][]
# - [ragna.assistants.OllamaLlava][]
# - [ragna.assistants.OllamaMistral][]
# - [ragna.assistants.OllamaMixtral][]
# - [ragna.assistants.OllamaOrcaMini][]
# - [ragna.assistants.OllamaPhi2][]

from ragna import assistants

Expand Down Expand Up @@ -99,26 +109,7 @@ def answer(self, prompt, sources):

rest_api = ragna_docs.RestApi()

client = rest_api.start(config, authenticate=True)

# %%
# Upload the document.

document_upload = (
client.post("/document", json={"name": document_path.name})
.raise_for_status()
.json()
)

document = document_upload["document"]

parameters = document_upload["parameters"]
client.request(
parameters["method"],
parameters["url"],
data=parameters["data"],
files={"file": open(document_path, "rb")},
).raise_for_status()
client, document = rest_api.start(config, authenticate=True, upload_document=True)

# %%
# Start and prepare the chat
Expand Down Expand Up @@ -173,6 +164,6 @@ def answer(self, prompt, sources):

# %%
# Before we close the example, let's stop the REST API and have a look at what would
# have printed in the terminal if we had started it the regular way.
# have printed in the terminal if we had started it with the `ragna api` command.

rest_api.stop()
17 changes: 11 additions & 6 deletions docs/references/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@ There are two main ways to generate a configuration file:
## Referencing Python objects

Some configuration options reference Python objects, e.g.
`document = ragna.core.LocalDocument`. You can inject your own objects here and do not
need to rely on the defaults by Ragna. To do so, make sure that the module the object is
defined in is on the
[`PYTHONPATH`](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH). The
`document` configuration mentioned before internally is roughly treated as
`document = ragna.core.LocalDocument`. Internally, this is roughly treated as
`from ragna.core import LocalDocument`.

You can inject your own objects here and do not need to rely on the defaults by Ragna.
To do so, make sure that the module the object is defined in is on
[Python's search path](https://docs.python.org/3/library/sys.html#sys.path). There are
multiple ways to achieve this, e.g.:

- Install your module as part of a package in your current environment.
- Set the [`PYTHONPATH`](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH)
environment variable to include the directory your module is located in.

## Environment variables

All configuration options can be set or overritten by environment variables by using the
All configuration options can be set or overridden by environment variables by using the
`RAGNA_` prefix. For example, `document = ragna.core.LocalDocument` in the configuration
file is equivalent to setting `RAGNA_DOCUMENT=ragna.core.LocalDocument`.

Expand Down
Loading

0 comments on commit dee960f

Please sign in to comment.