Update app.py
Browse files
app.py
CHANGED
@@ -22,8 +22,9 @@ import requests
|
|
22 |
from bs4 import BeautifulSoup
|
23 |
from langchain_core.documents import Document
|
24 |
from tenacity import retry, wait_exponential, stop_after_attempt, retry_if_exception_type
|
25 |
-
from langchain_core.language_models.chat_models import BaseChatModel
|
26 |
from langchain_core.outputs import ChatResult
|
|
|
|
|
27 |
|
28 |
# Configurar o tema para dark
|
29 |
st.set_page_config(page_title="RAG Q&A Conversacional", layout="wide", initial_sidebar_state="expanded", page_icon="🤖", menu_items=None)
|
@@ -169,7 +170,10 @@ huggingface_api_token = st.text_input("Insira seu token de API Hugging Face:", t
|
|
169 |
|
170 |
# Wrapper personalizado para ChatGroq com rate limiting
|
171 |
class RateLimitedChatGroq(BaseChatModel):
|
172 |
-
|
|
|
|
|
|
|
173 |
self.llm = ChatGroq(groq_api_key=groq_api_key, model_name=model_name, temperature=temperature)
|
174 |
|
175 |
@retry(
|
|
|
22 |
from bs4 import BeautifulSoup
|
23 |
from langchain_core.documents import Document
|
24 |
from tenacity import retry, wait_exponential, stop_after_attempt, retry_if_exception_type
|
|
|
25 |
from langchain_core.outputs import ChatResult
|
26 |
+
from langchain_groq import ChatGroq
|
27 |
+
from pydantic import Field
|
28 |
|
29 |
# Configurar o tema para dark
|
30 |
st.set_page_config(page_title="RAG Q&A Conversacional", layout="wide", initial_sidebar_state="expanded", page_icon="🤖", menu_items=None)
|
|
|
170 |
|
171 |
# Wrapper personalizado para ChatGroq com rate limiting
|
172 |
class RateLimitedChatGroq(BaseChatModel):
|
173 |
+
llm: ChatGroq = Field(default_factory=lambda: ChatGroq())
|
174 |
+
|
175 |
+
def __init__(self, groq_api_key: str, model_name: str, temperature: float = 0):
|
176 |
+
super().__init__()
|
177 |
self.llm = ChatGroq(groq_api_key=groq_api_key, model_name=model_name, temperature=temperature)
|
178 |
|
179 |
@retry(
|