Skip to content

Commit

Permalink
📝 add dependencies docs page
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Feb 15, 2024
1 parent a722f61 commit f8ad19a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/concepts/dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Dependencies

TODO: Write a docs for dependencies

## Example: RAG

```python
from operator import itemgetter
from typing import Annotated

from funcchain.syntax import chain, runnable
from funcchain.syntax.params import Depends
from langchain_community.vectorstores.faiss import FAISS
from langchain_openai.embeddings import OpenAIEmbeddings

retriever = FAISS.from_texts(
[
"cold showers are good for your immune system",
"i dont like when people are mean to me",
"japanese tea is full of heart warming flavors",
],
embedding=OpenAIEmbeddings(),
).as_retriever(
search_kwargs={"k": 1},
)


@runnable
def poem_with_retrieval(
topic: str,
context: Annotated[str, Depends(itemgetter("topic") | retriever)] = "N/A",
) -> str:
"""
Generate a poem about the topic with the given context.
"""
return chain()


print(
poem_with_retrieval.invoke({"topic": "love"}),
)
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nav:
- "Streaming": "concepts/streaming.md"
- "Unions": "concepts/unions.md"
- "Vision": "concepts/vision.md"
- "Dependencies": "concepts/dependencies.md"
- "Examples":
- "Enums": "features/enums.md"
- "Structured vision output": "features/vision.md"
Expand Down

0 comments on commit f8ad19a

Please sign in to comment.