how to pass dynamic path #17372
Asma-droid
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
hello very one!
i woul like to add dynamic data path to my below code. Any help please
app = FastAPI()
#Step 06:Downlaod the Embeddings
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
#Import Model
llm = LlamaCpp(
streaming = True,
model_path="/srv/nas_data/atrabelsi/Whisper-Analysis-Final/Meeting_summarization/summary/mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf",
temperature=0.01,
top_p=1,
verbose=True,
n_ctx=4096
)
faiss_index = FAISS.load_local("/srv/nas_data/atrabelsi/Whisper-Analysis-Final/RAG/LangServeDemo/langserve_index_5", embeddings)
retriever = faiss_index.as_retriever(search_kwargs={"k": 3})
prompt_template = """
Use the provided context to answer the user's question. If you don't know the answer, say you don't know.
Context:
{context}
Question:
{question}"""
rag_prompt = ChatPromptTemplate.from_template(prompt_template)
with open('/srv/nas_data/atrabelsi/Whisper-Analysis-Final/RAG/LangServeDemo/langserve_index_5/data.pkl', 'rb') as file:
# Call load method to deserialze
data = pickle.load(file)
def format_docs(data):
return "\n\n".join(doc.page_content for doc in data)
rag_chain_from_docs = (
RunnablePassthrough.assign(context=(lambda x: format_docs(x["context"])))
| rag_prompt
| llm
| StrOutputParser()
)
rag_chain_with_source = RunnableParallel(
{"context": retriever, "question": RunnablePassthrough()}
).assign(answer=rag_chain_from_docs)
@app.get("/")
async def redirect_root_to_docs():
return RedirectResponse("/docs")
if name == "main":
import uvicorn
Beta Was this translation helpful? Give feedback.
All reactions