tavily
Verschillen
Dit geeft de verschillen weer tussen de geselecteerde revisie en de huidige revisie van de pagina.
Beide kanten vorige revisieVorige revisieVolgende revisie | Vorige revisie | ||
tavily [2024/10/02 18:33] – [Voorbeelde gebruik Tavily] a3dijke | tavily [2024/10/13 22:26] (huidige) – [Tavily doorzoekt opgegeven websites] a3dijke | ||
---|---|---|---|
Regel 122: | Regel 122: | ||
| | ||
- | # WRKERS | + | # WERKERS |
def format_docs(self, | def format_docs(self, | ||
return " | return " | ||
Regel 129: | Regel 129: | ||
---- | ---- | ||
+ | ===== ✨ Tavily doorzoekt opgegeven websites ===== | ||
+ | < | ||
+ | from langchain_core.output_parsers import StrOutputParser | ||
+ | from langchain_core.prompts import ChatPromptTemplate | ||
+ | from langchain_core.runnables import RunnablePassthrough | ||
+ | from langchain_openai import ChatOpenAI | ||
+ | import os | ||
+ | import streamlit as st | ||
+ | import requests | ||
+ | |||
+ | |||
+ | class Test_2: | ||
+ | def __init__(self): | ||
+ | os.environ[" | ||
+ | |||
+ | # https:// | ||
+ | def tavilyLangChainWithChain(self, | ||
+ | try: | ||
+ | retriever = TavilySearchAPIRetriever( | ||
+ | k=3, | ||
+ | include_domains=[ | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | ) | ||
+ | prompt = ChatPromptTemplate.from_template( | ||
+ | """ | ||
+ | |||
+ | Context: {context} | ||
+ | |||
+ | Question: {question}""" | ||
+ | ) | ||
+ | llm = ChatOpenAI(model=" | ||
+ | |||
+ | chain = ( | ||
+ | {" | ||
+ | | prompt | ||
+ | | llm | ||
+ | | StrOutputParser() | ||
+ | ) | ||
+ | antw = chain.invoke(vraag) | ||
+ | return antw | ||
+ | |||
+ | |||
+ | except requests.exceptions.HTTPError as e: | ||
+ | print(f" | ||
+ | return "Er is een fout opgetreden: Invoer moet minimaal uit twee woorden bestaan!" | ||
+ | | ||
+ | |||
+ | # WERKER ======================================================== | ||
+ | def format_docs(self, | ||
+ | return " | ||
+ | |||
+ | |||
+ | ---- | ||
tavily.1727886806.txt.gz · Laatst gewijzigd: 2024/10/02 18:33 door a3dijke