mirror of
https://github.com/open-webui/docs
synced 2025-05-20 03:08:56 +00:00
docs: Add citation usage instructions in Tools documentation
This commit is contained in:
parent
17311cb893
commit
4aca5ffc30
@ -241,3 +241,33 @@ async def test_function(
|
||||
return f"Tell the user: {e}"
|
||||
```
|
||||
</details>
|
||||
|
||||
#### Citations
|
||||
This type is used to provide citations or references in the chat. You can utilize it to specify the content, the source, and any relevant metadata. Below is an example of how to emit a citation event:
|
||||
|
||||
```
|
||||
await __event_emitter__(
|
||||
{
|
||||
"type": "citation",
|
||||
"data": {
|
||||
"document": [content],
|
||||
"metadata": [
|
||||
{
|
||||
"date_accessed": datetime.now().isoformat(),
|
||||
"source": title,
|
||||
}
|
||||
],
|
||||
"source": {"name": title, "url": url},
|
||||
},
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
If you are sending multiple citations, you can iterate over citations and call the emitter multiple times. When implementing custom citations, ensure that you set `self.citation = False` in your `Tools` class `__init__` method. Otherwise, the built-in citations will override the ones you have pushed in. For example:
|
||||
|
||||
```python
|
||||
def __init__(self):
|
||||
self.citation = False
|
||||
```
|
||||
|
||||
Leaving `self.citation = True` will replace any custom citations you send with automatically generated ones. By disabling it, you can fully manage your own citation references.
|
||||
|
Loading…
Reference in New Issue
Block a user