alexkueck commited on
Commit
74265c9
1 Parent(s): 3e1429d

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +9 -8
utils.py CHANGED
@@ -31,22 +31,23 @@ from pygments.formatters import HtmlFormatter
31
 
32
  from langchain.chains import LLMChain, RetrievalQA
33
  from langgraph.graph import END, StateGraph
34
- from langchain.chat_models import ChatOpenAI
35
- from langchain.document_loaders import PyPDFLoader, WebBaseLoader, UnstructuredWordDocumentLoader, DirectoryLoader
36
  from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
37
  from langchain.document_loaders.generic import GenericLoader
38
  from langchain.document_loaders.parsers import OpenAIWhisperParser
39
  from langchain.schema import AIMessage, HumanMessage
40
- from langchain.llms import HuggingFaceHub
41
- from langchain.llms import HuggingFaceTextGenInference
42
- from langchain.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings, HuggingFaceBgeEmbeddings, HuggingFaceInferenceAPIEmbeddings
43
- from langchain.tools import DuckDuckGoSearchRun
44
  from langchain.retrievers.tavily_search_api import TavilySearchAPIRetriever
45
  from typing import Dict, TypedDict
46
  from langchain_core.messages import BaseMessage
47
  from langchain.embeddings.openai import OpenAIEmbeddings
48
  from langchain.prompts import PromptTemplate
49
 
 
50
  from langchain import hub
51
  from langchain.output_parsers.openai_tools import PydanticToolsParser
52
  from langchain.prompts import PromptTemplate
@@ -59,7 +60,7 @@ from langchain_core.pydantic_v1 import BaseModel, Field
59
  from langchain_core.runnables import RunnablePassthrough
60
  from langchain_core.utils.function_calling import convert_to_openai_tool
61
  from langchain.text_splitter import RecursiveCharacterTextSplitter
62
- from langchain.vectorstores import Chroma
63
  from chromadb.errors import InvalidDimensionException
64
  import io
65
  from PIL import Image, ImageDraw, ImageOps, ImageFont
@@ -398,7 +399,7 @@ def rag_chain(llm, prompt, retriever):
398
 
399
  if (len(filtered_docs)>0):
400
  llm_chain = LLMChain(llm = llm, prompt = RAG_CHAIN_PROMPT)
401
- result = llm_chain.run({"context": documents, "question": neu_prompt})
402
  else:
403
  #Normale Abfrage, da keine relevanten Dokumente gefunden
404
  llm_chain = LLMChain(llm = llm, prompt = LLM_CHAIN_PROMPT)
 
31
 
32
  from langchain.chains import LLMChain, RetrievalQA
33
  from langgraph.graph import END, StateGraph
34
+ from langchain_community.chat_models import ChatOpenAI
35
+ from langchain_community.document_loaders import PyPDFLoader, , WebBaseLoader, UnstructuredWordDocumentLoader, DirectoryLoader
36
  from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
37
  from langchain.document_loaders.generic import GenericLoader
38
  from langchain.document_loaders.parsers import OpenAIWhisperParser
39
  from langchain.schema import AIMessage, HumanMessage
40
+ from langchain_community.llms import HuggingFaceHub
41
+ from langchain_community.llms import HuggingFaceTextGenInference
42
+ from langchain_community.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings, HuggingFaceBgeEmbeddings, HuggingFaceInferenceAPIEmbeddings
43
+ from langchain_community.tools import DuckDuckGoSearchRun
44
  from langchain.retrievers.tavily_search_api import TavilySearchAPIRetriever
45
  from typing import Dict, TypedDict
46
  from langchain_core.messages import BaseMessage
47
  from langchain.embeddings.openai import OpenAIEmbeddings
48
  from langchain.prompts import PromptTemplate
49
 
50
+
51
  from langchain import hub
52
  from langchain.output_parsers.openai_tools import PydanticToolsParser
53
  from langchain.prompts import PromptTemplate
 
60
  from langchain_core.runnables import RunnablePassthrough
61
  from langchain_core.utils.function_calling import convert_to_openai_tool
62
  from langchain.text_splitter import RecursiveCharacterTextSplitter
63
+ from langchain_community.vectorstores import Chroma
64
  from chromadb.errors import InvalidDimensionException
65
  import io
66
  from PIL import Image, ImageDraw, ImageOps, ImageFont
 
399
 
400
  if (len(filtered_docs)>0):
401
  llm_chain = LLMChain(llm = llm, prompt = RAG_CHAIN_PROMPT)
402
+ result = llm_chain.run({"context": filtered_docs, "question": neu_prompt})
403
  else:
404
  #Normale Abfrage, da keine relevanten Dokumente gefunden
405
  llm_chain = LLMChain(llm = llm, prompt = LLM_CHAIN_PROMPT)